- Add type utilities for template key matching (IsTemplateKey, ExpandTemplateKey, ProcessKey)
- Add InferUseCacheValue<K> for automatic value type inference from template patterns
- Update useCache hook to support template keys with default value fallback
- Extend ESLint rule to validate template key syntax (e.g., 'scroll.position:${id}')
- Update CacheService.get() docs: clarify | undefined return is intentional
(developers need to know when value doesn't exist after deletion/TTL expiry)
- Update cache documentation with template key usage examples
BREAKING CHANGE: CacheService.get() now explicitly returns T | undefined
(was implicit before). Callers should use ?? defaultValue for fallback.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Clarified the Electron structure by removing Redux from the Renderer Process description.
- Enhanced the Data Layer section to specify the removal of Redux and Dexie, and the adoption of Cache/Preference/DataApi architecture.
- Updated the UI Layer section to reflect the removal of antd and styled-components, and the adoption of `@cherrystudio/ui` with Tailwind CSS and Shadcn UI.
- Introduced a file naming convention for ongoing migration with `*.v2.ts` suffix to indicate work-in-progress files.
- Added a new section for v2 refactoring to outline the major changes in the project structure and dependencies.
- Refactored `useQuery` and `useMutation` hooks to replace `loading` with `isLoading` for consistency in naming conventions.
- Enhanced `useQuery` to include `isRefreshing` state for better tracking of background revalidation.
- Updated documentation and examples to reflect changes in hook signatures and loading state management.
- Improved mock implementations in tests to align with the new hook signatures, ensuring accurate testing of loading states.
- Added detailed explanations and examples for cursor semantics in `api-types.md`, clarifying the exclusive nature of cursors in pagination.
- Updated `CursorPaginationParams` interface to emphasize the cursor's role as an exclusive boundary in responses.
- Refactored `BranchMessagesQueryParams` to extend `CursorPaginationParams`, aligning with the new pagination logic.
- Modified `MessageService` to implement cursor-based pagination semantics, ensuring accurate message retrieval and response structure.
- Enhanced documentation throughout to provide clearer guidance on pagination behavior and usage patterns.
- Introduced `OffsetPaginationParams`, `CursorPaginationParams`, and their corresponding response types to standardize pagination handling across the API.
- Updated existing API types and hooks to support both offset and cursor-based pagination, improving data fetching capabilities.
- Enhanced documentation with detailed usage examples for pagination, including request parameters and response structures, to aid developers in implementing pagination effectively.
- Refactored related components to utilize the new pagination types, ensuring consistency and clarity in data management.
* fix: preserve thinking time when stopping reply
Fixes#11886
Signed-off-by: Calvin <calvinvwei@gmail.com>
* fix: also preserve thinking time when stopping during thinking
This extends the previous fix to also handle the case when the user
stops the reply while thinking is still in progress (not just after
thinking is complete).
Signed-off-by: Calvin <calvinvwei@gmail.com>
* fix: auto-complete thinking when text output starts
This fixes the issue where the thinking timer continues running after
thinking is complete and text output begins. Some AI providers don't
send a reasoning-end event explicitly, so we now auto-complete thinking
when a text-start event is received with accumulated reasoning content.
Fixes#11796
Signed-off-by: Calvin <calvinvwei@gmail.com>
* refactor: extract emitThinkingCompleteIfNeeded to reduce duplication
Extract the shared logic for emitting THINKING_COMPLETE chunk into a
reusable method. This removes code duplication between text-start and
reasoning-end event handlers as suggested in code review.
Signed-off-by: Calvin <calvinvwei@gmail.com>
---------
Signed-off-by: Calvin <calvinvwei@gmail.com>
- Introduced a centralized `DEFAULT_SWR_OPTIONS` object to standardize SWR configuration across the useDataApi hook, improving consistency and maintainability.
- Refactored refetch logic to utilize useCallback for better performance and to avoid stale closures.
- Updated mutation handling to use a ref for options, ensuring the latest options are always applied during API calls.
- Added a useEffect to reset pagination state when query parameters change, enhancing the hook's responsiveness to dynamic queries.
- Introduced new TypeScript interfaces for query and mutation results, improving type safety and clarity in the useDataApi hook.
- Refactored existing functions to utilize these new types, ensuring consistent handling of loading states, errors, and data structures.
- Updated documentation and examples to reflect the new type-safe approach, enhancing developer experience and reducing potential runtime errors.
* feat(code-tools): add 302.AI as Claude Code provider
* feat(agent): add 302.AI anthropicApiHost to enable Agent support
302.AI now supports Claude Code (Agent) functionality by configuring
the anthropicApiHost endpoint. Users can use 302.AI's Claude models
(claude-sonnet-4-20250514, claude-opus-4-20250514) with Agent.
* feat(migrate): add migration 192 to set 302ai API host
- 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.
- Add session-based user data persistence using Electron partitions
- Implement multi-tab support with tab management operations
- Add new tools: create_tab, list_tabs, close_tab, switch_tab
- Update existing tools (open, execute, fetch, reset) to support tabId parameter
- Refactor controller to manage sessions with multiple tabs
- Add comprehensive documentation in README.md
- Add TypeScript interfaces for SessionInfo and TabInfo
BREAKING CHANGE: Controller now manages sessions with tabs instead of single windows per session
* refactor(translate): remove default temperature setting
* refactor(translate): Remove temperature setting from language detection
prompt
* refactor: Set default translate languages from user settings
Initialize target language from user's language setting, falling back to
zh-CN if unknown. Set alter language to en-US by default. Remove
redundant logic that was duplicated in the effect.
* fix(translate): translate action won't trigger twice
* fix(translate): Fix getLanguageByLangcode to return built-in language
when not loaded
Previously, the function would always return UNKNOWN if the languages
were not loaded, even for built-in language codes. This change ensures
built-in languages are returned if found, regardless of the load state.
* fix: Expose translation languages loaded state and fix initialization
Add `isLoaded` flag to `useTranslate` hook to track when translation
languages are available. Use this flag to prevent premature
initialization in `ActionTranslate` component, ensuring language lookups
succeed before creating assistants and topics.
Add error logging for failed custom language loading and update fallback
warning messages for better debugging.
* fix: set initialized when finished
- 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.
Fixes an Electron bug where zoom factor resets during route changes by listening to the 'did-navigate-in-page' event and reapplying the configured zoom factor.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
- 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.
* feat(i18n): add Romanian localization (ro-RO)
Added the ro-ro.json file to provide Romanian language support for the Cherry Studio interface.
This commit introduces a high-quality, professional translation for the Romanian language. The localization has been carefully reviewed to ensure linguistic accuracy and terminology consistency, so no further adjustments from other contributors are required at this stage. Thank you!
* chore: move ro-ro.json to translate folder and register in index.ts
Moved the Romanian translation file to the translate directory and updated the i18n index to support the automated workflow as requested.
* Delete src/renderer/src/i18n/locales/ro-ro.json
* chore: add ro-ro.json to translate folder
Finalized the relocation of the Romanian translation file to the translate directory to support the automated i18n workflow.
* chore(i18n): remove trailing comma in index.ts
Biome formatter removed trailing comma for consistency.
* feat(i18n): add Romanian (ro-RO) to language selector
Add Romanian language option in settings with Română label and 🇷🇴 flag.
* fix(i18n): add Romanian language support
- Add ro-RO to LanguageVarious type
- Add Romanian to language selector in settings
- Add emoji picker fallback to English (no Romanian CLDR data)
* feat: Add Romanian to auto-translation language map
* fix: Add Romanian language support in main
* fix: Add Romanian (ro-RO) locale support for AntdProvider
* fix: Add Romanian language support to smooth stream segmenter
* fix: Add Romanian translations for assistant preset groups
---------
Co-authored-by: George·Dong <GeorgeDong32@qq.com>
Co-authored-by: icarus <eurfelux@gmail.com>
- 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.