mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-05-10 22:31:05 -07:00
* fix: hide non-wiki workspaces from menu and disable remove for them (#694) * fix(workspace): make workspace settings save transactional to prevent data loss - Move disk write before memory update in Workspace.set() - Remove error swallowing in writeTidgiConfig() to let errors propagate - Add error handling in useForm.ts to catch and log save failures - Add UI error display in EditWorkspace/index.tsx - Only update Observable after successful persistence This fixes the issue where save button disappears but changes aren't persisted to tidgi.config.json, causing data loss when reopening settings. * feat(i18n): add error messages for workspace save failures Add SaveError and SaveErrorPrefix translations in English and Chinese to display error messages when workspace settings fail to save. * test(e2e): add test for tagNames persistence and missing step definitions - Add @edit-workspace-save-tagnames scenario to verify tagNames persist after save to tidgi.config.json - Add 'I clear and type' step definition for clearing input before typing - Add 'I close current window' step definition for closing windows - This test covers the regression where save button disappears but changes aren't persisted * use 5.4.0 * fix: spaced file in git op * fix: menu register race condition * Update pnpm-lock.yaml * Update wiki * fix: regenerate lockfile with pnpm 10.33.0 to fix checksum format * fix: remove unused import and useless constructor * fix: address Copilot review comments - Use new path for rename/copy in git operations - Ensure transactional workspace save (persist before cache update) - Normalize null label to undefined in menu * Remove close-window step; simplify UI typing Remove the Cucumber step that closed the current window and simplify a UI step by calling locator.fill(...) inline (also replace {tmpDir} in the input). Clean up minor whitespace in gitOperations and fix indentation/extra brace around startWiki error handling in the wiki service to correct control flow and prevent accidental scope issues. * Improve workspace form, git diff, and UI tests Refactor EditWorkspace form and UI behavior, make git diff/status handling more robust, and update E2E tests. - Add hasConfigChanges and related effects in useForm to correctly detect config-only changes and control restart requests; fix save button visibility in EditWorkspace and pass currentWorkspace to restart snackbar. Rename workspace section test id from 'workspace-section-search' to 'preference-section-search'. - Enhance gitOperations.getFileDiff to use porcelain -z and a helper to parse per-path status (getPorcelainStatusForPath) for reliable untracked/deleted detection. - Add clickBrowserViewElementWithRetry helper with backoff and text-aware selector handling; replace repetitive click logic in browser view step definitions and remove some redundant browser background assertions and a deprecated clear-and-type step. - Update feature files (gitLog, editWorkspace, vectorSearch) to reflect selector/id/name changes and i18n fallbacks for tab/button text. * doc * Use localized draft selector and show e2e window Update feature tests to target the localized draft tiddler title (data-tiddler-title$='的草稿') instead of the English prefix selector. Applied the change across features/hibernation.feature and features/tiddler.feature to ensure selectors match localized UI. Also enable SHOW_E2E_WINDOW=1 in the test:manual-e2e script in package.json so manual end-to-end runs open a visible window for debugging.
171 lines
18 KiB
Gherkin
171 lines
18 KiB
Gherkin
Feature: Vector Search - Embedding Generation and Semantic Search
|
||
As a user
|
||
I want to use vector database to perform semantic search in my wiki
|
||
So that I can find relevant content based on meaning rather than exact keywords
|
||
|
||
Background:
|
||
Given I add test ai settings
|
||
|
||
@vectorSearch @mockOpenAI
|
||
Scenario: Agent workflow - Create notes, update embeddings, then search
|
||
Given I have started the mock OpenAI server
|
||
| response | stream | embedding |
|
||
| <tool_use name="wiki-operation">{"workspaceName":"wiki","operation":"wiki-add-tiddler","title":"AI Agent Guide","text":"智能体是一种可以执行任务的AI系统,它可以使用工具、搜索信息并与用户交互。"}</tool_use> | false | |
|
||
| 已成功在工作区 wiki 中创建条目 "AI Agent Guide"。 | false | |
|
||
| <tool_use name="wiki-operation">{"workspaceName":"wiki","operation":"wiki-add-tiddler","title":"Vector Database Tutorial","text":"向量数据库用于存储和检索高维向量数据,支持语义搜索和相似度匹配。"}</tool_use> | false | |
|
||
| 已成功在工作区 wiki 中创建条目 "Vector Database Tutorial"。 | false | |
|
||
| <tool_use name="wiki-update-embeddings">{"workspaceName":"wiki","forceUpdate":false}</tool_use> | false | |
|
||
| | false | note1 |
|
||
| | false | note2 |
|
||
| 已成功为工作区 wiki 生成向量嵌入索引。总计2个笔记,2个嵌入向量。 | false | |
|
||
| <tool_use name="wiki-search">{"workspaceName":"wiki","searchType":"vector","query":"如何使用AI智能体","limit":5,"threshold":0.7}</tool_use> | false | |
|
||
| | false | query-note1 |
|
||
| 根据向量搜索结果,在工作区 wiki 中找到以下相关内容:\n\n**Tiddler: AI Agent Guide** (Similarity: 95.0%)\n这篇笔记介绍了AI智能体的基本概念和使用方法。 | false | |
|
||
# Launch application after mock server is ready
|
||
Then 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"
|
||
# Ensure we are in the agent workspace (not wiki workspace) for agent interaction
|
||
When I click on an "agent workspace button" element with selector "[data-testid='workspace-agent']"
|
||
And I should see a "new tab button" element with selector "[data-tab-id='new-tab-button']"
|
||
# Step 1: Open agent chat interface
|
||
When I click on a "new tab button" element with selector "[data-tab-id='new-tab-button']"
|
||
And I should see a "search interface" element with selector ".aa-Autocomplete"
|
||
When I click on a "search input box" element with selector ".aa-Input"
|
||
And I should see an "autocomplete panel" element with selector ".aa-Panel"
|
||
When I click on an "agent suggestion" element with selector '[data-autocomplete-source-id="agentsSource"] .aa-ItemWrapper'
|
||
# Step 2: Create first note
|
||
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
|
||
When I type "在 wiki 工作区创建一个名为 AI Agent Guide 的笔记,内容是:智能体是一种可以执行任务的AI系统,它可以使用工具、搜索信息并与用户交互。" in "chat input" element with selector "[data-testid='agent-message-input']"
|
||
And I press "Enter" key
|
||
Then I should see 4 messages in chat history
|
||
# Step 3: Create second note
|
||
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
|
||
When I type "再创建一个名为 Vector Database Tutorial 的笔记,内容是:向量数据库用于存储和检索高维向量数据,支持语义搜索和相似度匹配。" in "chat input" element with selector "[data-testid='agent-message-input']"
|
||
And I press "Enter" key
|
||
Then I should see 8 messages in chat history
|
||
# Step 4: Update vector embeddings using agent tool
|
||
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
|
||
When I type "为 wiki 工作区更新向量索引" in "chat input" element with selector "[data-testid='agent-message-input']"
|
||
And I press "Enter" key
|
||
Then I should see 12 messages in chat history
|
||
# Step 5: Perform vector search
|
||
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
|
||
When I type "使用向量搜索在 wiki 中查找关于如何使用AI智能体的内容" in "chat input" element with selector "[data-testid='agent-message-input']"
|
||
And I press "Enter" key
|
||
Then I should see 16 messages in chat history
|
||
# Verify the last message contains vector search results
|
||
And I should see "search result in last message" elements with selectors:
|
||
| element description | selector |
|
||
| search result in last message| [data-testid='message-bubble']:has-text('Tiddler: AI Agent Guide') |
|
||
|
||
@vectorSearch @mockOpenAI
|
||
Scenario: UI workflow - Generate embeddings via preferences, then search
|
||
Given I have started the mock OpenAI server
|
||
| response | stream | embedding |
|
||
| <tool_use name="wiki-operation">{"workspaceName":"wiki","operation":"wiki-add-tiddler","title":"Machine Learning Basics","text":"机器学习是人工智能的一个分支,通过算法让计算机从数据中学习规律。"}</tool_use> | false | |
|
||
| 已成功在工作区 wiki 中创建条目 "Machine Learning Basics"。 | false | |
|
||
| | false | note3 |
|
||
| <tool_use name="wiki-search">{"workspaceName":"wiki","searchType":"vector","query":"机器学习","limit":5,"threshold":0.7}</tool_use> | false | |
|
||
| | false | query-note3 |
|
||
| 根据向量搜索结果,在工作区 wiki 中找到以下相关内容:\n\n**Tiddler: Machine Learning Basics** (Similarity: 98.0%)\n这篇笔记介绍了机器学习的基本概念。 | false | |
|
||
# Launch application after mock server is ready
|
||
Then 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"
|
||
# Ensure we are in the agent workspace (not wiki workspace) for agent interaction
|
||
When I click on an "agent workspace button" element with selector "[data-testid='workspace-agent']"
|
||
And I should see a "new tab button" element with selector "[data-tab-id='new-tab-button']"
|
||
# Step 1: Create a test note via agent
|
||
When I click on "new tab button and create default agent button" elements with selectors:
|
||
| element description | selector |
|
||
| new tab button | [data-tab-id='new-tab-button'] |
|
||
| create default agent button| [data-testid='create-default-agent-button'] |
|
||
And I should see a "message input box" element with selector "[data-testid='agent-message-input']"
|
||
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
|
||
When I type "在 wiki 工作区创建一个名为 Machine Learning Basics 的笔记,内容是:机器学习是人工智能的一个分支,通过算法让计算机从数据中学习规律。" in "chat input" element with selector "[data-testid='agent-message-input']"
|
||
And I press "Enter" key
|
||
Then I should see 4 messages in chat history
|
||
# Step 2: Open workspace settings and navigate to Search/Embedding section to generate embeddings
|
||
When I open edit workspace window for workspace with name "wiki"
|
||
And I switch to "editWorkspace" window
|
||
When I click on a "search section" element with selector "[data-testid='preference-section-search']"
|
||
When I click on a "generate embeddings button" element with selector "[data-testid^='generate-embeddings-button-']"
|
||
Then I should see a "delete embeddings button after generation" element with selector "[data-testid^='delete-embeddings-button-']"
|
||
# Close workspace settings
|
||
When I close "editWorkspace" window
|
||
And I switch to "main" window
|
||
# Step 3: Perform vector search and verify results match agent workflow
|
||
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
|
||
When I type "使用向量搜索在 wiki 中查找关于机器学习的内容" in "chat input" element with selector "[data-testid='agent-message-input']"
|
||
And I press "Enter" key
|
||
Then I should see 8 messages in chat history
|
||
# Verify the last message contains vector search results
|
||
And I should see a "ML search result in last message" element with selector "[data-testid='message-bubble']:has-text('Tiddler: Machine Learning Basics')"
|
||
|
||
@vectorSearch @mockOpenAI
|
||
Scenario: Vector search with low similarity - No results below threshold, then lower threshold
|
||
Given I have started the mock OpenAI server
|
||
| response | stream | embedding |
|
||
| <tool_use name="wiki-operation">{"workspaceName":"wiki","operation":"wiki-add-tiddler","title":"AI Technology","text":"人工智能技术正在改变世界。"}</tool_use> | false | |
|
||
| 已成功在工作区 wiki 中创建条目 "AI Technology"。 | false | |
|
||
| <tool_use name="wiki-operation">{"workspaceName":"wiki","operation":"wiki-add-tiddler","title":"Machine Learning","text":"机器学习算法和应用。"}</tool_use> | false | |
|
||
| 已成功在工作区 wiki 中创建条目 "Machine Learning"。 | false | |
|
||
| <tool_use name="wiki-update-embeddings">{"workspaceName":"wiki","forceUpdate":false}</tool_use> | false | |
|
||
| | false | note4 |
|
||
| | false | note5 |
|
||
| 已成功为工作区 wiki 生成向量嵌入索引。总计2个笔记,2个嵌入向量。 | false | |
|
||
| <tool_use name="wiki-search">{"workspaceName":"wiki","searchType":"vector","query":"天气预报","limit":5,"threshold":0.7}</tool_use> | false | |
|
||
| | false | unrelated |
|
||
| 在Wiki工作空间"wiki"中未找到符合条件的向量搜索结果(相似度阈值:0.7)。 | false | |
|
||
| <tool_use name="wiki-search">{"workspaceName":"wiki","searchType":"vector","query":"天气预报","limit":5,"threshold":0.1}</tool_use> | false | |
|
||
| | false | unrelated |
|
||
| 根据向量搜索结果,在工作区 wiki 中找到以下相关内容:\n\n**Tiddler: AI Technology** (Similarity: 15.0%)\n低相似度结果。 | false | |
|
||
# Launch application after mock server is ready
|
||
Then 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"
|
||
# Ensure we are in the agent workspace (not wiki workspace) for agent interaction
|
||
When I click on an "agent workspace button" element with selector "[data-testid='workspace-agent']"
|
||
And I should see a "new tab button" element with selector "[data-tab-id='new-tab-button']"
|
||
# Step 1: Open agent chat interface
|
||
When I click on "new tab button and create default agent button" elements with selectors:
|
||
| element description | selector |
|
||
| new tab button | [data-tab-id='new-tab-button'] |
|
||
| create default agent button| [data-testid='create-default-agent-button'] |
|
||
And I should see a "message input box" element with selector "[data-testid='agent-message-input']"
|
||
# Step 2: Create first note about AI
|
||
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
|
||
When I type "在 wiki 工作区创建一个名为 AI Technology 的笔记,内容是:人工智能技术正在改变世界。" in "chat input" element with selector "[data-testid='agent-message-input']"
|
||
And I press "Enter" key
|
||
Then I should see 4 messages in chat history
|
||
# Step 3: Create second note about ML
|
||
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
|
||
When I type "再创建一个名为 Machine Learning 的笔记,内容是:机器学习算法和应用。" in "chat input" element with selector "[data-testid='agent-message-input']"
|
||
And I press "Enter" key
|
||
Then I should see 8 messages in chat history
|
||
# Step 4: Update vector embeddings
|
||
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
|
||
When I type "为 wiki 工作区更新向量索引" in "chat input" element with selector "[data-testid='agent-message-input']"
|
||
And I press "Enter" key
|
||
Then I should see 12 messages in chat history
|
||
# Step 5: Search for unrelated content with high threshold (should find nothing)
|
||
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
|
||
When I type "使用向量搜索在 wiki 中查找关于天气预报的内容,阈值设为0.7" in "chat input" element with selector "[data-testid='agent-message-input']"
|
||
And I press "Enter" key
|
||
Then I should see 16 messages in chat history
|
||
# Verify the response contains "no results found" with threshold info
|
||
Then I should see "no results and threshold 0.7" elements with selectors:
|
||
| element description | selector |
|
||
| no results message | [data-testid='message-bubble']:has-text('未找到符合条件') |
|
||
| threshold 0.7 message | [data-testid='message-bubble']:has-text('0.7') |
|
||
# Step 6: Lower threshold and search again (should find low-similarity results)
|
||
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
|
||
When I type "再次搜索天气预报,但这次把阈值降低到0.1" in "chat input" element with selector "[data-testid='agent-message-input']"
|
||
And I press "Enter" key
|
||
Then I should see 20 messages in chat history
|
||
# Verify the response contains low-similarity result
|
||
Then I should see "AI Technology and low similarity" elements with selectors:
|
||
| element description | selector |
|
||
| AI Technology message | [data-testid='message-bubble']:has-text('Tiddler: AI Technology') |
|
||
| low similarity message | [data-testid='message-bubble']:has-text('15') |
|