TidGi-Desktop/features/preference.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

81 lines
6.2 KiB
Gherkin

Feature: TidGi Preference
As a user
I want to configure my preferences for the intelligent agent and so on
So that I can customize its behavior and improve my experience
Background:
Given I launch the TidGi application
And I wait for the page to load completely
And I should see a "page body" element with selector "body"
@ai-setting
Scenario: Configure AI provider and default model
# Step 1: Configure AI settings first - Open preferences window, wait a second so its URL settle down.
When I click on a "settings button" element with selector "#open-preferences-button"
When I switch to "preferences" window
# Step 2: Navigate to External Services section (wait for sidebar animation)
When I click on an "external services section" element with selector "[data-testid='preference-section-externalAPI']"
# Step 3: Add new provider
When I click on an "add provider button" element with selector "[data-testid='add-new-provider-button']"
# Step 4: Fill provider form with mock server details (interface type already selected as openAICompatible)
When I type "TestProvider" in "provider name input" element with selector "[data-testid='new-provider-name-input']"
And I type "http://127.0.0.1:15121/v1" in "API endpoint input" element with selector "[data-testid='new-provider-base-url-input']"
When I click on an "add provider submit" element with selector "[data-testid='add-provider-submit-button']"
# Step 5: Select the new provider and add a model
When I click on "provider tab and add model button" elements with selectors:
| button[role='tab']:has-text('TestProvider') |
| [data-testid='add-new-model-button'] |
# Step 6: Add language model (will auto-fill as default language model)
When I type "test-model" in "model name input" element with selector "[data-testid='new-model-name-input']"
When I click on "save model button and add model button" elements with selectors:
| [data-testid='save-model-button'] |
| [data-testid='add-new-model-button'] |
# Step 7: Add embedding model (will auto-fill as default embedding model)
When I type "test-embedding-model" in "model name input" element with selector "[data-testid='new-model-name-input']"
When I click on "embedding feature checkbox and save model button and add model button" elements with selectors:
| [data-testid='feature-checkbox-embedding'] |
| [data-testid='save-model-button'] |
| [data-testid='add-new-model-button'] |
# Step 8: Add speech model (will auto-fill as default speech model)
When I type "test-speech-model" in "model name input" element with selector "[data-testid='new-model-name-input']"
# Uncheck language feature first (it's checked by default)
When I click on "language feature checkbox and speech feature checkbox and save model button" elements with selectors:
| [data-testid='feature-checkbox-language'] |
| [data-testid='feature-checkbox-speech'] |
| [data-testid='save-model-button'] |
# Step 9: Verify auto-fill worked by checking that autocomplete inputs have the correct selected values
# MUI Autocomplete shows selected value in the input, we check by looking for the model name in the visible text
Then I should see "default language model value test-model and default embedding model value test-embedding-model and default speech model value test-speech-model" elements with selectors:
| text='test-model' |
| text='test-embedding-model' |
| text='test-speech-model' |
# Verify the autocomplete is not empty and negative case remain explicit
Then I should not see a "empty first autocomplete placeholder" element with selector "xpath=(//label[contains(text(),'Preference.SelectModel')])[1]"
Then I should not see a "test-model after test-embedding-model (wrong order)" element with selector "xpath=//input[@value='test-embedding-model']/following::input[@value='test-model']"
# Verify there are exactly 3 filled model selectors
Then I should see "first autocomplete input with test-model and second autocomplete input with test-embedding-model and third autocomplete input with test-speech-model" elements with selectors:
| xpath=(//div[contains(@class,'MuiAutocomplete-root')]//input[@value='test-model'])[1] |
| xpath=(//div[contains(@class,'MuiAutocomplete-root')]//input[@value='test-embedding-model'])[1] |
| xpath=(//div[contains(@class,'MuiAutocomplete-root')]//input[@value='test-speech-model'])[1] |
# Step 10: Add ComfyUI provider with workflow path
When I click on "add provider button and select from preset dropdown and comfyui preset option and add provider submit and provider tab and add model button" elements with selectors:
| [data-testid='add-new-provider-button'] |
| div[role='combobox'] |
| li:has-text('comfyui') |
| [data-testid='add-provider-submit-button'] |
| button[role='tab']:has-text('comfyui') |
| [data-testid='add-new-model-button'] |
When I type "test-flux" in "model name input" element with selector "[data-testid='new-model-name-input']"
When I click on "language feature checkbox and imageGeneration feature checkbox" elements with selectors:
| [data-testid='feature-checkbox-language'] |
| [data-testid='feature-checkbox-imageGeneration'] |
When I type "C:/test/mock/workflow.json" in "workflow path input" element with selector "[data-testid='workflow-path-input']"
When I click on a "save model button" element with selector "[data-testid='save-model-button']"
Then I should see a "test-flux model chip" element with selector "[data-testid='model-chip-test-flux']"
# Verify workflow path was saved by clicking to edit
When I click on a "test-flux model chip" element with selector "[data-testid='model-chip-test-flux']"
Then I should see a "workflow path input with value" element with selector "[data-testid='workflow-path-input'][value='C:/test/mock/workflow.json']"
When I press "Escape" key
# Step 11: Close preferences window
When I close "preferences" window
And I ensure test ai settings exists