chore: Update channel improve (#8501)

* chore(env): add .env.example file and update .gitignore

- Introduced a new .env.example file with NODE_OPTIONS configuration.
- Updated .gitignore to exclude .env.example from being ignored.
- Added instructions in dev.md for copying .env.example to .env.

* fix(MessageTools): improve error handling and logging in message preview rendering (#8453)

- Enhanced the rendering logic for message previews by adding a try-catch block to handle JSON parsing errors more gracefully.
- Updated the error handling to provide clearer error messages in the preview when exceptions occur.
- Added debug logging to track the rendering process of message content.

* refactor(Theme): update theme management to use setTheme function

- Replaced toggleTheme with setTheme for more explicit theme handling.
- Removed unused SunMoon icon from TabContainer and Sidebar components.
- Updated theme icon rendering logic to directly reflect the current theme state.
- Adjusted ThemeProvider to include setTheme in context for better theme management.

* refactor(ModelList): streamline button layout and improve accessibility

- Removed tooltip wrappers from manage and add model buttons for a cleaner UI.
- Introduced a new Flex container for primary and default buttons, enhancing layout consistency.
- Updated button rendering to improve accessibility and user experience.

* feat(ModelList): add bulk add/remove functionality for models with confirmation dialog

- Implemented onAddAll and onRemoveAll functions to handle bulk actions for models.
- Added confirmation dialog for adding all models to the list, enhancing user experience.
- Updated translations for confirmation messages in multiple languages.

* chore(languages): update languages with a script (#8445)

* chore(languages): update languages with a script

* refactor: update languages and merge it into constants

* refactor: add usf and ush

* fix(ModelEdit): enhance model type management and introduce new selection logic (#8420)

* fix(ModelEdit): enhance model type management and introduce new selection logic

- Added support for 'rerank' model type in the ModelEditContent component.
- Refactored type selection logic to utilize new utility functions for finding differences and unions in model types.
- Updated model type handling to include user selection status, improving user experience in type management.
- Adjusted migration logic to initialize newType for existing models, ensuring backward compatibility.
- Introduced isUserSelectedModelType utility to streamline model type checks across the application.

* refactor(isFunctionCallingModel): simplify model type check logic

- Replaced the inline check for 'function_calling' model type with a call to the new utility function isUserSelectedModelType, enhancing code clarity and maintainability.

* feat(collection): add utility functions for array operations

- Introduced `findIntersection`, `findDifference`, and `findUnion` functions to handle array operations with support for custom key selectors and comparison functions.
- Removed previous implementations from `index.ts` to streamline utility exports.
- Added comprehensive tests for new functions covering basic types and object types with various edge cases.

* refactor(collection): rename utility functions for clarity

- Renamed `findIntersection`, `findDifference`, and `findUnion` to `getIntersection`, `getDifference`, and `getUnion` respectively for improved clarity and consistency in naming.
- Updated corresponding tests to reflect the new function names, ensuring all tests pass with the updated utility functions.

* refactor(ModelEditContent): update model type management and improve selection logic

- Replaced utility function calls to `findDifference` and `findUnion` with `getDifference` and `getUnion` for consistency.
- Introduced temporary state management for model types to enhance user selection handling.
- Added a reset functionality for model type selections, improving user experience.
- Updated the rendering logic to conditionally disable certain model types based on user selections.

* fix(ModelEditContent): enhance model type selection logic with conditional disabling

- Introduced logic to conditionally disable 'rerank' and 'embedding' model types based on user selections.
- Updated the state management for model types to ensure correct user selection handling.
- Improved the confirmation modal to reflect the updated selection logic for better user experience.

* fix(ModelEditContent): refine model type selection and update confirmation logic

- Enhanced the logic for model type selection to ensure accurate user selections for 'rerank' and 'embedding'.
- Updated the confirmation modal to reflect changes in selection handling, improving user experience.
- Adjusted state management to correctly handle updates based on selected model types.

* fix(models): update model support logic to include 'qwen3-235b-a22b-instruct'

* refactor(models): rename 'newType' to 'capabilities' and update related logic in ModelEditContent and migration scripts

* refactor(ModelEditContent): remove maskClosable prop for improved modal behavior

* fix(ThinkingTagExtraction): add new tag configuration for 'kimi-vl-a3b-thinking' model (#8459)

* feat(ThinkingTagExtraction): add new tag configuration for 'kimi-vl-a3b-thinking' model and update model regex patterns in config

- Introduced a new tag configuration for the 'kimi-vl-a3b-thinking' model in ThinkingTagExtractionMiddleware.
- Updated models.ts to include regex patterns for 'kimi-vl-a3b-thinking', 'llama-guard-4', and 'llama-4' to enhance model compatibility.

* feat(models): add regex pattern for 'gemma3' model to enhance model compatibility

* fix(RawStreamListenerMiddleware): update model check (#8433)

* fix(RawStreamListenerMiddleware): update model check for Anthropic API integration

- Replaced provider type check with model ID check to enhance compatibility with Claude models.
- Improved clarity in the middleware logic for handling raw output from the SDK.

* refactor(RawStreamListenerMiddleware): enhance model identification for Anthropic integration

- Introduced a new utility function `isAnthropicModel` to streamline model checks across the codebase.
- Updated middleware logic to utilize the new function for improved clarity and maintainability.
- Adjusted related tests to ensure compatibility with the updated model identification approach.

* test(ApiService.test): add mock for isAnthropicModel to enhance test coverage for model identification

* refactor(ChatNavbar, Navbar): simplify toggle functions and remove unused fullscreen hook

- Removed unnecessary useCallback functions for toggling assistants and topics, directly using the toggle functions instead.
- Eliminated the unused fullscreen hook import to clean up the code.
- Updated click handlers in the Navbar components for better readability and efficiency.

* chore(version): 1.5.3

* style(MinAppsPage): adjust padding for AppsContainerWrapper based on navbar position

- Increased padding for the AppsContainerWrapper to 50px for better spacing.
- Added conditional padding for when the navbar is positioned at the top, reverting to 20px for improved layout consistency.

* fix(AiProvider): remove unnecessary middleware removal logic for… (#8437)

* refactor(AiProvider): remove unnecessary middleware removal logic for improved clarity

* feat(PPIOAPIClient): add compatibility type check for OpenAIAPIClient

* refactor(ModelEditContent): rename state variable for clarity and update model capabilities handling

- Renamed `tempModelTypes` to `modelCapabilities` for improved clarity in the ModelEditContent component.
- Updated state management and logic to consistently use the new `modelCapabilities` variable throughout the component, enhancing readability and maintainability.

* Feat/vertex-claude-support (#7564)

* feat(migrate): add default settings for assistants during migration

- Introduced a new migration step to assign default settings for assistants that lack configuration.
- Default settings include temperature, context count, and other parameters to ensure consistent behavior across the application.

* chore(store): increment version number to 115 for persisted reducer

* feat(vertex-sdk): integrate Anthropic Vertex SDK and add access token retrieval

- Added support for the new `@anthropic-ai/vertex-sdk` in the project.
- Introduced a new IPC channel `VertexAI_GetAccessToken` to retrieve access tokens.
- Implemented `getAccessToken` method in `VertexAIService` to handle service account authentication.
- Updated the `IpcChannel` enum and related IPC handlers to support the new functionality.
- Enhanced the `VertexAPIClient` to utilize the `AnthropicVertexClient` for model handling.
- Refactored existing code to accommodate the integration of the Vertex SDK and improve modularity.

* feat(vertex-ai): enhance VertexAI settings and API host management

- Added a new method to format the API host URL in both AnthropicVertexClient and VertexAPIClient.
- Updated getBaseURL methods to utilize the new formatting logic.
- Enhanced VertexAISettings component to include an input for API host configuration, with help text for user guidance.
- Updated localization files to include new help text for the API host field in multiple languages.

* fix(vertex-sdk): update baseURL handling and patch dependencies

- Refactored baseURL assignment in AnthropicVertexClient to ensure it defaults to undefined when the URL is empty.
- Updated yarn.lock to reflect changes in dependency resolution and checksum for @anthropic-ai/vertex-sdk patch.

* refactor(VertexAISetting): use provider.id rather than provider

* refactor: improve API host formatting in AnthropicVertexClient

- Updated the `formatApiHost` method to streamline host URL handling.
- Introduced a helper function to determine if the original host should be used based on its format.
- Ensured consistent appending of the `/v1/` path for valid API requests.

* fix: handle empty host in AnthropicVertexClient

- Added a check in the `getBaseURL` method to return the host if it is empty, preventing potential errors.
- Included a console log for the base URL to aid in debugging and verification of the URL formatting.

* feat(AnthropicVertexClient): add logging for authentication errors and mock client in tests

- Introduced logging functionality in AnthropicVertexClient to replace console.error with logger service for better error tracking.
- Added mock implementation for AnthropicVertexClient in tests to enhance testing capabilities.
- Updated package.json to include the @aws-sdk/client-s3 dependency.

* feat(tests): add comprehensive tests for client compatibility types

- Introduced a new test file to validate compatibility types for various API clients including OpenAI, Anthropic, Gemini, Aihubmix, NewAPI, and Vertex.
- Implemented mock services to facilitate testing and ensure isolation of client behavior.
- Added tests for both direct API clients and decorator pattern clients, ensuring correct compatibility type returns.
- Enhanced middleware compatibility logic tests to verify correct identification of compatible clients.

---------

Co-authored-by: one <wangan.cs@gmail.com>

* fix(mcp-tools): enhance tool lookup logic to support partial matches (#8473)

* fix(mcp-tools): enhance tool lookup logic to support partial matches

- Updated the tool lookup logic in `geminiFunctionCallToMcpTool` to include partial matches for both tool IDs and names, improving the flexibility of tool identification.

* refactor(mcp-tools): simplify tool lookup logic for improved clarity

- Refactored the tool lookup logic in `geminiFunctionCallToMcpTool` to streamline the identification process by consolidating checks for tool IDs and names into a single variable. This enhances readability and maintains functionality for partial matches.

* chore(deps): update vite to rolldown-vite (#8460)

* chore(deps): update vite to rolldown-vite and add new dependencies

- Updated vite dependency to rolldown-vite@latest in package.json.
- Added new dependencies including @emnapi/core, @emnapi/runtime, and @napi-rs/wasm-runtime in yarn.lock.
- Introduced patches for atomically and file-stream-rotator packages.
- Added process import in index.ts for improved functionality.

* updrade vitest

* not package graceful-fs

* update yarn.lock

* fix(AppUpdater): improve update handling and logging for test plans

- Enhanced the update logic in AppUpdater to prevent sending an 'update not available' event when a test plan is enabled and the channel is not the latest.
- Refactored the feed URL and channel setting into a private method for better code organization.
- Added logging to provide clearer insights into the update check results and channel settings, particularly when the test plan is active.

---------

Co-authored-by: kangfenmao <kangfenmao@qq.com>
Co-authored-by: SuYao <sy20010504@gmail.com>
Co-authored-by: one <wangan.cs@gmail.com>
This commit is contained in:
beyondkmp 2025-07-25 13:20:01 +08:00 committed by GitHub
parent 949fc722dd
commit eef20e399c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 24 deletions

View File

@ -194,8 +194,7 @@ export const defaultLanguage = 'en-US'
export enum FeedUrl {
PRODUCTION = 'https://releases.cherry-ai.com',
GITHUB_LATEST = 'https://github.com/CherryHQ/cherry-studio/releases/latest/download',
PRERELEASE_LOWEST = 'https://github.com/CherryHQ/cherry-studio/releases/download/v1.4.0'
GITHUB_LATEST = 'https://github.com/CherryHQ/cherry-studio/releases/latest/download'
}
export enum UpgradeChannel {

View File

@ -47,6 +47,12 @@ export default class AppUpdater {
// 检测到不需要更新时
autoUpdater.on('update-not-available', () => {
if (configManager.getTestPlan() && this.autoUpdater.channel !== UpgradeChannel.LATEST) {
logger.info('test plan is enabled, but update is not available, do not send update not available event')
// will not send update not available event, because will check for updates with latest channel
return
}
mainWindow.webContents.send(IpcChannel.UpdateNotAvailable)
})
@ -84,12 +90,12 @@ export default class AppUpdater {
return item.prerelease && item.tag_name.includes(`-${channel}.`)
})
logger.info('release info', release)
if (!release) {
return null
}
logger.info(`prerelease url is ${release.tag_name}, set channel to ${channel}`)
return `https://github.com/CherryHQ/cherry-studio/releases/download/${release.tag_name}`
} catch (error) {
logger.error('Failed to get latest not draft version from github:', error as Error)
@ -152,37 +158,43 @@ export default class AppUpdater {
return UpgradeChannel.LATEST
}
private _setChannel(channel: UpgradeChannel, feedUrl: string) {
this.autoUpdater.channel = channel
this.autoUpdater.setFeedURL(feedUrl)
// disable downgrade after change the channel
this.autoUpdater.allowDowngrade = false
// github and gitcode don't support multiple range download
this.autoUpdater.disableDifferentialDownload = true
}
private async _setFeedUrl() {
const testPlan = configManager.getTestPlan()
if (testPlan) {
const channel = this._getTestChannel()
if (channel === UpgradeChannel.LATEST) {
this.autoUpdater.channel = UpgradeChannel.LATEST
this.autoUpdater.setFeedURL(FeedUrl.GITHUB_LATEST)
this._setChannel(UpgradeChannel.LATEST, FeedUrl.GITHUB_LATEST)
return
}
const preReleaseUrl = await this._getPreReleaseVersionFromGithub(channel)
if (preReleaseUrl) {
this.autoUpdater.setFeedURL(preReleaseUrl)
this.autoUpdater.channel = channel
logger.info(`prerelease url is ${preReleaseUrl}, set channel to ${channel}`)
this._setChannel(channel, preReleaseUrl)
return
}
// if no prerelease url, use lowest prerelease version to avoid error
this.autoUpdater.setFeedURL(FeedUrl.PRERELEASE_LOWEST)
this.autoUpdater.channel = UpgradeChannel.LATEST
// if no prerelease url, use github latest to avoid error
this._setChannel(UpgradeChannel.LATEST, FeedUrl.GITHUB_LATEST)
return
}
this.autoUpdater.channel = UpgradeChannel.LATEST
this.autoUpdater.setFeedURL(FeedUrl.PRODUCTION)
this._setChannel(UpgradeChannel.LATEST, FeedUrl.PRODUCTION)
const ipCountry = await this._getIpCountry()
logger.info('ipCountry', ipCountry)
logger.info(`ipCountry is ${ipCountry}, set channel to ${UpgradeChannel.LATEST}`)
if (ipCountry.toLowerCase() !== 'cn') {
this.autoUpdater.setFeedURL(FeedUrl.GITHUB_LATEST)
this._setChannel(UpgradeChannel.LATEST, FeedUrl.GITHUB_LATEST)
}
}
@ -202,16 +214,25 @@ export default class AppUpdater {
}
}
await this._setFeedUrl()
// disable downgrade after change the channel
this.autoUpdater.allowDowngrade = false
// github and gitcode don't support multiple range download
this.autoUpdater.disableDifferentialDownload = true
try {
await this._setFeedUrl()
this.updateCheckResult = await this.autoUpdater.checkForUpdates()
logger.info(
`update check result: ${this.updateCheckResult?.isUpdateAvailable}, channel: ${this.autoUpdater.channel}, currentVersion: ${this.autoUpdater.currentVersion}`
)
// if the update is not available, and the test plan is enabled, set the feed url to the github latest
if (
!this.updateCheckResult?.isUpdateAvailable &&
configManager.getTestPlan() &&
this.autoUpdater.channel !== UpgradeChannel.LATEST
) {
logger.info('test plan is enabled, but update is not available, set channel to latest')
this._setChannel(UpgradeChannel.LATEST, FeedUrl.GITHUB_LATEST)
this.updateCheckResult = await this.autoUpdater.checkForUpdates()
}
if (this.updateCheckResult?.isUpdateAvailable && !this.autoUpdater.autoDownload) {
// 如果 autoDownload 为 false则需要再调用下面的函数触发下
// do not use await, because it will block the return of this function