TidGi-Desktop/features/vectorSearch.feature
linonetwo 02c610c3d7 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.
2026-02-28 17:53:08 +08:00

185 lines
19 KiB
Gherkin
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 22 | 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%)\nAI使 | 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 preferences and navigate to Search section to generate embeddings
When I click on a "settings button" element with selector "#open-preferences-button"
When I switch to "preferences" window
When I click on a "search section" element with selector "[data-testid='preference-section-search']"
# Wait for workspace list to load
# The Search.tsx renders workspace cards with name, status, and buttons
And I should see a "wiki workspace card" element with selector "*:has-text('wiki')"
# Click the generate button - use button text "生成" instead of data-testid
# The button shows "生成" for initial generation, "更新嵌入" after generation
When I click on a "generate button with text" element with selector "button:has-text('')"
# Verify generation completed with detailed status information
# Should show: workspace name, embedding count, note count, last updated time and action buttons
Then I should see "workspace name in status and embedding count status and embedding word and last updated label and update button after generation and delete button after generation" elements with selectors:
| element description | selector |
| workspace name in status | *:has-text('wiki') |
| embedding count status | *:has-text('') |
| embedding word | *:has-text('') |
| last updated label | *:has-text('') |
| update button after generation | button:has-text('') |
| delete button after generation | button:has-text('') |
# Close preferences
When I close "preferences" 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 22 | 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') |