mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-04-09 15:22:26 -07:00
2 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2a5eb349f2
|
Fix/misc bug (#686)
* refactor: replace time-window echo prevention with mtime+size and content checks FileSystemWatcher: use recorded mtime+size (lastWriteStats) and saving-state flag (titlesBeingSaved) to skip own-write echoes, plus content identity fallback. Removes unreliable setTimeout-based exclude/scheduleFileInclusion. ipcServerRoutes: replace TTL Map with synchronous Set (ipcPendingTitles), attach changeCount as revision to change Observable. ipc-syncadaptor: use lastSavedRevisions for revision-based echo prevention, batch large syncs via requestIdleCallback. Also: EditWorkspace controlled input fixes, port field local state, agent framework config setConfig/persistConfig split, misc value ?? '' fixes. * Enhance e2e screenshots and test logging Improve end-to-end test reliability and diagnostics: - Capture window screenshots for non-BrowserView steps: add captureWindowScreenshot and use it in AfterStep to capture the Electron BrowserWindow via webContents.capturePage() when appropriate; keep existing captureScreenshot for BrowserView steps. (features/supports/webContentsViewHelper.ts, features/stepDefinitions/application.ts) - Prevent wiki restart race: wait for the wiki worker '[test-id-WIKI_WORKER_STARTED]' marker before restarting to avoid DoubleWikiInstanceError. (features/stepDefinitions/wiki.ts) - Make git-related test markers more visible by switching logger.debug → logger.info for git init/commit/sync/checkout/revert and git-log rendering markers, ensuring e2e tests can reliably detect these events. (src/services/git/index.ts, src/windows/GitLog/useGitLogData.ts) - Minor feature test tweak: wait for page to load in defaultWiki.feature before interacting with the editWorkspace window. These changes reduce flaky screenshots and timing races in tests and improve test marker visibility for e2e detection. * Enhance e2e screenshots and test logging Improve end-to-end test reliability and diagnostics: - Capture window screenshots for non-BrowserView steps: add captureWindowScreenshot and use it in AfterStep to capture the Electron BrowserWindow via webContents.capturePage() when appropriate; keep existing captureScreenshot for BrowserView steps. (features/supports/webContentsViewHelper.ts, features/stepDefinitions/application.ts) - Prevent wiki restart race: wait for the wiki worker '[test-id-WIKI_WORKER_STARTED]' marker before restarting to avoid DoubleWikiInstanceError. (features/stepDefinitions/wiki.ts) - Make git-related test markers more visible by switching logger.debug → logger.info for git init/commit/sync/checkout/revert and git-log rendering markers, ensuring e2e tests can reliably detect these events. (src/services/git/index.ts, src/windows/GitLog/useGitLogData.ts) - Minor feature test tweak: wait for page to load in defaultWiki.feature before interacting with the editWorkspace window. These changes reduce flaky screenshots and timing races in tests and improve test marker visibility for e2e detection. * Use startTransition to update port on change Import startTransition from React and update the port input handler to capture the raw value, update local display state, and defer parsing/setting the workspace port inside startTransition. The handler now parses an empty value as 0, validates the number (non-NaN and >= 0) before calling workspaceSetter, improving responsiveness by marking the workspace update as non-urgent. Also removed an obsolete inline comment. * Improve E2E, view sync, and wiki IPC robustness Multiple fixes and improvements across E2E tests, view management, wiki IPC, and workspace handling: - Docs: add SHOW_E2E_WINDOW env var note to allow visible Electron windows during manual E2E runs. - Features: simplify/adjust cross-window sync scenario and refine hibernation workspace selectors to avoid collisions with similarly named workspaces. - E2E steps: make AI-request assertion resilient by polling (backOff); replace brittle DOM-driven tiddler creation with direct TiddlyWiki API calls in browserView step definitions for reliability; add small UI click pause and longer click timeout in ui steps. - Timeouts: unify global timeout to 25s and derive Playwright short/log wait timeouts from it. - WebContents helpers: prefer the last child wiki view (active one) when multiple views exist and update comments. - WikiEmbedTabContent: wake workspace on mount and simplify cleanup to always clear custom bounds on unmount; handle errors. - Chat UI: hide TabListDropdown in split view. - Agent instances: default missing agentFrameworkID to 'basicPromptConcatHandler' for older definitions. - View service: add activelyShownViews set to avoid hiding views that were explicitly shown via showView(); clear stale custom bounds when showing views; avoid moving views offscreen when actively shown; ensure cleanup removes active flag. - IPC server routes: prefer URL-based workspace ID (resolve correct casing via workspace service) to handle cross-session routing; pass effective workspace ID to route handlers. - Wiki service: add startup timeout to avoid indefinite hangs waiting for worker boot message. - IPC sync adaptor: implement titlesBeingSaved/titlesBeingLoaded sets to prevent save-back and SSE echo issues; mark titles when saving/loading and suppress spurious saves. - Wiki worker IPC routes: replace per-subscriber addEventListener with a shared Subject and single change listener to avoid missed events and cross-window sync bugs; forward subject events to subscribers and log readiness. - Windows: keep windows hidden during tests by default but allow showing them when SHOW_E2E_WINDOW=1. - Workspaces: compute next insert order so new wiki workspaces appear at the top of regular workspaces (shift others down). Overall these changes reduce flakiness in tests, prevent cross-window echo and routing bugs, make view lifecycle handling safer, and improve developer ergonomics for debugging E2E runs. * fix(e2e): bypass system proxy for git HTTP operations in sync test Git clone/push/fetch to localhost was routed through the system proxy (port 1080), which returned 502 Bad Gateway. Add -c http.proxy= to disable proxy for all HTTP git commands in the sync test step definitions. * fix: address CI lint errors and Copilot review comments Lint fixes: - useOptimisticField: rename *Ref/*Fn vars to *Reference/*Function (unicorn/prevent-abbreviations) - wiki/index: rename args to arguments_ (unicorn/prevent-abbreviations) - FileSystemWatcher: use specific type assertion for tiddler fields to avoid no-base-to-string warning - webContentsViewHelper: rename loop var i to index - interface.ts: merge duplicate imports from same module (dprint) - ipc-syncadaptor: expand queueMicrotask callback (dprint) Copilot review fixes: - ipcServerRoutes: move subscription to outer scope so Observable teardown is returned synchronously from the constructor, preventing subscription leaks when observers are disposed before the async IIFE resolves - useOptimisticField: capture localValue at focus time; on blur only commit when user actually changed the value (not when serverValue updated while focused) - FileSystemWatcher.markSaveComplete: guard scheduleGitNotification behind non-empty absoluteFilePath to avoid spurious git notifications on error paths * fix(e2e): handle corrupt settings.json in cleanup and use filechooser intercept for image upload - tidgiMiniWindow cleanup: wrap readJson with try/catch so truncated/empty settings.json (race between app shutdown write and After hook read) is handled gracefully instead of throwing SyntaxError - application.ts: add 'I prepare to select file ... for file chooser' step that registers a Playwright one-shot filechooser handler BEFORE the click that triggers fileInput.click(). This prevents the native OS dialog from appearing entirely (the chooser is resolved directly with the supplied file). - talkWithAI.feature: replace two-step 'click then setInputFiles' with the new 'prepare filechooser click' pattern so no OS dialog is shown during the AI image attachment test |
||
|
|
64cc965a4a
|
Feat/discuss note with agent (#685)
* Add wiki tiddler attachment support to agent chat Implements the ability to attach wiki tiddlers to agent chat messages. Updates the UI to allow selection of tiddlers from active wiki workspaces, fetches and renders tiddler content as plain text, and appends it to the user message sent to the AI. Includes e2e tests, updates to store actions, service interfaces, and prompt concatenation logic to support this feature. * fix: callback not useCallback cause autocomplete panel flash * Add wiki tiddler attachments to message bubbles Message bubbles now display attached wiki tiddlers as clickable chips, allowing users to navigate directly to the referenced tiddler in the appropriate workspace. Metadata handling and persistence for wiki tiddlers has been updated to include workspaceId, and tests have been added to verify the new UI behavior. The chat view also now closes the TiddlyWiki sidebar for better focus when navigating from a selection. * Support split view navigation for wiki tiddler attachments Adds isSplitView prop to ChatTabContent and related components to distinguish between split view and normal tab modes. Wiki tiddler attachment navigation now uses a different strategy in split view, opening tiddlers directly in the browser view. Updates types and tests to reflect the new behavior, and improves robustness of response handling in several places. * docs: move to .github/instructions/testing.instructions.md * test: view loading slow on mac * refactor(e2e): move wiki load steps to Background in talkWithAI.feature; remove all sidebar close delays and polling, only set state when TiddlyWiki is ready; clean up code and logs for sidebar auto-close in split view * docs: make test inst shorter * lint * refactor(view): slim ViewService, move menu to separate file, orchestrate view logic in WorkspaceViewService, update all callers, fix lint floating promise, all unit and e2e tests pass * fix: add data-testid to attachment listbox for E2E test - Add slotProps to MUI Autocomplete to ensure attachment-listbox is rendered with correct test-id - Fix E2E test timeout when waiting for attachment listbox element * lint * put 'Talk with AI' menu on top and attachment i18n Introduce a reusable createTalkWithAIMenuItems helper to build "Talk with AI" menu entries (default agent + other agents submenu) and integrate it into workspace menu generation. Add new i18n keys for Agent.Attachment and WikiEmbed across locales and update UI to use translation keys (remove hardcoded fallback strings). Improve chat input/attachment behavior: expose a test-id for the attachment listbox, use i18n for labels/placeholders, and tweak input component wiring. Fix Cucumber step handling by normalizing expected newline sequences and safely handling empty message content. Also adjust memo deps in SortableWorkspaceSelectorButton to include id. * feat: enhance AI interaction in workspace context menu with local trigger support * feat: add tool approval and timeout settings - Introduced ToolApprovalConfig and related types for managing tool execution approvals. - Implemented WebFetch and ZxScript tools for fetching web content and executing scripts, respectively. - Added token estimation utilities for context window management. - Enhanced ModelInfo interface with context window size and max output tokens. - Created API Retry Utility for handling transient failures with exponential backoff. - Updated AIAgent preferences section to include Tool Approval & Timeout Settings dialog. - Developed ToolApprovalSettingsDialog for configuring tool-specific approval rules and retry settings. - Modified vitest configuration to support aliasing for easier imports and stubbing. * Refactor agent instance tools and services for improved modularity and maintainability - Extracted type definitions and tool registry from defineTool.ts into separate files (defineToolTypes.ts, toolRegistry.ts) to reduce file size and enhance importability. - Implemented a retry mechanism in ExternalAPIService for stream creation to handle transient failures. - Updated ToolApprovalSettingsDialog to persist settings using localStorage instead of a preference service. - Created agentMessagePersistence.ts and agentRepository.ts to manage agent message and instance CRUD operations, reducing the size of AgentInstanceService. - Added a progress tracker document (AgentTODO.md) for the ongoing enhancement plan of the TidGi Agent. * feat: add AgentSwitcher component for agent definition switching - Implemented AgentSwitcher component with dropdown functionality for selecting agent definitions. - Integrated loading of agent definitions on dropdown open. - Added visual feedback for current selection and disabled state. feat: create ToolResultRenderer for generic tool result messages - Developed ToolResultRenderer to handle rendering of <functions_result> messages. - Included collapsible parameters and result display with error handling. - Added truncation for long results in collapsed view. test: add comprehensive tests for MessageRenderer components - Implemented tests for AskQuestionRenderer, ToolResultRenderer, ToolApprovalRenderer, and BaseMessageRenderer. - Ensured proper rendering and functionality for various message types and states. - Included pattern routing tests for MessageRenderer. feat: introduce TurnActionBar for action management in agent turns - Created TurnActionBar component for managing actions like rollback, retry, delete, and copy. - Integrated visual feedback for file changes and rollback status. - Added functionality for copying agent responses and full conversation to clipboard. feat: implement askQuestionPending for managing user responses - Developed infrastructure for handling pending ask-question requests. - Implemented promise-based blocking until user responds to agent questions. - Added timeout handling for ask-question requests. * feat: Implement background task management for agent instances - Added functionality to restore heartbeat timers and alarms for active agents upon service initialization. - Introduced methods to retrieve active background tasks and cancel them via the UI. - Enhanced alarm clock tool to persist alarm data in the database, ensuring alarms survive app restarts. - Updated agent instance schema to include scheduled alarm data. - Modified prompt concatenation logic to support context window size for message history. - Removed system prompt parameter from model parameters schema and related components. - Improved UI to display and manage background tasks, including heartbeat and alarm details. * feat: Implement Scheduled Tasks Management and Background Task Settings - Add feature for managing scheduled tasks for agents, including viewing, adding, and editing tasks. - Create tests for agent repository and background task settings APIs. - Introduce ScheduledTaskManager for unified scheduling of tasks with interval, at, and cron schedules. - Implement edit-agent-definition tool for modifying agent configurations, including heartbeat and prompt settings. - Ensure tasks persist across app restarts and respect active hours filtering. * Update wiki * fix(security): harden htmlToText against XSS via encoded tags - Use tolerant script/style regex that handles </script > with spaces - Stop decoding </> entities to prevent reintroducing HTML tags - Decode & last to avoid double-unescaping (&lt; < <) - Fixes all 4 CodeQL findings (bad filtering, incomplete sanitization, double escaping, incomplete multi-character sanitization) * fix: lint and format errors (eslint naming, dprint formatting, stub classes) * fix: exclude tidgi.config.json from template copy and fix log marker pattern - Skip tidgi.config.json when copying wiki template to prevent overriding workspace name - Change waitForLogMarker default pattern from 'wiki-' to '*' to match actual log filenames - Filter tidgi.config.json in e2e step too (fs.copy in wiki creation step) * perf(e2e): merge 5 scheduledTask scenarios into 2 to reduce app restarts * perf(e2e): merge crossWindowSync and streamingStatus scenarios to reduce CI time * ci: increase test timeout to 20min for larger e2e scenario count * perf(e2e): merge agent scenarios and enable parallel on CI - Merge agent.feature wiki-search + wiki-operation into one scenario - Merge agent.feature create-agent-from-newtab + create-agent-from-fallback into one - Enable cucumber parallel: 2 on CI (7GB RAM, dynamic ports for mock servers) - Total scenarios: 66 -> 61 * fix: cleanup MCP client processes when deleting or closing agent * ci: disable parallel (CPU contention), increase timeout to 30min for 61 scenarios * perf(e2e): merge 3 preference background-task scenarios into 1, increase timeout to 45min - Preference alarm/heartbeat CRUD merged into single scenario (saves 2 app restarts) - Total scenarios: 59 (was 66) - CI timeout 45min for the expanded e2e suite * fix: restructure e2e scenarios, fix subscription leak and debounce cleanup - Restructure agent/talkWithAI/streamingStatus feature files for reliability - Fix talkWithAI scenarios missing mock server startup and app launch - Remove duplicate subscription in handleSwitchAgent (useEffect already handles it) - Clean up debounced update functions when agent is deleted/closed - Use agentId:messageId key for debounced functions to enable per-agent cleanup * fix(e2e): remove :last-child selectors broken by TurnActionBar, fix tab/dialog selectors, increase CI timeout to 25min * fix: use const for non-reassigned variable (lint) * fix(e2e): fix close-all-tabs opacity issue, scheduledTask undefined steps, MUI multiline textarea targeting * fix(e2e): use tab-list-dropdown to close all tabs, fix selector for actual TabListDropdown component * fix(e2e): add timing waits for BrowserView repositioning and git log UI refresh * fix(e2e): make 'should not see' step wait for element to disappear instead of instant check * fix(e2e): increase executeInBrowserView default timeout from 500ms to 2000ms |