- Introduced new pagination types and interfaces, including `PaginationMode`, `BasePaginatedResponse`, `OffsetPaginatedResponse`, and `CursorPaginatedResponse`, to standardize pagination handling.
- Updated `useDataApi` hook to support both offset and cursor-based pagination, improving data fetching capabilities.
- Added `useInfiniteQuery` and `usePaginatedQuery` hooks for better management of paginated data, including loading states and pagination controls.
- Refactored existing pagination logic to improve clarity and maintainability, ensuring consistent handling of pagination across the application.
- Removed retry logic for finalizing streaming sessions, streamlining the process to handle success and error cases more clearly.
- Enhanced error logging to provide immediate feedback on failures without retaining session data, preventing potential memory leaks.
- Improved code readability by consolidating the success and error handling paths, ensuring a more straightforward flow in the session finalization logic.
- Refined `streamCallback.integration.test.ts` to streamline mock setups and enhance clarity in testing logic, including the addition of utility functions for handling persisted data.
- Improved the organization of mock services and their integration into tests, ensuring better maintainability and readability of test cases.
- Enhanced comments and documentation within tests to provide clearer guidance on the purpose and functionality of various mock utilities.
- Introduced a new path alias '@test-mocks' in TypeScript configuration files to simplify the import of mock utilities across the project.
- Updated relevant files to utilize the new alias, enhancing code readability and maintainability.
- Enhanced the README for test mocks to document the new import path, providing clearer guidance for developers on using mock utilities.
- Consolidated block addition logic in BlockManager to enhance clarity and maintainability, ensuring that new blocks also update message references internally.
- Updated StreamingService to improve documentation and clarify the relationship between parentId and askId for backward compatibility.
- Removed redundant block reference handling, simplifying the message structure and improving performance during streaming sessions.
- Enhanced comments and documentation throughout to provide clearer guidance on the updated functionality and its implications for message processing.
- Added a new section in the data management documentation for testing, including a link to unified test mocks for Cache, Preference, and DataApi.
- Refined the README for test mocks, providing a clearer overview and detailed descriptions of available mocks and their organization.
- Improved the structure and clarity of mock usage examples, ensuring better guidance for developers on utilizing the testing utilities effectively.
- Introduced methods for managing a shared cache, including `getShared`, `setShared`, `hasShared`, and `deleteShared`, enhancing testing capabilities for shared data scenarios.
- Implemented utility functions for shared cache operations, such as `setSharedCacheValue`, `getSharedCacheValue`, and `getAllSharedCacheEntries`, to facilitate easier testing and state management.
- Updated cache statistics to include shared cache entries, improving visibility into cache usage during tests.
- Updated `CacheService` mock to include TTL support and type-safe memory and shared cache methods, enhancing the accuracy of cache behavior during tests.
- Refactored `DataApiService` mock to implement realistic HTTP methods and subscription handling, including retry configuration and request management, improving the fidelity of API interactions in tests.
- Enhanced `useDataApi` mocks to align with actual hook signatures, providing a more accurate simulation of data fetching and mutation behaviors, including loading and error states.
- Introduced utility functions for managing mock state and triggering subscription callbacks, streamlining the testing process for components relying on these services.
- Added a new method `createAssistantMessage` in StreamingService to facilitate the creation of assistant messages through the Data API, ensuring server-generated message IDs while maintaining client-side data integrity.
- Updated `messageThunk` to utilize the new method for creating assistant messages, replacing previous direct API calls and enhancing the overall message handling process.
- Introduced a conversion method to transform shared message formats from the Data API into the renderer's expected format, streamlining message processing and improving code organization.
- Changed logger context strings in ApiServer, MiddlewareEngine, IpcAdapter, MessageService, TestService, and TopicService to follow a consistent naming convention with the prefix 'DataApi:'.
- This refactor enhances clarity and organization in logging across the API services.
- Introduced a new method `runCustomMigrations` in `DbService` to execute custom SQL statements that Drizzle cannot manage, such as triggers and virtual tables.
- Updated `database-patterns.md` and `README.md` to document the handling of custom SQL and its importance in maintaining database integrity during migrations.
- Refactored `messageFts.ts` to define FTS5 virtual table and associated triggers as idempotent SQL statements for better migration management.
- Added a new method `createUserMessage` in StreamingService to handle user message creation through the Data API, generating server-side message IDs while preserving client-generated block IDs.
- Updated `sendMessage` thunk to utilize the new method for normal topics, ensuring proper message handling based on the active agent session.
- Refactored block conversion logic to streamline the process of preparing message data for the API.
- Introduced a new SQL migration script to create the `__new_message` table with updated schema, including foreign key constraints and check constraints for `role` and `status`.
- Migrated existing data from the old `message` table to the new structure and renamed the table to `message`.
- Added indexes for improved query performance on `parent_id`, `topic_id`, and `trace_id`.
- Updated metadata to reflect the new migration version and breakpoints for debugging.
- Updated CreateMessageDto to include detailed behavior for the parentId field, allowing for auto-resolution based on topic state, explicit root creation, or attachment to a specified parent message.
- Refactored MessageService to implement the new parentId logic, ensuring proper validation and error handling for message creation based on the topic's current state and existing messages.
- Enhanced transaction safety and clarity in the message insertion process by resolving parentId before inserting new messages.
- Replaced Redux dispatch and state management with StreamingService in BlockManager and various callback modules.
- Simplified dependencies by removing unnecessary dispatch and getState parameters.
- Updated block handling logic to utilize StreamingService for immediate updates and persistence during streaming.
- Enhanced architecture for better performance and maintainability as part of the v2 data refactoring initiative.
- Added optional fields `traceId` and `stats` to the `UpdateMessageDto` interface for enhanced message tracking and statistics.
- Updated `MessageService` to handle the new fields during message updates, ensuring they are correctly processed in the database.
Remove the confusing V2 naming from message thunk functions to avoid conflicts with the upcoming real V2 data refactoring.
Changes:
- Inline V2 function implementations directly into messageThunk.ts
- Replace V2 function calls with direct dbService calls
- Remove messageThunk.v2.ts file
- Remove misleading "V2 DATA&UI REFACTORING" header comments
The V2 suffix was originally added for agent session support, not for a data layer refactoring. This cleanup clears the naming space for the actual V2 refactoring work.
- Updated comments to clarify that the file is part of the v1 codebase despite its v2 naming, preventing potential confusion for developers.
- Removed outdated references to v2 implementations in the documentation to ensure accuracy.
- Enhanced duplicate message ID handling by updating parentId references and ensuring transaction safety.
- Implemented a smart selection logic for determining activeNodeId, prioritizing original active nodes and foldSelected messages.
- Updated documentation to reflect changes in duplicate handling and active node selection strategies.
- Implemented detailed preparation, execution, and validation phases for migrating chat topics and messages from Dexie to SQLite.
- Added robust logging and error handling to track migration progress and issues.
- Introduced data transformation strategies to convert old message structures into a new tree format, ensuring data integrity and consistency.
- Updated migration guide documentation to reflect changes in migrator registration and detailed comments for maintainability.
- Modified the `message` table to include `siblings_group_id` and `stats`, while removing `usage` and `metrics`.
- Renamed `response_group_id` to `siblings_group_id` for clarity.
- Enhanced the `topic` table by adding `active_node_id` and ensuring `sort_order` and `is_name_manually_edited` are defined correctly.
- Updated the database schema to reflect these changes and removed obsolete migration files.
- Added new enums and interfaces for content references, including `ReferenceCategory`, `CitationType`, and various citation reference types (Web, Knowledge, Memory).
- Unified inline references in `MainTextBlock` with a new `references` property, replacing the deprecated `citationReferences` and `CitationBlock`.
- Implemented type guards for reference validation, enhancing type safety and clarity in message handling.
- Updated documentation to reflect changes and migration notes for version 2.0.
* fix(ovms): make ovms manager windows-only and lazy load it
Add platform check in OvmsManager constructor to throw error on non-Windows platforms
Lazy load ovmsManager instance and handle IPC registration only on Windows
Update will-quit handler to conditionally cleanup ovms resources
* feat(preload): add windows-only OVMS API and improve type safety
Extract OVMS API methods into a separate windowsOnlyApi object for better organization
Add explicit return type for getDeviceType method
* feat(system): add system utils and refine ovms support check
- Add new system utility functions for device type, hostname and CPU name
- Refactor OVMS support check to require both Windows and Intel CPU
- Update IPC handlers to use new system utils and provide proper OVMS fallbacks
* Revert "feat(preload): add windows-only OVMS API and improve type safety"
This reverts commit d7c5c2b9a4.
* feat(ovms): add support check for ovms provider
Add new IPC channel and handler to check if OVMS is supported on the current system. This replaces the previous device type and CPU name checks with a more maintainable solution.
* fix(OvmsManager): improve intel cpu check for ovms manager
Move isOvmsSupported check before class definition and update error message to reflect intel cpu requirement
* fix: use isOvmsSupported flag for ovms cleanup check
Replace platform check with feature flag to properly determine if ovms cleanup should run
* fix: improve warning message for undefined ovmsManager
* fix(system): handle edge cases in getCpuName function
Add error handling and null checks to prevent crashes when CPU information is unavailable
* feat(runtime): add ovms support check during app init
Add isOvmsSupported state to runtime store and check support status during app initialization. Move ovms support check from ProviderList component to useAppInit hook for centralized management.
- Commented out `modelId` and `knowledgeBaseIds` properties in `BaseBlock` and `MainTextBlock` interfaces, marking them as dead code for future removal in v2.
- This change helps to clean up the codebase and prepare for upcoming version updates.
* feat: add fuzzy search for file list with relevance scoring
- Add fuzzy option to DirectoryListOptions (default: true)
- Implement isFuzzyMatch for subsequence matching
- Add getFuzzyMatchScore for relevance-based sorting
- Remove searchByContent method (content-based search)
- Increase maxDepth to 10 and maxEntries to 20
* perf: optimize fuzzy search with ripgrep glob pre-filtering
- Add queryToGlobPattern to convert query to glob pattern
- Use ripgrep --iglob for initial filtering instead of loading all files
- Reduces memory footprint and improves performance for large directories
* feat: add greedy substring match fallback for fuzzy search
- Add isGreedySubstringMatch for flexible matching
- Fallback to greedy match when glob pre-filter returns empty
- Allows 'updatercontroller' to match 'updateController.ts'
* fix: improve greedy substring match algorithm
- Search from longest to shortest substring for better matching
- Fix issue where 'updatercontroller' couldn't match 'updateController'
* docs: add fuzzy search documentation (en/zh)
* refactor: extract MAX_ENTRIES_PER_SEARCH constant
* refactor: use logarithmic scaling for path length penalty
- Replace linear penalty (0.8 * length) with logarithmic scaling
- Prevents long paths from dominating the score
- Add PATH_LENGTH_PENALTY_FACTOR constant with explanation
* refactor: extract scoring constants with documentation
- Add named constants for scoring factors (SCORE_SEGMENT_MATCH, etc.)
- Update en/zh documentation with scoring strategy explanation
* refactor: move PATH_LENGTH_PENALTY_FACTOR to class level constant
* refactor: extract buildRipgrepBaseArgs helper method
- Reduce code duplication for ripgrep argument building
- Consolidate directory exclusion patterns and depth handling
* refactor: rename MAX_ENTRIES_PER_SEARCH to MAX_SEARCH_RESULTS
* fix: escape ! character in glob pattern for negation support
* fix: avoid duplicate scoring for filename starts and contains
* docs: clarify fuzzy search filtering and scoring strategies
* fix: limit word boundary bonus to single match
* fix: add dedicated scoring for greedy substring match
- Add getGreedyMatchScore function that rewards fewer fragments and tighter matches
- Add isFuzzyMatch validation before scoring in fuzzy glob path
- Use greedy scoring for fallback path to properly rank longest matches first
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
---------
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
- Introduced type-safe access methods for shared cache in the Main process, including `getShared`, `setShared`, `hasShared`, and `deleteShared`.
- Implemented `getAllShared` for initializing new Renderer windows with the complete shared cache state.
- Updated IPC communication to support bidirectional synchronization of shared cache between Main and Renderer processes.
- Enhanced cache management with absolute timestamps for TTL, ensuring precise expiration handling across windows.
- Added ready state tracking in Renderer for improved synchronization feedback during initialization.
- Refactored related documentation to reflect new features and usage patterns for shared cache.
- Added resolutions for React and React DOM to ensure consistent usage of version 19.2.0 across the project.
- Removed outdated version entries from yarn.lock to streamline dependency management.
- Changed utility imports from '@cherrystudio/ui/utils' to '@cherrystudio/ui/lib/utils' across multiple components for better organization.
- Introduced a new internal utility module for class name merging, ensuring consistent usage across the UI components.
- Updated relevant components to reflect the new import paths, enhancing maintainability and clarity.
* feat(tokenflux): add Anthropic host support using OpenRouter package
- Add anthropicApiHost to TokenFlux provider config
- Map TokenFlux to OpenRouter in STATIC_PROVIDER_MAPPING for full compatibility
* feat(tokenflux): update API URLs and add migration
- Update apiHost to https://api.tokenflux.ai/openai/v1
- Update anthropicApiHost to https://api.tokenflux.ai/anthropic
- Add migration 191 to update existing TokenFlux users
* fix(tokenflux): add to Anthropic compatible providers list
Enable Anthropic API host configuration in TokenFlux provider settings UI
- Removed outdated sections on database architecture and data access patterns for clarity.
- Introduced a new table format for data management systems, detailing use cases and APIs.
- Updated references to the database schema and migration processes for better guidance.
- Consolidated key architectural components to streamline the documentation structure.
- Revised the README files for shared data and main data layers to improve clarity and structure.
- Consolidated documentation on shared data types and API types, removing the now-deleted `api-design-guidelines.md`.
- Streamlined directory structure descriptions and updated links to relevant documentation.
- Enhanced quick reference sections for better usability and understanding of the data architecture.
- Enhanced `getTree` method to utilize Common Table Expressions (CTEs) for fetching active paths and tree structures in a single query, reducing database load.
- Updated `getBranchMessages` to implement a similar optimization, allowing for efficient retrieval of message paths without loading all messages.
- Refactored `getPathToNode` to use a recursive CTE for fetching ancestors, addressing the N+1 query problem in deep message trees.
- Introduced transaction handling in `create` and `update` methods to ensure atomic operations and data integrity during message modifications.
- Introduced `ActiveNodeStrategy` type to define strategies for updating `activeNodeId` when a message is deleted.
- Updated `DeleteMessageResponse` to include `newActiveNodeId` for tracking changes to the active node after deletion.
- Modified the `DELETE` endpoint to accept `activeNodeStrategy` as a query parameter, allowing for flexible handling of active node updates.
- Enhanced the `delete` method in `MessageService` to implement the new strategies, ensuring consistent behavior during message deletions.
- Added sections on basic usage of foreign keys, self-referencing foreign keys, and circular foreign key references.
- Provided TypeScript code examples to illustrate best practices and avoid common pitfalls.
- Explained the rationale behind using soft references in SQLite for improved data integrity and simplified operations.
- Added `setAsActive` property to `CreateMessageDto` for controlling active node status in topics.
- Updated `messageTable` and `topicTable` schemas to include foreign key constraints and improved handling of active node references.
- Refactored message and topic service methods to utilize `.returning()` for better data retrieval after inserts and updates.
- Implemented hard delete functionality for messages and topics, replacing soft delete logic to ensure data integrity.
- Changed the default status for messages from 'success' to 'pending' to better reflect the message processing state. This aligns with recent updates to the MessageStatus type.
- Updated MessageStatus type to include 'pending' as a new state, reflecting the message processing lifecycle.
- Modified CreateMessageDto and UpdateMessageDto interfaces to utilize the updated MessageStatus type for improved clarity and consistency in message status management.
- Consolidated imports from '@cherrystudio/ui' for better readability.
- Replaced RadioGroup with Radio component from 'antd' for consistency in the SelectionAssistantSettings file.
- Adjusted event handling for trigger and filter modes to align with the new Radio component structure.