Commit Graph

5658 Commits

Author SHA1 Message Date
fullex
fb51df99d0 feat(cache): add template key support for useCache with type inference
- 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>
2026-01-05 12:23:19 +08:00
fullex
b6a1240bd8 chore: update CLAUDE.md for v2 migration details
- 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.
2026-01-05 10:15:42 +08:00
fullex
9b6c8f1f60 Merge branch 'main' of github.com:CherryHQ/cherry-studio into v2 2026-01-05 01:01:11 +08:00
fullex
6567d9d255 feat: update useDataApi hook and documentation for improved loading states and refetch logic
- 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.
2026-01-05 00:12:01 +08:00
fullex
7cac5b55f6 feat: enhance cursor-based pagination in API documentation and types
- 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.
2026-01-04 22:31:15 +08:00
fullex
81bb8e7981 feat: implement new pagination types and enhance API documentation
- 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.
2026-01-04 21:12:41 +08:00
Calvin Wade
b4aeced1f9 fix: thinking time on stop (#11900)
* 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>
2026-01-04 19:44:25 +08:00
kangfenmao
d27d750bc5 feat(i18n): add "open" label for app data directory in multiple languages 2026-01-04 19:36:46 +08:00
kangfenmao
a2639053ef chore(release): v1.7.9
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-04 18:36:03 +08:00
fullex
6a6f114946 feat: enhance useDataApi hook with default SWR options and improved refetch logic
- 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.
2026-01-04 18:28:51 +08:00
fullex
952e7c350b feat: enhance useDataApi hook with type-safe query and mutation results
- 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.
2026-01-04 18:08:26 +08:00
George·Dong
68a75dc4e3
feat(code-tools): add 302.AI as Claude Code provider (#12254)
* 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
2026-01-04 18:07:49 +08:00
kangfenmao
4c67e5b43a fix: update links in README and AboutSettings for correct documentation paths 2026-01-04 16:07:56 +08:00
fullex
b01113aae6 feat: enhance pagination support in API types and hooks
- 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.
2026-01-04 15:52:18 +08:00
Tsingv
2383fd06db
fix: resolve unexpected miniwindow loop closure on Mac (#12106)
fix: resolve unexpected miniwindow loop closure on MacOS 26+
2026-01-04 14:29:00 +08:00
Zhaolin Liang
f8519f0bf0
fix: HTML preview tab controls not working in fullscreen (#12152) 2026-01-04 13:49:40 +08:00
github-actions[bot]
2012378341
🤖 Weekly Auto I18N Sync: Jan 04, 2026 (#12262)
feat(bot): Weekly automated script run

Co-authored-by: EurFelux <59059173+EurFelux@users.noreply.github.com>
2026-01-04 13:47:59 +08:00
LiuVaayne
86adb2e11c
feat(browser): add user data persistence and multi-tab support (#12082)
- 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
2026-01-04 13:28:48 +08:00
Phantom
680bda3993
fix(translate): Fix ActionTranslate duplicate execution and getLanguageByLangcode logic (#12241)
* 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
2026-01-04 13:25:08 +08:00
fullex
24288cecf9 refactor: simplify error handling and session finalization in StreamingService
- 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.
2026-01-04 11:33:50 +08:00
fullex
60204e2166 fix: streamCallback.integration.test.ts test 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.
2026-01-04 11:12:41 +08:00
fullex
11843e21d5 feat: add test mocks path alias for improved import management
- 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.
2026-01-04 11:06:03 +08:00
fullex
61dddad22f refactor: streamline block management and update StreamingService integration
- 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.
2026-01-04 10:47:42 +08:00
fullex
37eac8c7fd feat: update documentation and enhance test mocks for data management
- 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.
2026-01-04 10:44:38 +08:00
fullex
f36ad573f5 feat: add shared cache functionality to MockMainCacheService
- 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.
2026-01-04 10:33:01 +08:00
fullex
773e9eac32 feat: enhance mock services for improved testing capabilities
- 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.
2026-01-04 10:24:35 +08:00
fullex
542702ad56 feat: implement assistant message creation via StreamingService
- 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.
2026-01-04 09:49:32 +08:00
fullex
7e8cc430a8 refactor: update logger context for DataApi components
- 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.
2026-01-04 09:10:14 +08:00
dependabot[bot]
acd1ecc09c
ci(deps): bump peter-evans/create-pull-request from 6 to 8 (#12224)
Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 6 to 8.
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](https://github.com/peter-evans/create-pull-request/compare/v6...v8)

---
updated-dependencies:
- dependency-name: peter-evans/create-pull-request
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-01-04 08:49:16 +08:00
fullex
3dfd5c7c2b feat: add custom SQL handling for triggers and virtual tables
- 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.
2026-01-04 01:07:04 +08:00
fullex
b1de7283dc feat: implement user message creation via Data API in StreamingService
- 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.
2026-01-03 23:58:48 +08:00
fullex
e6f85ba9fc fix(migration): add ‘pending' to check
- 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.
2026-01-03 23:55:56 +08:00
fullex
f1b9ab4250 feat: enhance CreateMessageDto and MessageService for improved parentId handling
- 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.
2026-01-03 22:47:44 +08:00
beyondkmp
e3d1996254
fix: prevent zoom reset during in-page navigation (#12257)
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>
2026-01-03 22:07:53 +08:00
fullex
f2cd361ab8 refactor: migrate v1 message streaming to v2 StreamingService for state management
- 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.
2026-01-03 22:00:02 +08:00
Nicolae Fericitu
56cf347909
feat(i18n): add professional Romanian localization (ro-RO) (#12216)
* 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>
2026-01-03 21:22:19 +08:00
fullex
01d8888601 feat: extend UpdateMessageDto with traceId and stats fields
- 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.
2026-01-03 18:52:11 +08:00
Zhaolin Liang
2a3955919e
fix: prevent crash when switching between agent and assistant (#12252)
Some checks failed
Auto I18N Weekly / Auto I18N (push) Has been cancelled
2026-01-03 17:20:52 +08:00
fullex
f558b99ca3 Merge branch 'main' of github.com:CherryHQ/cherry-studio into v2 2026-01-03 16:40:51 +08:00
fullex
ca2b0ac28d refactor: merge messageThunk.v2.ts into messageThunk.ts
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.
2026-01-03 16:36:53 +08:00
Hizome
078cf39313
fix: implement navigation in agent mode (#12238)
fix: add navigation in agentm mode

Co-authored-by: harry <harry@mock.com>
2026-01-03 16:14:12 +08:00
SuYao
48a582820f
feat: update-t2i-image (#12236)
* chore: comment

* chore: comment 2

* fix: comment

* chore: var name
2026-01-02 16:26:28 +08:00
fullex
26948b70a2 fix(thunk): clarify v2 file naming and comments in messageThunk.v2.ts
- 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.
2026-01-02 16:18:11 +08:00
fullex
71a7b1b7ea refactor(migration): improve ChatMigrator's handling of duplicate messages and active node selection
- 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.
2026-01-01 23:26:28 +08:00
fullex
4f4785396a feat(migration): enhance ChatMigrator for comprehensive chat data migration
- 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.
2026-01-01 23:13:43 +08:00
fullex
4fcf047fa9 refactor(database): update message and topic table structures
- 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.
2026-01-01 21:18:28 +08:00
Northword
77e024027c
fix(miniapps): switch to new google ai studio logo (#12229) 2026-01-01 19:13:24 +08:00
fullex
7145a1ded3 Merge branch 'main' of github.com:CherryHQ/cherry-studio into v2 2026-01-01 16:42:35 +08:00
Phantom
d391e55a8a
refactor(ovms): lazy-load OVMS support check with SWR (#12226) 2026-01-01 16:40:12 +08:00
Here_is_Daiyu
f878c8ab3b
Update minimax API documentation link (#12220) 2026-01-01 16:36:52 +08:00