TidGi-Desktop/features/tidgiMiniWindowWorkspace.feature
lin onetwo 9a6f3480f5
Feat/watch fs (#649)
* Add watch-filesystem-adaptor plugin and worker IPC

Introduces the watch-filesystem-adaptor TiddlyWiki plugin, enabling tag-based routing of tiddlers to sub-wikis by querying workspace info via worker thread IPC. Adds workerServiceCaller utility for worker-to-main service calls, updates workerAdapter and bindServiceAndProxy to support explicit service registration for workers, and documents the new IPC architecture. Updates wikiWorker and startNodeJSWiki to preload workspace ID and load the new plugin. Also updates the plugin build script to compile and copy the new plugin.

* test: wiki operation steps

* Add per-wiki labeled logging and console hijack

Introduces labeled loggers for each wiki, writing logs to separate files. Adds a logFor method to NativeService for logging with labels, updates interfaces, and hijacks worker thread console methods to redirect logs to main process for wiki-specific logging. Refactors workspaceID usage to workspace object for improved context.

* Update log handling for wiki worker and tests

Enhanced logging tests to check all log files, including wiki logs. Adjusted logger to write wiki worker logs to the main log directory. Updated e2e app script comment for correct usage.

* Enable worker thread access to main process services

Introduces a proxy system allowing worker threads to call main process services with full type safety and observable support. Adds worker-side service proxy creation, auto-attaches proxies to global.service, and updates service registration to use IPC descriptors. Documentation is added for usage and architecture.

* Update ErrorDuringStart.md

* chore: upgrade ipc cat and allow clean vite cache

* Refactor wiki worker initialization and service readiness

Moved wiki worker implementation from wikiWorker.ts to wikiWorker/index.ts and deleted the old file. Added servicesReady.ts to manage worker service readiness and callbacks, and integrated notifyServicesReady into the worker lifecycle. Updated console hijack logic to wait for service readiness before hijacking. Improved worker management in Wiki service to support detaching workers and notifying readiness.

* Refactor wiki logging to use centralized logger

Removed per-wiki loggers and console hijacking in favor of a single labeled logger. All wiki logs, including errors, are now written to a unified log file. Updated worker and service code to route logs through the main logger and removed obsolete log file naming and management logic.

* fix: ipc cat log error

* Refactor wiki test paths and improve file save logic

Updated test step to use wikiTestRootPath for directory replacements and added wikiTestRootPath to paths.ts for clarity. Improved error handling and directory logic in watch-filesystem-adaptor.ts, including saving tiddlers directly to sub-wiki folders, more informative logging, and ensuring cleanup after file writes is properly awaited.

* rename

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* feat: basic watch-fs

* feat: check file not exist

* refactor: use exponential-backoff

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* Initial commit when init a new git.

* fix: cleanup

* Refactor test setup and cleanup to separate file

Moved Before and After hooks from application.ts to a new cleanup.ts file for better organization and separation of concerns. Also removed unused imports and related code from application.ts. Minor type simplification in agent.ts for row parsing.

* test: modify and rename

* feat: enableFileSystemWatch

* refactor: unused utils.ts

* Update watch-filesystem-adaptor.ts

* refactor: use node-sentinel-file-watcher

* refactor: extract to two classes

* The logFor method lacks JSDoc describing the level parameter's

* Update startNodeJSWiki.ts

* fix: napi build

* Update electron-rebuild command in workflows

Changed the electron-rebuild command in release and test GitHub Actions workflows to use a comma-separated list for native modules instead of multiple -w flags. This simplifies the rebuild step for better-sqlite3 and nsfw modules.

* lint

* not build nsfw, try use prebuild

* Update package.json

* Update workerAdapter.ts

* remove subWikiPlugin.ts as we use new filesystem adaptor that supports tag based sub wiki

* fix: build

* fix: wrong type

* lint

* remove `act(...)` warnings

* uninstall chokidar

* refactor and test

* lint

* remove unused logic, as we already use ipc syncadaptor, not afriad of wiki status change

* Update translation.json

* test: increast timeout in CI

* Update application.ts

* fix: AI's wrong cleanup logic hidden by as unknown as

* fix: AI's wrong  as unknown as

* Update agent.feature

* Update wikiSearchPlugin.ts

* fix: A dynamic import callback was not specified.
2025-10-28 13:25:46 +08:00

130 lines
No EOL
8.4 KiB
Gherkin

@tidgi-mini-window
Feature: TidGi Mini Window Workspace Switching
As a user with tidgi mini window already enabled
I want to test tidgi mini window behavior with different workspace configurations
So that I can verify workspace switching and fixed workspace features
Background:
Given I configure tidgi mini window with shortcut
Then I launch the TidGi application
And I wait for the page to load completely
Then I switch to "main" window
Scenario: TidGi mini window syncs with main window switching to agent workspace
# Switch main window to agent workspace
When I click on an "agent workspace button" element with selector "[data-testid='workspace-agent']"
# Verify tidgi mini window exists in background (created but not visible)
And I wait for 0.2 seconds
Then I confirm the "tidgiMiniWindow" window exists
And I confirm the "tidgiMiniWindow" window not visible
When I press the key combination "CommandOrControl+Shift+M"
And I confirm the "tidgiMiniWindow" window visible
And I confirm the "tidgiMiniWindow" window browser view is not positioned within visible window bounds
Then I switch to "tidgiMiniWindow" window
# In sync mode, browser view shows the current active workspace (agent), sidebar is hidden
And I should see a "new tab button" element with selector "[data-tab-id='new-tab-button']"
Scenario: TidGi mini window with fixed agent workspace shows no view and fixed wiki workspace shows browser view
# Configure fixed agent workspace through UI
And I click on an "open preferences button" element with selector "#open-preferences-button"
And I switch to "preferences" window
When I click on "tidgi mini window section and disable sync workspace switch" elements with selectors:
| [data-testid='preference-section-tidgiMiniWindow'] |
| [data-testid='tidgi-mini-window-sync-workspace-switch'] |
# Enable sidebar to see workspace buttons
And I click on a "Enable sidebar toggle switch" element with selector "[data-testid='sidebar-on-tidgi-mini-window-switch']"
And I wait for 0.2 seconds
# Select agent workspace (which is a page type workspace)
And I select "agent" from MUI Select with test id "tidgi-mini-window-fixed-workspace-select"
# Open tidgi mini window - should show agent workspace and no browser view
When I press the key combination "CommandOrControl+Shift+M"
And I confirm the "tidgiMiniWindow" window visible
And I confirm the "tidgiMiniWindow" window browser view is not positioned within visible window bounds
Then I switch to "tidgiMiniWindow" window
# Verify sidebar is visible
And I should see a "main sidebar" element with selector "[data-testid='main-sidebar']"
# Verify agent workspace is active
And I should see a "agent workspace active button" element with selector "[data-testid='workspace-agent'][data-active='true']"
# Close tidgi mini window and switch to wiki workspace
And I wait for 0.2 seconds
Then I switch to "preferences" window
When I press the key combination "CommandOrControl+Shift+M"
And I confirm the "tidgiMiniWindow" window not visible
# Get the first wiki workspace ID and select it
And I select "wiki" from MUI Select with test id "tidgi-mini-window-fixed-workspace-select"
And I wait for 0.2 seconds
# Open tidgi mini window again - should show wiki workspace with browser view
When I press the key combination "CommandOrControl+Shift+M"
And I confirm the "tidgiMiniWindow" window visible
And I confirm the "tidgiMiniWindow" window browser view is positioned within visible window bounds
Then I switch to "tidgiMiniWindow" window
# Verify sidebar is visible
And I should see a "main sidebar" element with selector "[data-testid='main-sidebar']"
# Verify browser view content is visible and wiki workspace is active
And I should see " TiddlyWiki" in the browser view content
And I should see a "wiki workspace active button" element with selector "[data-active='true']"
Scenario: Enabling sync workspace automatically hides sidebar
# Configure tidgi mini window with fixed workspace first
When I click on "agent workspace button and open preferences button" elements with selectors:
| [data-testid='workspace-agent'] |
| #open-preferences-button |
And I switch to "preferences" window
When I click on "tidgi mini window section and disable sync workspace switch" elements with selectors:
| [data-testid='preference-section-tidgiMiniWindow'] |
| [data-testid='tidgi-mini-window-sync-workspace-switch'] |
And I should see a "sidebar toggle switch" element with selector "[data-testid='sidebar-on-tidgi-mini-window-switch']"
# Enable sidebar to see it in mini window
And I click on a "Enable sidebar toggle switch" element with selector "[data-testid='sidebar-on-tidgi-mini-window-switch']"
# Open tidgi mini window and verify sidebar is visible
When I press the key combination "CommandOrControl+Shift+M"
And I confirm the "tidgiMiniWindow" window visible
And I switch to "tidgiMiniWindow" window
And I should see a "main sidebar" element with selector "[data-testid='main-sidebar']"
# Close mini window and go back to preferences
Then I switch to "preferences" window
When I press the key combination "CommandOrControl+Shift+M"
And I confirm the "tidgiMiniWindow" window not visible
# Now enable sync workspace - should automatically hide sidebar
When I click on a "Enable tidgi mini window sync workspace switch" element with selector "[data-testid='tidgi-mini-window-sync-workspace-switch']"
# Verify sidebar option is now hidden
And I should not see "sidebar toggle switch and fixed workspace select" elements with selectors:
| [data-testid='sidebar-on-tidgi-mini-window-switch'] |
| [data-testid='tidgi-mini-window-fixed-workspace-select'] |
# Open tidgi mini window in sync mode - should sync to agent workspace
When I press the key combination "CommandOrControl+Shift+M"
And I confirm the "tidgiMiniWindow" window visible
And I switch to "tidgiMiniWindow" window
# In sync mode, sidebar should not be visible (automatically hidden)
And I should not see a "main sidebar" element with selector "[data-testid='main-sidebar']"
Scenario: Clicking workspace button in mini window updates fixed workspace ID
# First click on guide workspace in main window to set a different active workspace
Then I switch to "main" window
When I click on a "guide workspace button" element with selector "[data-testid='workspace-guide']"
And I wait for 0.2 seconds
# Configure tidgi mini window with fixed workspace
And I click on an "open preferences button" element with selector "#open-preferences-button"
And I switch to "preferences" window
When I click on "tidgi mini window section and disable sync workspace switch" elements with selectors:
| [data-testid='preference-section-tidgiMiniWindow'] |
| [data-testid='tidgi-mini-window-sync-workspace-switch'] |
# Enable sidebar to see workspace buttons
And I click on a "Enable sidebar toggle switch" element with selector "[data-testid='sidebar-on-tidgi-mini-window-switch']"
And I wait for 0.2 seconds
# Select agent workspace as fixed workspace
And I select "agent" from MUI Select with test id "tidgi-mini-window-fixed-workspace-select"
And I wait for 0.2 seconds
# Open tidgi mini window
When I press the key combination "CommandOrControl+Shift+M"
And I confirm the "tidgiMiniWindow" window visible
Then I switch to "tidgiMiniWindow" window
# Verify agent workspace is active initially
And I should see a "agent workspace button with active state" element with selector "[data-testid='workspace-agent'][data-active='true']"
# Click on guide workspace button to update fixed workspace ID
When I click on a "guide workspace button" element with selector "[data-testid='workspace-guide']"
And I wait for 0.2 seconds
# Verify guide workspace is now active and agent workspace is no longer active
And I should see "guide workspace button with active state and agent workspace button without active state" elements with selectors:
| [data-testid='workspace-guide'][data-active='true'] |
| [data-testid='workspace-agent'][data-active='false'] |