Commit graph

673 commits

Author SHA1 Message Date
wyh
8d7561d58c feat: 暂存. 2025-08-29 14:01:23 +08:00
Yizong ZHOU
2785b170d5
remove duplicated feature bullet point (#1756) 2025-08-26 15:33:41 -07:00
Logan Yang
d85420bc06
3.0.0 (#1753)
* Revise README.md to highlight new features and improvements in Copilot V3

* 3.0.0
2025-08-25 21:23:58 -07:00
Logan Yang
eb830dfa6f
Support image and chat context menu in free modes (#1746) 2025-08-25 19:59:57 -07:00
Logan Yang
b446a68b02
Update default embedding requests per minute setting to 60 and adjust related description in QASettings for clarity (#1742) 2025-08-22 22:17:45 -07:00
Logan Yang
e12f4b7a40
Update default chat model and chores (#1741) 2025-08-22 21:38:54 -07:00
Logan Yang
41bb213be6
feat: add back garbage collection command for Copilot index (#1740) 2025-08-22 21:16:27 -07:00
Logan Yang
d1ddbd766c
Use salient terms for lexical ranking (#1739) 2025-08-22 20:40:01 -07:00
James Zhang
e045e50fe2
fix(embeddingManager.ts): fix embedding with LM Studio (#1735) 2025-08-22 18:29:35 -07:00
Logan Yang
a0d5d0b8ea
Go back to orama for semantic search (#1737)
* refactor: transition to semantic search with VectorStoreManager

- Updated the search architecture to utilize VectorStoreManager for semantic indexing and retrieval, replacing the legacy MemoryIndexManager.
- Removed deprecated Orama components and streamlined the search process for improved performance and clarity.
- Enhanced settings management by removing legacy search options and clarifying semantic search configurations.
- Refactored various components to support the new semantic search system, ensuring consistent behavior and improved user experience.
- Updated documentation to reflect changes in search functionality and settings management.

* feat: add optional parameters for search configuration in ChainManager and VaultQAChainRunner

- Introduced new optional parameters: timeRange, textWeight, returnAll, and useRerankerThreshold to enhance search configuration flexibility.
- Updated findRelevantNotes to correctly compute average embeddings by dividing the sum by the number of embeddings, ensuring accurate average calculations.
- Enhanced SearchTools to include timeRange and textWeight in search tool configurations, improving search customization options.

* feat: add textWeight and additional parameters to search configuration

- Introduced textWeight, timeRange, returnAll, and useRerankerThreshold as optional parameters in the CopilotPlugin to enhance search configuration flexibility.
- Updated the search logic to accommodate these new parameters, improving customization options for users.

* refactor: remove deprecated indexing components and streamline search architecture

- Deleted the IndexingNotificationManager, IndexingPipeline, IndexingProgressTracker, and IndexPersistenceManager classes to simplify the codebase and remove unused functionality.
- Updated README.md to reflect the removal of semantic search features and clarify the current search architecture.
- Enhanced documentation to provide clear guidance on the new chunk-based lexical search system, emphasizing its performance and memory efficiency.
- Removed associated tests to maintain code clarity and focus on active components.

* feat: introduce LLM timeout configuration and enhance query handling

- Added LLM_TIMEOUT_MS constant for a standardized timeout of 10 seconds for LLM operations.
- Updated HybridRetriever to utilize withTimeout for query rewriting, ensuring operations respect the new timeout.
- Adjusted QueryExpander and SearchCore to use LLM_TIMEOUT_MS for consistent timeout handling across components.
- Enhanced localSearchTool to delegate between lexical and semantic search based on settings, improving search flexibility.

* feat: enhance localSearch handling and tool confirmation messages

- Added special handling in getToolDisplayName for localSearch to display the search type based on settings.
- Updated getToolConfirmtionMessage to include salient terms for lexical search when applicable, improving user feedback during tool calls.
- Integrated settings retrieval to conditionally display relevant information based on user preferences.

* feat: add number of partitions setting to QASettings for improved indexing control

- Introduced a new setting for "Number of Partitions" in QASettings, allowing users to configure the number of partitions for the Copilot index.
- Updated the UI to provide a description and options for selecting the number of partitions, enhancing user experience and flexibility in managing large vaults.
- Removed the previous conditional rendering of the partitions setting based on semantic search, streamlining the settings interface.

* fix: update default requests per minute setting in QASettings

- Changed the default value for "Requests per Minute" from 90 to 30 to better align with user needs and prevent rate limiting issues.
- Adjusted the maximum value for the setting from 300 to 60, ensuring users stay within optimal limits for embedding requests.
- Updated the value assignment to ensure it does not exceed the new maximum, enhancing the robustness of the settings configuration.
2025-08-22 18:17:53 -07:00
Logan Yang
615330f4b8
fix: AI response streaming UI broken with react error 409 (#1723) 2025-08-19 21:38:08 -07:00
Emt-lin
9e77e4b86d
Optimize error msg and Improve UI (#1734)
* feat: Output more error messages for easier user viewing.

* feat: Optimize UI text style and color consistency.
2025-08-19 19:03:25 -07:00
Logan Yang
18f6405c76
Search v3 improvement 2 (#1733)
* feat: implement chunk-based search architecture and enhance retrieval consistency

- Introduced a new `ChunkManager` for managing note chunking, enabling efficient handling of large documents.
- Added comprehensive tests for `ChunkManager`, `SearchCore`, and `TieredLexicalRetriever` to ensure consistent chunk retrieval and scoring.
- Updated `SearchCore` to utilize chunk-based retrieval, improving performance and relevance in search results.
- Enhanced `FullTextEngine` to support chunk indexing, optimizing memory usage and search accuracy.
- Refactored scoring mechanisms to maintain chunk order and consistency across search results.
- Updated documentation to reflect changes in search architecture and chunking strategies.

feat: integrate ChunkManager into SearchCore and related components

- Added ChunkManager to SearchCore for improved chunk-based retrieval.
- Updated FullTextEngine to accept ChunkManager as an optional parameter, enhancing memory management.
- Refactored TieredLexicalRetriever to utilize the shared ChunkManager instance from SearchCore, ensuring consistent chunk handling.
- Enhanced tests for TieredLexicalRetriever to mock ChunkManager functionality, validating chunk retrieval behavior.

* feat: add enableLexicalBoosts flag to enhance search capabilities. Fix expanded term in ranking bug.

- Introduced `enableLexicalBoosts` setting in `CopilotSettings` to control the application of lexical boosts during search operations.
- Updated `SearchCore` to utilize the new setting, allowing for conditional application of folder and graph-based relevance boosts.
- Enhanced `QueryExpander` and related interfaces to include `expandedTerms`, capturing LLM-generated terms for improved recall.
- Added tests to validate the behavior of lexical boosts based on the new setting, ensuring expected functionality in various scenarios.
- Updated documentation to reflect the new feature and its implications for search performance and relevance.

* feat: enhance SearchCore to conditionally skip lexical and semantic searches based on semantic weight

- Updated SearchCore to skip lexical search when semantic weight is 100% and skip semantic search when weight is 0%, improving performance.
- Added logging to indicate when searches are skipped, enhancing traceability.
- Introduced new tests to validate the behavior of search execution under different semantic weight scenarios, ensuring expected functionality.

* feat: enhance ChunkManager and SearchCore with input validation and error handling

- Improved input validation in `ChunkManager` to ensure valid note paths and handle edge cases, including empty and excessively long inputs.
- Enhanced error handling in `SearchCore` to gracefully manage failures during chunk retrieval and fallback to simple grep results when necessary.
- Updated `QueryExpander` to utilize a race condition approach for timeout handling, improving reliability during query expansion.
- Removed deprecated tests and added new tests to validate the behavior of input validation and error handling, ensuring robustness in various scenarios.
- Updated documentation to reflect changes in input handling and error management strategies.

* fix: update semanticWeight assignment to use nullish coalescing operator

- Changed the assignment of `semanticWeight` in `TieredLexicalRetriever` to utilize the nullish coalescing operator (`??`) for better handling of undefined values, ensuring a default value of 0.6 is applied when no weight is provided.

* feat: enhance CopilotPlusChainRunner and MemoryIndexManager for improved source handling

- Added deduplication of sources in CopilotPlusChainRunner to ensure unique results.
- Refactored MemoryIndexManager to aggregate scores by chunk ID instead of note path, improving consistency in scoring.
- Introduced a new method for aggregating scores per chunk, enhancing the retrieval process.
- Updated tests to validate the new behavior in source handling and scoring aggregation.

* feat: standardize chunk ID formatting and enhance ChunkManager functionality

- Updated chunk ID format to consistently use zero-padding for indices across all components, ensuring uniformity in chunk identification.
- Refactored ChunkManager to include automatic cache validation and regeneration for chunk retrieval, improving reliability and performance.
- Introduced content hash for chunks to validate content integrity and prevent stale data usage.
- Enhanced tests to validate new chunk ID formatting and ensure consistent behavior across various scenarios.
- Updated documentation to reflect changes in chunk ID handling and retrieval processes.

* feat: streamline index clearing process in registerCommands

- Removed redundant file removal logic for clearing local Copilot semantic index.
- Introduced IndexPersistenceManager to handle index file clearing, improving code clarity and maintainability.
- Updated user notification to reflect the new index clearing process.

* feat: add comprehensive tests for FullTextEngine's clear method

- Introduced multiple test cases for the clear method in FullTextEngine to ensure safe operation under various conditions, including uninitialized index, multiple clear calls, and handling of index cleanup methods.
- Enhanced the clear method to handle scenarios where the index may throw errors during cleanup, ensuring robust state management.
- Verified memory management reset during the clear operation, improving overall reliability of the FullTextEngine.

* feat: implement TimeoutError and withTimeout utility for enhanced error handling

- Introduced a new TimeoutError class for consistent timeout error management across operations.
- Added withTimeout utility function to execute operations with a specified timeout, utilizing AbortController for proper cancellation.
- Updated QueryExpander and SearchCore to leverage withTimeout for handling LLM requests, improving reliability during long-running operations.
- Enhanced tests for withTimeout and TimeoutError to ensure correct behavior under various scenarios, including timeout handling and error propagation.
- Updated documentation to reflect the new timeout handling features and their usage.

* fix: OOM error for single file index update

- Introduced memory safety checks in IndexPersistenceManager to prevent out-of-memory (OOM) errors during record processing.
- Implemented batch processing for writing records and updating file records, improving memory efficiency.
- Added methods for estimating memory usage and checking memory safety thresholds.
- Enhanced MemoryIndexManager to utilize incremental updates for modified files, reducing memory load during reindexing.
- Updated tests to validate the new memory-safe operations and ensure correct behavior under high memory usage scenarios.

* fix: have semantic search completely independent of grep and lexical search

* refactor: update chunk ID formatting to non-padded indices

- Changed chunk ID format in ChunkManager and related components to use non-padded indices, improving consistency and simplifying ID generation.
- Updated tests to reflect the new ID format and ensure correct behavior across various scenarios.
- Removed legacy checks for old padded formats in tests, streamlining the codebase.

* feat: add SemanticSearchToggleModal for enabling/disabling semantic search

- Introduced SemanticSearchToggleModal to confirm user actions for enabling or disabling semantic search.
- Updated QASettings to utilize the new modal for handling semantic search state changes, providing user feedback and guidance on index management.

* refactor: streamline embedding model handling in BasicSettings and QASettings

- Removed the embedding model selection from BasicSettings, consolidating its functionality within QASettings.
- Introduced a new handler for setting the default embedding model in QASettings, ensuring user confirmation via RebuildIndexConfirmModal.
- Updated the UI components in QASettings to provide detailed descriptions and tooltips for embedding model selection, enhancing user experience and clarity.

* refactor: remove unused components and streamline memory management

- Deleted the SemanticReranker and VaultPathValidator classes to simplify the codebase and remove unused functionality.
- Removed the index.ts file for v3 search, consolidating exports and reducing clutter.
- Updated MemoryIndexManager to utilize a simplified in-memory approach for reindexing, enhancing performance and memory efficiency.
- Adjusted tests to reflect changes in the MemoryIndexManager's reindexing strategy, ensuring consistent behavior and improved reliability.
2025-08-19 19:00:15 -07:00
Logan Yang
e26561ba40
feat: introduce unified search system with legacy support (#1728)
* feat: introduce unified search system with legacy support

- Added a new `SearchSystem` interface and `SearchSystemFactory` to manage both legacy and v3 search implementations.
- Updated various components to utilize the new factory for creating retrievers and managing indexing operations.
- Introduced `useLegacySearch` setting to toggle between legacy and v3 search systems, enhancing user control over search functionality.
- Refactored existing search-related code to streamline indexing and retrieval processes, improving overall performance and maintainability.
- Updated documentation to reflect changes in search architecture and settings management.

* feat: enhance V3 indexing responses with document count

- Updated the V3SearchIndexer to return the document count after incremental and full indexing operations.
- Modified success messages to include the number of documents indexed, improving user feedback and clarity on indexing results.

* feat: improve error handling and user feedback for indexing operations

- Enhanced the indexing process by adding error handling for both incremental and full indexing operations, providing users with clear notifications in case of failures.
- Updated the `refreshVaultIndex` and `forceReindexVault` functions to log errors and display messages when indexing fails, improving overall user experience and transparency.
- Refactored the main indexing logic in `CopilotPlugin` to ensure proper loading of indexes based on the selected strategy, enhancing functionality and reliability.

* fix: update indexing logic for search system consistency

- Changed comments to clarify that the index loading occurs even when search is disabled.
- Refactored the index loading process to consistently use `SearchSystemFactory`, enhancing code clarity and maintainability.
- Updated the condition for enabling semantic search to account for the new `useLegacySearch` setting, improving search functionality control.
2025-08-17 16:32:21 -07:00
Emt-lin
214fd8d44d
feat: enhance optional parameter controls with toggle functionality. (#1716)
* feat: enhance optional parameter controls with toggle functionality.

* fix: fix the issue of the ParameterControl Fails with Undefined and Zero.

* feat: Change Reasoning Effort/Verbosity parameters to optional parameters.
2025-08-15 21:32:29 -07:00
Zero Liu
315ba1aca7
Update live mode check (#1719) 2025-08-15 21:25:13 -07:00
Logan Yang
7bc84923fa
Improve Search v3 (#1721)
* Implement graph boost and remove graph expander

- Removed the GraphExpander class and its associated tests, streamlining the search process.
- Eliminated the graphHops setting from CopilotSettings and related sanitization logic.
- Updated SearchCore and TieredLexicalRetriever to utilize direct candidate limiting without graph expansion.
- Introduced GraphBoostCalculator for link-based reranking, enhancing search result relevance based on candidate connections.
- Updated documentation to reflect changes in search architecture and removed references to graph expansion.

* Refactor search scoring and implement folder boosting

- Updated the search scoring mechanism to remove the grep prior, simplifying the ranking process.
- Introduced the FolderBoostCalculator to apply logarithmic boosts for documents in folders with multiple matches, enhancing result relevance.
- Updated SearchCore to integrate folder boosting after the weighted RRF fusion.
- Refactored FullTextEngine to remove the folder boosting logic, centralizing it in the new calculator.
- Added comprehensive tests for the FolderBoostCalculator to ensure correct boost application and behavior.
- Revised documentation to reflect changes in the search architecture and boosting strategies.

* Enhance search functionality with scoring normalization and explanations

- Introduced ScoreNormalizer to apply z-score and tanh normalization, preventing auto-1.0 scores and improving score distribution.
- Updated FullTextEngine to include lexical match explanations in search results, providing insights into scoring factors.
- Enhanced SearchCore to pass the same candidate set to both full-text and semantic searches, ensuring consistency in results.
- Implemented detailed logging for candidate filtering and search processes, improving traceability and debugging.
- Added comprehensive tests for ScoreNormalizer and updated existing tests to validate new scoring behaviors.

* Add semantic weight slider

- Added `semanticSearchWeight` to `DEFAULT_SETTINGS` for controlling the balance between semantic and lexical search.
- Updated `SettingItem` and `SettingSlider` components to support a suffix for better user experience in displaying semantic weight.
- Introduced a new slider in the QASettings UI for adjusting semantic search weight, allowing users to set preferences between 0% and 100%.
- Implemented tests for the new semantic weight functionality in `SearchCore`, ensuring correct application of weights during search operations.

* Enhance memory management and search functionality

- Added `lexicalSearchRamLimit` to `DEFAULT_SETTINGS` for controlling RAM usage in lexical search, with a default of 100 MB and a range of 20-1000 MB.
- Updated `MemoryManager` to utilize the new RAM limit setting, ensuring proper memory allocation and management during search operations.
- Refactored `GrepScanner` to simplify batch size handling and yield intervals, improving performance.
- Introduced unit tests for `MemoryManager` to validate RAM limit functionality and memory tracking behaviors.
- Removed the deprecated `platformUtils` module, streamlining the codebase.

* Enhance sources modal with source explanations

- Updated source structures across various components to include an optional `explanation` field, providing additional context for search results.
- Modified `SourcesModal` to display explanations in a collapsible format, improving user experience and clarity.
- Adjusted `SearchCore`, `TieredLexicalRetriever`, and related classes to preserve and pass explanation data through the search pipeline.
- Refactored relevant utility functions to accommodate the new explanation field, ensuring consistency in source handling.
- Enhanced logging and documentation to reflect changes in search result structures and explanation handling.

* Enhance weighted RRF function to merge explanations

- Updated the `weightedRRF` function to merge explanations from both lexical and semantic search results, improving the clarity and depth of search result context.
- Implemented logic to combine lexical matches and semantic scores, ensuring comprehensive explanation handling for each item.
- Adjusted the explanation merging process to maintain existing scores while integrating new data, enhancing the overall search experience.

* Update QASettings component to clarify description for Max Sources setting

- Changed the description for the Max Sources slider to specify that Copilot now retrieves relevant notes instead of blocks, and updated the default value for N from 3 to 15, enhancing user understanding of the setting's functionality.

* Refactor search architecture to enable parallel execution of lexical and semantic searches

- Updated the search pipeline to run full-text and semantic searches concurrently, improving performance and reducing latency.
- Introduced new methods for executing lexical and semantic searches separately, enhancing code organization and clarity.
- Adjusted documentation to reflect changes in search execution and added details on the parallel search process.
- Increased LLM generation timeout and refined candidate handling for improved search accuracy.

* Increase default tool timeout to 60 seconds and update search result formatting to include full content for LLM context.

* Enhance graph boost functionality and improve search performance

- Updated SourcesModal to include detailed explanations for graph connections, enhancing user understanding of search results.
- Refactored SearchCore to apply graph boosts more effectively, including logging improvements for better traceability.
- Modified GraphBoostCalculator to support new connection types and weights, allowing for more nuanced scoring based on backlinks, co-citations, and shared tags.
- Adjusted FolderBoostCalculator to reduce the maximum boost factor, ensuring more balanced scoring.
- Enhanced FullTextEngine to defer index creation for improved UI responsiveness and added memory management features.
- Updated tests for GraphBoostCalculator to validate new functionality and ensure accurate scoring behavior.

* Improve search signals

- Updated QueryExpander to include original user query and expanded variants in the response structure, improving clarity and usability.
- Refactored SearchCore to log search details with reduced verbosity, focusing on significant query expansion results and candidate counts.
- Improved FullTextEngine to ensure scoring is based solely on the original query and salient terms, while expanded queries are used only for recall.
- Enhanced logging throughout the search process for better traceability and debugging, including detailed results summaries and performance metrics.

* Fix tests

* Update field weights in FullTextEngine for improved scoring consistency

- Adjusted weights for metadata fields (path, headings, tags, props, links) from 2.5 and 2 to 1.5, ensuring a more balanced scoring system.
- Updated corresponding tests to reflect the new weight values, maintaining alignment between implementation and test cases.

* Refactor modelAdapter to improve query handling and guidelines

- Moved the import statement for BaseChatModel to the correct position for better organization.
- Added new guidelines for query handling, emphasizing the use of personal knowledge or notes before web searches, and clarifying the use of tool names in responses.

* Update README.md to reflect changes in search scoring and normalization

- Adjusted field weights for Full-Text and Graph Boosts to improve scoring consistency and balance.
- Changed normalization method from Z-score to Min-max, enhancing score range management.
- Updated documentation to clarify the new scoring parameters and their implications for search results.

* Refactor localSearch result processing for improved consistency and clarity

- Introduced a new utility module for handling localSearch results, including formatting and source extraction.
- Updated AutonomousAgentChainRunner and CopilotPlusChainRunner to utilize the new processing methods, ensuring consistent handling of localSearch outputs.
- Enhanced error handling and logging for localSearch results, improving traceability and user feedback.
- Removed redundant code related to localSearch result processing, streamlining the execution flow.

* Enhance error handling in IndexingPipeline for embedding failures

- Added detailed logging for token counts when embedding errors occur, aiding in debugging and user guidance.
- Implemented a try-catch block around the embedding process to capture and log specific error messages related to token limits.
- Introduced ChatModelManager to analyze token counts for each chunk, providing insights into potential batch size adjustments.

* Reduce maxCandidates in GraphBoostCalculator from 50 to 3 for improved search performance and relevance.

* Enhance GraphBoostCalculator with semantic similarity threshold and max candidates adjustments

- Increased maxCandidates from 3 to 10 to allow for more comprehensive result analysis.
- Introduced semanticSimilarityThreshold to boost results based on a minimum similarity score of 0.75, improving relevance in search results.
- Updated filtering logic to respect both the semantic threshold and max candidates limit, ensuring only the most relevant results are boosted.

* Fix tests, update readme

- Added a Jest mock for ChatModelManager to simulate token counting without requiring the actual SDK, streamlining test execution and improving isolation of unit tests.

* Fix ToolResultFormatter and add tests

- Introduced comprehensive tests for the ToolResultFormatter class, covering various scenarios for both local and web search formats.
- Validated handling of XML-wrapped search results, including cases with multiple documents, empty results, and malformed XML.
- Ensured fallback to JSON parsing for non-XML results and tested for proper formatting of output messages.
- Enhanced test coverage to improve reliability and maintainability of the formatting logic.

* Enhance FolderBoostCalculator with relevance ratio and improved scoring logic

- Added totalDocsInFolder and relevanceRatio to the FolderBoostResult interface to provide better insights into folder statistics.
- Updated the boost calculation logic to apply boosts based on a minimum relevance ratio, ensuring only folders with a significant portion of relevant documents receive boosts.
- Revised README.md to reflect changes in folder boost calculations, including new requirements for minimum relevant documents and relevance ratio thresholds.
- Enhanced unit tests for FolderBoostCalculator to cover new scenarios and ensure correct behavior under various conditions.

* Fix test warnings

- Added a check to ensure the getConfig method exists before calling it, enhancing compatibility with test environments.
- Updated error logging to only occur in non-test environments, reducing unnecessary console output during testing.
2025-08-15 21:24:42 -07:00
Michael Rumyantsev
9823fb19d5
fix(utils): Fix handling of headers in the safeFetch util (#1720) 2025-08-15 20:31:22 -07:00
Logan Yang
021153606f
Update docs to make it clear that url processing is for user input only (#1714)
- Updated ContextProcessor to clarify that note content is included as-is without URL extraction.
- Modified ContextManager and Mention classes to ensure only URLs from user input are processed, improving clarity on URL handling.
- Added documentation to emphasize the importance of processing URLs exclusively from user chat input, aligning with existing functionality.
2025-08-11 22:47:21 -07:00
Logan Yang
8f8f4f7454
Adapt gpt5 (#1713)
* Use responses api for GPT-5 models

- Updated configuration for GPT-5 models to utilize the Responses API for verbosity settings, ensuring proper handling of verbosity as a nested parameter.
- Added logging to indicate when the Responses API is enabled for GPT-5 models during model instance creation.
- Refactored model instance creation logic to automatically set the useResponsesApi flag for GPT-5 models, improving clarity and functionality in model configuration.

* Add GPT-5 specific enhancements to model adapter

- Introduced a method to check if the model is part of the GPT-5 family, enhancing model-specific behavior.
- Added GPT-5 specific instructions for tool usage, improving clarity on tool call requirements.
- Implemented a response sanitization method for GPT-5 to handle multiple iterations, ensuring only the most relevant response is returned.
- Refactored user message enhancement logic to streamline tool reminder messages based on the presence of required tools.

* Enhance tool execution responses with structured JSON format

- Updated the `executeSequentialToolCall` function to return an empty JSON object instead of a plain string when tools return null/undefined results, improving compatibility.
- Refactored the `writeToFileTool` and `replaceInFileTool` to return structured JSON responses, ensuring consistent parsing and better handling of results.
- Modified the `webSearchTool` to return a structured JSON array of results, aligning with the new response format for improved consistency across tools.
- Enhanced the `ToolResultFormatter` to handle the new JSON response formats, ensuring user-friendly display of tool results in the UI.
2025-08-11 22:21:55 -07:00
Wenzheng Jiang
7a884ab473
Pass necessary context to validateLicenseKey (#1708)
* Pass necessary context to validateLicenseKey

* Resolve comments

* Prevent overriding reserved keys in Brevilabs client context

Co-authored-by: logancyang <logancyang@gmail.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: logancyang <logancyang@gmail.com>
2025-08-11 22:01:22 -07:00
Emt-lin
ea9e96b4d6
feat: remove the verifyApiKey button in the ApiKeyDialog. (#1711) 2025-08-11 20:48:50 -07:00
Logan Yang
df3efaecc0
Implement vault search v3 (#1703)
* Add LexicalEngine and related interfaces for enhanced search functionality

- Implement LexicalEngine class utilizing FlexSearch for efficient document indexing and searching.
- Create Hit, SearchResult, SearchOptions, and RetrieverEngine interfaces to standardize search operations.
- Update package.json and package-lock.json to include new dependencies: flexsearch and p-queue.

* Add QueryExpander class and tests for enhanced search query expansion

* Add README for Tiered Note-Level Lexical Retrieval with multilingual support and enhanced search pipeline

* Implement v3 tiered search with GrepScanner, FullTextEngine, and GraphExpander

- Add GrepScanner for fast substring search (L0)
- Implement FullTextEngine with ephemeral FlexSearch index (L1)
- Add GraphExpander for link-based candidate expansion
- Create MemoryManager with platform-aware limits
- Implement weighted RRF fusion for result combination
- Add SemanticReranker placeholder for future integration
- Include comprehensive tests for core components
- Simplify code based on review: use TextEncoder, extract methods, streamline RRF
- Add clear logging for debugging search pipeline

The architecture follows a tiered approach:
1. Grep scan for initial candidates
2. Graph expansion to increase recall
3. Full-text search on expanded set
4. Optional semantic reranking
5. RRF fusion to combine signals

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Enhance tiered retrieval recall with both rewritten queries and the expanded salient terms

- Added detailed example of end-to-end query processing in README.md
- Updated TieredRetriever to log salient terms during query expansion
- Modified FullTextEngine to index link basenames for improved searchability
- Adjusted NoteDoc interface to clarify link handling and indexing

* Refactor QueryExpander configuration and caching logic for improved clarity and performance; enhance GraphExpander documentation and testing; remove unused fields from NoteDoc interface.

* Refactor search retrieval system to wire in TieredLexicalRetriever

- Replaced HybridRetriever with TieredLexicalRetriever in ChainManager, VaultQAChainRunner, and main.ts for improved multi-stage retrieval.
- Updated README.md to reflect new integration tasks and performance benchmarks.
- Introduced TieredLexicalRetriever class to handle on-demand indexing and retrieval.
- Enhanced GrepScanner to support inclusion/exclusion patterns for file indexing.
- Modified TieredRetriever to combine expanded salient terms and improved logging for final results.
- Removed legacy index management in favor of ephemeral indexing with TieredLexicalRetriever.
- Updated interfaces and utility functions to support new retrieval logic.

* feat: Implement first working TieredLexicalRetriever and refactor search scoring

- Added comprehensive tests for TieredLexicalRetriever, covering folder boosting and result combination.
- Refactored TieredLexicalRetriever to utilize SearchCore instead of TieredRetriever.
- Enhanced FullTextEngine with improved scoring mechanisms, including field weighting and multi-field match bonuses.
- Introduced FuzzyMatcher utility for fuzzy matching capabilities, including Levenshtein distance and variant generation.
- Updated GrepScanner to prioritize path matching for faster search results.
- Implemented normalized scoring in RRF for better ranking consistency.

* feat: Update vault search result display to show snippet of content instead of full text

* feat: Enhance FullTextEngine to index frontmatter property values and improve search scoring

* feat: Improve scoring and logging

* feat: Refactor TieredLexicalRetriever to support time-based queries and improve document retrieval logic

* Remove TODO.md from tracking and add to .gitignore

- TODO.md is now a local-only development session tracker
- Prevents accidental commits of work-in-progress task lists
- Each developer can maintain their own TODO.md without conflicts

* feat: Update dependencies and enhance search functionality

- Upgraded axios to version 1.11.0 and electron to version 27.3.11 for improved performance and security.
- Refactored QueryExpander to limit queries to the original for strict fallback tests.
- Enhanced SearchCore to rank grep hits by evidence quality before fusion, improving retrieval accuracy.
- Implemented a new method in SearchCore to rank grep hits based on evidence strength.
- Updated TieredLexicalRetriever tests to ensure proper integration with mocked SearchCore.
- Improved FuzzyMatcher to include plural/singular normalization for better fuzzy matching.

* feat: Add tool call marker encoding/decoding

- Introduced new utility functions for encoding and decoding tool call markers to ensure safe embedding in HTML comments.
- Updated `updateChatMemory` to handle encoded tool call markers, preserving their integrity during memory storage.
- Enhanced logging to decode tool marker results for better readability while maintaining encoded formats for storage.
- Added comprehensive tests for tool call marker functionality to ensure correct encoding and decoding behavior.
- Refactored related components to integrate the new encoding/decoding logic seamlessly.

* feat: Enhance FullTextEngine search to support low-weight terms and improve scoring

- Updated FullTextEngine to accept low-weight terms in the search method, allowing for better handling of salient terms.
- Implemented downweighting for boolean and numeric tokens in the properties field to reduce noise in search results.
- Added a new test case to validate the downweighting behavior for boolean and numeric queries in FullTextEngine.
- Improved logging for full-text search results to provide clearer insights into the search process.

* feat: Update GraphExpander to enhance search recall with adaptive hop logic

- Implemented guardrails in GraphExpander to adjust hop depth based on the number of grep hits: allows +1 hop for small sets (<5) and limits to 1 hop for large sets (≥50).
- Updated README.md to reflect new guardrail logic and scoring normalization in search results.
- Enhanced test cases to validate the new behavior of skipping co-citations for large result sets and allowing additional hops for smaller sets.

* feat: Filter out background tools during streaming to enhance user experience

- Added logic to determine and filter out background tools, preventing their names from appearing in the tool call display during streaming.
- Implemented a mechanism to include partial tool names only if they meet a specified length threshold, improving clarity in tool call presentations.

* feat: Enhance search tools to support time-based queries and display modified time

- Updated localSearchTool to ensure a healthy cap on max source chunks for time-based queries, improving recall.
- Modified ToolResultFormatter to display actual modified time for time-filtered results, enhancing clarity in search results.
- Adjusted output formatting to differentiate between recency and relevance scores based on query type.

* feat: Introduce semantic search capabilities with Memory Index support

- Added `enableSemanticSearchV3` setting to control the new semantic search feature.
- Implemented `MemoryIndexManager` for managing in-memory vector indexing with JSONL persistence.
- Enhanced `SearchCore` to utilize semantic retrieval based on the new memory index.
- Introduced command to build the semantic memory index, improving search accuracy and retrieval efficiency.
- Updated relevant components to integrate semantic search functionality seamlessly.

* feat: Add unit tests for MemoryIndexManager to validate functionality

- Introduced comprehensive tests for the MemoryIndexManager, covering scenarios such as loading from a file, building a vector store, and indexing vault contents.
- Implemented a mock embeddings API to facilitate testing without external dependencies.
- Added a utility function to reset the MemoryIndexManager state between tests, ensuring isolation and reliability of test outcomes.

* feat: Enhance MemoryIndexManager and related components for improved semantic indexing

- Introduced incremental indexing capabilities in MemoryIndexManager to update the JSONL index with new or modified files, enhancing efficiency.
- Updated commands to utilize the new incremental indexing method, providing users with real-time updates to the semantic memory index.
- Refactored existing indexing logic to support partitioned writes, improving performance and manageability of large datasets.
- Enhanced user notifications during indexing processes to provide better feedback on progress and status.
- Added a setting to enable semantic search, allowing users to blend semantic similarity into search results seamlessly.

* feat: Refine scoring display and enhance search result handling

- Updated SourcesModal to display relevance scores with four decimal places for consistency with SearchCore logs.
- Enhanced TieredLexicalRetriever to include a new `rerank_score` field for better score management and consistency across search results.
- Modified the combineResults method to ensure that title matches retain their original score while incorporating a fused score as `rerank_score`.
- Adjusted formatting in SearchTools to ensure both `score` and `rerank_score` reflect the same final score when present.
- Updated ToolResultFormatter to display scores with four decimal places, improving clarity in search result presentations.

* refactor: Simplify relevant notes retrieval by removing VectorStoreManager dependency

- Removed the use of VectorStoreManager in the relevant notes fetching logic, streamlining the process.
- Integrated MemoryIndexManager for improved handling of in-memory indexing and note retrieval.
- Enhanced error handling to ensure relevant notes are only fetched when the embedding index is available.
- Updated related functions to utilize the new memory index approach, improving performance and reliability.

* refactor: Remove VectorStoreManager dependency and streamline indexing logic

- Eliminated the VectorStoreManager from various components, transitioning to MemoryIndexManager for indexing and retrieval.
- Updated project and chain managers to remove unnecessary dependencies, enhancing code clarity and maintainability.
- Improved error handling and indexing conditions, particularly for mobile users, ensuring a more robust initialization process.
- Refactored settings components to utilize the new memory indexing approach, simplifying the user experience and reducing legacy code.

* chore: Mark legacy components as deprecated in preparation for v3 transition

- Annotated various files including DebugSearchModal, OramaSearchModal, chunkedStorage, dbOperations, hybridRetriever, and vectorStoreManager as deprecated, indicating they are obsolete in v3.
- Updated README.md to reflect the current implementation status and migration notes, emphasizing the removal of Orama-based modules and the transition to MemoryIndexManager for indexing and retrieval.

* feat: Implement file tracking and reindexing for modified files

- Introduced a new FileTrackingState interface to manage the last active file and its modification time.
- Enhanced the CopilotPlugin to opportunistically reindex the previous active file if it was modified while active, contingent on semantic search settings.
- Updated MemoryIndexManager to support reindexing of single modified files, improving efficiency in handling changes.
- Added unit tests for reindexSingleFileIfModified to ensure correct functionality and performance.

* feat: Add graph hops setting for enhanced search result expansion

- Introduced a new `graphHops` setting in `CopilotSettings` to control the number of hops for graph expansion during search, with a default value of 1 and a range of 1-3.
- Updated the `sanitizeSettings` function to validate the `graphHops` value.
- Enhanced the `SearchCore` and `TieredLexicalRetriever` classes to utilize the `graphHops` setting for improved search result relevance.
- Updated documentation in `README.md` to reflect the new feature and its security optimizations.

* refactor: Improve error handling and indexing logic in MemoryIndexManager and related components

- Replaced console error logging with structured logging using logError and logWarn for better error tracking.
- Enhanced the refresh and reindexing functions to ensure proper user notifications and error handling.
- Updated the logic for managing indexed files, including handling exclusions and ensuring accurate reporting of indexed and unindexed files.
- Implemented rate limiting in the MemoryIndexManager to optimize embedding requests and prevent overloading the service.
- Refactored chunk processing to improve efficiency and clarity in the indexing workflow.

* chore: Update README.md to reflect final session completion and key fixes

- Expanded the final session summary with a date and detailed list of completed features and fixes, including UI enhancements and improved logging practices.
- Clarified the status of deferred features and provided migration notes for better user guidance.
- Ensured documentation aligns with the latest implementation changes and optimizations.

* chore: Update memory limits in README.md and MemoryManager.ts for improved performance

- Adjusted memory limits for mobile and desktop platforms in both README.md and MemoryManager.ts to reflect increased capacity (20MB mobile, 100MB desktop).
- Ensured documentation aligns with the latest implementation changes for better clarity on resource management.

* feat: Integrate HyDE document generation into SearchCore for enhanced semantic search

- Implemented a new method to generate hypothetical documents (HyDE) to improve semantic search capabilities.
- Added timeout handling for HyDE generation to ensure graceful error management.
- Updated SearchCore to utilize HyDE documents in search queries, enhancing the relevance of results when semantic search is enabled.
- Introduced unit tests to validate the integration and functionality of HyDE generation within the search process.

* refactor: Enhance MemoryIndexManager with public methods for better indexing management

- Introduced public methods in MemoryIndexManager to streamline access to indexed file paths, check if a file is indexed, retrieve embeddings, and clear the index.
- Updated related components to utilize these new methods, improving code clarity and reducing direct access to internal properties.
- Enhanced error handling and user notifications during memory index operations.

* feat: Implement indexing notification and progress management

- Introduced the IndexingNotificationManager to handle UI notifications during indexing operations, allowing users to pause or stop the process.
- Added the IndexingProgressTracker to track progress across multiple files, enhancing user feedback during indexing.
- Developed the IndexingPipeline to manage the chunking and processing of files into embeddings, improving the overall indexing workflow.
- Created the IndexPersistenceManager for managing the persistence of indexed data, ensuring efficient storage and retrieval of index records.
- Refactored MemoryIndexManager to utilize the new components, streamlining the indexing process and improving code organization.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-11 16:58:04 -07:00
Wenzheng Jiang
40fec215b9
Add tool call marker for the tool call that is being generated (#1694) 2025-08-08 13:01:26 -07:00
Emt-lin
fe26c8943b
feat: Add project new context loading ui. (#1695) 2025-08-08 09:59:00 -07:00
Logan Yang
eca41a929b
Update version to 2.9.5 (#1700)
- Update manifest.json to 2.9.5
- Update versions.json to include 2.9.5
- Update package.json and package-lock.json to 2.9.5
2025-08-08 09:40:47 -07:00
Logan Yang
bc82d39756
Update manifest version to 2.9.5 for temperature fix release (#1699) 2025-08-08 09:35:53 -07:00
Logan Yang
8c532ecbdc
Add GPT5 models (#1698)
* Add GPT5 models

* Refactor BUILTIN_CHAT_MODELS: remove some models

* Fix temperature again
2025-08-08 09:30:46 -07:00
Anatolii Tsyplenkov
2292a0a6fd
Update Gemini Flash-Lite (#1675) 2025-08-06 13:42:55 -07:00
Wenzheng Jiang
4884d9513d
Setup Prompt test for Agent (#1688)
* Implement autonomous agent mode and new message architecture

- Implement autonomous agent mode with sequential thinking capabilities
- Migrate from sharedState to new clean message management architecture
- Add ChatManager, MessageRepository, and ContextManager for better separation of concerns
- Implement project-based chat isolation with separate message repositories per project
- Add ChatPersistenceManager for saving/loading chat history
- Refactor chain runner architecture with specialized runners (Autonomous, Project, VaultQA)
- Add XML tool call handling for better compatibility across LLM providers
- Introduce vault and web search toggles in settings
- Enhance model adapters with explicit tool usage instructions
- Add comprehensive test coverage for new architecture components
- Update UI components to use new ChatUIState instead of SharedState

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Enhance context processing and documentation

- Added detailed XML structure for context notes, including metadata (creation and modification times) for notes and selected text.
- Introduced new tests for message lifecycle and XML tag formatting to ensure proper context handling.
- Created TODO.md to track technical debt and future improvements related to context processing and file handling.
- Updated CLAUDE.md to reference the new TODO.md for technical debt awareness.

This commit improves the clarity and functionality of context processing in messages, ensuring rich context is maintained throughout the message lifecycle.

* Fix composer instruction in new message implementation

* Add writeToFile tool to agent (#1632)

* Add writeToFile tool call to agent

* Update src/LLMProviders/chainRunner/AutonomousAgentChainRunner.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/tools/ComposerTools.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove unuseful comment

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix tests

* Enhance context processing with new XML tags for notes and selected text (#1633)

* Enhance context processing with new XML tags for notes and selected text

- Introduced new constants for XML tags: SELECTED_TEXT_TAG, VARIABLE_TAG, VARIABLE_NOTE_TAG, EMBEDDED_PDF_TAG, VAULT_NOTE_TAG, and RETRIEVED_DOCUMENT_TAG.
- Updated context processing to format embedded PDFs and notes with XML structure.
- Modified prompt processing to include XML tags for selected text and variables, improving clarity and structure in generated outputs.
- Enhanced tests to validate the new XML formatting in processed prompts.

* Implement XML escaping utility functions and integrate into context processing

- Added `escapeXml` and `escapeXmlAttribute` functions to handle XML special character escaping, enhancing security against XML injection.
- Updated context processing to utilize these functions for escaping note titles, paths, and content, ensuring proper XML formatting.
- Enhanced tests to validate XML escaping functionality across various scenarios, including selected text and variable names.
- Introduced new test files for XML utility functions to ensure comprehensive coverage and reliability.

* Refactor XML utility functions and update imports

- Moved `escapeXml` and `escapeXmlAttribute` functions from `utils/xmlUtils` to `LLMProviders/chainRunner/utils/xmlParsing`, enhancing modularity.
- Updated all relevant imports across the codebase to reflect the new location of XML utility functions.
- Removed obsolete `xmlUtils` file and its associated tests, consolidating XML handling in a single module for better maintainability.

* Add message creation callback in ChatManager for immediate UI updates (#1634)

- Introduced a new method `setOnMessageCreatedCallback` in ChatManager to allow setting a callback that triggers when a message is created.
- Updated ChatUIState to utilize this callback for notifying listeners, ensuring the UI updates immediately upon message creation.
- This enhancement improves the responsiveness of the chat interface by synchronizing message creation events with UI state updates.

* Enhance TimeTools tests for invalid expressions

- Added setup to mock console.warn in tests for invalid time expressions.
- Verified that the appropriate warning message is logged when parsing fails.
- Improved test coverage for handling various invalid time inputs.

* Refactor local search handling and restore sources display

- Unified tool handling in CopilotPlusChainRunner to fix websearch results being ignored when localSearch has results
- All tool outputs now go through the same prepareEnhancedUserMessage method
- Preserved QA format and instruction when only localSearch is used
- Added proper validation for localSearch results (non-empty documents array)
- Maintained time expression support for temporal queries
- Fixed source tracking and display in ChatUIState
- Enhanced error handling for JSON parsing of search results

* Enhance AutonomousAgentChainRunner to track tool calls and results (#1639)

- Introduced a new property to store LLM-formatted messages for memory management.
- Reset LLM messages at the start of each run to ensure fresh context.
- Updated response handling to include LLM-formatted outputs, enhancing memory context for future iterations.
- Modified the base class to accept an optional LLM-formatted output parameter for improved context saving.
- Enhanced the writeToFile tool's response message for clarity on user actions.

* Quick Command (cmd+k) (#1640)

* Quick Command (cmd+k)

* Update custom command modal style

* Improve prompt

* Use submenu for commands

* Fix cursor comment

* Align selected_text variable name

* Fix embedded image wikilinks (#1641)

- Updated the `extractEmbeddedImages` method to accept an optional `sourcePath` parameter for resolving wikilinks.
- Implemented logic to determine the source path from context notes or fallback to the active file.
- Enhanced logging for unresolved images to improve debugging and user feedback.
- Ensured that embedded images are processed correctly based on the new source path handling.

* Fix salient term language issue

* Dedupe source notes (#1642)

* Fix salient term language issue

* Refactor source handling to include path in addition to title and score

- Updated source structures across multiple classes to include a `path` property alongside `title` and `score`.
- Modified methods in `AutonomousAgentChainRunner`, `BaseChainRunner`, and `CopilotPlusChainRunner` to accommodate the new source format.
- Enhanced the `deduplicateSources` function to use `path` as the unique key, falling back to `title` if necessary.
- Adjusted the `SourcesModal` to display paths correctly and ensure links open using the appropriate source path.
- Updated type definitions in `message.ts` to reflect the new source structure.

* Update path handling in source mapping for AutonomousAgentChainRunner

- Modified the source mapping logic to ensure the `path` property defaults to an empty string if not provided, enhancing robustness in source data handling.
- This change improves the consistency of source objects by ensuring that all properties are defined, which aids in downstream processing.

* Bump manifest version to v3

* Fix image (#1643)

* Fix salient term language issue

* Bump manifest version to v3

* Fix image passing

- Updated Chat, ChatManager, MessageRepository, and ChatUIState to include an optional `content` parameter in message handling.
- Adjusted method signatures and message creation logic to accommodate the new parameter, improving flexibility in message processing.

* Fix regenerate (#1644)

* Fix image in agent chain (#1646)

* Add YouTube transcription processing to AutonomousAgentChainRunner (#1647)

- Implemented a new method to extract and process YouTube URLs from user messages.
- Fetch transcriptions using the simpleYoutubeTranscriptionTool and handle errors gracefully.
- Updated conversation messages to include fetched transcriptions for improved context in responses.

* Disable quick command when live-mode is not on (#1648)

* Do not call writeToFileTool again for accepted changes as well (#1652)

* Trigger youtube tool only for urls in prompt not context (#1653)

* Stop calling youtube tool in context notes in agent mode

- Added a new instruction for handling YouTube URLs in the DEFAULT_SYSTEM_PROMPT.
- Removed the direct usage of simpleYoutubeTranscriptionTool in the AutonomousAgentChainRunner, as YouTube transcriptions are now automatically processed.
- Updated parameter naming conventions in modelAdapter for clarity and consistency.
- Cleaned up the simpleYoutubeTranscriptionTool definition by removing unnecessary parameters.

* Add agent loop limit message (#1655)

* Add composer toggle and implement auto-preview (#1651)

* Update composer output format to XML and refactor related components

- Changed the output format for composer instructions from JSON to XML in `constants.ts`.
- Updated `CopilotPlusChainRunner` to utilize the new XML format and adjusted streaming logic accordingly.
- Added a toggle for the composer feature in `ChatInput.tsx` and updated UI elements to reflect this change.
- Removed the `ComposerCodeBlock` component as it is no longer needed with the new implementation.
- Cleaned up unused code and comments in `ChatSingleMessage.tsx` related to the previous composer handling.

* Update src/constants.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/constants.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove redundant tests

* Update doc

* Refactor composer handling and implement ActionBlockStreamer

- Replaced `ComposerBlockStreamer` with `ActionBlockStreamer` to handle `writeToFile` blocks more efficiently.
- Updated `constants.ts` to reflect changes in output format for composer instructions.
- Enhanced `ChatSingleMessage.tsx` to process `writeToFile` sections and integrate collapsible UI elements.
- Removed the deprecated `ComposerBlockStreamer` and its associated tests.
- Improved handling of XML codeblocks and unclosed tags during streaming.

* Fix reported bugs

* Refactor ActionBlockStreamer tests and implementation

- Updated `processChunks` to always push content, including null and empty strings, to the output.
- Adjusted test expectations to reflect changes in output handling for chunks with null content.
- Simplified regex in `findCompleteBlock` method by removing XML format handling.

* Fix reported issue

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix tool description generation (#1659)

* Access tool description from zod.shape when zod.properties is missing.

* Remove the access to schema.properties

* Remove unused print

* Also support schema.propertes

* Implement SimpleTool and remove Langchain tool calling (#1662)

* Make web search tool not overly eager

* Use SimpleTool interface instead of langchain tool call

- Replaced LangChain tool definitions with a new SimpleTool interface for better type safety and validation.
- Updated existing tools (e.g., writeToFile, localSearch, webSearch, and YouTube transcription) to utilize the new createTool function.
- Enhanced parameter extraction from Zod schemas for improved tool description generation.
- Cleaned up related code and documentation to reflect the new tool structure and ensure consistency across the codebase.
- Add tests

* Update ChatManager tests to handle undefined context cases

- Modified test cases in ChatManager to include handling of undefined context parameters.
- Ensured that the tests accurately reflect scenarios where no active file exists and when context is undefined.
- Improved overall test coverage for message processing in various contexts.

* Add validation tests for tool schemas and improve schema definitions

- Introduced comprehensive validation tests for tool schemas in `allTools.validation.test.ts` and `SearchTools.schema.test.ts` to ensure adherence to best practices and proper typing.
- Enhanced `SearchTools.ts` by replacing `z.any()` with specific object schemas for `chatHistory` to improve type safety.
- Added tests for various tool patterns, including metadata validation and schema best practices, ensuring tools are correctly defined and validated against expected interfaces.

* Add back example content for canvas file in ComposerTools schema

* Make web search tool not overly eager

* Add license key in agent mode (#1663)

* Add tool execution tests and implement Plus subscription checks (#1664)

- Introduced unit tests for the `executeSequentialToolCall` function to validate tool execution behavior, including handling of Plus-only tools.
- Enhanced `executeSequentialToolCall` to check for Plus subscription requirements before executing tools.
- Updated `createTool` and `SimpleTool` interfaces to include an `isPlusOnly` flag, indicating tools that require a Copilot Plus subscription.
- Marked existing tools (e.g., webSearch and YouTube transcription) as Plus-only where applicable.

* Add timezone conversion tools and enhance current time functionality (#1665)

* Add timezone conversion tools and enhance current time functionality

- Introduced `convertTimeBetweenTimezonesTool` to allow conversion of time between different timezones.
- Updated `getCurrentTimeTool` to accept an optional timezone parameter, improving its functionality to return time in specified timezones.
- Enhanced documentation and added examples for both tools in the codebase.
- Added comprehensive unit tests for the new timezone conversion functionality to ensure accuracy and reliability.

* Enhance timezone functionality and add unit tests

- Updated `getCurrentTime` and `convertToTimeInfo` functions to utilize Luxon's offset for accurate timezone calculations.
- Adjusted timezone offset handling to reflect correct signs.
- Added unit tests for Tokyo and New York timezone offsets to ensure accuracy in timezone calculations.

* Add unit test for past time conversion in timezone tool

- Introduced a new test case to verify that converting a past time (6:00 AM PT) to Tokyo correctly reflects the same day (January 15) without erroneously adding a day.
- Updated the `convertTimeBetweenTimezones` function to ensure accurate handling of past times without unintended date shifts.

* Enhance timezone handling and update related tests

- Added `convertTimeBetweenTimezonesTool` to facilitate time conversion between different UTC offsets.
- Updated `getCurrentTimeTool` to accept timezone offsets instead of names, improving accuracy and flexibility.
- Enhanced error handling for invalid timezone offset formats and added comprehensive unit tests to validate new functionality.
- Updated existing tests to reflect changes in timezone offset handling and ensure consistent behavior across various scenarios.

* Refactor timezone handling in convertTimeBetweenTimezones function

- Updated the creation of DateTime objects to interpret parsed dates as already being in the source timezone, improving clarity and accuracy in timezone conversions.

* Fix image in chat history (#1666)

* Refactor chat history handling to preserve multimodal content

- Removed the deprecated `extractChatHistory` function and replaced it with direct access to raw history from memory, allowing for the preservation of multimodal content.
- Updated `AutonomousAgentChainRunner`, `BaseChainRunner`, and `CopilotPlusChainRunner` to utilize `BaseMessage` objects for chat history, ensuring that both user and AI messages maintain their original structure and content.
- Enhanced message processing to accommodate multimodal inputs, storing them appropriately for later use.

* Refactor chat history handling to improve message processing

- Introduced `addChatHistoryToMessages` utility to streamline the addition of chat history, ensuring safe handling of various message formats.
- Updated `AutonomousAgentChainRunner` and `CopilotPlusChainRunner` to utilize the new utility, enhancing clarity and maintainability of the code.
- Removed deprecated manual processing of chat history to improve code efficiency and readability.

* Refactor chat history processing to enhance multimodal support

- Removed the deprecated `extractChatHistory` function and replaced it with `processRawChatHistory` to ensure consistent handling of chat history.
- Introduced `processedMessagesToTextOnly` function to extract text-only content from multimodal messages, improving clarity for question condensing.
- Updated `CopilotPlusChainRunner` to utilize the new processing functions, ensuring that both LLM and question condensing use the same data format.
- Added comprehensive unit tests for `processedMessagesToTextOnly` to validate its functionality across various message formats.

* Refactor memory management in BaseChainRunner to enhance context saving

- Removed the creation of `HumanMessage` and `AIMessage` objects for chat history, simplifying the process.
- Implemented `saveContext` for atomic operations, ensuring proper memory management while preserving input and output data.
- Noted that LangChain's memory now expects text content, which limits the saving of multimodal content.

* Remove multimodal content storage from userMessage in AutonomousAgentChainRunner and CopilotPlusChainRunner to streamline message processing. This change aligns with recent refactors to enhance memory management and improve clarity in handling chat history.

* Enhance ChatInput component with autonomous agent toggle button (#1669)

- Added a toggle for the autonomous agent feature, allowing users to enable or disable it within the ChatInput component.
- Updated the state management to synchronize the autonomous agent toggle with user settings.
- Introduced a button for toggling the autonomous agent mode, which is only visible in Copilot Plus mode.
- Refactored tool call logic to accommodate the new autonomous agent toggle, ensuring proper handling of tool calls based on the toggle state.

* Implement custom topic in conversation history (#1670)

* Refactor LoadChatHistoryModal and ChatPersistenceManager for enhanced topic handling

- Updated LoadChatHistoryModal to prioritize custom topics from file frontmatter, falling back to filename extraction if not present.
- Enhanced ChatPersistenceManager to generate AI topics for new chat files and preserve existing topics when updating files.
- Introduced new methods for finding files by epoch and generating AI topics based on conversation content, improving chat file management and organization.

* Refactor LoadChatHistoryModal and ChatPersistenceManager for improved topic handling

- Updated LoadChatHistoryModal to ensure custom topics are trimmed and validated before use.
- Enhanced ChatPersistenceManager to utilize reduce for efficient conversation summary generation, introducing constants for message and character limits to improve readability and maintainability.

* Implement tool call UI banner (#1671)

* Only add tool call to the user message when agent is off

- Updated the tool call logic to only add tool calls when the autonomous agent toggle is off, ensuring that the autonomous agent manages all tools internally when enabled.
- Improved code clarity by adding comments to explain the new logic.

* Implement tool call collapsible UI element

- Introduced a new utility for managing tool call markers, allowing for structured display and tracking of tool calls during execution.
- Updated the AutonomousAgentChainRunner to utilize the new tool call markers, improving clarity in the streaming response and tool execution process.
- Added a ToolCallBanner component for better visualization of tool calls in the chat interface, including execution status and results.
- Refactored ChatSingleMessage to handle tool call updates dynamically, ensuring that the UI reflects the current state of tool calls.
- Enhanced CSS for tool call containers and added animations for improved user experience.

* Fix disappearing tool call in final response

* Implement tool call result formatting

- Updated ChatSingleMessage to use a stable ID for message roots, enhancing memory management and preventing leaks.
- Implemented cleanup logic for old message roots to optimize performance.
- Introduced ToolResultFormatter to format tool results for better display in the UI, ensuring user-friendly output for various tool types.
- Enhanced ToolCallBanner to utilize the new formatter, improving the presentation of tool call results in the chat interface.

* Add YouTube transcription tool in agent and avoid mistrigger from context

- Replaced the deprecated simpleYoutubeTranscriptionTool with a new youtubeTranscriptionTool that automatically extracts YouTube URLs from user messages.
- Removed the processYouTubeUrls method to streamline the handling of YouTube transcriptions.
- Updated tool execution logic to pass the original user message to tools that require it, enhancing flexibility in tool usage.
- Improved the ToolResultFormatter to support multi-URL responses and provide better error handling for transcription failures.
- Enhanced documentation for YouTube transcription usage in the codebase.

* Enhance ToolCallBanner and ToolResultFormatter for improved user experience

- Added animation constants to ToolCallBanner for better visual feedback.
- Updated ToolResultFormatter to robustly handle JSON parsing, improving error handling for both single objects and arrays.
- Implemented input validation in YouTube transcription tool to prevent excessive input lengths and ensure proper data types.

* Refactor tool execution messages and enhance JSON parsing in ToolResultFormatter

- Updated the confirmation message for the writeToFile tool to be more concise.
- Added a private method in ToolResultFormatter to robustly parse JSON strings, improving error handling and ensuring consistent results.
- Streamlined the handling of search results by separating JSON parsing and regex extraction logic in ToolResultFormatter.
- Enforced required user message content in the YouTube transcription tool to prevent potential errors.

* Truncate long tool results for compact memory (#1672)

* Truncate long tool results for compact memory

- Introduced `processToolResults` utility to format tool results for different contexts, allowing for both truncated and full results.
- Updated `AutonomousAgentChainRunner` to utilize the new utility for improved memory management and clarity in tool result presentation.
- Added unit tests for `toolResultUtils` to ensure proper functionality of truncation and formatting methods, enhancing reliability and maintainability of tool result processing.

* Enhance tool results handling in AutonomousAgentChainRunner

- Added a conditional check to ensure that only non-null tool results are pushed to the llmFormattedMessages array, improving the robustness of message formatting and preventing potential errors from undefined values.

* Add Agent settings section (#1676)

* Add autonomous agent settings and tool configurations

- Introduced settings for enabling the autonomous agent mode, including maximum iterations and available tools.
- Updated the CopilotPlusSettings component to allow users to toggle tools like local search, web search, and YouTube transcription.
- Enhanced the model adapter to utilize the new settings for tool management.

* Enhance tool management by adding always available tools and updating tool usage guidelines in autonomous agent mode

* Make filetree tool always available

* Refactor tool management system to use a centralized ToolRegistry, enabling dynamic tool registration and configuration. Update settings structure to support enabled tool IDs and enhance UI for tool selection in the Copilot settings.

* Initialize built-in tools with vault access and improve tool registration logic

* Enhance documentation for initializeBuiltinTools function to clarify tool registration process and dynamic filtering of user-enabled tools.

* fix: Fix the shouldIndexFile method to return all files when inclusions is empty in project mode. (#1667)

* feat: Display all category items by default in the context-manage-modal. (#1657)

* Remove escapingXML for context data (#1678)

* Add apply command (#1677)

* Implement ReplaceInFile tool (#1661)

* Relevant note improvements (#1681)

* Change message scrolling behavior (#1680)

* Fix timetools and tests (#1683)

* Refactor time tool descriptions for clarity and examples

* Update XML escaping tests to reflect correct behavior and remove unnecessary settings mock

* Strip partial tool call tag (#1682)

* Strip partial tool call tag

* Show a placeholder message

* Remove perserveToolIndicators option

* Add tool dynamic prompt (#1679)

* feat: Enhance tool execution error messages and update custom prompt instructions for built-in tools

* feat: Add unit tests for ModelAdapter and enhance tool instructions for time-based queries

* feat: Implement detailed formatting for replaceInFile tool results

* feat: Enhance GPT model instructions and refine replaceInFile tool usage guidelines

* feat: Expand documentation on schema descriptions and custom instructions for tool usage

* feat: Refine tool documentation by clarifying schema descriptions and custom prompt instructions

* feat: Update GitHub Actions workflow to run on all pull requests regardless of target branch

* Fix tests

* feat: Update integration tests to validate writeToFile blocks and enhance replaceInFile usage example

* Enhance image extraction logic to support both wiki-style and markdown image syntax (#1685)

* Turn off agent when in Projects mode (#1686)

* Remove think and action blocks from copy and insert (#1687)

* Remove think and action blocks from copy, and fix composer for thinking models

* Setup AgentTest with correct prompt and tools

* Clean up

* Add a few more tests and validate call order

---------

Co-authored-by: Logan Yang <logancyang@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Zero Liu <zero@lumos.com>
Co-authored-by: Emt-lin <41323133+Emt-lin@users.noreply.github.com>
2025-08-06 13:42:07 -07:00
Logan Yang
c1c95ca36d
Update version to 2.9.4 in manifest.json (#1691) 2025-08-04 12:06:15 -07:00
Logan Yang
f652cf0fb3
Remove beta labels from Copilot Plus (#1690)
- Remove "(beta)" from Copilot Plus in all UI components
- Update PlusSettings.tsx heading and description
- Update BasicSettings.tsx ChainType label
- Update ChatControls.tsx dropdown menu items

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-04 10:18:03 -07:00
Logan Yang
bc2d7f660a
Implement autonomous agent (#1689)
* Implement autonomous agent mode and new message architecture

- Implement autonomous agent mode with sequential thinking capabilities
- Migrate from sharedState to new clean message management architecture
- Add ChatManager, MessageRepository, and ContextManager for better separation of concerns
- Implement project-based chat isolation with separate message repositories per project
- Add ChatPersistenceManager for saving/loading chat history
- Refactor chain runner architecture with specialized runners (Autonomous, Project, VaultQA)
- Add XML tool call handling for better compatibility across LLM providers
- Introduce vault and web search toggles in settings
- Enhance model adapters with explicit tool usage instructions
- Add comprehensive test coverage for new architecture components
- Update UI components to use new ChatUIState instead of SharedState

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Enhance context processing and documentation

- Added detailed XML structure for context notes, including metadata (creation and modification times) for notes and selected text.
- Introduced new tests for message lifecycle and XML tag formatting to ensure proper context handling.
- Created TODO.md to track technical debt and future improvements related to context processing and file handling.
- Updated CLAUDE.md to reference the new TODO.md for technical debt awareness.

This commit improves the clarity and functionality of context processing in messages, ensuring rich context is maintained throughout the message lifecycle.

* Fix composer instruction in new message implementation

* Add writeToFile tool to agent (#1632)

* Add writeToFile tool call to agent

* Update src/LLMProviders/chainRunner/AutonomousAgentChainRunner.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/tools/ComposerTools.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove unuseful comment

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix tests

* Enhance context processing with new XML tags for notes and selected text (#1633)

* Enhance context processing with new XML tags for notes and selected text

- Introduced new constants for XML tags: SELECTED_TEXT_TAG, VARIABLE_TAG, VARIABLE_NOTE_TAG, EMBEDDED_PDF_TAG, VAULT_NOTE_TAG, and RETRIEVED_DOCUMENT_TAG.
- Updated context processing to format embedded PDFs and notes with XML structure.
- Modified prompt processing to include XML tags for selected text and variables, improving clarity and structure in generated outputs.
- Enhanced tests to validate the new XML formatting in processed prompts.

* Implement XML escaping utility functions and integrate into context processing

- Added `escapeXml` and `escapeXmlAttribute` functions to handle XML special character escaping, enhancing security against XML injection.
- Updated context processing to utilize these functions for escaping note titles, paths, and content, ensuring proper XML formatting.
- Enhanced tests to validate XML escaping functionality across various scenarios, including selected text and variable names.
- Introduced new test files for XML utility functions to ensure comprehensive coverage and reliability.

* Refactor XML utility functions and update imports

- Moved `escapeXml` and `escapeXmlAttribute` functions from `utils/xmlUtils` to `LLMProviders/chainRunner/utils/xmlParsing`, enhancing modularity.
- Updated all relevant imports across the codebase to reflect the new location of XML utility functions.
- Removed obsolete `xmlUtils` file and its associated tests, consolidating XML handling in a single module for better maintainability.

* Add message creation callback in ChatManager for immediate UI updates (#1634)

- Introduced a new method `setOnMessageCreatedCallback` in ChatManager to allow setting a callback that triggers when a message is created.
- Updated ChatUIState to utilize this callback for notifying listeners, ensuring the UI updates immediately upon message creation.
- This enhancement improves the responsiveness of the chat interface by synchronizing message creation events with UI state updates.

* Enhance TimeTools tests for invalid expressions

- Added setup to mock console.warn in tests for invalid time expressions.
- Verified that the appropriate warning message is logged when parsing fails.
- Improved test coverage for handling various invalid time inputs.

* Refactor local search handling and restore sources display

- Unified tool handling in CopilotPlusChainRunner to fix websearch results being ignored when localSearch has results
- All tool outputs now go through the same prepareEnhancedUserMessage method
- Preserved QA format and instruction when only localSearch is used
- Added proper validation for localSearch results (non-empty documents array)
- Maintained time expression support for temporal queries
- Fixed source tracking and display in ChatUIState
- Enhanced error handling for JSON parsing of search results

* Enhance AutonomousAgentChainRunner to track tool calls and results (#1639)

- Introduced a new property to store LLM-formatted messages for memory management.
- Reset LLM messages at the start of each run to ensure fresh context.
- Updated response handling to include LLM-formatted outputs, enhancing memory context for future iterations.
- Modified the base class to accept an optional LLM-formatted output parameter for improved context saving.
- Enhanced the writeToFile tool's response message for clarity on user actions.

* Quick Command (cmd+k) (#1640)

* Quick Command (cmd+k)

* Update custom command modal style

* Improve prompt

* Use submenu for commands

* Fix cursor comment

* Align selected_text variable name

* Fix embedded image wikilinks (#1641)

- Updated the `extractEmbeddedImages` method to accept an optional `sourcePath` parameter for resolving wikilinks.
- Implemented logic to determine the source path from context notes or fallback to the active file.
- Enhanced logging for unresolved images to improve debugging and user feedback.
- Ensured that embedded images are processed correctly based on the new source path handling.

* Fix salient term language issue

* Dedupe source notes (#1642)

* Fix salient term language issue

* Refactor source handling to include path in addition to title and score

- Updated source structures across multiple classes to include a `path` property alongside `title` and `score`.
- Modified methods in `AutonomousAgentChainRunner`, `BaseChainRunner`, and `CopilotPlusChainRunner` to accommodate the new source format.
- Enhanced the `deduplicateSources` function to use `path` as the unique key, falling back to `title` if necessary.
- Adjusted the `SourcesModal` to display paths correctly and ensure links open using the appropriate source path.
- Updated type definitions in `message.ts` to reflect the new source structure.

* Update path handling in source mapping for AutonomousAgentChainRunner

- Modified the source mapping logic to ensure the `path` property defaults to an empty string if not provided, enhancing robustness in source data handling.
- This change improves the consistency of source objects by ensuring that all properties are defined, which aids in downstream processing.

* Bump manifest version to v3

* Fix image (#1643)

* Fix salient term language issue

* Bump manifest version to v3

* Fix image passing

- Updated Chat, ChatManager, MessageRepository, and ChatUIState to include an optional `content` parameter in message handling.
- Adjusted method signatures and message creation logic to accommodate the new parameter, improving flexibility in message processing.

* Fix regenerate (#1644)

* Fix image in agent chain (#1646)

* Add YouTube transcription processing to AutonomousAgentChainRunner (#1647)

- Implemented a new method to extract and process YouTube URLs from user messages.
- Fetch transcriptions using the simpleYoutubeTranscriptionTool and handle errors gracefully.
- Updated conversation messages to include fetched transcriptions for improved context in responses.

* Disable quick command when live-mode is not on (#1648)

* Do not call writeToFileTool again for accepted changes as well (#1652)

* Trigger youtube tool only for urls in prompt not context (#1653)

* Stop calling youtube tool in context notes in agent mode

- Added a new instruction for handling YouTube URLs in the DEFAULT_SYSTEM_PROMPT.
- Removed the direct usage of simpleYoutubeTranscriptionTool in the AutonomousAgentChainRunner, as YouTube transcriptions are now automatically processed.
- Updated parameter naming conventions in modelAdapter for clarity and consistency.
- Cleaned up the simpleYoutubeTranscriptionTool definition by removing unnecessary parameters.

* Add agent loop limit message (#1655)

* Add composer toggle and implement auto-preview (#1651)

* Update composer output format to XML and refactor related components

- Changed the output format for composer instructions from JSON to XML in `constants.ts`.
- Updated `CopilotPlusChainRunner` to utilize the new XML format and adjusted streaming logic accordingly.
- Added a toggle for the composer feature in `ChatInput.tsx` and updated UI elements to reflect this change.
- Removed the `ComposerCodeBlock` component as it is no longer needed with the new implementation.
- Cleaned up unused code and comments in `ChatSingleMessage.tsx` related to the previous composer handling.

* Update src/constants.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/constants.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove redundant tests

* Update doc

* Refactor composer handling and implement ActionBlockStreamer

- Replaced `ComposerBlockStreamer` with `ActionBlockStreamer` to handle `writeToFile` blocks more efficiently.
- Updated `constants.ts` to reflect changes in output format for composer instructions.
- Enhanced `ChatSingleMessage.tsx` to process `writeToFile` sections and integrate collapsible UI elements.
- Removed the deprecated `ComposerBlockStreamer` and its associated tests.
- Improved handling of XML codeblocks and unclosed tags during streaming.

* Fix reported bugs

* Refactor ActionBlockStreamer tests and implementation

- Updated `processChunks` to always push content, including null and empty strings, to the output.
- Adjusted test expectations to reflect changes in output handling for chunks with null content.
- Simplified regex in `findCompleteBlock` method by removing XML format handling.

* Fix reported issue

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix tool description generation (#1659)

* Access tool description from zod.shape when zod.properties is missing.

* Remove the access to schema.properties

* Remove unused print

* Also support schema.propertes

* Implement SimpleTool and remove Langchain tool calling (#1662)

* Make web search tool not overly eager

* Use SimpleTool interface instead of langchain tool call

- Replaced LangChain tool definitions with a new SimpleTool interface for better type safety and validation.
- Updated existing tools (e.g., writeToFile, localSearch, webSearch, and YouTube transcription) to utilize the new createTool function.
- Enhanced parameter extraction from Zod schemas for improved tool description generation.
- Cleaned up related code and documentation to reflect the new tool structure and ensure consistency across the codebase.
- Add tests

* Update ChatManager tests to handle undefined context cases

- Modified test cases in ChatManager to include handling of undefined context parameters.
- Ensured that the tests accurately reflect scenarios where no active file exists and when context is undefined.
- Improved overall test coverage for message processing in various contexts.

* Add validation tests for tool schemas and improve schema definitions

- Introduced comprehensive validation tests for tool schemas in `allTools.validation.test.ts` and `SearchTools.schema.test.ts` to ensure adherence to best practices and proper typing.
- Enhanced `SearchTools.ts` by replacing `z.any()` with specific object schemas for `chatHistory` to improve type safety.
- Added tests for various tool patterns, including metadata validation and schema best practices, ensuring tools are correctly defined and validated against expected interfaces.

* Add back example content for canvas file in ComposerTools schema

* Make web search tool not overly eager

* Add license key in agent mode (#1663)

* Add tool execution tests and implement Plus subscription checks (#1664)

- Introduced unit tests for the `executeSequentialToolCall` function to validate tool execution behavior, including handling of Plus-only tools.
- Enhanced `executeSequentialToolCall` to check for Plus subscription requirements before executing tools.
- Updated `createTool` and `SimpleTool` interfaces to include an `isPlusOnly` flag, indicating tools that require a Copilot Plus subscription.
- Marked existing tools (e.g., webSearch and YouTube transcription) as Plus-only where applicable.

* Add timezone conversion tools and enhance current time functionality (#1665)

* Add timezone conversion tools and enhance current time functionality

- Introduced `convertTimeBetweenTimezonesTool` to allow conversion of time between different timezones.
- Updated `getCurrentTimeTool` to accept an optional timezone parameter, improving its functionality to return time in specified timezones.
- Enhanced documentation and added examples for both tools in the codebase.
- Added comprehensive unit tests for the new timezone conversion functionality to ensure accuracy and reliability.

* Enhance timezone functionality and add unit tests

- Updated `getCurrentTime` and `convertToTimeInfo` functions to utilize Luxon's offset for accurate timezone calculations.
- Adjusted timezone offset handling to reflect correct signs.
- Added unit tests for Tokyo and New York timezone offsets to ensure accuracy in timezone calculations.

* Add unit test for past time conversion in timezone tool

- Introduced a new test case to verify that converting a past time (6:00 AM PT) to Tokyo correctly reflects the same day (January 15) without erroneously adding a day.
- Updated the `convertTimeBetweenTimezones` function to ensure accurate handling of past times without unintended date shifts.

* Enhance timezone handling and update related tests

- Added `convertTimeBetweenTimezonesTool` to facilitate time conversion between different UTC offsets.
- Updated `getCurrentTimeTool` to accept timezone offsets instead of names, improving accuracy and flexibility.
- Enhanced error handling for invalid timezone offset formats and added comprehensive unit tests to validate new functionality.
- Updated existing tests to reflect changes in timezone offset handling and ensure consistent behavior across various scenarios.

* Refactor timezone handling in convertTimeBetweenTimezones function

- Updated the creation of DateTime objects to interpret parsed dates as already being in the source timezone, improving clarity and accuracy in timezone conversions.

* Fix image in chat history (#1666)

* Refactor chat history handling to preserve multimodal content

- Removed the deprecated `extractChatHistory` function and replaced it with direct access to raw history from memory, allowing for the preservation of multimodal content.
- Updated `AutonomousAgentChainRunner`, `BaseChainRunner`, and `CopilotPlusChainRunner` to utilize `BaseMessage` objects for chat history, ensuring that both user and AI messages maintain their original structure and content.
- Enhanced message processing to accommodate multimodal inputs, storing them appropriately for later use.

* Refactor chat history handling to improve message processing

- Introduced `addChatHistoryToMessages` utility to streamline the addition of chat history, ensuring safe handling of various message formats.
- Updated `AutonomousAgentChainRunner` and `CopilotPlusChainRunner` to utilize the new utility, enhancing clarity and maintainability of the code.
- Removed deprecated manual processing of chat history to improve code efficiency and readability.

* Refactor chat history processing to enhance multimodal support

- Removed the deprecated `extractChatHistory` function and replaced it with `processRawChatHistory` to ensure consistent handling of chat history.
- Introduced `processedMessagesToTextOnly` function to extract text-only content from multimodal messages, improving clarity for question condensing.
- Updated `CopilotPlusChainRunner` to utilize the new processing functions, ensuring that both LLM and question condensing use the same data format.
- Added comprehensive unit tests for `processedMessagesToTextOnly` to validate its functionality across various message formats.

* Refactor memory management in BaseChainRunner to enhance context saving

- Removed the creation of `HumanMessage` and `AIMessage` objects for chat history, simplifying the process.
- Implemented `saveContext` for atomic operations, ensuring proper memory management while preserving input and output data.
- Noted that LangChain's memory now expects text content, which limits the saving of multimodal content.

* Remove multimodal content storage from userMessage in AutonomousAgentChainRunner and CopilotPlusChainRunner to streamline message processing. This change aligns with recent refactors to enhance memory management and improve clarity in handling chat history.

* Enhance ChatInput component with autonomous agent toggle button (#1669)

- Added a toggle for the autonomous agent feature, allowing users to enable or disable it within the ChatInput component.
- Updated the state management to synchronize the autonomous agent toggle with user settings.
- Introduced a button for toggling the autonomous agent mode, which is only visible in Copilot Plus mode.
- Refactored tool call logic to accommodate the new autonomous agent toggle, ensuring proper handling of tool calls based on the toggle state.

* Implement custom topic in conversation history (#1670)

* Refactor LoadChatHistoryModal and ChatPersistenceManager for enhanced topic handling

- Updated LoadChatHistoryModal to prioritize custom topics from file frontmatter, falling back to filename extraction if not present.
- Enhanced ChatPersistenceManager to generate AI topics for new chat files and preserve existing topics when updating files.
- Introduced new methods for finding files by epoch and generating AI topics based on conversation content, improving chat file management and organization.

* Refactor LoadChatHistoryModal and ChatPersistenceManager for improved topic handling

- Updated LoadChatHistoryModal to ensure custom topics are trimmed and validated before use.
- Enhanced ChatPersistenceManager to utilize reduce for efficient conversation summary generation, introducing constants for message and character limits to improve readability and maintainability.

* Implement tool call UI banner (#1671)

* Only add tool call to the user message when agent is off

- Updated the tool call logic to only add tool calls when the autonomous agent toggle is off, ensuring that the autonomous agent manages all tools internally when enabled.
- Improved code clarity by adding comments to explain the new logic.

* Implement tool call collapsible UI element

- Introduced a new utility for managing tool call markers, allowing for structured display and tracking of tool calls during execution.
- Updated the AutonomousAgentChainRunner to utilize the new tool call markers, improving clarity in the streaming response and tool execution process.
- Added a ToolCallBanner component for better visualization of tool calls in the chat interface, including execution status and results.
- Refactored ChatSingleMessage to handle tool call updates dynamically, ensuring that the UI reflects the current state of tool calls.
- Enhanced CSS for tool call containers and added animations for improved user experience.

* Fix disappearing tool call in final response

* Implement tool call result formatting

- Updated ChatSingleMessage to use a stable ID for message roots, enhancing memory management and preventing leaks.
- Implemented cleanup logic for old message roots to optimize performance.
- Introduced ToolResultFormatter to format tool results for better display in the UI, ensuring user-friendly output for various tool types.
- Enhanced ToolCallBanner to utilize the new formatter, improving the presentation of tool call results in the chat interface.

* Add YouTube transcription tool in agent and avoid mistrigger from context

- Replaced the deprecated simpleYoutubeTranscriptionTool with a new youtubeTranscriptionTool that automatically extracts YouTube URLs from user messages.
- Removed the processYouTubeUrls method to streamline the handling of YouTube transcriptions.
- Updated tool execution logic to pass the original user message to tools that require it, enhancing flexibility in tool usage.
- Improved the ToolResultFormatter to support multi-URL responses and provide better error handling for transcription failures.
- Enhanced documentation for YouTube transcription usage in the codebase.

* Enhance ToolCallBanner and ToolResultFormatter for improved user experience

- Added animation constants to ToolCallBanner for better visual feedback.
- Updated ToolResultFormatter to robustly handle JSON parsing, improving error handling for both single objects and arrays.
- Implemented input validation in YouTube transcription tool to prevent excessive input lengths and ensure proper data types.

* Refactor tool execution messages and enhance JSON parsing in ToolResultFormatter

- Updated the confirmation message for the writeToFile tool to be more concise.
- Added a private method in ToolResultFormatter to robustly parse JSON strings, improving error handling and ensuring consistent results.
- Streamlined the handling of search results by separating JSON parsing and regex extraction logic in ToolResultFormatter.
- Enforced required user message content in the YouTube transcription tool to prevent potential errors.

* Truncate long tool results for compact memory (#1672)

* Truncate long tool results for compact memory

- Introduced `processToolResults` utility to format tool results for different contexts, allowing for both truncated and full results.
- Updated `AutonomousAgentChainRunner` to utilize the new utility for improved memory management and clarity in tool result presentation.
- Added unit tests for `toolResultUtils` to ensure proper functionality of truncation and formatting methods, enhancing reliability and maintainability of tool result processing.

* Enhance tool results handling in AutonomousAgentChainRunner

- Added a conditional check to ensure that only non-null tool results are pushed to the llmFormattedMessages array, improving the robustness of message formatting and preventing potential errors from undefined values.

* Add Agent settings section (#1676)

* Add autonomous agent settings and tool configurations

- Introduced settings for enabling the autonomous agent mode, including maximum iterations and available tools.
- Updated the CopilotPlusSettings component to allow users to toggle tools like local search, web search, and YouTube transcription.
- Enhanced the model adapter to utilize the new settings for tool management.

* Enhance tool management by adding always available tools and updating tool usage guidelines in autonomous agent mode

* Make filetree tool always available

* Refactor tool management system to use a centralized ToolRegistry, enabling dynamic tool registration and configuration. Update settings structure to support enabled tool IDs and enhance UI for tool selection in the Copilot settings.

* Initialize built-in tools with vault access and improve tool registration logic

* Enhance documentation for initializeBuiltinTools function to clarify tool registration process and dynamic filtering of user-enabled tools.

* fix: Fix the shouldIndexFile method to return all files when inclusions is empty in project mode. (#1667)

* feat: Display all category items by default in the context-manage-modal. (#1657)

* Remove escapingXML for context data (#1678)

* Add apply command (#1677)

* Implement ReplaceInFile tool (#1661)

* Relevant note improvements (#1681)

* Change message scrolling behavior (#1680)

* Fix timetools and tests (#1683)

* Refactor time tool descriptions for clarity and examples

* Update XML escaping tests to reflect correct behavior and remove unnecessary settings mock

* Strip partial tool call tag (#1682)

* Strip partial tool call tag

* Show a placeholder message

* Remove perserveToolIndicators option

* Add tool dynamic prompt (#1679)

* feat: Enhance tool execution error messages and update custom prompt instructions for built-in tools

* feat: Add unit tests for ModelAdapter and enhance tool instructions for time-based queries

* feat: Implement detailed formatting for replaceInFile tool results

* feat: Enhance GPT model instructions and refine replaceInFile tool usage guidelines

* feat: Expand documentation on schema descriptions and custom instructions for tool usage

* feat: Refine tool documentation by clarifying schema descriptions and custom prompt instructions

* feat: Update GitHub Actions workflow to run on all pull requests regardless of target branch

* Fix tests

* feat: Update integration tests to validate writeToFile blocks and enhance replaceInFile usage example

* Enhance image extraction logic to support both wiki-style and markdown image syntax (#1685)

* Turn off agent when in Projects mode (#1686)

* Remove think and action blocks from copy and insert (#1687)

* Remove think and action blocks from copy, and fix composer for thinking models

* Refactor ToolSettingsSection layout for improved readability and consistency

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: wenzhengjiang <jwzh.hi@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Zero Liu <zero@lumos.com>
Co-authored-by: Emt-lin <41323133+Emt-lin@users.noreply.github.com>
2025-08-04 09:51:18 -07:00
Logan Yang
b79b8d0a38
Migrate chat messages (#1629)
* Migrate from sharedState to new chat message system

- Replaced SharedState with a new ChatManager and ChatUIState architecture to streamline message processing and UI integration.
- Updated message imports to utilize the new types from "@/types/message".
- Introduced unique message IDs for better tracking and management.
- Enhanced the Chat component to support pending messages and improved message deletion logic.
- Removed deprecated shared state references and cleaned up related code for clarity and maintainability.

Enhance message management architecture and context processing

- Introduced a new MessageRepository for single source of truth in message storage, eliminating dual-array synchronization.
- Updated ChatManager to coordinate message operations and context processing, ensuring fresh context during edits.
- Refactored ChatUIState for clean UI state management, delegating business logic to ChatManager.
- Added comprehensive testing for message handling and context processing to prevent bugs and ensure reliability.
- Removed legacy SharedState references and improved overall architecture for clarity and maintainability.

Update claude.md

Remove conditional project tag from chat content rendering in Chat component

Ensure project chat isolation

- Introduced a method to retrieve the current project ID in ProjectManager.
- Enhanced ChatManager to manage multiple project-specific message repositories, allowing for dynamic switching based on the current project.
- Implemented logic to load existing messages from the ProjectManager's cache when creating new message repositories.
- Updated message handling methods in ChatManager to utilize the current project's message repository, ensuring context consistency across project switches.

* Fix message isolation between projects and non-project

- Introduced ChatManager and ChatUIState to streamline message processing and UI updates.
- Removed legacy message caching from ProjectManager, delegating message persistence to ChatManager.
- Updated CopilotView and Chat components to utilize the new architecture, enhancing message loading and project switching.
- Cleaned up deprecated code related to pending messages and shared state for improved maintainability.

* Implement a new chat persistence module

- Introduced ChatPersistenceManager to handle saving and loading chat history in markdown format, ensuring project-aware file naming.
- Updated ChatManager to utilize the new persistence functionality, streamlining message loading and saving processes.
- Refactored ChatUIState to support asynchronous loading and saving of messages, improving UI responsiveness.
- Added comprehensive tests for ChatPersistenceManager to ensure reliability in chat content formatting and parsing.
- Updated architecture documentation to reflect the new message management structure and flow.

* Update message management architecture doc

- Removed detailed architecture diagrams from CLAUDE.md and linked to MESSAGE_ARCHITECTURE.md for clarity.
- Updated MESSAGE_ARCHITECTURE.md to include project isolation features, enhancing the message management system.
- Improved documentation on message flow and project-specific repositories, ensuring seamless context switching.
- Streamlined the explanation of core classes and their interactions within the new architecture.

* Fix test

* Use llm message for commands to ensure context access

* Update docs
2025-07-17 01:41:53 -07:00
Zero Liu
b0f7971a4c
Custom command settings improvement (#1611)
* Auto add frontmatter when adding or renaming custom prompt files

* Make custom command enable slash and right click command by default

* Make add command button open the command edit dialog

* More improvements

* Fix test

* Fix cursor reported errors

* Add 'create new custom command' command back

* Fix rename race condition

* Fix more cursor errors

* Fix race conditions
2025-07-14 23:19:11 -07:00
Logan Yang
607b3c0907
2.9.4 (#1622) 2025-07-10 16:50:40 -07:00
Logan Yang
c1dbc965ed
Exclude copilot folders from indexing by default (#1621) 2025-07-10 16:25:31 -07:00
Logan Yang
c07ab31685
Implement file type validation for context in ChatInput and BaseNoteModal components (#1620)
- Added `isAllowedFileForContext` utility function to check if a file is of allowed types (markdown, PDF, or canvas).
- Updated `ChatInput` to use this function for setting the current active note.
- Refactored `BaseNoteModal` to utilize the new utility for filtering files and managing the active note state.
2025-07-10 15:40:45 -07:00
Logan Yang
592b7602d4
Fix copilot-plus-small (#1619) 2025-07-10 00:22:31 -07:00
Wenzheng Jiang
c345ddda60
Fix composer canvas codeblock (#1617) 2025-07-09 13:48:31 -07:00
Logan Yang
e06ace16b1
2.9.3 (#1605) 2025-07-03 12:05:25 -07:00
Logan Yang
2625fa949f
Add Projects rate limit UI change (#1603) 2025-07-03 00:25:34 -07:00
Logan Yang
831ae77354
Update file upload guidelines and rate limit information (#1602) 2025-07-02 21:55:31 -07:00
Logan Yang
1f1703906f
Fix slash trigger (#1600) 2025-07-02 15:54:54 -07:00
Logan Yang
aae4548f3b
Fix default model reset (#1599) 2025-07-02 15:42:06 -07:00
Logan Yang
276dd992d8
2.9.2 (#1595) 2025-07-01 15:49:45 -07:00
Logan Yang
ccf2c3f34a
Implement auto youtube tool (#1594) 2025-07-01 15:32:00 -07:00
Mathieu Colmon
ecf8eeff53
feat(chat): Implement autosave for chat after messages and responses (#1582)
* feat(chat): Implement autosave for chat after messages and responses

Adds autosave functionality to the chat component, saving the chat after every user message and AI response if the autosave setting is enabled. Updates the autosave chat setting description for clarity.

* fix(chat): Use sharedState for visible messages in Chat

Updated the Chat component to filter visible messages using sharedState.getMessages() instead of chatHistory, ensuring the latest messages are used. Also removed a redundant notice when updating an existing note.

* fix(chat): Make autosave non-blocking

The handleSaveAsNote function is now called without await in autosaveChat blocks.

---------

Co-authored-by: Logan Yang <logancyang@gmail.com>
2025-07-01 13:18:27 -07:00
Mathieu Colmon
50b3389344
Add Escape key support to cancel message editing (#1589)
Pressing Escape while editing a message now cancels the edit and restores the original message. Also removed onBlur save behavior to prevent accidental saves when focus is lost.
2025-07-01 12:39:13 -07:00
Logan Yang
73bf983511
Fix auto index trigger (#1593) 2025-07-01 12:30:51 -07:00