From 7b7819217fe37fe07bf26ab3920ff2389da75a37 Mon Sep 17 00:00:00 2001 From: David Zhang <61440144+WAcry@users.noreply.github.com> Date: Sun, 29 Jun 2025 12:14:58 -0700 Subject: [PATCH 001/246] chore(OpenAIApiClient): handle empty delta objects in non-streaming esponses (#7658) chore(OpenAIApiClient): handle empty delta objects in non-streaming responses --- .../src/aiCore/clients/openai/OpenAIApiClient.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts b/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts index 499edfbb5c..6c6e524b53 100644 --- a/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts +++ b/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts @@ -639,9 +639,15 @@ export class OpenAIAPIClient extends OpenAIBaseClient< if (!choice) return - // 对于流式响应,使用delta;对于非流式响应,使用message - const contentSource: OpenAISdkRawContentSource | null = - 'delta' in choice ? choice.delta : 'message' in choice ? choice.message : null + // 对于流式响应,使用 delta;对于非流式响应,使用 message。 + // 然而某些 OpenAI 兼容平台在非流式请求时会错误地返回一个空对象的 delta 字段。 + // 如果 delta 为空对象,应当忽略它并回退到 message,避免造成内容缺失。 + let contentSource: OpenAISdkRawContentSource | null = null + if ('delta' in choice && choice.delta && Object.keys(choice.delta).length > 0) { + contentSource = choice.delta + } else if ('message' in choice) { + contentSource = choice.message + } if (!contentSource) return From 4c988ede52678f21485eddaeaae27fa4b0640faf Mon Sep 17 00:00:00 2001 From: cnJasonZ Date: Mon, 30 Jun 2025 10:16:22 +0800 Subject: [PATCH 002/246] Feat/ppio rerank (#7567) * feat: add PPIO rerank and embedding models * fix: fix migrate.ts * fix: set ppio provider type to openai * fix: remove 'ppio' from ProviderType definition --------- Co-authored-by: suyao --- .../src/aiCore/clients/ApiClientFactory.ts | 6 ++ .../src/aiCore/clients/ppio/PPIOAPIClient.ts | 65 +++++++++++++++ src/renderer/src/config/models.ts | 80 +++++++++++++------ src/renderer/src/store/index.ts | 2 +- src/renderer/src/store/llm.ts | 2 +- src/renderer/src/store/migrate.ts | 11 +++ 6 files changed, 139 insertions(+), 27 deletions(-) create mode 100644 src/renderer/src/aiCore/clients/ppio/PPIOAPIClient.ts diff --git a/src/renderer/src/aiCore/clients/ApiClientFactory.ts b/src/renderer/src/aiCore/clients/ApiClientFactory.ts index adc97e70e0..b0fbe3e479 100644 --- a/src/renderer/src/aiCore/clients/ApiClientFactory.ts +++ b/src/renderer/src/aiCore/clients/ApiClientFactory.ts @@ -7,6 +7,7 @@ import { GeminiAPIClient } from './gemini/GeminiAPIClient' import { VertexAPIClient } from './gemini/VertexAPIClient' import { OpenAIAPIClient } from './openai/OpenAIApiClient' import { OpenAIResponseAPIClient } from './openai/OpenAIResponseAPIClient' +import { PPIOAPIClient } from './ppio/PPIOAPIClient' /** * Factory for creating ApiClient instances based on provider configuration @@ -31,6 +32,11 @@ export class ApiClientFactory { instance = new AihubmixAPIClient(provider) as BaseApiClient return instance } + if (provider.id === 'ppio') { + console.log(`[ApiClientFactory] Creating PPIOAPIClient for provider: ${provider.id}`) + instance = new PPIOAPIClient(provider) as BaseApiClient + return instance + } // 然后检查标准的provider type switch (provider.type) { diff --git a/src/renderer/src/aiCore/clients/ppio/PPIOAPIClient.ts b/src/renderer/src/aiCore/clients/ppio/PPIOAPIClient.ts new file mode 100644 index 0000000000..2b8dec332d --- /dev/null +++ b/src/renderer/src/aiCore/clients/ppio/PPIOAPIClient.ts @@ -0,0 +1,65 @@ +import { isSupportedModel } from '@renderer/config/models' +import { Provider } from '@renderer/types' +import OpenAI from 'openai' + +import { OpenAIAPIClient } from '../openai/OpenAIApiClient' + +export class PPIOAPIClient extends OpenAIAPIClient { + constructor(provider: Provider) { + super(provider) + } + + override async listModels(): Promise { + try { + const sdk = await this.getSdkInstance() + + // PPIO requires three separate requests to get all model types + const [chatModelsResponse, embeddingModelsResponse, rerankerModelsResponse] = await Promise.all([ + // Chat/completion models + sdk.request({ + method: 'get', + path: '/models' + }), + // Embedding models + sdk.request({ + method: 'get', + path: '/models?model_type=embedding' + }), + // Reranker models + sdk.request({ + method: 'get', + path: '/models?model_type=reranker' + }) + ]) + + // Extract models from all responses + // @ts-ignore - PPIO response structure may not be typed + const allModels = [ + ...((chatModelsResponse as any)?.data || []), + ...((embeddingModelsResponse as any)?.data || []), + ...((rerankerModelsResponse as any)?.data || []) + ] + + // Process and standardize model data + const processedModels = allModels.map((model: any) => ({ + id: model.id || model.name, + description: model.description || model.display_name || model.summary, + object: 'model' as const, + owned_by: model.owned_by || model.publisher || model.organization || 'ppio', + created: model.created || Date.now() + })) + + // Clean up model IDs and filter supported models + processedModels.forEach((model) => { + if (model.id) { + model.id = model.id.trim() + } + }) + + return processedModels.filter(isSupportedModel) + } catch (error) { + console.error('Error listing PPIO models:', error) + return [] + } + } +} diff --git a/src/renderer/src/config/models.ts b/src/renderer/src/config/models.ts index 3bb9d099fa..3c2902a489 100644 --- a/src/renderer/src/config/models.ts +++ b/src/renderer/src/config/models.ts @@ -767,6 +767,30 @@ export const SYSTEM_MODELS: Record = { } ], ppio: [ + { + id: 'deepseek/deepseek-r1-0528', + provider: 'ppio', + name: 'DeepSeek R1-0528', + group: 'deepseek' + }, + { + id: 'deepseek/deepseek-v3-0324', + provider: 'ppio', + name: 'DeepSeek V3-0324', + group: 'deepseek' + }, + { + id: 'deepseek/deepseek-r1-turbo', + provider: 'ppio', + name: 'DeepSeek R1 Turbo', + group: 'deepseek' + }, + { + id: 'deepseek/deepseek-v3-turbo', + provider: 'ppio', + name: 'DeepSeek V3 Turbo', + group: 'deepseek' + }, { id: 'deepseek/deepseek-r1/community', name: 'DeepSeek: DeepSeek R1 (Community)', @@ -780,52 +804,58 @@ export const SYSTEM_MODELS: Record = { group: 'deepseek' }, { - id: 'deepseek/deepseek-r1', + id: 'minimaxai/minimax-m1-80k', provider: 'ppio', - name: 'DeepSeek R1', - group: 'deepseek' + name: 'MiniMax M1-80K', + group: 'minimaxai' }, { - id: 'deepseek/deepseek-v3', + id: 'qwen/qwen3-235b-a22b-fp8', provider: 'ppio', - name: 'DeepSeek V3', - group: 'deepseek' - }, - { - id: 'qwen/qwen-2.5-72b-instruct', - provider: 'ppio', - name: 'Qwen2.5-72B-Instruct', + name: 'Qwen3 235B', group: 'qwen' }, { - id: 'qwen/qwen2.5-32b-instruct', + id: 'qwen/qwen3-32b-fp8', provider: 'ppio', - name: 'Qwen2.5-32B-Instruct', + name: 'Qwen3 32B', group: 'qwen' }, { - id: 'meta-llama/llama-3.1-70b-instruct', + id: 'qwen/qwen3-30b-a3b-fp8', provider: 'ppio', - name: 'Llama-3.1-70B-Instruct', - group: 'meta-llama' + name: 'Qwen3 30B', + group: 'qwen' }, { - id: 'meta-llama/llama-3.1-8b-instruct', + id: 'qwen/qwen2.5-vl-72b-instruct', provider: 'ppio', - name: 'Llama-3.1-8B-Instruct', - group: 'meta-llama' + name: 'Qwen2.5 VL 72B', + group: 'qwen' }, { - id: '01-ai/yi-1.5-34b-chat', + id: 'qwen/qwen3-embedding-8b', provider: 'ppio', - name: 'Yi-1.5-34B-Chat', - group: '01-ai' + name: 'Qwen3 Embedding 8B', + group: 'qwen' }, { - id: '01-ai/yi-1.5-9b-chat', + id: 'qwen/qwen3-reranker-8b', provider: 'ppio', - name: 'Yi-1.5-9B-Chat', - group: '01-ai' + name: 'Qwen3 Reranker 8B', + group: 'qwen' + }, + { + id: 'thudm/glm-z1-32b-0414', + provider: 'ppio', + name: 'GLM-Z1 32B', + group: 'thudm' + }, + { + id: 'thudm/glm-z1-9b-0414', + provider: 'ppio', + name: 'GLM-Z1 9B', + group: 'thudm' } ], alayanew: [], diff --git a/src/renderer/src/store/index.ts b/src/renderer/src/store/index.ts index 4a26bf96c0..3b6cba1040 100644 --- a/src/renderer/src/store/index.ts +++ b/src/renderer/src/store/index.ts @@ -50,7 +50,7 @@ const persistedReducer = persistReducer( { key: 'cherry-studio', storage, - version: 116, + version: 117, blacklist: ['runtime', 'messages', 'messageBlocks'], migrate }, diff --git a/src/renderer/src/store/llm.ts b/src/renderer/src/store/llm.ts index f70c4ef2ba..d42b4dc065 100644 --- a/src/renderer/src/store/llm.ts +++ b/src/renderer/src/store/llm.ts @@ -79,7 +79,7 @@ export const INITIAL_PROVIDERS: Provider[] = [ name: 'PPIO', type: 'openai', apiKey: '', - apiHost: 'https://api.ppinfra.com/v3/openai', + apiHost: 'https://api.ppinfra.com/v3/openai/', models: SYSTEM_MODELS.ppio, isSystem: true, enabled: false diff --git a/src/renderer/src/store/migrate.ts b/src/renderer/src/store/migrate.ts index 8eea0a34a7..56ffa33cbe 100644 --- a/src/renderer/src/store/migrate.ts +++ b/src/renderer/src/store/migrate.ts @@ -1656,6 +1656,17 @@ const migrateConfig = { state.settings.testChannel = UpgradeChannel.LATEST } + return state + } catch (error) { + return state + } + }, + '117': (state: RootState) => { + try { + updateProvider(state, 'ppio', { + models: SYSTEM_MODELS.ppio, + apiHost: 'https://api.ppinfra.com/v3/openai/' + }) return state } catch (error) { return state From 1034b946288e2b6dd326441c8fd46be9de91e7e1 Mon Sep 17 00:00:00 2001 From: Wang Jiyuan <59059173+EurFelux@users.noreply.github.com> Date: Mon, 30 Jun 2025 10:43:19 +0800 Subject: [PATCH 003/246] fix(translate): improve language options with clearer values (#7640) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(翻译配置): 修正简体中文语言选项的值和标签显示 将'chinese'改为更明确的'chinese-simplified' * style(translate): 统一语言选项的显示格式为规范名称 --- src/renderer/src/config/translate.ts | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/renderer/src/config/translate.ts b/src/renderer/src/config/translate.ts index b8e5cd0b4e..9a85b68ecc 100644 --- a/src/renderer/src/config/translate.ts +++ b/src/renderer/src/config/translate.ts @@ -9,116 +9,116 @@ export interface TranslateLanguageOption { export const TranslateLanguageOptions: TranslateLanguageOption[] = [ { - value: 'english', + value: 'English', langCode: 'en-us', label: i18n.t('languages.english'), emoji: '🇬🇧' }, { - value: 'chinese', + value: 'Chinese (Simplified)', langCode: 'zh-cn', label: i18n.t('languages.chinese'), emoji: '🇨🇳' }, { - value: 'chinese-traditional', + value: 'Chinese (Traditional)', langCode: 'zh-tw', label: i18n.t('languages.chinese-traditional'), emoji: '🇭🇰' }, { - value: 'japanese', + value: 'Japanese', langCode: 'ja-jp', label: i18n.t('languages.japanese'), emoji: '🇯🇵' }, { - value: 'korean', + value: 'Korean', langCode: 'ko-kr', label: i18n.t('languages.korean'), emoji: '🇰🇷' }, { - value: 'french', + value: 'French', langCode: 'fr-fr', label: i18n.t('languages.french'), emoji: '🇫🇷' }, { - value: 'german', + value: 'German', langCode: 'de-de', label: i18n.t('languages.german'), emoji: '🇩🇪' }, { - value: 'italian', + value: 'Italian', langCode: 'it-it', label: i18n.t('languages.italian'), emoji: '🇮🇹' }, { - value: 'spanish', + value: 'Spanish', langCode: 'es-es', label: i18n.t('languages.spanish'), emoji: '🇪🇸' }, { - value: 'portuguese', + value: 'Portuguese', langCode: 'pt-pt', label: i18n.t('languages.portuguese'), emoji: '🇵🇹' }, { - value: 'russian', + value: 'Russian', langCode: 'ru-ru', label: i18n.t('languages.russian'), emoji: '🇷🇺' }, { - value: 'polish', + value: 'Polish', langCode: 'pl-pl', label: i18n.t('languages.polish'), emoji: '🇵🇱' }, { - value: 'arabic', + value: 'Arabic', langCode: 'ar-ar', label: i18n.t('languages.arabic'), emoji: '🇸🇦' }, { - value: 'turkish', + value: 'Turkish', langCode: 'tr-tr', label: i18n.t('languages.turkish'), emoji: '🇹🇷' }, { - value: 'thai', + value: 'Thai', langCode: 'th-th', label: i18n.t('languages.thai'), emoji: '🇹🇭' }, { - value: 'vietnamese', + value: 'Vietnamese', langCode: 'vi-vn', label: i18n.t('languages.vietnamese'), emoji: '🇻🇳' }, { - value: 'indonesian', + value: 'Indonesian', langCode: 'id-id', label: i18n.t('languages.indonesian'), emoji: '🇮🇩' }, { - value: 'urdu', + value: 'Urdu', langCode: 'ur-pk', label: i18n.t('languages.urdu'), emoji: '🇵🇰' }, { - value: 'malay', + value: 'Malay', langCode: 'ms-my', label: i18n.t('languages.malay'), emoji: '🇲🇾' @@ -129,7 +129,7 @@ export const translateLanguageOptions = (): typeof TranslateLanguageOptions => { return TranslateLanguageOptions.map((option) => { return { value: option.value, - label: i18n.t(`languages.${option.value}`), + label: option.label, emoji: option.emoji } }) From a9a9d884ce8ec7104c2b23ce6b3dc71a0d58966f Mon Sep 17 00:00:00 2001 From: SuYao Date: Mon, 30 Jun 2025 13:51:23 +0800 Subject: [PATCH 004/246] Fix/gemini (#7659) * refactor: update Gemini and OpenAI API clients for improved reasoning model handling - Replaced isGeminiReasoningModel with isSupportedThinkingTokenGeminiModel in GeminiAPIClient for better model validation. - Enhanced OpenAIAPIClient to support additional configurations for reasoning efforts and thinking budgets based on model type. - Introduced new thinking tags for Gemini models in ThinkingTagExtractionMiddleware. - Updated model checks in models.ts to streamline reasoning model identification. - Adjusted ThinkingButton component to differentiate between Gemini and Gemini Pro models based on regex checks. * refactor(GeminiAPIClient): streamline reasoning configuration handling - Simplified the logic for returning thinking configuration when reasoningEffort is undefined in GeminiAPIClient. - Updated ApiService to include enableReasoning flag for API calls, enhancing control over reasoning capabilities. * fix(OpenAIAPIClient): add support for non-flash Gemini models in reasoning configuration - Introduced a check for non-flash models in the OpenAIAPIClient to enhance reasoning configuration handling for supported Gemini models. - This change ensures that reasoning is correctly configured based on the model type, improving overall model validation. --- .../aiCore/clients/gemini/GeminiAPIClient.ts | 26 ++++++------ .../aiCore/clients/openai/OpenAIApiClient.ts | 40 ++++++++++++++++++- .../feat/ThinkingTagExtractionMiddleware.ts | 2 + src/renderer/src/config/models.ts | 6 ++- .../pages/home/Inputbar/ThinkingButton.tsx | 15 +++++-- src/renderer/src/services/ApiService.ts | 1 + src/renderer/src/types/sdk.ts | 1 + 7 files changed, 71 insertions(+), 20 deletions(-) diff --git a/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts b/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts index 549e931966..f37bcd3d30 100644 --- a/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts +++ b/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts @@ -22,8 +22,8 @@ import { GenericChunk } from '@renderer/aiCore/middleware/schemas' import { findTokenLimit, GEMINI_FLASH_MODEL_REGEX, - isGeminiReasoningModel, isGemmaModel, + isSupportedThinkingTokenGeminiModel, isVisionModel } from '@renderer/config/models' import { CacheService } from '@renderer/services/CacheService' @@ -393,29 +393,29 @@ export class GeminiAPIClient extends BaseApiClient< * @returns The reasoning effort */ private getBudgetToken(assistant: Assistant, model: Model) { - if (isGeminiReasoningModel(model)) { + if (isSupportedThinkingTokenGeminiModel(model)) { const reasoningEffort = assistant?.settings?.reasoning_effort // 如果thinking_budget是undefined,不思考 if (reasoningEffort === undefined) { - return { - thinkingConfig: { - includeThoughts: false, - ...(GEMINI_FLASH_MODEL_REGEX.test(model.id) ? { thinkingBudget: 0 } : {}) - } as ThinkingConfig - } + return GEMINI_FLASH_MODEL_REGEX.test(model.id) + ? { + thinkingConfig: { + thinkingBudget: 0 + } + } + : {} } - const effortRatio = EFFORT_RATIO[reasoningEffort] - - if (effortRatio > 1) { + if (reasoningEffort === 'auto') { return { thinkingConfig: { - includeThoughts: true + includeThoughts: true, + thinkingBudget: -1 } } } - + const effortRatio = EFFORT_RATIO[reasoningEffort] const { min, max } = findTokenLimit(model.id) || { min: 0, max: 0 } // 计算 budgetTokens,确保不低于 min const budget = Math.floor((max - min) * effortRatio + min) diff --git a/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts b/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts index 6c6e524b53..9b72758c97 100644 --- a/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts +++ b/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts @@ -114,6 +114,9 @@ export class OpenAIAPIClient extends OpenAIBaseClient< if (!reasoningEffort) { if (model.provider === 'openrouter') { + if (isSupportedThinkingTokenGeminiModel(model) && !GEMINI_FLASH_MODEL_REGEX.test(model.id)) { + return {} + } return { reasoning: { enabled: false, exclude: true } } } if (isSupportedThinkingTokenQwenModel(model)) { @@ -126,7 +129,15 @@ export class OpenAIAPIClient extends OpenAIBaseClient< if (isSupportedThinkingTokenGeminiModel(model)) { if (GEMINI_FLASH_MODEL_REGEX.test(model.id)) { - return { reasoning_effort: 'none' } + return { + extra_body: { + google: { + thinking_config: { + thinking_budget: 0 + } + } + } + } } return {} } @@ -169,12 +180,37 @@ export class OpenAIAPIClient extends OpenAIBaseClient< } // OpenAI models - if (isSupportedReasoningEffortOpenAIModel(model) || isSupportedThinkingTokenGeminiModel(model)) { + if (isSupportedReasoningEffortOpenAIModel(model)) { return { reasoning_effort: reasoningEffort } } + if (isSupportedThinkingTokenGeminiModel(model)) { + if (reasoningEffort === 'auto') { + return { + extra_body: { + google: { + thinking_config: { + thinking_budget: -1, + include_thoughts: true + } + } + } + } + } + return { + extra_body: { + google: { + thinking_config: { + thinking_budget: budgetTokens, + include_thoughts: true + } + } + } + } + } + // Claude models if (isSupportedThinkingTokenClaudeModel(model)) { const maxTokens = assistant.settings?.maxTokens diff --git a/src/renderer/src/aiCore/middleware/feat/ThinkingTagExtractionMiddleware.ts b/src/renderer/src/aiCore/middleware/feat/ThinkingTagExtractionMiddleware.ts index 440de40045..fe2d51d8de 100644 --- a/src/renderer/src/aiCore/middleware/feat/ThinkingTagExtractionMiddleware.ts +++ b/src/renderer/src/aiCore/middleware/feat/ThinkingTagExtractionMiddleware.ts @@ -11,11 +11,13 @@ export const MIDDLEWARE_NAME = 'ThinkingTagExtractionMiddleware' // 不同模型的思考标签配置 const reasoningTags: TagConfig[] = [ { openingTag: '', closingTag: '', separator: '\n' }, + { openingTag: '', closingTag: '', separator: '\n' }, { openingTag: '###Thinking', closingTag: '###Response', separator: '\n' } ] const getAppropriateTag = (model?: Model): TagConfig => { if (model?.id?.includes('qwen3')) return reasoningTags[0] + if (model?.id?.includes('gemini-2.5')) return reasoningTags[1] // 可以在这里添加更多模型特定的标签配置 return reasoningTags[0] // 默认使用 标签 } diff --git a/src/renderer/src/config/models.ts b/src/renderer/src/config/models.ts index 3c2902a489..48560007ca 100644 --- a/src/renderer/src/config/models.ts +++ b/src/renderer/src/config/models.ts @@ -2509,14 +2509,16 @@ export function isGeminiReasoningModel(model?: Model): boolean { return true } - if (model.id.includes('gemini-2.5')) { + if (isSupportedThinkingTokenGeminiModel(model)) { return true } return false } -export const isSupportedThinkingTokenGeminiModel = isGeminiReasoningModel +export const isSupportedThinkingTokenGeminiModel = (model: Model): boolean => { + return model.id.includes('gemini-2.5') +} export function isQwenReasoningModel(model?: Model): boolean { if (!model) { diff --git a/src/renderer/src/pages/home/Inputbar/ThinkingButton.tsx b/src/renderer/src/pages/home/Inputbar/ThinkingButton.tsx index 21db131cef..5bf57d9c9c 100644 --- a/src/renderer/src/pages/home/Inputbar/ThinkingButton.tsx +++ b/src/renderer/src/pages/home/Inputbar/ThinkingButton.tsx @@ -7,6 +7,7 @@ import { } from '@renderer/components/Icons/SVGIcon' import { useQuickPanel } from '@renderer/components/QuickPanel' import { + GEMINI_FLASH_MODEL_REGEX, isDoubaoThinkingAutoModel, isSupportedReasoningEffortGrokModel, isSupportedThinkingTokenDoubaoModel, @@ -37,13 +38,14 @@ const MODEL_SUPPORTED_OPTIONS: Record = { default: ['off', 'low', 'medium', 'high'], grok: ['off', 'low', 'high'], gemini: ['off', 'low', 'medium', 'high', 'auto'], + gemini_pro: ['low', 'medium', 'high', 'auto'], qwen: ['off', 'low', 'medium', 'high'], doubao: ['off', 'auto', 'high'] } // 选项转换映射表:当选项不支持时使用的替代选项 const OPTION_FALLBACK: Record = { - off: 'off', + off: 'low', // off -> low (for Gemini Pro models) low: 'high', medium: 'high', // medium -> high (for Grok models) high: 'high', @@ -57,6 +59,7 @@ const ThinkingButton: FC = ({ ref, model, assistant, ToolbarButton }): Re const isGrokModel = isSupportedReasoningEffortGrokModel(model) const isGeminiModel = isSupportedThinkingTokenGeminiModel(model) + const isGeminiFlashModel = GEMINI_FLASH_MODEL_REGEX.test(model.id) const isQwenModel = isSupportedThinkingTokenQwenModel(model) const isDoubaoModel = isSupportedThinkingTokenDoubaoModel(model) @@ -66,12 +69,18 @@ const ThinkingButton: FC = ({ ref, model, assistant, ToolbarButton }): Re // 确定当前模型支持的选项类型 const modelType = useMemo(() => { - if (isGeminiModel) return 'gemini' + if (isGeminiModel) { + if (isGeminiFlashModel) { + return 'gemini' + } else { + return 'gemini_pro' + } + } if (isGrokModel) return 'grok' if (isQwenModel) return 'qwen' if (isDoubaoModel) return 'doubao' return 'default' - }, [isGeminiModel, isGrokModel, isQwenModel, isDoubaoModel]) + }, [isGeminiModel, isGrokModel, isQwenModel, isDoubaoModel, isGeminiFlashModel]) // 获取当前模型支持的选项 const supportedOptions = useMemo(() => { diff --git a/src/renderer/src/services/ApiService.ts b/src/renderer/src/services/ApiService.ts index 4704a8bfd3..abc3db81b0 100644 --- a/src/renderer/src/services/ApiService.ts +++ b/src/renderer/src/services/ApiService.ts @@ -607,6 +607,7 @@ export async function checkApi(provider: Provider, model: Model): Promise messages: 'hi', assistant, streamOutput: true, + enableReasoning: false, shouldThrow: true } diff --git a/src/renderer/src/types/sdk.ts b/src/renderer/src/types/sdk.ts index 6505210b60..c7eeb9500c 100644 --- a/src/renderer/src/types/sdk.ts +++ b/src/renderer/src/types/sdk.ts @@ -53,6 +53,7 @@ export type ReasoningEffortOptionalParams = { enable_thinking?: boolean thinking_budget?: number enable_reasoning?: boolean + extra_body?: Record // Add any other potential reasoning-related keys here if they exist } From 21ba35b6bf20073d366764e134bfc2780a6f53ae Mon Sep 17 00:00:00 2001 From: SuYao Date: Mon, 30 Jun 2025 15:17:05 +0800 Subject: [PATCH 005/246] fix(ImageGenerationMiddleware): read image binary data (#7681) - Replaced direct API call for reading binary images with FileManager's readBinaryImage method to streamline image handling in the ImageGenerationMiddleware. --- .../src/aiCore/middleware/feat/ImageGenerationMiddleware.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/aiCore/middleware/feat/ImageGenerationMiddleware.ts b/src/renderer/src/aiCore/middleware/feat/ImageGenerationMiddleware.ts index d0a4dc4903..6c01759bec 100644 --- a/src/renderer/src/aiCore/middleware/feat/ImageGenerationMiddleware.ts +++ b/src/renderer/src/aiCore/middleware/feat/ImageGenerationMiddleware.ts @@ -1,5 +1,6 @@ import { BaseApiClient } from '@renderer/aiCore/clients/BaseApiClient' import { isDedicatedImageGenerationModel } from '@renderer/config/models' +import FileManager from '@renderer/services/FileManager' import { ChunkType } from '@renderer/types/chunk' import { findImageBlocks, getMainTextContent } from '@renderer/utils/messageUtils/find' import OpenAI from 'openai' @@ -46,7 +47,7 @@ export const ImageGenerationMiddleware: CompletionsMiddleware = const userImages = await Promise.all( userImageBlocks.map(async (block) => { if (!block.file) return null - const binaryData: Uint8Array = await window.api.file.binaryImage(block.file.id) + const binaryData: Uint8Array = await FileManager.readBinaryImage(block.file) const mimeType = `${block.file.type}/${block.file.ext.slice(1)}` return await toFile(new Blob([binaryData]), block.file.origin_name || 'image.png', { type: mimeType }) }) From db4ce9fb7f6e5b2ee94e899ca6ba8d610684c4cf Mon Sep 17 00:00:00 2001 From: Teo Date: Mon, 30 Jun 2025 16:13:25 +0800 Subject: [PATCH 006/246] fix(Inputbar): fix enter key confict (#7679) fix(Inputbar): prevent default behavior for Enter key when quick panel is visible --- src/renderer/src/pages/home/Inputbar/Inputbar.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index af18b7fe23..462ef0adb6 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -348,8 +348,9 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic, topic }) = //other keys should be ignored const isEnterPressed = event.key === 'Enter' && !event.nativeEvent.isComposing if (isEnterPressed) { + if (quickPanel.isVisible) return event.preventDefault() + if (isSendMessageKeyPressed(event, sendMessageShortcut)) { - if (quickPanel.isVisible) return event.preventDefault() sendMessage() return event.preventDefault() } else { From ac03aab29fcaa242ed0389bc1ec8d3ab2e2cbec0 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Mon, 30 Jun 2025 17:04:48 +0800 Subject: [PATCH 007/246] chore(package): add opendal dependency to package.json (#7685) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5455f348b2..dd835ee9fe 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "jsdom": "26.1.0", "node-stream-zip": "^1.15.0", "notion-helper": "^1.3.22", + "opendal": "0.47.11", "os-proxy-config": "^1.1.2", "selection-hook": "^0.9.23", "turndown": "7.2.0" @@ -181,7 +182,6 @@ "npx-scope-finder": "^1.2.0", "officeparser": "^4.1.1", "openai": "patch:openai@npm%3A5.1.0#~/.yarn/patches/openai-npm-5.1.0-0e7b3ccb07.patch", - "opendal": "0.47.11", "p-queue": "^8.1.0", "playwright": "^1.52.0", "prettier": "^3.5.3", From 8c657b57f723438f8ee60c9170d0b686c98d5391 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Mon, 30 Jun 2025 20:23:22 +0800 Subject: [PATCH 008/246] feat: add country flag emoji support and enhance UI components (#7646) * feat: add country flag emoji support and enhance UI components * Added country-flag-emoji-polyfill to package.json and yarn.lock * Integrated polyfill in AddAgentPopup, GeneralSettings, and AssistantPromptSettings components * Updated emoji rendering styles for better visual consistency * fix: update country flag emoji polyfill to use 'Twemoji Country Flags' * feat: enhance emoji components with country flag support * Integrated country-flag-emoji-polyfill in EmojiIcon, EmojiPicker, and AssistantItem components. * Updated font-family styles across various components for consistent emoji rendering. * Removed redundant polyfill calls from AddAgentPopup and AssistantPromptSettings. * refactor: streamline country flag emoji integration * Removed redundant polyfill calls from EmojiIcon, AssistantItem, and GeneralSettings components. * Updated EmojiPicker to use a local font file for country flag emojis. * Added country flag font import in index.scss for improved styling consistency. * format code * refactor: standardize country flag font usage across components * Introduced a new CSS class for country flag font to streamline styling. * Updated various components (GeneralSettings, EmojiIcon, EmojiAvatar, AssistantPromptSettings, TranslatePage) to utilize the new class for consistent font application. * Removed inline font-family styles to enhance maintainability. * refactor: update font styles for improved consistency and maintainability * Added Windows-specific font configuration in font.scss for better emoji rendering. * Removed inline font-family styles from various components (EmojiAvatar, GeneralSettings, AssistantPromptSettings, TranslatePage) to enhance code clarity and maintainability. * refactor: remove inline font-family styles from EmojiIcon for improved maintainability --- package.json | 1 + .../TwemojiCountryFlags.woff2 | Bin 0 -> 77476 bytes .../assets/fonts/country-flag-fonts/flag.css | 13 +++++++ src/renderer/src/assets/styles/font.scss | 32 +++++++++++------- src/renderer/src/assets/styles/index.scss | 1 + .../src/components/Avatar/EmojiAvatar.tsx | 1 + .../src/components/EmojiPicker/index.tsx | 6 ++++ .../AssistantPromptSettings.tsx | 10 +++++- yarn.lock | 8 +++++ 9 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 src/renderer/src/assets/fonts/country-flag-fonts/TwemojiCountryFlags.woff2 create mode 100644 src/renderer/src/assets/fonts/country-flag-fonts/flag.css diff --git a/package.json b/package.json index dd835ee9fe..360da4ae11 100644 --- a/package.json +++ b/package.json @@ -141,6 +141,7 @@ "axios": "^1.7.3", "browser-image-compression": "^2.0.2", "color": "^5.0.0", + "country-flag-emoji-polyfill": "0.1.8", "dayjs": "^1.11.11", "dexie": "^4.0.8", "dexie-react-hooks": "^1.1.7", diff --git a/src/renderer/src/assets/fonts/country-flag-fonts/TwemojiCountryFlags.woff2 b/src/renderer/src/assets/fonts/country-flag-fonts/TwemojiCountryFlags.woff2 new file mode 100644 index 0000000000000000000000000000000000000000..7f5bebba53e42cb9e1a7a55bb4a20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Lc6 zulhWF;hQif!ms{Y2c|7pZOtET11Y;@D*ut70CWld(!&aXlT?Wkqrsap*KkQu2B24G zT2>@?+*N5`IV~s79!b(ydk(IX1v(2+y*pm!OsADyoOFr>6>4rUlEz&hd#zkm{|c2% z1c+qAg|f)(Ws9NPQb7T08&HLp9yS1QQfKCx6E|y&=~E2jgKyIJ3e}eWbF39xH>LIEMZ^LYw=+e zfF|607(2~~fy3BeIg` height: ${(props) => props.$size}px; font-size: ${(props) => props.$fontSize}px; transition: opacity 0.3s ease; + &:hover { opacity: 0.8; } diff --git a/src/renderer/src/components/EmojiPicker/index.tsx b/src/renderer/src/components/EmojiPicker/index.tsx index eb8a90dbde..406d6d1865 100644 --- a/src/renderer/src/components/EmojiPicker/index.tsx +++ b/src/renderer/src/components/EmojiPicker/index.tsx @@ -1,4 +1,6 @@ +import TwemojiCountryFlagsWoff2 from '@renderer/assets/fonts/country-flag-fonts/TwemojiCountryFlags.woff2?url' import { useTheme } from '@renderer/context/ThemeProvider' +import { polyfillCountryFlagEmojis } from 'country-flag-emoji-polyfill' import { FC, useEffect, useRef } from 'react' interface Props { @@ -9,6 +11,10 @@ const EmojiPicker: FC = ({ onEmojiClick }) => { const { theme } = useTheme() const ref = useRef(null) + useEffect(() => { + polyfillCountryFlagEmojis('Twemoji Mozilla', TwemojiCountryFlagsWoff2) + }, []) + useEffect(() => { if (ref.current) { ref.current.addEventListener('emoji-click', (event: any) => { diff --git a/src/renderer/src/pages/settings/AssistantSettings/AssistantPromptSettings.tsx b/src/renderer/src/pages/settings/AssistantSettings/AssistantPromptSettings.tsx index 22ff2a7d62..a473c683ed 100644 --- a/src/renderer/src/pages/settings/AssistantSettings/AssistantPromptSettings.tsx +++ b/src/renderer/src/pages/settings/AssistantSettings/AssistantPromptSettings.tsx @@ -65,7 +65,15 @@ const AssistantPromptSettings: React.FC = ({ assistant, updateAssistant } } arrow trigger="click"> - + {emoji && ( Date: Mon, 30 Jun 2025 20:40:32 +0800 Subject: [PATCH 009/246] style(antd): Optimize antd components through patch method (#7683) * fix(dependencies): update antd to patch version 5.24.7 and apply custom patch * refactor(AddAgentPopup): remove unused ChevronDown import * feat(AntdProvider): add paddingXS to Dropdown component for improved layout --- .../patches/antd-npm-5.24.7-356a553ae5.patch | 69 +++++++++++++++++++ package.json | 2 +- src/renderer/src/assets/styles/index.scss | 2 +- src/renderer/src/context/AntdProvider.tsx | 3 +- .../pages/agents/components/AddAgentPopup.tsx | 2 - .../components/AddKnowledgePopup.tsx | 15 +--- .../components/KnowledgeSettingsPopup.tsx | 9 +-- .../AssistantKnowledgeBaseSettings.tsx | 3 +- .../AssistantModelSettings.tsx | 5 +- .../settings/ModelSettings/ModelSettings.tsx | 8 +-- .../ProviderSettings/ModelEditContent.tsx | 1 - .../CompressionSettings/CutoffSettings.tsx | 3 +- .../CompressionSettings/RagSettings.tsx | 4 +- .../CompressionSettings/index.tsx | 2 - .../src/pages/translate/TranslatePage.tsx | 7 +- yarn.lock | 64 ++++++++++++++++- 16 files changed, 145 insertions(+), 54 deletions(-) create mode 100644 .yarn/patches/antd-npm-5.24.7-356a553ae5.patch diff --git a/.yarn/patches/antd-npm-5.24.7-356a553ae5.patch b/.yarn/patches/antd-npm-5.24.7-356a553ae5.patch new file mode 100644 index 0000000000..d5f7a89edb --- /dev/null +++ b/.yarn/patches/antd-npm-5.24.7-356a553ae5.patch @@ -0,0 +1,69 @@ +diff --git a/es/dropdown/dropdown.js b/es/dropdown/dropdown.js +index 986877a762b9ad0aca596a8552732cd12d2eaabb..1f18aa2ea745e68950e4cee16d4d655f5c835fd5 100644 +--- a/es/dropdown/dropdown.js ++++ b/es/dropdown/dropdown.js +@@ -2,7 +2,7 @@ + + import * as React from 'react'; + import LeftOutlined from "@ant-design/icons/es/icons/LeftOutlined"; +-import RightOutlined from "@ant-design/icons/es/icons/RightOutlined"; ++import { ChevronRight } from 'lucide-react'; + import classNames from 'classnames'; + import RcDropdown from 'rc-dropdown'; + import useEvent from "rc-util/es/hooks/useEvent"; +@@ -158,8 +158,10 @@ const Dropdown = props => { + className: `${prefixCls}-menu-submenu-arrow` + }, direction === 'rtl' ? (/*#__PURE__*/React.createElement(LeftOutlined, { + className: `${prefixCls}-menu-submenu-arrow-icon` +- })) : (/*#__PURE__*/React.createElement(RightOutlined, { +- className: `${prefixCls}-menu-submenu-arrow-icon` ++ })) : (/*#__PURE__*/React.createElement(ChevronRight, { ++ size: 16, ++ strokeWidth: 1.8, ++ className: `${prefixCls}-menu-submenu-arrow-icon lucide-custom` + }))), + mode: "vertical", + selectable: false, +diff --git a/es/dropdown/style/index.js b/es/dropdown/style/index.js +index 768c01783002c6901c85a73061ff6b3e776a60ce..39b1b95a56cdc9fb586a193c3adad5141f5cf213 100644 +--- a/es/dropdown/style/index.js ++++ b/es/dropdown/style/index.js +@@ -240,7 +240,8 @@ const genBaseStyle = token => { + marginInlineEnd: '0 !important', + color: token.colorTextDescription, + fontSize: fontSizeIcon, +- fontStyle: 'normal' ++ fontStyle: 'normal', ++ marginTop: 3, + } + } + }), +diff --git a/es/select/useIcons.js b/es/select/useIcons.js +index 959115be936ef8901548af2658c5dcfdc5852723..c812edd52123eb0faf4638b1154fcfa1b05b513b 100644 +--- a/es/select/useIcons.js ++++ b/es/select/useIcons.js +@@ -4,10 +4,10 @@ import * as React from 'react'; + import CheckOutlined from "@ant-design/icons/es/icons/CheckOutlined"; + import CloseCircleFilled from "@ant-design/icons/es/icons/CloseCircleFilled"; + import CloseOutlined from "@ant-design/icons/es/icons/CloseOutlined"; +-import DownOutlined from "@ant-design/icons/es/icons/DownOutlined"; + import LoadingOutlined from "@ant-design/icons/es/icons/LoadingOutlined"; + import SearchOutlined from "@ant-design/icons/es/icons/SearchOutlined"; + import { devUseWarning } from '../_util/warning'; ++import { ChevronDown } from 'lucide-react'; + export default function useIcons(_ref) { + let { + suffixIcon, +@@ -56,8 +56,10 @@ export default function useIcons(_ref) { + className: iconCls + })); + } +- return getSuffixIconNode(/*#__PURE__*/React.createElement(DownOutlined, { +- className: iconCls ++ return getSuffixIconNode(/*#__PURE__*/React.createElement(ChevronDown, { ++ size: 16, ++ strokeWidth: 1.8, ++ className: `${iconCls} lucide-custom` + })); + }; + } diff --git a/package.json b/package.json index 360da4ae11..93b7ce697f 100644 --- a/package.json +++ b/package.json @@ -135,7 +135,7 @@ "@vitest/ui": "^3.1.4", "@vitest/web-worker": "^3.1.4", "@xyflow/react": "^12.4.4", - "antd": "^5.22.5", + "antd": "patch:antd@npm%3A5.24.7#~/.yarn/patches/antd-npm-5.24.7-356a553ae5.patch", "archiver": "^7.0.1", "async-mutex": "^0.5.0", "axios": "^1.7.3", diff --git a/src/renderer/src/assets/styles/index.scss b/src/renderer/src/assets/styles/index.scss index 62f7eae852..7507507888 100644 --- a/src/renderer/src/assets/styles/index.scss +++ b/src/renderer/src/assets/styles/index.scss @@ -170,7 +170,7 @@ ul { } } -.lucide { +.lucide:not(.lucide-custom) { color: var(--color-icon); } diff --git a/src/renderer/src/context/AntdProvider.tsx b/src/renderer/src/context/AntdProvider.tsx index 7d22fbb6a5..206f65e262 100644 --- a/src/renderer/src/context/AntdProvider.tsx +++ b/src/renderer/src/context/AntdProvider.tsx @@ -79,7 +79,8 @@ const AntdProvider: FC = ({ children }) => { Dropdown: { controlPaddingHorizontal: 8, borderRadiusLG: 10, - borderRadiusSM: 8 + borderRadiusSM: 8, + paddingXS: 4 }, Popover: { borderRadiusLG: 10 diff --git a/src/renderer/src/pages/agents/components/AddAgentPopup.tsx b/src/renderer/src/pages/agents/components/AddAgentPopup.tsx index 089ec16fa1..108052a701 100644 --- a/src/renderer/src/pages/agents/components/AddAgentPopup.tsx +++ b/src/renderer/src/pages/agents/components/AddAgentPopup.tsx @@ -14,7 +14,6 @@ import { Agent, KnowledgeBase } from '@renderer/types' import { getLeadingEmoji, uuid } from '@renderer/utils' import { Button, Form, FormInstance, Input, Modal, Popover, Select, SelectProps } from 'antd' import TextArea from 'antd/es/input/TextArea' -import { ChevronDown } from 'lucide-react' import { useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import stringWidth from 'string-width' @@ -213,7 +212,6 @@ const PopupContainer: React.FC = ({ resolve }) => { .toLowerCase() .includes(input.toLowerCase()) } - suffixIcon={} /> )} diff --git a/src/renderer/src/pages/knowledge/components/AddKnowledgePopup.tsx b/src/renderer/src/pages/knowledge/components/AddKnowledgePopup.tsx index 5ce1801243..128d63f07e 100644 --- a/src/renderer/src/pages/knowledge/components/AddKnowledgePopup.tsx +++ b/src/renderer/src/pages/knowledge/components/AddKnowledgePopup.tsx @@ -13,7 +13,6 @@ import { KnowledgeBase, Model } from '@renderer/types' import { getErrorMessage } from '@renderer/utils/error' import { Flex, Form, Input, InputNumber, Modal, Select, Slider, Switch } from 'antd' import { find, sortBy } from 'lodash' -import { ChevronDown } from 'lucide-react' import { nanoid } from 'nanoid' import { useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -183,12 +182,7 @@ const PopupContainer: React.FC = ({ title, resolve }) => { label={t('models.embedding_model')} tooltip={{ title: t('models.embedding_model_tooltip'), placement: 'right' }} rules={[{ required: true, message: t('message.error.enter.model') }]}> - = ({ title, resolve }) => { label={t('models.rerank_model')} tooltip={{ title: t('models.rerank_model_tooltip'), placement: 'right' }} rules={[{ required: false, message: t('message.error.enter.model') }]}> - {t('models.rerank_model_not_support_provider', { diff --git a/src/renderer/src/pages/knowledge/components/KnowledgeSettingsPopup.tsx b/src/renderer/src/pages/knowledge/components/KnowledgeSettingsPopup.tsx index 625ca2c90f..6b44684d5a 100644 --- a/src/renderer/src/pages/knowledge/components/KnowledgeSettingsPopup.tsx +++ b/src/renderer/src/pages/knowledge/components/KnowledgeSettingsPopup.tsx @@ -140,13 +140,7 @@ const PopupContainer: React.FC = ({ base: _base, resolve }) => { initialValue={getModelUniqId(base.model)} tooltip={{ title: t('models.embedding_model_tooltip'), placement: 'right' }} rules={[{ required: true, message: t('message.error.enter.model') }]}> - = ({ base: _base, resolve }) => { options={rerankSelectOptions} placeholder={t('settings.models.empty')} allowClear - suffixIcon={} /> diff --git a/src/renderer/src/pages/settings/AssistantSettings/AssistantKnowledgeBaseSettings.tsx b/src/renderer/src/pages/settings/AssistantSettings/AssistantKnowledgeBaseSettings.tsx index a593f41cbe..169ed3ffd5 100644 --- a/src/renderer/src/pages/settings/AssistantSettings/AssistantKnowledgeBaseSettings.tsx +++ b/src/renderer/src/pages/settings/AssistantSettings/AssistantKnowledgeBaseSettings.tsx @@ -3,7 +3,7 @@ import { Box } from '@renderer/components/Layout' import { useAppSelector } from '@renderer/store' import { Assistant, AssistantSettings } from '@renderer/types' import { Row, Segmented, Select, SelectProps, Tooltip } from 'antd' -import { ChevronDown, CircleHelp } from 'lucide-react' +import { CircleHelp } from 'lucide-react' import { useTranslation } from 'react-i18next' import styled from 'styled-components' @@ -46,7 +46,6 @@ const AssistantKnowledgeBaseSettings: React.FC = ({ assistant, updateAssi .toLowerCase() .includes(input.toLowerCase()) } - suffixIcon={} /> diff --git a/src/renderer/src/pages/settings/AssistantSettings/AssistantModelSettings.tsx b/src/renderer/src/pages/settings/AssistantSettings/AssistantModelSettings.tsx index 31e44abfbb..7017b02890 100644 --- a/src/renderer/src/pages/settings/AssistantSettings/AssistantModelSettings.tsx +++ b/src/renderer/src/pages/settings/AssistantSettings/AssistantModelSettings.tsx @@ -10,7 +10,6 @@ import { Assistant, AssistantSettingCustomParameters, AssistantSettings } from ' import { modalConfirm } from '@renderer/utils' import { Button, Col, Divider, Input, InputNumber, Row, Select, Slider, Switch, Tooltip } from 'antd' import { isNull } from 'lodash' -import { ChevronDown } from 'lucide-react' import { FC, useCallback, useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import styled from 'styled-components' @@ -118,7 +117,6 @@ const AssistantModelSettings: FC = ({ assistant, updateAssistant, updateA { label: 'true', value: true }, { label: 'false', value: false } ]} - suffixIcon={} /> ) case 'json': @@ -437,8 +435,7 @@ const AssistantModelSettings: FC = ({ assistant, updateAssistant, updateA ) }))} - suffixIcon={} /> )} @@ -455,7 +452,6 @@ const TranslatePage: FC = () => { ) }))} - suffixIcon={} /> ) } @@ -555,7 +551,6 @@ const TranslatePage: FC = () => { ) })) ]} - suffixIcon={} /> - - - - ) -} - -const Container = styled.div` - margin: 10px; - display: flex; - flex-direction: row; - gap: 8px; - padding-bottom: 10px; -` - -export default Artifacts diff --git a/src/renderer/src/components/CodeBlockView/HtmlArtifactsCard.tsx b/src/renderer/src/components/CodeBlockView/HtmlArtifactsCard.tsx new file mode 100644 index 0000000000..0691a25d18 --- /dev/null +++ b/src/renderer/src/components/CodeBlockView/HtmlArtifactsCard.tsx @@ -0,0 +1,408 @@ +import { CodeOutlined, LinkOutlined } from '@ant-design/icons' +import { useTheme } from '@renderer/context/ThemeProvider' +import { ThemeMode } from '@renderer/types' +import { extractTitle } from '@renderer/utils/formats' +import { Button } from 'antd' +import { Code, Download, Globe, Sparkles } from 'lucide-react' +import { FC, useMemo, useState } from 'react' +import { useTranslation } from 'react-i18next' +import { ClipLoader } from 'react-spinners' +import styled, { keyframes } from 'styled-components' + +import HtmlArtifactsPopup from './HtmlArtifactsPopup' + +interface Props { + html: string +} + +const HtmlArtifactsCard: FC = ({ html }) => { + const { t } = useTranslation() + const title = extractTitle(html) || 'HTML Artifacts' + const [isPopupOpen, setIsPopupOpen] = useState(false) + const { theme } = useTheme() + + const htmlContent = html || '' + const hasContent = htmlContent.trim().length > 0 + + // 判断是否正在流式生成的逻辑 + const isStreaming = useMemo(() => { + if (!hasContent) return false + + const trimmedHtml = htmlContent.trim() + + // 检查 HTML 是否看起来是完整的 + const indicators = { + // 1. 检查常见的 HTML 结构完整性 + hasHtmlTag: /]*>/i.test(trimmedHtml), + hasClosingHtmlTag: /<\/html\s*>$/i.test(trimmedHtml), + + // 2. 检查 body 标签完整性 + hasBodyTag: /]*>/i.test(trimmedHtml), + hasClosingBodyTag: /<\/body\s*>/i.test(trimmedHtml), + + // 3. 检查是否以未闭合的标签结尾 + endsWithIncompleteTag: /<[^>]*$/.test(trimmedHtml), + + // 4. 检查是否有未配对的标签 + hasUnmatchedTags: checkUnmatchedTags(trimmedHtml), + + // 5. 检查是否以常见的"流式结束"模式结尾 + endsWithTypicalCompletion: /(<\/html>\s*|<\/body>\s*|<\/div>\s*|<\/script>\s*|<\/style>\s*)$/i.test(trimmedHtml) + } + + // 如果有明显的未完成标志,则认为正在生成 + if (indicators.endsWithIncompleteTag || indicators.hasUnmatchedTags) { + return true + } + + // 如果有 HTML 结构但不完整 + if (indicators.hasHtmlTag && !indicators.hasClosingHtmlTag) { + return true + } + + // 如果有 body 结构但不完整 + if (indicators.hasBodyTag && !indicators.hasClosingBodyTag) { + return true + } + + // 对于简单的 HTML 片段,检查是否看起来是完整的 + if (!indicators.hasHtmlTag && !indicators.hasBodyTag) { + // 如果是简单片段且没有明显的结束标志,可能还在生成 + return !indicators.endsWithTypicalCompletion && trimmedHtml.length < 500 + } + + return false + }, [htmlContent, hasContent]) + + // 检查未配对标签的辅助函数 + function checkUnmatchedTags(html: string): boolean { + const stack: string[] = [] + const tagRegex = /<\/?([a-zA-Z][a-zA-Z0-9]*)[^>]*>/g + let match + + while ((match = tagRegex.exec(html)) !== null) { + const [fullTag, tagName] = match + const isClosing = fullTag.startsWith('') || ['img', 'br', 'hr', 'input', 'meta', 'link'].includes(tagName.toLowerCase()) + + if (isSelfClosing) continue + + if (isClosing) { + if (stack.length === 0 || stack.pop() !== tagName.toLowerCase()) { + return true // 找到不匹配的闭合标签 + } + } else { + stack.push(tagName.toLowerCase()) + } + } + + return stack.length > 0 // 还有未闭合的标签 + } + + // 获取格式化的代码预览 + function getFormattedCodePreview(html: string): string { + const trimmed = html.trim() + const lines = trimmed.split('\n') + const lastFewLines = lines.slice(-3) // 显示最后3行 + return lastFewLines.join('\n') + } + + /** + * 在编辑器中打开 + */ + const handleOpenInEditor = () => { + setIsPopupOpen(true) + } + + /** + * 关闭弹窗 + */ + const handleClosePopup = () => { + setIsPopupOpen(false) + } + + /** + * 外部链接打开 + */ + const handleOpenExternal = async () => { + const path = await window.api.file.createTempFile('artifacts-preview.html') + await window.api.file.write(path, htmlContent) + const filePath = `file://${path}` + + if (window.api.shell && window.api.shell.openExternal) { + window.api.shell.openExternal(filePath) + } else { + console.error(t('artifacts.preview.openExternal.error.content')) + } + } + + /** + * 下载到本地 + */ + const handleDownload = async () => { + const fileName = `${title.replace(/[^a-zA-Z0-9\s]/g, '').replace(/\s+/g, '-') || 'html-artifact'}.html` + await window.api.file.save(fileName, htmlContent) + window.message.success({ content: t('message.download.success'), key: 'download' }) + } + + return ( + <> + +
+ + {isStreaming ? : } + + + {title} + + + HTML + + + {isStreaming && ( + + + {t('html_artifacts.generating')} + + )} +
+ + {isStreaming && !hasContent ? ( + + + {t('html_artifacts.generating_content', 'Generating content...')} + + ) : isStreaming && hasContent ? ( + <> + + + + $ + + {getFormattedCodePreview(htmlContent)} + + + + + + + + + + ) : ( + + + + + + )} + +
+ + {/* 弹窗组件 */} + + + ) +} + +const shimmer = keyframes` + 0% { + background-position: -200px 0; + } + 100% { + background-position: calc(200px + 100%) 0; + } +` + +const Container = styled.div<{ $isStreaming: boolean }>` + background: var(--color-background); + border: 1px solid var(--color-border); + border-radius: 8px; + overflow: hidden; + margin: 16px 0; +` + +const GeneratingContainer = styled.div` + display: flex; + justify-content: center; + align-items: center; + gap: 8px; + padding: 20px; + min-height: 78px; +` + +const GeneratingText = styled.div` + font-size: 14px; + color: var(--color-text-secondary); +` + +const Header = styled.div` + display: flex; + align-items: center; + gap: 12px; + padding: 20px 24px 16px; + background: var(--color-background-soft); + border-bottom: 1px solid var(--color-border); + position: relative; + border-radius: 8px 8px 0 0; + + &::before { + content: ''; + position: absolute; + top: 0; + left: 0; + right: 0; + height: 3px; + background: linear-gradient(90deg, #3b82f6, #8b5cf6, #06b6d4); + background-size: 200% 100%; + animation: ${shimmer} 3s ease-in-out infinite; + border-radius: 8px 8px 0 0; + } +` + +const IconWrapper = styled.div<{ $isStreaming: boolean }>` + display: flex; + align-items: center; + justify-content: center; + width: 40px; + height: 40px; + background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); + border-radius: 12px; + color: white; + box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3); + transition: background 0.3s ease; + + ${(props) => + props.$isStreaming && + ` + background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); /* Darker orange for loading */ + box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.3); + `} +` + +const TitleSection = styled.div` + flex: 1; + display: flex; + flex-direction: column; + gap: 6px; +` + +const Title = styled.h3` + margin: 0 !important; + font-size: 16px; + font-weight: 600; + color: var(--color-text); + line-height: 1.4; +` + +const TypeBadge = styled.div` + display: inline-flex; + align-items: center; + gap: 4px; + padding: 4px 8px; + background: var(--color-background-mute); + border: 1px solid var(--color-border); + border-radius: 6px; + font-size: 11px; + font-weight: 500; + color: var(--color-text-secondary); + width: fit-content; +` + +const StreamingIndicator = styled.div` + display: flex; + align-items: center; + gap: 8px; + padding: 8px 12px; + background: var(--color-status-warning); + border: 1px solid var(--color-status-warning); + border-radius: 8px; + color: var(--color-text); + font-size: 12px; + opacity: 0.9; + + [theme-mode='light'] & { + background: #fef3c7; + border-color: #fbbf24; + color: #92400e; + } +` + +const StreamingText = styled.div` + display: flex; + align-items: center; + gap: 4px; + font-weight: 500; +` + +const Content = styled.div` + padding: 0; + background: var(--color-background); +` + +const ButtonContainer = styled.div` + margin: 16px; + display: flex; + flex-direction: row; + gap: 8px; +` + +const TerminalPreview = styled.div<{ $theme: ThemeMode }>` + margin: 16px; + background: ${(props) => (props.$theme === 'dark' ? '#1e1e1e' : '#f0f0f0')}; + border-radius: 8px; + overflow: hidden; + font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace; +` + +const TerminalContent = styled.div<{ $theme: ThemeMode }>` + padding: 12px; + background: ${(props) => (props.$theme === 'dark' ? '#1e1e1e' : '#f0f0f0')}; + color: ${(props) => (props.$theme === 'dark' ? '#cccccc' : '#333333')}; + font-size: 13px; + line-height: 1.4; + min-height: 80px; +` + +const TerminalLine = styled.div` + display: flex; + align-items: flex-start; + gap: 8px; +` + +const TerminalCodeLine = styled.span<{ $theme: ThemeMode }>` + flex: 1; + white-space: pre-wrap; + word-break: break-word; + color: ${(props) => (props.$theme === 'dark' ? '#cccccc' : '#333333')}; + background-color: transparent !important; +` + +const TerminalPrompt = styled.span<{ $theme: ThemeMode }>` + color: ${(props) => (props.$theme === 'dark' ? '#00ff00' : '#007700')}; + font-weight: bold; + flex-shrink: 0; +` + +const TerminalCursor = styled.span<{ $theme: ThemeMode }>` + display: inline-block; + width: 2px; + height: 16px; + background: ${(props) => (props.$theme === 'dark' ? '#00ff00' : '#007700')}; + animation: ${keyframes` + 0%, 50% { opacity: 1; } + 51%, 100% { opacity: 0; } + `} 1s infinite; + margin-left: 2px; +` + +export default HtmlArtifactsCard diff --git a/src/renderer/src/components/CodeBlockView/HtmlArtifactsPopup.tsx b/src/renderer/src/components/CodeBlockView/HtmlArtifactsPopup.tsx new file mode 100644 index 0000000000..afba9f04e1 --- /dev/null +++ b/src/renderer/src/components/CodeBlockView/HtmlArtifactsPopup.tsx @@ -0,0 +1,445 @@ +import CodeEditor from '@renderer/components/CodeEditor' +import { isMac } from '@renderer/config/constant' +import { Button, Modal } from 'antd' +import { Code, Maximize2, Minimize2, Monitor, MonitorSpeaker, X } from 'lucide-react' +import { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { useTranslation } from 'react-i18next' +import styled from 'styled-components' + +interface HtmlArtifactsPopupProps { + open: boolean + title: string + html: string + onClose: () => void +} + +type ViewMode = 'split' | 'code' | 'preview' + +// 视图模式配置 +const VIEW_MODE_CONFIG = { + split: { + key: 'split' as const, + icon: MonitorSpeaker, + i18nKey: 'html_artifacts.split' + }, + code: { + key: 'code' as const, + icon: Code, + i18nKey: 'html_artifacts.code' + }, + preview: { + key: 'preview' as const, + icon: Monitor, + i18nKey: 'html_artifacts.preview' + } +} as const + +// 抽取头部组件 +interface ModalHeaderProps { + title: string + isFullscreen: boolean + viewMode: ViewMode + onViewModeChange: (mode: ViewMode) => void + onToggleFullscreen: () => void + onCancel: () => void +} + +const ModalHeaderComponent: React.FC = ({ + title, + isFullscreen, + viewMode, + onViewModeChange, + onToggleFullscreen, + onCancel +}) => { + const { t } = useTranslation() + + const viewButtons = useMemo(() => { + return Object.values(VIEW_MODE_CONFIG).map(({ key, icon: Icon, i18nKey }) => ( + } + onClick={() => onViewModeChange(key)}> + {t(i18nKey)} + + )) + }, [viewMode, onViewModeChange, t]) + + return ( + + + {title} + + + {viewButtons} + + + - - -
diff --git a/src/renderer/src/pages/settings/MCPSettings/NpxSearch.tsx b/src/renderer/src/pages/settings/MCPSettings/NpxSearch.tsx index 54fa3201a9..0b6a001b8a 100644 --- a/src/renderer/src/pages/settings/MCPSettings/NpxSearch.tsx +++ b/src/renderer/src/pages/settings/MCPSettings/NpxSearch.tsx @@ -3,7 +3,6 @@ import { nanoid } from '@reduxjs/toolkit' import logo from '@renderer/assets/images/cherry-text-logo.svg' import { Center, HStack } from '@renderer/components/Layout' import { useMCPServers } from '@renderer/hooks/useMCPServers' -import { builtinMCPServers } from '@renderer/store/mcp' import { MCPServer } from '@renderer/types' import { getMcpConfigSampleFromReadme } from '@renderer/utils' import { Button, Card, Flex, Input, Space, Spin, Tag, Typography } from 'antd' @@ -23,7 +22,7 @@ interface SearchResult { configSample?: MCPServer['configSample'] } -const npmScopes = ['@cherry', '@modelcontextprotocol', '@gongrzhe', '@mcpmarket'] +const npmScopes = ['@modelcontextprotocol', '@gongrzhe', '@mcpmarket'] let _searchResults: SearchResult[] = [] @@ -32,7 +31,7 @@ const NpxSearch: FC = () => { const { Text, Link } = Typography // Add new state variables for npm scope search - const [npmScope, setNpmScope] = useState('@cherry') + const [npmScope, setNpmScope] = useState('@modelcontextprotocol') const [searchLoading, setSearchLoading] = useState(false) const [searchResults, setSearchResults] = useState(_searchResults) const { addMCPServer, mcpServers } = useMCPServers() @@ -52,22 +51,6 @@ const NpxSearch: FC = () => { return } - if (searchScope === '@cherry') { - setSearchResults( - builtinMCPServers.map((server) => ({ - key: server.id, - name: server.name, - description: server.description || '', - version: '1.0.0', - usage: '参考下方链接中的使用说明', - npmLink: 'https://docs.cherry-ai.com/advanced-basic/mcp/in-memory', - fullName: server.name, - type: server.type || 'inMemory' - })) - ) - return - } - setSearchLoading(true) try { @@ -190,14 +173,6 @@ const NpxSearch: FC = () => { return } - const buildInServer = builtinMCPServers.find((server) => server.name === record.name) - - if (buildInServer) { - addMCPServer(buildInServer) - window.message.success({ content: t('settings.mcp.addSuccess'), key: 'mcp-add-server' }) - return - } - const newServer = { id: nanoid(), name: record.name, diff --git a/src/renderer/src/pages/settings/SettingsPage.tsx b/src/renderer/src/pages/settings/SettingsPage.tsx index 9a37ceb263..59abda1ec4 100644 --- a/src/renderer/src/pages/settings/SettingsPage.tsx +++ b/src/renderer/src/pages/settings/SettingsPage.tsx @@ -71,18 +71,18 @@ const SettingsPage: FC = () => { {t('settings.display.title')} - - - - {t('settings.tool.title')} - - {t('settings.mcp.title')} + + + + {t('settings.tool.title')} + + From 97dbfe492ea9216d29a4f3709c5ccee134db5147 Mon Sep 17 00:00:00 2001 From: Jason Young <44939412+farion1231@users.noreply.github.com> Date: Thu, 10 Jul 2025 14:35:40 +0800 Subject: [PATCH 136/246] test: enhance download and fetch utility test coverage with bug fix (#7891) * test: enhance download and fetch utility test coverage - Add MIME type handling tests for data URLs in download.test.ts - Add timestamp generation tests for blob and network downloads - Add Content-Type header handling test for extensionless files - Add format parameter tests (markdown/html/text) for fetchWebContent - Add timeout signal handling tests for fetch operations - Add combined signal (user + timeout) test for AbortSignal.any These tests improve coverage of edge cases and ensure critical functionality is properly tested. * fix: add missing error handling for fetch in download utility - Add .catch() handler for network request failures in download() - Use window.message.error() for user-friendly error notifications - Update tests to verify error handling behavior - Ensure proper error messages are shown to users This fixes a missing error handler that was discovered during test development. * refactor: improve test structure and add i18n support for download utility - Unified test structure with two-layer describe blocks (filename -> function name) - Added afterEach with restoreAllMocks for consistent mock cleanup - Removed individual mockRestore calls in favor of centralized cleanup - Added i18n support to download.ts for error messages - Updated error handling logic to avoid duplicate messages - Updated test expectations to match new i18n error messages * test: fix react-i18next mock for Markdown test Add missing initReactI18next to mock to resolve test failures caused by i18n initialization when download utility imports i18n module. --- .../home/Markdown/__tests__/Markdown.test.tsx | 6 +- .../src/utils/__tests__/download.test.ts | 241 ++++++++++++++++++ .../src/utils/__tests__/fetch.test.ts | 208 +++++++++++++++ src/renderer/src/utils/download.ts | 11 + 4 files changed, 465 insertions(+), 1 deletion(-) create mode 100644 src/renderer/src/utils/__tests__/download.test.ts create mode 100644 src/renderer/src/utils/__tests__/fetch.test.ts diff --git a/src/renderer/src/pages/home/Markdown/__tests__/Markdown.test.tsx b/src/renderer/src/pages/home/Markdown/__tests__/Markdown.test.tsx index be9b18c13b..6adb5f5736 100644 --- a/src/renderer/src/pages/home/Markdown/__tests__/Markdown.test.tsx +++ b/src/renderer/src/pages/home/Markdown/__tests__/Markdown.test.tsx @@ -17,7 +17,11 @@ vi.mock('@renderer/hooks/useSettings', () => ({ })) vi.mock('react-i18next', () => ({ - useTranslation: () => mockUseTranslation() + useTranslation: () => mockUseTranslation(), + initReactI18next: { + type: '3rdParty', + init: vi.fn() + } })) // Mock services diff --git a/src/renderer/src/utils/__tests__/download.test.ts b/src/renderer/src/utils/__tests__/download.test.ts new file mode 100644 index 0000000000..3a49ccf4fb --- /dev/null +++ b/src/renderer/src/utils/__tests__/download.test.ts @@ -0,0 +1,241 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' + +// Mock @renderer/i18n to avoid initialization issues +vi.mock('@renderer/i18n', () => ({ + default: { + t: vi.fn((key: string) => { + const translations: Record = { + 'message.download.failed': '下载失败', + 'message.download.failed.network': '下载失败,请检查网络' + } + return translations[key] || key + }) + } +})) + +import { download } from '../download' + +// Mock DOM 方法 +const mockCreateElement = vi.fn() +const mockAppendChild = vi.fn() +const mockClick = vi.fn() + +// Mock URL API +const mockCreateObjectURL = vi.fn() +const mockRevokeObjectURL = vi.fn() + +// Mock fetch +const mockFetch = vi.fn() + +// Mock window.message +const mockMessage = { + error: vi.fn(), + success: vi.fn(), + warning: vi.fn(), + info: vi.fn() +} + +// 辅助函数 +const waitForAsync = () => new Promise((resolve) => setTimeout(resolve, 10)) +const createMockResponse = (options = {}) => ({ + ok: true, + headers: new Headers(), + blob: () => Promise.resolve(new Blob(['test'])), + ...options +}) + +describe('download', () => { + describe('download', () => { + beforeEach(() => { + vi.clearAllMocks() + + // 设置 window.message mock + Object.defineProperty(window, 'message', { value: mockMessage, writable: true }) + + // 设置 DOM mock + const mockElement = { + href: '', + download: '', + click: mockClick, + remove: vi.fn() + } + mockCreateElement.mockReturnValue(mockElement) + + Object.defineProperty(document, 'createElement', { value: mockCreateElement }) + Object.defineProperty(document.body, 'appendChild', { value: mockAppendChild }) + Object.defineProperty(URL, 'createObjectURL', { value: mockCreateObjectURL }) + Object.defineProperty(URL, 'revokeObjectURL', { value: mockRevokeObjectURL }) + + global.fetch = mockFetch + mockCreateObjectURL.mockReturnValue('blob:mock-url') + }) + + afterEach(() => { + vi.restoreAllMocks() + }) + + describe('Direct download support', () => { + it('should handle local file URLs', () => { + download('file:///path/to/document.pdf', 'test.pdf') + + const element = mockCreateElement.mock.results[0].value + expect(element.href).toBe('file:///path/to/document.pdf') + expect(element.download).toBe('test.pdf') + expect(mockClick).toHaveBeenCalled() + }) + + it('should handle blob URLs', () => { + download('blob:http://localhost:3000/12345') + + const element = mockCreateElement.mock.results[0].value + expect(element.href).toBe('blob:http://localhost:3000/12345') + expect(mockClick).toHaveBeenCalled() + }) + + it('should handle data URLs', () => { + const dataUrl = + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==' + + download(dataUrl) + + const element = mockCreateElement.mock.results[0].value + expect(element.href).toBe(dataUrl) + expect(mockClick).toHaveBeenCalled() + }) + + it('should handle different MIME types in data URLs', async () => { + const now = Date.now() + vi.spyOn(Date, 'now').mockReturnValue(now) + + // 只有 image/png 和 image/jpeg 会直接下载 + const directDownloadTests = [ + { url: 'data:image/jpeg;base64,xxx', expectedExt: '.jpg' }, + { url: 'data:image/png;base64,xxx', expectedExt: '.png' } + ] + + directDownloadTests.forEach(({ url, expectedExt }) => { + mockCreateElement.mockClear() + download(url) + const element = mockCreateElement.mock.results[0].value + expect(element.download).toBe(`${now}_download${expectedExt}`) + }) + + // 其他类型会通过 fetch 处理 + mockCreateElement.mockClear() + mockFetch.mockResolvedValueOnce( + createMockResponse({ + headers: new Headers({ 'Content-Type': 'application/pdf' }) + }) + ) + + download('data:application/pdf;base64,xxx') + await waitForAsync() + + expect(mockFetch).toHaveBeenCalled() + }) + + it('should generate filename with timestamp for blob URLs', () => { + const now = Date.now() + vi.spyOn(Date, 'now').mockReturnValue(now) + + download('blob:http://localhost:3000/12345') + + const element = mockCreateElement.mock.results[0].value + expect(element.download).toBe(`${now}_diagram.svg`) + }) + }) + + describe('Filename handling', () => { + it('should extract filename from file path', () => { + download('file:///Users/test/Documents/report.pdf') + + const element = mockCreateElement.mock.results[0].value + expect(element.download).toBe('report.pdf') + }) + + it('should handle URL encoded filenames', () => { + download('file:///path/to/%E6%96%87%E6%A1%A3.pdf') // 编码的"文档.pdf" + + const element = mockCreateElement.mock.results[0].value + expect(element.download).toBe('文档.pdf') + }) + }) + + describe('Network download', () => { + it('should handle successful network request', async () => { + mockFetch.mockResolvedValue(createMockResponse()) + + download('https://example.com/file.pdf', 'custom.pdf') + await waitForAsync() + + expect(mockFetch).toHaveBeenCalledWith('https://example.com/file.pdf') + expect(mockCreateObjectURL).toHaveBeenCalledWith(expect.any(Blob)) + expect(mockClick).toHaveBeenCalled() + }) + + it('should extract filename from URL and headers', async () => { + const headers = new Headers() + headers.set('Content-Disposition', 'attachment; filename="server-file.pdf"') + mockFetch.mockResolvedValue(createMockResponse({ headers })) + + download('https://example.com/files/document.docx') + await waitForAsync() + + // 验证下载被触发(具体文件名由实现决定) + expect(mockClick).toHaveBeenCalled() + }) + + it('should add timestamp to network downloaded files', async () => { + const now = Date.now() + vi.spyOn(Date, 'now').mockReturnValue(now) + + mockFetch.mockResolvedValue(createMockResponse()) + + download('https://example.com/file.pdf') + await waitForAsync() + + const element = mockCreateElement.mock.results[0].value + expect(element.download).toBe(`${now}_file.pdf`) + }) + + it('should handle Content-Type when filename has no extension', async () => { + const headers = new Headers() + headers.set('Content-Type', 'application/pdf') + mockFetch.mockResolvedValue(createMockResponse({ headers })) + + download('https://example.com/download') + await waitForAsync() + + const element = mockCreateElement.mock.results[0].value + expect(element.download).toMatch(/\d+_download\.pdf$/) + }) + }) + + describe('Error handling', () => { + it('should handle network errors gracefully', async () => { + const networkError = new Error('Network error') + mockFetch.mockRejectedValue(networkError) + + expect(() => download('https://example.com/file.pdf')).not.toThrow() + await waitForAsync() + + expect(mockMessage.error).toHaveBeenCalledWith('下载失败:Network error') + }) + + it('should handle fetch errors without message', async () => { + mockFetch.mockRejectedValue(new Error()) + + expect(() => download('https://example.com/file.pdf')).not.toThrow() + await waitForAsync() + + expect(mockMessage.error).toHaveBeenCalledWith('下载失败,请检查网络') + }) + + it('should handle HTTP errors gracefully', async () => { + mockFetch.mockResolvedValue({ ok: false, status: 404 }) + + expect(() => download('https://example.com/file.pdf')).not.toThrow() + }) + }) + }) +}) diff --git a/src/renderer/src/utils/__tests__/fetch.test.ts b/src/renderer/src/utils/__tests__/fetch.test.ts new file mode 100644 index 0000000000..6b36cb41f8 --- /dev/null +++ b/src/renderer/src/utils/__tests__/fetch.test.ts @@ -0,0 +1,208 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest' + +// Mock 外部依赖 +vi.mock('turndown', () => ({ + default: vi.fn(() => ({ + turndown: vi.fn(() => '# Test content') + })) +})) +vi.mock('@mozilla/readability', () => ({ + Readability: vi.fn(() => ({ + parse: vi.fn(() => ({ + title: 'Test Article', + content: '

Test content

', + textContent: 'Test content' + })) + })) +})) +vi.mock('@reduxjs/toolkit', () => ({ + nanoid: vi.fn(() => 'test-id') +})) + +import { fetchRedirectUrl, fetchWebContent, fetchWebContents } from '../fetch' + +// 设置基础 mocks +global.DOMParser = vi.fn().mockImplementation(() => ({ + parseFromString: vi.fn(() => ({})) +})) as any + +global.window = { + api: { + searchService: { + openUrlInSearchWindow: vi.fn() + } + } +} as any + +// 辅助函数 +const createMockResponse = (overrides = {}) => + ({ + ok: true, + status: 200, + text: vi.fn().mockResolvedValue('Test content'), + ...overrides + }) as unknown as Response + +describe('fetch', () => { + beforeEach(() => { + // Mock fetch 和 AbortSignal + global.fetch = vi.fn() + global.AbortSignal = { + timeout: vi.fn(() => ({})), + any: vi.fn(() => ({})) + } as any + + // 清理 mock 调用历史 + vi.clearAllMocks() + }) + + describe('fetchWebContent', () => { + it('should fetch and return content successfully', async () => { + vi.mocked(global.fetch).mockResolvedValueOnce(createMockResponse()) + + const result = await fetchWebContent('https://example.com') + + expect(result).toEqual({ + title: 'Test Article', + url: 'https://example.com', + content: '# Test content' + }) + expect(global.fetch).toHaveBeenCalledWith('https://example.com', expect.any(Object)) + }) + + it('should use browser mode when specified', async () => { + vi.mocked(window.api.searchService.openUrlInSearchWindow).mockResolvedValueOnce( + 'Browser content' + ) + + const result = await fetchWebContent('https://example.com', 'markdown', true) + + expect(result.content).toBe('# Test content') + expect(window.api.searchService.openUrlInSearchWindow).toHaveBeenCalled() + }) + + it('should handle errors gracefully', async () => { + const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {}) + + // 无效 URL + const invalidResult = await fetchWebContent('not-a-url') + expect(invalidResult.content).toBe('No content found') + + // 网络错误 + vi.mocked(global.fetch).mockRejectedValueOnce(new Error('Network error')) + const networkResult = await fetchWebContent('https://example.com') + expect(networkResult.content).toBe('No content found') + + consoleSpy.mockRestore() + }) + + it('should rethrow abort errors', async () => { + const abortError = new DOMException('Aborted', 'AbortError') + vi.mocked(global.fetch).mockRejectedValueOnce(abortError) + + await expect(fetchWebContent('https://example.com')).rejects.toThrow(DOMException) + }) + + it.each([ + ['markdown', '# Test content'], + ['html', '

Test content

'], + ['text', 'Test content'] + ])('should return %s format correctly', async (format, expectedContent) => { + vi.mocked(global.fetch).mockResolvedValueOnce(createMockResponse()) + + const result = await fetchWebContent('https://example.com', format as any) + + expect(result.content).toBe(expectedContent) + expect(result.title).toBe('Test Article') + expect(result.url).toBe('https://example.com') + }) + + it('should handle timeout signal in AbortSignal.any', async () => { + const mockTimeoutSignal = new AbortController().signal + vi.spyOn(global.AbortSignal, 'timeout').mockReturnValue(mockTimeoutSignal) + + vi.mocked(global.fetch).mockResolvedValueOnce(createMockResponse()) + + await fetchWebContent('https://example.com') + + // 验证 AbortSignal.timeout 是否被调用,并传入 30000ms + expect(global.AbortSignal.timeout).toHaveBeenCalledWith(30000) + + vi.spyOn(global.AbortSignal, 'timeout').mockRestore() + }) + + it('should combine user signal with timeout signal', async () => { + const userController = new AbortController() + const mockAnyCalls: any[] = [] + + vi.spyOn(global.AbortSignal, 'any').mockImplementation((signals) => { + mockAnyCalls.push(signals) + return new AbortController().signal + }) + + vi.mocked(global.fetch).mockResolvedValueOnce(createMockResponse()) + + await fetchWebContent('https://example.com', 'markdown', false, { + signal: userController.signal + }) + + // 验证 AbortSignal.any 是否被调用,并传入两个信号 + expect(mockAnyCalls).toHaveLength(1) + expect(mockAnyCalls[0]).toHaveLength(2) + expect(mockAnyCalls[0]).toContain(userController.signal) + + vi.spyOn(global.AbortSignal, 'any').mockRestore() + }) + }) + + describe('fetchWebContents', () => { + it('should fetch multiple URLs in parallel', async () => { + vi.mocked(global.fetch).mockResolvedValueOnce(createMockResponse()).mockResolvedValueOnce(createMockResponse()) + + const urls = ['https://example1.com', 'https://example2.com'] + const results = await fetchWebContents(urls) + + expect(results).toHaveLength(2) + expect(results[0].content).toBe('# Test content') + expect(results[1].content).toBe('# Test content') + }) + + it('should handle partial failures gracefully', async () => { + vi.mocked(global.fetch) + .mockResolvedValueOnce(createMockResponse()) + .mockRejectedValueOnce(new Error('Network error')) + + const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {}) + const results = await fetchWebContents(['https://success.com', 'https://fail.com']) + + expect(results).toHaveLength(2) + expect(results[0].content).toBe('# Test content') + expect(results[1].content).toBe('No content found') + + consoleSpy.mockRestore() + }) + }) + + describe('fetchRedirectUrl', () => { + it('should return final redirect URL', async () => { + vi.mocked(global.fetch).mockResolvedValueOnce({ + url: 'https://redirected.com/final' + } as any) + + const result = await fetchRedirectUrl('https://example.com') + + expect(result).toBe('https://redirected.com/final') + expect(global.fetch).toHaveBeenCalledWith('https://example.com', expect.any(Object)) + }) + + it('should return original URL on error', async () => { + vi.mocked(global.fetch).mockRejectedValueOnce(new Error('Network error')) + const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {}) + + const result = await fetchRedirectUrl('https://example.com') + expect(result).toBe('https://example.com') + + consoleSpy.mockRestore() + }) + }) +}) diff --git a/src/renderer/src/utils/download.ts b/src/renderer/src/utils/download.ts index 5e207eff67..454c1ac82a 100644 --- a/src/renderer/src/utils/download.ts +++ b/src/renderer/src/utils/download.ts @@ -1,3 +1,5 @@ +import i18n from '@renderer/i18n' + export const download = (url: string, filename?: string) => { // 处理可直接通过 标签下载的 URL: // - 本地文件 ( file:// ) @@ -76,6 +78,15 @@ export const download = (url: string, filename?: string) => { URL.revokeObjectURL(blobUrl) link.remove() }) + .catch((error) => { + console.error('Download failed:', error) + // 显示用户友好的错误提示 + if (error.message) { + window.message?.error(`${i18n.t('message.download.failed')}:${error.message}`) + } else { + window.message?.error(i18n.t('message.download.failed.network')) + } + }) } // 辅助函数:根据MIME类型获取文件扩展名 From f8c6b5c05fe4a2ca91dbe6ebf51d745985236160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=87=AA=E7=94=B1=E7=9A=84=E4=B8=96=E7=95=8C=E4=BA=BA?= <3196812536@qq.com> Date: Thu, 10 Jul 2025 15:09:59 +0800 Subject: [PATCH 137/246] Fix translation key for unlimited backups label (#7987) Updated the translation key for the 'unlimited' backups option in WebDavSettings to use the correct namespace. --- src/renderer/src/pages/settings/DataSettings/WebDavSettings.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/pages/settings/DataSettings/WebDavSettings.tsx b/src/renderer/src/pages/settings/DataSettings/WebDavSettings.tsx index 54db33f024..977c5c1329 100644 --- a/src/renderer/src/pages/settings/DataSettings/WebDavSettings.tsx +++ b/src/renderer/src/pages/settings/DataSettings/WebDavSettings.tsx @@ -202,7 +202,7 @@ const WebDavSettings: FC = () => { onChange={onMaxBackupsChange} disabled={!webdavHost} options={[ - { label: t('settings.data.webdav.maxBackups.unlimited'), value: 0 }, + { label: t('settings.data.local.maxBackups.unlimited'), value: 0 }, { label: '1', value: 1 }, { label: '3', value: 3 }, { label: '5', value: 5 }, From 05f3b88f304df7931fd6a8fb546d17c49bf0e688 Mon Sep 17 00:00:00 2001 From: SuYao Date: Thu, 10 Jul 2025 15:15:13 +0800 Subject: [PATCH 138/246] fix(Inputbar): update resizeTextArea call to improve functionality (#8010) --- src/renderer/src/pages/home/Inputbar/Inputbar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index 1a8b0fed8d..775debfd34 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -240,7 +240,7 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic, topic }) = setText('') setFiles([]) setTimeout(() => setText(''), 500) - setTimeout(() => resizeTextArea(), 0) + setTimeout(() => resizeTextArea(true), 0) setExpend(false) } catch (error) { console.error('Failed to send message:', error) From f85f46c2487c517eb90de75e1c9b9a22df968f9a Mon Sep 17 00:00:00 2001 From: SuYao Date: Thu, 10 Jul 2025 15:15:38 +0800 Subject: [PATCH 139/246] fix(middleware): ollama qwen think (#8026) refactor(AiProvider): comment out unnecessary middleware removal for performance optimization - Commented out the removal of ThinkingTagExtractionMiddlewareName to prevent potential performance degradation while maintaining existing functionality. - Retained the removal of ThinkChunkMiddlewareName as part of the existing logic for non-reasoning scenarios. --- src/renderer/src/aiCore/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/aiCore/index.ts b/src/renderer/src/aiCore/index.ts index 18bf2e8524..34edc1b755 100644 --- a/src/renderer/src/aiCore/index.ts +++ b/src/renderer/src/aiCore/index.ts @@ -75,7 +75,8 @@ export default class AiProvider { } else { // Existing logic for other models if (!params.enableReasoning) { - builder.remove(ThinkingTagExtractionMiddlewareName) + // 这里注释掉不会影响正常的关闭思考,可忽略不计的性能下降 + // builder.remove(ThinkingTagExtractionMiddlewareName) builder.remove(ThinkChunkMiddlewareName) } // 注意:用client判断会导致typescript类型收窄 From 3350c3e2e52b470c78473dd49427644d32a613d9 Mon Sep 17 00:00:00 2001 From: SuYao Date: Thu, 10 Jul 2025 15:16:23 +0800 Subject: [PATCH 140/246] fix(GeminiAPIClient, mcp-tools): enhance tool call handling and lookup logic (#8009) * fix(GeminiAPIClient, mcp-tools): enhance tool call handling and lookup logic * fix: unuse log --- src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts | 7 +++++++ src/renderer/src/utils/mcp-tools.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts b/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts index 0f1bad0bf8..d32564d962 100644 --- a/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts +++ b/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts @@ -593,6 +593,13 @@ export class GeminiAPIClient extends BaseApiClient< } } as LLMWebSearchCompleteChunk) } + if (toolCalls.length > 0) { + controller.enqueue({ + type: ChunkType.MCP_TOOL_CREATED, + tool_calls: [...toolCalls] + }) + toolCalls.length = 0 + } controller.enqueue({ type: ChunkType.LLM_RESPONSE_COMPLETE, response: { diff --git a/src/renderer/src/utils/mcp-tools.ts b/src/renderer/src/utils/mcp-tools.ts index b39d9b6bc3..4b7a2e4735 100644 --- a/src/renderer/src/utils/mcp-tools.ts +++ b/src/renderer/src/utils/mcp-tools.ts @@ -391,7 +391,7 @@ export function geminiFunctionCallToMcpTool( ): MCPTool | undefined { if (!toolCall) return undefined if (!mcpTools) return undefined - const tool = mcpTools.find((tool) => tool.id === toolCall.name) + const tool = mcpTools.find((tool) => tool.id === toolCall.name || tool.name === toolCall.name) if (!tool) { return undefined } From 3afa81eb5d2aea73b672940379c236fec790bcc8 Mon Sep 17 00:00:00 2001 From: SuYao Date: Thu, 10 Jul 2025 16:58:35 +0800 Subject: [PATCH 141/246] fix(Anthropic): content truncation (#7942) * fix(Anthropic): content truncation * feat: add start event and fix content truncation * fix (gemini): some event * revert: index.tsx * revert(messageThunk): error block * fix: ci * chore: unuse log --- .../clients/anthropic/AnthropicAPIClient.ts | 28 +-- .../aiCore/clients/gemini/GeminiAPIClient.ts | 18 +- .../aiCore/clients/openai/OpenAIApiClient.ts | 16 +- .../clients/openai/OpenAIResponseAPIClient.ts | 26 ++ .../middleware/core/TextChunkMiddleware.ts | 17 +- .../middleware/core/ThinkChunkMiddleware.ts | 12 +- .../feat/ToolUseExtractionMiddleware.ts | 1 + .../home/Messages/Blocks/MainTextBlock.tsx | 8 +- .../Blocks/__tests__/MainTextBlock.test.tsx | 45 ---- .../src/services/StreamProcessingService.ts | 12 + src/renderer/src/store/thunk/messageThunk.ts | 227 ++++++++---------- src/renderer/src/types/chunk.ts | 32 +++ 12 files changed, 213 insertions(+), 229 deletions(-) diff --git a/src/renderer/src/aiCore/clients/anthropic/AnthropicAPIClient.ts b/src/renderer/src/aiCore/clients/anthropic/AnthropicAPIClient.ts index c946f114fe..93176a9566 100644 --- a/src/renderer/src/aiCore/clients/anthropic/AnthropicAPIClient.ts +++ b/src/renderer/src/aiCore/clients/anthropic/AnthropicAPIClient.ts @@ -49,10 +49,10 @@ import { LLMWebSearchCompleteChunk, LLMWebSearchInProgressChunk, MCPToolCreatedChunk, - TextCompleteChunk, TextDeltaChunk, - ThinkingCompleteChunk, - ThinkingDeltaChunk + TextStartChunk, + ThinkingDeltaChunk, + ThinkingStartChunk } from '@renderer/types/chunk' import { type Message } from '@renderer/types/newMessage' import { @@ -519,7 +519,6 @@ export class AnthropicAPIClient extends BaseApiClient< return () => { let accumulatedJson = '' const toolCalls: Record = {} - const ChunkIdTypeMap: Record = {} return { async transform(rawChunk: AnthropicSdkRawChunk, controller: TransformStreamDefaultController) { switch (rawChunk.type) { @@ -615,16 +614,16 @@ export class AnthropicAPIClient extends BaseApiClient< break } case 'text': { - if (!ChunkIdTypeMap[rawChunk.index]) { - ChunkIdTypeMap[rawChunk.index] = ChunkType.TEXT_DELTA // 用textdelta代表文本块 - } + controller.enqueue({ + type: ChunkType.TEXT_START + } as TextStartChunk) break } case 'thinking': case 'redacted_thinking': { - if (!ChunkIdTypeMap[rawChunk.index]) { - ChunkIdTypeMap[rawChunk.index] = ChunkType.THINKING_DELTA // 用thinkingdelta代表思考块 - } + controller.enqueue({ + type: ChunkType.THINKING_START + } as ThinkingStartChunk) break } } @@ -661,15 +660,6 @@ export class AnthropicAPIClient extends BaseApiClient< break } case 'content_block_stop': { - if (ChunkIdTypeMap[rawChunk.index] === ChunkType.TEXT_DELTA) { - controller.enqueue({ - type: ChunkType.TEXT_COMPLETE - } as TextCompleteChunk) - } else if (ChunkIdTypeMap[rawChunk.index] === ChunkType.THINKING_DELTA) { - controller.enqueue({ - type: ChunkType.THINKING_COMPLETE - } as ThinkingCompleteChunk) - } const toolCall = toolCalls[rawChunk.index] if (toolCall) { try { diff --git a/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts b/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts index d32564d962..bcf7c0d592 100644 --- a/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts +++ b/src/renderer/src/aiCore/clients/gemini/GeminiAPIClient.ts @@ -41,7 +41,7 @@ import { ToolCallResponse, WebSearchSource } from '@renderer/types' -import { ChunkType, LLMWebSearchCompleteChunk } from '@renderer/types/chunk' +import { ChunkType, LLMWebSearchCompleteChunk, TextStartChunk, ThinkingStartChunk } from '@renderer/types/chunk' import { Message } from '@renderer/types/newMessage' import { GeminiOptions, @@ -547,20 +547,34 @@ export class GeminiAPIClient extends BaseApiClient< } getResponseChunkTransformer(): ResponseChunkTransformer { + const toolCalls: FunctionCall[] = [] + let isFirstTextChunk = true + let isFirstThinkingChunk = true return () => ({ async transform(chunk: GeminiSdkRawChunk, controller: TransformStreamDefaultController) { - const toolCalls: FunctionCall[] = [] if (chunk.candidates && chunk.candidates.length > 0) { for (const candidate of chunk.candidates) { if (candidate.content) { candidate.content.parts?.forEach((part) => { const text = part.text || '' if (part.thought) { + if (isFirstThinkingChunk) { + controller.enqueue({ + type: ChunkType.THINKING_START + } as ThinkingStartChunk) + isFirstThinkingChunk = false + } controller.enqueue({ type: ChunkType.THINKING_DELTA, text: text }) } else if (part.text) { + if (isFirstTextChunk) { + controller.enqueue({ + type: ChunkType.TEXT_START + } as TextStartChunk) + isFirstTextChunk = false + } controller.enqueue({ type: ChunkType.TEXT_DELTA, text: text diff --git a/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts b/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts index c1994dcb95..e3ccc8edd0 100644 --- a/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts +++ b/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts @@ -31,7 +31,7 @@ import { ToolCallResponse, WebSearchSource } from '@renderer/types' -import { ChunkType } from '@renderer/types/chunk' +import { ChunkType, TextStartChunk, ThinkingStartChunk } from '@renderer/types/chunk' import { Message } from '@renderer/types/newMessage' import { OpenAISdkMessageParam, @@ -659,6 +659,8 @@ export class OpenAIAPIClient extends OpenAIBaseClient< isFinished = true } + let isFirstThinkingChunk = true + let isFirstTextChunk = true return (context: ResponseChunkTransformerContext) => ({ async transform(chunk: OpenAISdkRawChunk, controller: TransformStreamDefaultController) { // 持续更新usage信息 @@ -699,6 +701,12 @@ export class OpenAIAPIClient extends OpenAIBaseClient< // @ts-ignore - reasoning_content is not in standard OpenAI types but some providers use it const reasoningText = contentSource.reasoning_content || contentSource.reasoning if (reasoningText) { + if (isFirstThinkingChunk) { + controller.enqueue({ + type: ChunkType.THINKING_START + } as ThinkingStartChunk) + isFirstThinkingChunk = false + } controller.enqueue({ type: ChunkType.THINKING_DELTA, text: reasoningText @@ -707,6 +715,12 @@ export class OpenAIAPIClient extends OpenAIBaseClient< // 处理文本内容 if (contentSource.content) { + if (isFirstTextChunk) { + controller.enqueue({ + type: ChunkType.TEXT_START + } as TextStartChunk) + isFirstTextChunk = false + } controller.enqueue({ type: ChunkType.TEXT_DELTA, text: contentSource.content diff --git a/src/renderer/src/aiCore/clients/openai/OpenAIResponseAPIClient.ts b/src/renderer/src/aiCore/clients/openai/OpenAIResponseAPIClient.ts index 2af0b8376f..898e7eec44 100644 --- a/src/renderer/src/aiCore/clients/openai/OpenAIResponseAPIClient.ts +++ b/src/renderer/src/aiCore/clients/openai/OpenAIResponseAPIClient.ts @@ -424,6 +424,8 @@ export class OpenAIResponseAPIClient extends OpenAIBaseClient< const outputItems: OpenAI.Responses.ResponseOutputItem[] = [] let hasBeenCollectedToolCalls = false let hasReasoningSummary = false + let isFirstThinkingChunk = true + let isFirstTextChunk = true return () => ({ async transform(chunk: OpenAIResponseSdkRawChunk, controller: TransformStreamDefaultController) { // 处理chunk @@ -435,6 +437,12 @@ export class OpenAIResponseAPIClient extends OpenAIBaseClient< switch (output.type) { case 'message': if (output.content[0].type === 'output_text') { + if (isFirstTextChunk) { + controller.enqueue({ + type: ChunkType.TEXT_START + }) + isFirstTextChunk = false + } controller.enqueue({ type: ChunkType.TEXT_DELTA, text: output.content[0].text @@ -451,6 +459,12 @@ export class OpenAIResponseAPIClient extends OpenAIBaseClient< } break case 'reasoning': + if (isFirstThinkingChunk) { + controller.enqueue({ + type: ChunkType.THINKING_START + }) + isFirstThinkingChunk = false + } controller.enqueue({ type: ChunkType.THINKING_DELTA, text: output.summary.map((s) => s.text).join('\n') @@ -510,6 +524,12 @@ export class OpenAIResponseAPIClient extends OpenAIBaseClient< hasReasoningSummary = true break case 'response.reasoning_summary_text.delta': + if (isFirstThinkingChunk) { + controller.enqueue({ + type: ChunkType.THINKING_START + }) + isFirstThinkingChunk = false + } controller.enqueue({ type: ChunkType.THINKING_DELTA, text: chunk.delta @@ -535,6 +555,12 @@ export class OpenAIResponseAPIClient extends OpenAIBaseClient< }) break case 'response.output_text.delta': { + if (isFirstTextChunk) { + controller.enqueue({ + type: ChunkType.TEXT_START + }) + isFirstTextChunk = false + } controller.enqueue({ type: ChunkType.TEXT_DELTA, text: chunk.delta diff --git a/src/renderer/src/aiCore/middleware/core/TextChunkMiddleware.ts b/src/renderer/src/aiCore/middleware/core/TextChunkMiddleware.ts index 3905d52058..0affc6b382 100644 --- a/src/renderer/src/aiCore/middleware/core/TextChunkMiddleware.ts +++ b/src/renderer/src/aiCore/middleware/core/TextChunkMiddleware.ts @@ -1,5 +1,5 @@ import Logger from '@renderer/config/logger' -import { ChunkType, TextCompleteChunk, TextDeltaChunk } from '@renderer/types/chunk' +import { ChunkType, TextDeltaChunk } from '@renderer/types/chunk' import { CompletionsParams, CompletionsResult, GenericChunk } from '../schemas' import { CompletionsContext, CompletionsMiddleware } from '../types' @@ -38,7 +38,6 @@ export const TextChunkMiddleware: CompletionsMiddleware = // 用于跨chunk的状态管理 let accumulatedTextContent = '' - let hasTextCompleteEventEnqueue = false const enhancedTextStream = resultFromUpstream.pipeThrough( new TransformStream({ transform(chunk: GenericChunk, controller) { @@ -53,18 +52,7 @@ export const TextChunkMiddleware: CompletionsMiddleware = // 创建新的chunk,包含处理后的文本 controller.enqueue(chunk) - } else if (chunk.type === ChunkType.TEXT_COMPLETE) { - const textChunk = chunk as TextCompleteChunk - controller.enqueue({ - ...textChunk, - text: accumulatedTextContent - }) - if (params.onResponse) { - params.onResponse(accumulatedTextContent, true) - } - hasTextCompleteEventEnqueue = true - accumulatedTextContent = '' - } else if (accumulatedTextContent && !hasTextCompleteEventEnqueue) { + } else if (accumulatedTextContent && chunk.type !== ChunkType.TEXT_START) { if (chunk.type === ChunkType.LLM_RESPONSE_COMPLETE) { const finalText = accumulatedTextContent ctx._internal.customState!.accumulatedText = finalText @@ -89,7 +77,6 @@ export const TextChunkMiddleware: CompletionsMiddleware = }) controller.enqueue(chunk) } - hasTextCompleteEventEnqueue = true accumulatedTextContent = '' } else { // 其他类型的chunk直接传递 diff --git a/src/renderer/src/aiCore/middleware/core/ThinkChunkMiddleware.ts b/src/renderer/src/aiCore/middleware/core/ThinkChunkMiddleware.ts index dccdde7f10..22eaabe96d 100644 --- a/src/renderer/src/aiCore/middleware/core/ThinkChunkMiddleware.ts +++ b/src/renderer/src/aiCore/middleware/core/ThinkChunkMiddleware.ts @@ -65,17 +65,7 @@ export const ThinkChunkMiddleware: CompletionsMiddleware = thinking_millsec: thinkingStartTime > 0 ? Date.now() - thinkingStartTime : 0 } controller.enqueue(enhancedChunk) - } else if (chunk.type === ChunkType.THINKING_COMPLETE) { - const thinkingCompleteChunk = chunk as ThinkingCompleteChunk - controller.enqueue({ - ...thinkingCompleteChunk, - text: accumulatedThinkingContent, - thinking_millsec: thinkingStartTime > 0 ? Date.now() - thinkingStartTime : 0 - }) - hasThinkingContent = false - accumulatedThinkingContent = '' - thinkingStartTime = 0 - } else if (hasThinkingContent && thinkingStartTime > 0) { + } else if (hasThinkingContent && thinkingStartTime > 0 && chunk.type !== ChunkType.THINKING_START) { // 收到任何非THINKING_DELTA的chunk时,如果有累积的思考内容,生成THINKING_COMPLETE const thinkingCompleteChunk: ThinkingCompleteChunk = { type: ChunkType.THINKING_COMPLETE, diff --git a/src/renderer/src/aiCore/middleware/feat/ToolUseExtractionMiddleware.ts b/src/renderer/src/aiCore/middleware/feat/ToolUseExtractionMiddleware.ts index b53d7348f1..3e606f6683 100644 --- a/src/renderer/src/aiCore/middleware/feat/ToolUseExtractionMiddleware.ts +++ b/src/renderer/src/aiCore/middleware/feat/ToolUseExtractionMiddleware.ts @@ -79,6 +79,7 @@ function createToolUseExtractionTransform( toolCounter += toolUseResponses.length if (toolUseResponses.length > 0) { + controller.enqueue({ type: ChunkType.TEXT_COMPLETE, text: '' }) // 生成 MCP_TOOL_CREATED chunk const mcpToolCreatedChunk: MCPToolCreatedChunk = { type: ChunkType.MCP_TOOL_CREATED, diff --git a/src/renderer/src/pages/home/Messages/Blocks/MainTextBlock.tsx b/src/renderer/src/pages/home/Messages/Blocks/MainTextBlock.tsx index 524fcd4160..0f0d52907d 100644 --- a/src/renderer/src/pages/home/Messages/Blocks/MainTextBlock.tsx +++ b/src/renderer/src/pages/home/Messages/Blocks/MainTextBlock.tsx @@ -19,8 +19,6 @@ interface Props { role: Message['role'] } -const toolUseRegex = /([\s\S]*?)<\/tool_use>/g - const MainTextBlock: React.FC = ({ block, citationBlockId, role, mentions = [] }) => { // Use the passed citationBlockId directly in the selector const { renderInputMessageAsMarkdown } = useSettings() @@ -38,10 +36,6 @@ const MainTextBlock: React.FC = ({ block, citationBlockId, role, mentions return withCitationTags(block.content, rawCitations, sourceType) }, [block.content, block.citationReferences, citationBlockId, rawCitations]) - const ignoreToolUse = useMemo(() => { - return processedContent.replace(toolUseRegex, '') - }, [processedContent]) - return ( <> {/* Render mentions associated with the message */} @@ -57,7 +51,7 @@ const MainTextBlock: React.FC = ({ block, citationBlockId, role, mentions {block.content}

) : ( - + )} ) diff --git a/src/renderer/src/pages/home/Messages/Blocks/__tests__/MainTextBlock.test.tsx b/src/renderer/src/pages/home/Messages/Blocks/__tests__/MainTextBlock.test.tsx index 551e0d9371..4683aae9bb 100644 --- a/src/renderer/src/pages/home/Messages/Blocks/__tests__/MainTextBlock.test.tsx +++ b/src/renderer/src/pages/home/Messages/Blocks/__tests__/MainTextBlock.test.tsx @@ -261,51 +261,6 @@ describe('MainTextBlock', () => { }) describe('content processing', () => { - it('should filter tool_use tags from content', () => { - const testCases = [ - { - name: 'single tool_use tag', - content: 'Before tool content after', - expectsFiltering: true - }, - { - name: 'multiple tool_use tags', - content: 'Start tool1 middle tool2 end', - expectsFiltering: true - }, - { - name: 'multiline tool_use', - content: `Text before - - multiline - tool content - -text after`, - expectsFiltering: true - }, - { - name: 'malformed tool_use', - content: 'Before unclosed tag', - expectsFiltering: false // Should preserve malformed tags - } - ] - - testCases.forEach(({ content, expectsFiltering }) => { - const block = createMainTextBlock({ content }) - const { unmount } = renderMainTextBlock({ block, role: 'assistant' }) - - const renderedContent = getRenderedMarkdown() - expect(renderedContent).toBeInTheDocument() - - if (expectsFiltering) { - // Check that tool_use content is not visible to user - expect(screen.queryByText(/tool content|tool1|tool2|multiline/)).not.toBeInTheDocument() - } - - unmount() - }) - }) - it('should process content through format utilities', () => { const block = createMainTextBlock({ content: 'Content to process', diff --git a/src/renderer/src/services/StreamProcessingService.ts b/src/renderer/src/services/StreamProcessingService.ts index 6c166ca6a9..c6afa85e39 100644 --- a/src/renderer/src/services/StreamProcessingService.ts +++ b/src/renderer/src/services/StreamProcessingService.ts @@ -8,10 +8,14 @@ import { AssistantMessageStatus } from '@renderer/types/newMessage' export interface StreamProcessorCallbacks { // LLM response created onLLMResponseCreated?: () => void + // Text content start + onTextStart?: () => void // Text content chunk received onTextChunk?: (text: string) => void // Full text content received onTextComplete?: (text: string) => void + // thinking content start + onThinkingStart?: () => void // Thinking/reasoning content chunk received (e.g., from Claude) onThinkingChunk?: (text: string, thinking_millsec?: number) => void onThinkingComplete?: (text: string, thinking_millsec?: number) => void @@ -54,6 +58,10 @@ export function createStreamProcessor(callbacks: StreamProcessorCallbacks = {}) if (callbacks.onLLMResponseCreated) callbacks.onLLMResponseCreated() break } + case ChunkType.TEXT_START: { + if (callbacks.onTextStart) callbacks.onTextStart() + break + } case ChunkType.TEXT_DELTA: { if (callbacks.onTextChunk) callbacks.onTextChunk(data.text) break @@ -62,6 +70,10 @@ export function createStreamProcessor(callbacks: StreamProcessorCallbacks = {}) if (callbacks.onTextComplete) callbacks.onTextComplete(data.text) break } + case ChunkType.THINKING_START: { + if (callbacks.onThinkingStart) callbacks.onThinkingStart() + break + } case ChunkType.THINKING_DELTA: { if (callbacks.onThinkingChunk) callbacks.onThinkingChunk(data.text, data.thinking_millsec) break diff --git a/src/renderer/src/store/thunk/messageThunk.ts b/src/renderer/src/store/thunk/messageThunk.ts index 996044bb24..63ca59fa43 100644 --- a/src/renderer/src/store/thunk/messageThunk.ts +++ b/src/renderer/src/store/thunk/messageThunk.ts @@ -41,7 +41,7 @@ import { createTranslationBlock, resetAssistantMessage } from '@renderer/utils/messageUtils/create' -import { getMainTextContent } from '@renderer/utils/messageUtils/find' +import { findMainTextBlocks, getMainTextContent } from '@renderer/utils/messageUtils/find' import { getTopicQueue } from '@renderer/utils/queue' import { waitForTopicQueue } from '@renderer/utils/queue' import { isOnHomePage } from '@renderer/utils/window' @@ -226,31 +226,6 @@ export const cleanupMultipleBlocks = (dispatch: AppDispatch, blockIds: string[]) } } -// // 修改: 节流更新单个块的内容/状态到数据库 (仅用于 Text/Thinking Chunks) -// export const throttledBlockDbUpdate = throttle( -// async (blockId: string, blockChanges: Partial) => { -// // Check if blockId is valid before attempting update -// if (!blockId) { -// console.warn('[DB Throttle Block Update] Attempted to update with null/undefined blockId. Skipping.') -// return -// } -// const state = store.getState() -// const block = state.messageBlocks.entities[blockId] -// // throttle是异步函数,可能会在complete事件触发后才执行 -// if ( -// blockChanges.status === MessageBlockStatus.STREAMING && -// (block?.status === MessageBlockStatus.SUCCESS || block?.status === MessageBlockStatus.ERROR) -// ) -// return -// try { -// } catch (error) { -// console.error(`[DB Throttle Block Update] Failed for block ${blockId}:`, error) -// } -// }, -// 300, // 可以调整节流间隔 -// { leading: false, trailing: true } -// ) - // 新增: 通用的、非节流的函数,用于保存消息和块的更新到数据库 const saveUpdatesToDB = async ( messageId: string, @@ -351,9 +326,9 @@ const fetchAndProcessAssistantResponseImpl = async ( let accumulatedContent = '' let accumulatedThinking = '' - // 专注于管理UI焦点和块切换 let lastBlockId: string | null = null let lastBlockType: MessageBlockType | null = null + let currentActiveBlockType: MessageBlockType | null = null // 专注于块内部的生命周期处理 let initialPlaceholderBlockId: string | null = null let citationBlockId: string | null = null @@ -365,6 +340,28 @@ const fetchAndProcessAssistantResponseImpl = async ( const toolCallIdToBlockIdMap = new Map() const notificationService = NotificationService.getInstance() + /** + * 智能更新策略:根据块类型连续性自动判断使用节流还是立即更新 + * - 连续同类块:使用节流(减少重渲染) + * - 块类型切换:立即更新(确保状态正确) + */ + const smartBlockUpdate = (blockId: string, changes: Partial, blockType: MessageBlockType) => { + const isBlockTypeChanged = currentActiveBlockType !== null && currentActiveBlockType !== blockType + + if (isBlockTypeChanged) { + if (lastBlockId && lastBlockId !== blockId) { + cancelThrottledBlockUpdate(lastBlockId) + } + dispatch(updateOneBlock({ id: blockId, changes })) + saveUpdatedBlockToDB(blockId, assistantMsgId, topicId, getState) + } else { + throttledBlockUpdate(blockId, changes) + } + + // 更新当前活跃块类型 + currentActiveBlockType = blockType + } + const handleBlockTransition = async (newBlock: MessageBlock, newBlockType: MessageBlockType) => { lastBlockId = newBlock.id lastBlockType = newBlockType @@ -428,6 +425,25 @@ const fetchAndProcessAssistantResponseImpl = async ( initialPlaceholderBlockId = baseBlock.id await handleBlockTransition(baseBlock as PlaceholderMessageBlock, MessageBlockType.UNKNOWN) }, + onTextStart: async () => { + if (initialPlaceholderBlockId) { + lastBlockType = MessageBlockType.MAIN_TEXT + const changes = { + type: MessageBlockType.MAIN_TEXT, + content: accumulatedContent, + status: MessageBlockStatus.STREAMING + } + smartBlockUpdate(initialPlaceholderBlockId, changes, MessageBlockType.MAIN_TEXT) + mainTextBlockId = initialPlaceholderBlockId + initialPlaceholderBlockId = null + } else if (!mainTextBlockId) { + const newBlock = createMainTextBlock(assistantMsgId, accumulatedContent, { + status: MessageBlockStatus.STREAMING + }) + mainTextBlockId = newBlock.id + await handleBlockTransition(newBlock, MessageBlockType.MAIN_TEXT) + } + }, onTextChunk: async (text) => { const citationBlockSource = citationBlockId ? (getState().messageBlocks.entities[citationBlockId] as CitationMessageBlock).response?.source @@ -435,31 +451,11 @@ const fetchAndProcessAssistantResponseImpl = async ( accumulatedContent += text if (mainTextBlockId) { const blockChanges: Partial = { - content: accumulatedContent, - status: MessageBlockStatus.STREAMING - } - throttledBlockUpdate(mainTextBlockId, blockChanges) - } else if (initialPlaceholderBlockId) { - // 将占位块转换为主文本块 - const initialChanges: Partial = { - type: MessageBlockType.MAIN_TEXT, content: accumulatedContent, status: MessageBlockStatus.STREAMING, citationReferences: citationBlockId ? [{ citationBlockId, citationBlockSource }] : [] } - mainTextBlockId = initialPlaceholderBlockId - // 清理占位块 - initialPlaceholderBlockId = null - lastBlockType = MessageBlockType.MAIN_TEXT - dispatch(updateOneBlock({ id: mainTextBlockId, changes: initialChanges })) - saveUpdatedBlockToDB(mainTextBlockId, assistantMsgId, topicId, getState) - } else { - const newBlock = createMainTextBlock(assistantMsgId, accumulatedContent, { - status: MessageBlockStatus.STREAMING, - citationReferences: citationBlockId ? [{ citationBlockId, citationBlockSource }] : [] - }) - mainTextBlockId = newBlock.id // 立即设置ID,防止竞态条件 - await handleBlockTransition(newBlock, MessageBlockType.MAIN_TEXT) + smartBlockUpdate(mainTextBlockId, blockChanges, MessageBlockType.MAIN_TEXT) } }, onTextComplete: async (finalText) => { @@ -468,18 +464,35 @@ const fetchAndProcessAssistantResponseImpl = async ( content: finalText, status: MessageBlockStatus.SUCCESS } - cancelThrottledBlockUpdate(mainTextBlockId) - dispatch(updateOneBlock({ id: mainTextBlockId, changes })) - saveUpdatedBlockToDB(mainTextBlockId, assistantMsgId, topicId, getState) - if (!assistant.enableWebSearch) { - mainTextBlockId = null - } + smartBlockUpdate(mainTextBlockId, changes, MessageBlockType.MAIN_TEXT) + mainTextBlockId = null } else { console.warn( `[onTextComplete] Received text.complete but last block was not MAIN_TEXT (was ${lastBlockType}) or lastBlockId is null.` ) } }, + onThinkingStart: async () => { + if (initialPlaceholderBlockId) { + lastBlockType = MessageBlockType.THINKING + const changes = { + type: MessageBlockType.THINKING, + content: accumulatedThinking, + status: MessageBlockStatus.STREAMING, + thinking_millsec: 0 + } + thinkingBlockId = initialPlaceholderBlockId + initialPlaceholderBlockId = null + smartBlockUpdate(thinkingBlockId, changes, MessageBlockType.THINKING) + } else if (!thinkingBlockId) { + const newBlock = createThinkingBlock(assistantMsgId, accumulatedThinking, { + status: MessageBlockStatus.STREAMING, + thinking_millsec: 0 + }) + thinkingBlockId = newBlock.id + await handleBlockTransition(newBlock, MessageBlockType.THINKING) + } + }, onThinkingChunk: async (text, thinking_millsec) => { accumulatedThinking += text if (thinkingBlockId) { @@ -488,26 +501,7 @@ const fetchAndProcessAssistantResponseImpl = async ( status: MessageBlockStatus.STREAMING, thinking_millsec: thinking_millsec } - throttledBlockUpdate(thinkingBlockId, blockChanges) - } else if (initialPlaceholderBlockId) { - // First chunk for this block: Update type and status immediately - lastBlockType = MessageBlockType.THINKING - const initialChanges: Partial = { - type: MessageBlockType.THINKING, - content: accumulatedThinking, - status: MessageBlockStatus.STREAMING - } - thinkingBlockId = initialPlaceholderBlockId - initialPlaceholderBlockId = null - dispatch(updateOneBlock({ id: thinkingBlockId, changes: initialChanges })) - saveUpdatedBlockToDB(thinkingBlockId, assistantMsgId, topicId, getState) - } else { - const newBlock = createThinkingBlock(assistantMsgId, accumulatedThinking, { - status: MessageBlockStatus.STREAMING, - thinking_millsec: 0 - }) - thinkingBlockId = newBlock.id // 立即设置ID,防止竞态条件 - await handleBlockTransition(newBlock, MessageBlockType.THINKING) + smartBlockUpdate(thinkingBlockId, blockChanges, MessageBlockType.THINKING) } }, onThinkingComplete: (finalText, final_thinking_millsec) => { @@ -518,9 +512,7 @@ const fetchAndProcessAssistantResponseImpl = async ( status: MessageBlockStatus.SUCCESS, thinking_millsec: final_thinking_millsec } - cancelThrottledBlockUpdate(thinkingBlockId) - dispatch(updateOneBlock({ id: thinkingBlockId, changes })) - saveUpdatedBlockToDB(thinkingBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(thinkingBlockId, changes, MessageBlockType.THINKING) } else { console.warn( `[onThinkingComplete] Received thinking.complete but last block was not THINKING (was ${lastBlockType}) or lastBlockId is null.` @@ -539,8 +531,7 @@ const fetchAndProcessAssistantResponseImpl = async ( } toolBlockId = initialPlaceholderBlockId initialPlaceholderBlockId = null - dispatch(updateOneBlock({ id: toolBlockId, changes })) - saveUpdatedBlockToDB(toolBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(toolBlockId, changes, MessageBlockType.TOOL) toolCallIdToBlockIdMap.set(toolResponse.id, toolBlockId) } else if (toolResponse.status === 'pending') { const toolBlock = createToolBlock(assistantMsgId, toolResponse.id, { @@ -566,8 +557,7 @@ const fetchAndProcessAssistantResponseImpl = async ( status: MessageBlockStatus.PROCESSING, metadata: { rawMcpToolResponse: toolResponse } } - dispatch(updateOneBlock({ id: targetBlockId, changes })) - saveUpdatedBlockToDB(targetBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(targetBlockId, changes, MessageBlockType.TOOL) } else if (!targetBlockId) { console.warn( `[onToolCallInProgress] No block ID found for tool ID: ${toolResponse.id}. Available mappings:`, @@ -601,9 +591,7 @@ const fetchAndProcessAssistantResponseImpl = async ( if (finalStatus === MessageBlockStatus.ERROR) { changes.error = { message: `Tool execution failed/error`, details: toolResponse.response } } - cancelThrottledBlockUpdate(existingBlockId) - dispatch(updateOneBlock({ id: existingBlockId, changes })) - saveUpdatedBlockToDB(existingBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(existingBlockId, changes, MessageBlockType.TOOL) } else { console.warn( `[onToolCallComplete] Received unhandled tool status: ${toolResponse.status} for ID: ${toolResponse.id}` @@ -624,8 +612,7 @@ const fetchAndProcessAssistantResponseImpl = async ( knowledge: externalToolResult.knowledge, status: MessageBlockStatus.SUCCESS } - dispatch(updateOneBlock({ id: citationBlockId, changes })) - saveUpdatedBlockToDB(citationBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(citationBlockId, changes, MessageBlockType.CITATION) } else { console.error('[onExternalToolComplete] citationBlockId is null. Cannot update.') } @@ -639,8 +626,7 @@ const fetchAndProcessAssistantResponseImpl = async ( status: MessageBlockStatus.PROCESSING } lastBlockType = MessageBlockType.CITATION - dispatch(updateOneBlock({ id: initialPlaceholderBlockId, changes })) - saveUpdatedBlockToDB(initialPlaceholderBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(initialPlaceholderBlockId, changes, MessageBlockType.CITATION) initialPlaceholderBlockId = null } else { const citationBlock = createCitationBlock(assistantMsgId, {}, { status: MessageBlockStatus.PROCESSING }) @@ -656,22 +642,19 @@ const fetchAndProcessAssistantResponseImpl = async ( response: llmWebSearchResult, status: MessageBlockStatus.SUCCESS } - dispatch(updateOneBlock({ id: blockId, changes })) - saveUpdatedBlockToDB(blockId, assistantMsgId, topicId, getState) + smartBlockUpdate(blockId, changes, MessageBlockType.CITATION) - if (mainTextBlockId) { - const state = getState() - const existingMainTextBlock = state.messageBlocks.entities[mainTextBlockId] - if (existingMainTextBlock && existingMainTextBlock.type === MessageBlockType.MAIN_TEXT) { - const currentRefs = existingMainTextBlock.citationReferences || [] - const mainTextChanges = { - citationReferences: [...currentRefs, { blockId, citationBlockSource: llmWebSearchResult.source }] - } - dispatch(updateOneBlock({ id: mainTextBlockId, changes: mainTextChanges })) - saveUpdatedBlockToDB(mainTextBlockId, assistantMsgId, topicId, getState) + const state = getState() + const existingMainTextBlocks = findMainTextBlocks(state.messages.entities[assistantMsgId]) + if (existingMainTextBlocks.length > 0) { + const existingMainTextBlock = existingMainTextBlocks[0] + const currentRefs = existingMainTextBlock.citationReferences || [] + const mainTextChanges = { + citationReferences: [...currentRefs, { blockId, citationBlockSource: llmWebSearchResult.source }] } - mainTextBlockId = null + smartBlockUpdate(existingMainTextBlock.id, mainTextChanges, MessageBlockType.MAIN_TEXT) } + if (initialPlaceholderBlockId) { citationBlockId = initialPlaceholderBlockId initialPlaceholderBlockId = null @@ -687,21 +670,15 @@ const fetchAndProcessAssistantResponseImpl = async ( } ) citationBlockId = citationBlock.id - if (mainTextBlockId) { - const state = getState() - const existingMainTextBlock = state.messageBlocks.entities[mainTextBlockId] - if (existingMainTextBlock && existingMainTextBlock.type === MessageBlockType.MAIN_TEXT) { - const currentRefs = existingMainTextBlock.citationReferences || [] - const mainTextChanges = { - citationReferences: [ - ...currentRefs, - { citationBlockId, citationBlockSource: llmWebSearchResult.source } - ] - } - dispatch(updateOneBlock({ id: mainTextBlockId, changes: mainTextChanges })) - saveUpdatedBlockToDB(mainTextBlockId, assistantMsgId, topicId, getState) + const state = getState() + const existingMainTextBlocks = findMainTextBlocks(state.messages.entities[assistantMsgId]) + if (existingMainTextBlocks.length > 0) { + const existingMainTextBlock = existingMainTextBlocks[0] + const currentRefs = existingMainTextBlock.citationReferences || [] + const mainTextChanges = { + citationReferences: [...currentRefs, { citationBlockId, citationBlockSource: llmWebSearchResult.source }] } - mainTextBlockId = null + smartBlockUpdate(existingMainTextBlock.id, mainTextChanges, MessageBlockType.MAIN_TEXT) } await handleBlockTransition(citationBlock, MessageBlockType.CITATION) } @@ -716,8 +693,7 @@ const fetchAndProcessAssistantResponseImpl = async ( lastBlockType = MessageBlockType.IMAGE imageBlockId = initialPlaceholderBlockId initialPlaceholderBlockId = null - dispatch(updateOneBlock({ id: imageBlockId, changes: initialChanges })) - saveUpdatedBlockToDB(imageBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(imageBlockId, initialChanges, MessageBlockType.IMAGE) } else if (!imageBlockId) { const imageBlock = createImageBlock(assistantMsgId, { status: MessageBlockStatus.STREAMING @@ -734,8 +710,7 @@ const fetchAndProcessAssistantResponseImpl = async ( metadata: { generateImageResponse: imageData }, status: MessageBlockStatus.STREAMING } - dispatch(updateOneBlock({ id: imageBlockId, changes })) - saveUpdatedBlockToDB(imageBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(imageBlockId, changes, MessageBlockType.IMAGE) } }, onImageGenerated: (imageData) => { @@ -744,8 +719,7 @@ const fetchAndProcessAssistantResponseImpl = async ( const changes: Partial = { status: MessageBlockStatus.SUCCESS } - dispatch(updateOneBlock({ id: imageBlockId, changes })) - saveUpdatedBlockToDB(imageBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(imageBlockId, changes, MessageBlockType.IMAGE) } else { const imageUrl = imageData.images?.[0] || 'placeholder_image_url' const changes: Partial = { @@ -753,8 +727,7 @@ const fetchAndProcessAssistantResponseImpl = async ( metadata: { generateImageResponse: imageData }, status: MessageBlockStatus.SUCCESS } - dispatch(updateOneBlock({ id: imageBlockId, changes })) - saveUpdatedBlockToDB(imageBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(imageBlockId, changes, MessageBlockType.IMAGE) } } else { console.error('[onImageGenerated] Last block was not an Image block or ID is missing.') @@ -802,9 +775,7 @@ const fetchAndProcessAssistantResponseImpl = async ( const changes: Partial = { status: isErrorTypeAbort ? MessageBlockStatus.PAUSED : MessageBlockStatus.ERROR } - cancelThrottledBlockUpdate(possibleBlockId) - dispatch(updateOneBlock({ id: possibleBlockId, changes })) - saveUpdatedBlockToDB(possibleBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(possibleBlockId, changes, MessageBlockType.MAIN_TEXT) } const errorBlock = createErrorBlock(assistantMsgId, serializableError, { status: MessageBlockStatus.SUCCESS }) @@ -846,9 +817,7 @@ const fetchAndProcessAssistantResponseImpl = async ( const changes: Partial = { status: MessageBlockStatus.SUCCESS } - cancelThrottledBlockUpdate(possibleBlockId) - dispatch(updateOneBlock({ id: possibleBlockId, changes })) - saveUpdatedBlockToDB(possibleBlockId, assistantMsgId, topicId, getState) + smartBlockUpdate(possibleBlockId, changes, lastBlockType!) } const endTime = Date.now() diff --git a/src/renderer/src/types/chunk.ts b/src/renderer/src/types/chunk.ts index c5e84a4673..1fdbbdae6f 100644 --- a/src/renderer/src/types/chunk.ts +++ b/src/renderer/src/types/chunk.ts @@ -19,13 +19,16 @@ export enum ChunkType { EXTERNEL_TOOL_COMPLETE = 'externel_tool_complete', LLM_RESPONSE_CREATED = 'llm_response_created', LLM_RESPONSE_IN_PROGRESS = 'llm_response_in_progress', + TEXT_START = 'text.start', TEXT_DELTA = 'text.delta', TEXT_COMPLETE = 'text.complete', + AUDIO_START = 'audio.start', AUDIO_DELTA = 'audio.delta', AUDIO_COMPLETE = 'audio.complete', IMAGE_CREATED = 'image.created', IMAGE_DELTA = 'image.delta', IMAGE_COMPLETE = 'image.complete', + THINKING_START = 'thinking.start', THINKING_DELTA = 'thinking.delta', THINKING_COMPLETE = 'thinking.complete', LLM_WEB_SEARCH_IN_PROGRESS = 'llm_websearch_in_progress', @@ -56,6 +59,18 @@ export interface LLMResponseInProgressChunk { response?: Response type: ChunkType.LLM_RESPONSE_IN_PROGRESS } + +export interface TextStartChunk { + /** + * The type of the chunk + */ + type: ChunkType.TEXT_START + + /** + * The ID of the chunk + */ + chunk_id?: number +} export interface TextDeltaChunk { /** * The text content of the chunk @@ -90,6 +105,13 @@ export interface TextCompleteChunk { type: ChunkType.TEXT_COMPLETE } +export interface AudioStartChunk { + /** + * The type of the chunk + */ + type: ChunkType.AUDIO_START +} + export interface AudioDeltaChunk { /** * A chunk of Base64 encoded audio data @@ -140,6 +162,13 @@ export interface ImageCompleteChunk { image?: { type: 'url' | 'base64'; images: string[] } } +export interface ThinkingStartChunk { + /** + * The type of the chunk + */ + type: ChunkType.THINKING_START +} + export interface ThinkingDeltaChunk { /** * The text content of the chunk @@ -365,13 +394,16 @@ export type Chunk = | ExternalToolCompleteChunk // 外部工具调用完成,外部工具包含搜索互联网,知识库,MCP服务器 | LLMResponseCreatedChunk // 大模型响应创建,返回即将创建的块类型 | LLMResponseInProgressChunk // 大模型响应进行中 + | TextStartChunk // 文本内容生成开始 | TextDeltaChunk // 文本内容生成中 | TextCompleteChunk // 文本内容生成完成 + | AudioStartChunk // 音频内容生成开始 | AudioDeltaChunk // 音频内容生成中 | AudioCompleteChunk // 音频内容生成完成 | ImageCreatedChunk // 图片内容创建 | ImageDeltaChunk // 图片内容生成中 | ImageCompleteChunk // 图片内容生成完成 + | ThinkingStartChunk // 思考内容生成开始 | ThinkingDeltaChunk // 思考内容生成中 | ThinkingCompleteChunk // 思考内容生成完成 | LLMWebSearchInProgressChunk // 大模型内部搜索进行中,无明显特征 From dff44f272179fa8a741546ca5245d0f978c7157d Mon Sep 17 00:00:00 2001 From: Alaina Hardie Date: Thu, 10 Jul 2025 05:01:31 -0400 Subject: [PATCH 142/246] Fix: Require typechecking for Mac and Linux target builds (#7219) fix: Mac builds do not auto-run typecheck, but Windows builds do. This requires an extra manual step when building for Mac. Update build scripts in package.json to use `npm run build` directly for Mac and Linux targets.. --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 41f1f58bf7..e56b1e261c 100644 --- a/package.json +++ b/package.json @@ -27,12 +27,12 @@ "build:win": "dotenv npm run build && electron-builder --win --x64 --arm64", "build:win:x64": "dotenv npm run build && electron-builder --win --x64", "build:win:arm64": "dotenv npm run build && electron-builder --win --arm64", - "build:mac": "dotenv electron-vite build && electron-builder --mac --arm64 --x64", - "build:mac:arm64": "dotenv electron-vite build && electron-builder --mac --arm64", - "build:mac:x64": "dotenv electron-vite build && electron-builder --mac --x64", - "build:linux": "dotenv electron-vite build && electron-builder --linux --x64 --arm64", - "build:linux:arm64": "dotenv electron-vite build && electron-builder --linux --arm64", - "build:linux:x64": "dotenv electron-vite build && electron-builder --linux --x64", + "build:mac": "dotenv npm run build && electron-builder --mac --arm64 --x64", + "build:mac:arm64": "dotenv npm run build && electron-builder --mac --arm64", + "build:mac:x64": "dotenv npm run build && electron-builder --mac --x64", + "build:linux": "dotenv npm run build && electron-builder --linux --x64 --arm64", + "build:linux:arm64": "dotenv npm run build && electron-builder --linux --arm64", + "build:linux:x64": "dotenv npm run build && electron-builder --linux --x64", "build:npm": "node scripts/build-npm.js", "release": "node scripts/version.js", "publish": "yarn build:check && yarn release patch push", From ffbd6445df811194dca7d3764eb5a1abd6a131cf Mon Sep 17 00:00:00 2001 From: one Date: Thu, 10 Jul 2025 17:26:38 +0800 Subject: [PATCH 143/246] refactor(Inputbar): make button tooltips disappear faster (#8011) --- .../src/components/TranslateButton.tsx | 1 + .../pages/home/Inputbar/AttachmentButton.tsx | 6 +++++- .../home/Inputbar/GenerateImageButton.tsx | 1 + .../src/pages/home/Inputbar/Inputbar.tsx | 2 +- .../src/pages/home/Inputbar/InputbarTools.tsx | 18 +++++++++++++++--- .../home/Inputbar/KnowledgeBaseButton.tsx | 2 +- .../src/pages/home/Inputbar/MCPToolsButton.tsx | 2 +- .../home/Inputbar/MentionModelsButton.tsx | 2 +- .../pages/home/Inputbar/NewContextButton.tsx | 6 +++++- .../pages/home/Inputbar/QuickPhrasesButton.tsx | 2 +- .../src/pages/home/Inputbar/ThinkingButton.tsx | 2 +- .../pages/home/Inputbar/WebSearchButton.tsx | 6 +++++- 12 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/renderer/src/components/TranslateButton.tsx b/src/renderer/src/components/TranslateButton.tsx index d52448b488..41a29a6fa4 100644 --- a/src/renderer/src/components/TranslateButton.tsx +++ b/src/renderer/src/components/TranslateButton.tsx @@ -77,6 +77,7 @@ const TranslateButton: FC = ({ text, onTranslated, disabled, style, isLoa {isTranslating ? : } diff --git a/src/renderer/src/pages/home/Inputbar/AttachmentButton.tsx b/src/renderer/src/pages/home/Inputbar/AttachmentButton.tsx index a06229bd7c..576f034a24 100644 --- a/src/renderer/src/pages/home/Inputbar/AttachmentButton.tsx +++ b/src/renderer/src/pages/home/Inputbar/AttachmentButton.tsx @@ -54,7 +54,11 @@ const AttachmentButton: FC = ({ })) return ( - + diff --git a/src/renderer/src/pages/home/Inputbar/GenerateImageButton.tsx b/src/renderer/src/pages/home/Inputbar/GenerateImageButton.tsx index 889919b7f5..c7d930bf5d 100644 --- a/src/renderer/src/pages/home/Inputbar/GenerateImageButton.tsx +++ b/src/renderer/src/pages/home/Inputbar/GenerateImageButton.tsx @@ -21,6 +21,7 @@ const GenerateImageButton: FC = ({ model, ToolbarButton, assistant, onEna title={ isGenerateImageModel(model) ? t('chat.input.generate_image') : t('chat.input.generate_image_not_supported') } + mouseLeaveDelay={0} arrow> diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index 775debfd34..a07f7b73b2 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -909,7 +909,7 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic, topic }) = /> {loading && ( - + diff --git a/src/renderer/src/pages/home/Inputbar/InputbarTools.tsx b/src/renderer/src/pages/home/Inputbar/InputbarTools.tsx index a6596aed19..7609b8cfe3 100644 --- a/src/renderer/src/pages/home/Inputbar/InputbarTools.tsx +++ b/src/renderer/src/pages/home/Inputbar/InputbarTools.tsx @@ -290,7 +290,11 @@ const InputbarTools = ({ key: 'new_topic', label: t('chat.input.new_topic', { Command: '' }), component: ( - + @@ -395,7 +399,11 @@ const InputbarTools = ({ key: 'clear_topic', label: t('chat.input.clear', { Command: '' }), component: ( - + @@ -406,7 +414,11 @@ const InputbarTools = ({ key: 'toggle_expand', label: isExpended ? t('chat.input.collapse') : t('chat.input.expand'), component: ( - + {isExpended ? : } diff --git a/src/renderer/src/pages/home/Inputbar/KnowledgeBaseButton.tsx b/src/renderer/src/pages/home/Inputbar/KnowledgeBaseButton.tsx index 3462788bdc..8e4782c8a7 100644 --- a/src/renderer/src/pages/home/Inputbar/KnowledgeBaseButton.tsx +++ b/src/renderer/src/pages/home/Inputbar/KnowledgeBaseButton.tsx @@ -85,7 +85,7 @@ const KnowledgeBaseButton: FC = ({ ref, selectedBases, onSelect, disabled })) return ( - + diff --git a/src/renderer/src/pages/home/Inputbar/MCPToolsButton.tsx b/src/renderer/src/pages/home/Inputbar/MCPToolsButton.tsx index ec64e7d4a7..cc8bc67ca5 100644 --- a/src/renderer/src/pages/home/Inputbar/MCPToolsButton.tsx +++ b/src/renderer/src/pages/home/Inputbar/MCPToolsButton.tsx @@ -454,7 +454,7 @@ const MCPToolsButton: FC = ({ ref, setInputValue, resizeTextArea, Toolbar })) return ( - + = ({ })) return ( - + diff --git a/src/renderer/src/pages/home/Inputbar/NewContextButton.tsx b/src/renderer/src/pages/home/Inputbar/NewContextButton.tsx index c8c2b9fced..26c9941cff 100644 --- a/src/renderer/src/pages/home/Inputbar/NewContextButton.tsx +++ b/src/renderer/src/pages/home/Inputbar/NewContextButton.tsx @@ -16,7 +16,11 @@ const NewContextButton: FC = ({ onNewContext, ToolbarButton }) => { useShortcut('toggle_new_context', onNewContext) return ( - + diff --git a/src/renderer/src/pages/home/Inputbar/QuickPhrasesButton.tsx b/src/renderer/src/pages/home/Inputbar/QuickPhrasesButton.tsx index d15c982a87..d6e9621fd5 100644 --- a/src/renderer/src/pages/home/Inputbar/QuickPhrasesButton.tsx +++ b/src/renderer/src/pages/home/Inputbar/QuickPhrasesButton.tsx @@ -148,7 +148,7 @@ const QuickPhrasesButton = ({ ref, setInputValue, resizeTextArea, ToolbarButton, return ( <> - + diff --git a/src/renderer/src/pages/home/Inputbar/ThinkingButton.tsx b/src/renderer/src/pages/home/Inputbar/ThinkingButton.tsx index 1338b03fcc..810d0158f4 100644 --- a/src/renderer/src/pages/home/Inputbar/ThinkingButton.tsx +++ b/src/renderer/src/pages/home/Inputbar/ThinkingButton.tsx @@ -190,7 +190,7 @@ const ThinkingButton: FC = ({ ref, model, assistant, ToolbarButton }): Re })) return ( - + {getThinkingIcon()} diff --git a/src/renderer/src/pages/home/Inputbar/WebSearchButton.tsx b/src/renderer/src/pages/home/Inputbar/WebSearchButton.tsx index c17f5fe2cc..6eeed391f4 100644 --- a/src/renderer/src/pages/home/Inputbar/WebSearchButton.tsx +++ b/src/renderer/src/pages/home/Inputbar/WebSearchButton.tsx @@ -127,7 +127,11 @@ const WebSearchButton: FC = ({ ref, assistant, ToolbarButton }) => { })) return ( - + Date: Thu, 10 Jul 2025 17:26:57 +0800 Subject: [PATCH 144/246] =?UTF-8?q?fix(McpToolChunkMiddleware):=20add=20lo?= =?UTF-8?q?gging=20for=20tool=20calls=20and=20enhance=20l=E2=80=A6=20(#802?= =?UTF-8?q?8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(McpToolChunkMiddleware): add logging for tool calls and enhance lookup logic --- .../src/aiCore/middleware/core/McpToolChunkMiddleware.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/aiCore/middleware/core/McpToolChunkMiddleware.ts b/src/renderer/src/aiCore/middleware/core/McpToolChunkMiddleware.ts index 29c35b0e15..b74c4895dc 100644 --- a/src/renderer/src/aiCore/middleware/core/McpToolChunkMiddleware.ts +++ b/src/renderer/src/aiCore/middleware/core/McpToolChunkMiddleware.ts @@ -253,7 +253,8 @@ async function executeToolCalls( (toolCall.name?.includes(confirmed.tool.name) || toolCall.name?.includes(confirmed.tool.id))) || confirmed.tool.name === toolCall.id || confirmed.tool.id === toolCall.id || - ('toolCallId' in confirmed && confirmed.toolCallId === toolCall.id) + ('toolCallId' in confirmed && confirmed.toolCallId === toolCall.id) || + ('function' in toolCall && toolCall.function.name.toLowerCase().includes(confirmed.tool.name.toLowerCase())) ) }) }) From 7e672d86e73383b83b8970205a57ca7b0b80d627 Mon Sep 17 00:00:00 2001 From: one Date: Thu, 10 Jul 2025 17:29:43 +0800 Subject: [PATCH 145/246] refactor: do not jump on enabling content search (#7922) * fix: content search count on enable * refactor(ContentSearch): do not jump on enabling content search * refactor: simplify result count --- src/renderer/src/components/ContentSearch.tsx | 51 +++++++++---------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/renderer/src/components/ContentSearch.tsx b/src/renderer/src/components/ContentSearch.tsx index a172d40570..6842312137 100644 --- a/src/renderer/src/components/ContentSearch.tsx +++ b/src/renderer/src/components/ContentSearch.tsx @@ -140,7 +140,7 @@ export const ContentSearch = React.forwardRef( const [isCaseSensitive, setIsCaseSensitive] = useState(false) const [isWholeWord, setIsWholeWord] = useState(false) const [allRanges, setAllRanges] = useState([]) - const [currentIndex, setCurrentIndex] = useState(0) + const [currentIndex, setCurrentIndex] = useState(-1) const prevSearchText = useRef('') const { t } = useTranslation() @@ -182,15 +182,18 @@ export const ContentSearch = React.forwardRef( [allRanges, currentIndex] ) - const search = useCallback(() => { - const searchText = searchInputRef.current?.value.trim() ?? null - setSearchCompleted(SearchCompletedState.Searched) - if (target && searchText !== null && searchText !== '') { - const ranges = findRangesInTarget(target, filter, searchText, isCaseSensitive, isWholeWord) - setAllRanges(ranges) - setCurrentIndex(0) - } - }, [target, filter, isCaseSensitive, isWholeWord]) + const search = useCallback( + (jump = false) => { + const searchText = searchInputRef.current?.value.trim() ?? null + setSearchCompleted(SearchCompletedState.Searched) + if (target && searchText !== null && searchText !== '') { + const ranges = findRangesInTarget(target, filter, searchText, isCaseSensitive, isWholeWord) + setAllRanges(ranges) + setCurrentIndex(jump && ranges.length > 0 ? 0 : -1) + } + }, + [target, filter, isCaseSensitive, isWholeWord] + ) const implementation = useMemo( () => ({ @@ -207,7 +210,7 @@ export const ContentSearch = React.forwardRef( requestAnimationFrame(() => { inputEl.focus() inputEl.select() - search() + search(false) }) } else { requestAnimationFrame(() => { @@ -231,11 +234,11 @@ export const ContentSearch = React.forwardRef( setSearchCompleted(SearchCompletedState.NotSearched) }, search: () => { - search() + search(true) locateByIndex(true) }, silentSearch: () => { - search() + search(false) locateByIndex(false) }, focus: () => { @@ -302,7 +305,7 @@ export const ContentSearch = React.forwardRef( useEffect(() => { if (enableContentSearch && searchInputRef.current?.value.trim()) { - search() + search(true) } }, [isCaseSensitive, isWholeWord, enableContentSearch, search]) @@ -365,16 +368,12 @@ export const ContentSearch = React.forwardRef( - {searchCompleted !== SearchCompletedState.NotSearched ? ( - allRanges.length > 0 ? ( - <> - {currentIndex + 1} - / - {allRanges.length} - - ) : ( - {t('common.no_results')} - ) + {searchCompleted !== SearchCompletedState.NotSearched && allRanges.length > 0 ? ( + <> + {currentIndex + 1} + / + {allRanges.length} + ) : ( 0/0 )} @@ -477,10 +476,6 @@ const SearchResultsPlaceholder = styled.span` opacity: 0.5; ` -const NoResults = styled.span` - color: var(--color-text-1); -` - const SearchResultCount = styled.span` color: var(--color-text); ` From fca93b6c5132683e0879d2ec3088323a618f6ea6 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Thu, 10 Jul 2025 18:59:00 +0800 Subject: [PATCH 146/246] style: update various component styles for improved layout and readability - Adjusted color for list items in color.scss for better contrast. - Modified line-height and margins in markdown.scss for improved text readability. - Changed height property in FloatingSidebar.tsx for consistent layout. - Increased padding in AgentsPage.tsx for better spacing. - Updated padding and border-radius in Inputbar.tsx for enhanced aesthetics. - Reduced margin in MessageHeader.tsx for tighter layout. - Refactored GroupTitle styles in AssistantsTab.tsx for better alignment and spacing. --- src/renderer/src/assets/styles/color.scss | 2 +- src/renderer/src/assets/styles/markdown.scss | 5 ++-- .../src/components/Popups/FloatingSidebar.tsx | 5 +++- src/renderer/src/pages/agents/AgentsPage.tsx | 2 +- .../src/pages/home/Inputbar/Inputbar.tsx | 4 ++-- .../src/pages/home/Messages/MessageHeader.tsx | 2 +- .../src/pages/home/Tabs/AssistantsTab.tsx | 24 ++++++++++++------- 7 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/renderer/src/assets/styles/color.scss b/src/renderer/src/assets/styles/color.scss index 3f23425afc..224566e199 100644 --- a/src/renderer/src/assets/styles/color.scss +++ b/src/renderer/src/assets/styles/color.scss @@ -44,7 +44,7 @@ --color-reference-text: #ffffff; --color-reference-background: #0b0e12; - --color-list-item: #222; + --color-list-item: #252525; --color-list-item-hover: #1e1e1e; --modal-background: #111111; diff --git a/src/renderer/src/assets/styles/markdown.scss b/src/renderer/src/assets/styles/markdown.scss index b5c2ee17d1..19e10df41f 100644 --- a/src/renderer/src/assets/styles/markdown.scss +++ b/src/renderer/src/assets/styles/markdown.scss @@ -1,6 +1,6 @@ .markdown { color: var(--color-text); - line-height: 2; + line-height: 1.6; user-select: text; word-break: break-word; letter-spacing: 0.02em; @@ -21,7 +21,7 @@ h4, h5, h6 { - margin: 2em 0 1em 0; + margin: 1.5em 0 1em 0; line-height: 1.3; font-weight: bold; font-family: var(--font-family); @@ -60,6 +60,7 @@ margin: 1.3em 0; white-space: pre-wrap; text-align: justify; + line-height: 2; &:last-child { margin-bottom: 5px; diff --git a/src/renderer/src/components/Popups/FloatingSidebar.tsx b/src/renderer/src/components/Popups/FloatingSidebar.tsx index 1c281bc0d2..3fc464465e 100644 --- a/src/renderer/src/components/Popups/FloatingSidebar.tsx +++ b/src/renderer/src/components/Popups/FloatingSidebar.tsx @@ -54,7 +54,7 @@ const FloatingSidebar: FC = ({ style={{ background: 'transparent', border: 'none', - maxHeight: maxHeight + height: '100%' }} /> @@ -82,6 +82,9 @@ const FloatingSidebar: FC = ({ const PopoverContent = styled.div<{ maxHeight: number }>` max-height: ${(props) => props.maxHeight}px; + &.ant-popover-inner-content { + overflow-y: hidden; + } ` export default FloatingSidebar diff --git a/src/renderer/src/pages/agents/AgentsPage.tsx b/src/renderer/src/pages/agents/AgentsPage.tsx index 1a8e3ce990..dbcb7c5e57 100644 --- a/src/renderer/src/pages/agents/AgentsPage.tsx +++ b/src/renderer/src/pages/agents/AgentsPage.tsx @@ -266,7 +266,7 @@ const AgentsGroupList = styled(Scrollbar)` display: flex; flex-direction: column; gap: 8px; - padding: 8px 0; + padding: 12px 0; border-right: 0.5px solid var(--color-border); border-top-left-radius: inherit; border-bottom-left-radius: inherit; diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index a07f7b73b2..6bc5623b75 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -955,14 +955,14 @@ const Container = styled.div` flex-direction: column; position: relative; z-index: 2; - padding: 0 16px 16px 16px; + padding: 0 20px 18px 20px; ` const InputBarContainer = styled.div` border: 0.5px solid var(--color-border); transition: all 0.2s ease; position: relative; - border-radius: 15px; + border-radius: 20px; padding-top: 8px; // 为拖动手柄留出空间 background-color: var(--color-background-opacity); diff --git a/src/renderer/src/pages/home/Messages/MessageHeader.tsx b/src/renderer/src/pages/home/Messages/MessageHeader.tsx index ddeae08c27..d3f76232a9 100644 --- a/src/renderer/src/pages/home/Messages/MessageHeader.tsx +++ b/src/renderer/src/pages/home/Messages/MessageHeader.tsx @@ -126,7 +126,7 @@ const Container = styled.div` align-items: center; gap: 10px; position: relative; - margin-bottom: 8px; + margin-bottom: 5px; ` const UserWrap = styled.div` diff --git a/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx b/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx index a089bd536b..20e3456be6 100644 --- a/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/AssistantsTab.tsx @@ -6,7 +6,7 @@ import { useAssistants } from '@renderer/hooks/useAssistant' import { useAssistantsTabSortType } from '@renderer/hooks/useStore' import { useTags } from '@renderer/hooks/useTags' import { Assistant, AssistantsSortType } from '@renderer/types' -import { Divider, Tooltip } from 'antd' +import { Tooltip } from 'antd' import { FC, useCallback, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import styled from 'styled-components' @@ -87,7 +87,7 @@ const Assistants: FC = ({ {group.tag} - + )} {!collapsedTags[group.tag] && ( @@ -198,13 +198,16 @@ const AssistantAddItem = styled.div` ` const GroupTitle = styled.div` - padding: 8px 0; - position: relative; color: var(--color-text-2); font-size: 12px; font-weight: 500; - margin-bottom: -8px; cursor: pointer; + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + height: 24px; + margin: 5px 0; ` const GroupTitleName = styled.div` @@ -212,13 +215,18 @@ const GroupTitleName = styled.div` text-overflow: ellipsis; white-space: nowrap; overflow: hidden; - background-color: var(--color-background); box-sizing: border-box; padding: 0 4px; color: var(--color-text); - position: absolute; - transform: translateY(2px); font-size: 13px; + line-height: 24px; + margin-right: 5px; + display: flex; +` + +const GroupTitleDivider = styled.div` + flex: 1; + border-top: 1px solid var(--color-border); ` const AssistantName = styled.div` From db642f08372b70310efcc22d1330cf70a7f3a2df Mon Sep 17 00:00:00 2001 From: SuYao Date: Thu, 10 Jul 2025 19:27:53 +0800 Subject: [PATCH 147/246] feat(models): support Grok4 (#8032) refactor(models): rename and enhance reasoning model functions for clarity and functionality --- src/renderer/src/config/models.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/config/models.ts b/src/renderer/src/config/models.ts index f05a0447b3..c162dab6ea 100644 --- a/src/renderer/src/config/models.ts +++ b/src/renderer/src/config/models.ts @@ -2487,7 +2487,7 @@ export function isGrokModel(model?: Model): boolean { return model.id.includes('grok') } -export function isGrokReasoningModel(model?: Model): boolean { +export function isSupportedReasoningEffortGrokModel(model?: Model): boolean { if (!model) { return false } @@ -2499,7 +2499,16 @@ export function isGrokReasoningModel(model?: Model): boolean { return false } -export const isSupportedReasoningEffortGrokModel = isGrokReasoningModel +export function isGrokReasoningModel(model?: Model): boolean { + if (!model) { + return false + } + if (isSupportedReasoningEffortGrokModel(model) || model.id.includes('grok-4')) { + return true + } + + return false +} export function isGeminiReasoningModel(model?: Model): boolean { if (!model) { From 2a72f391b71debb9b26b67319a1a602526e49bb9 Mon Sep 17 00:00:00 2001 From: one Date: Thu, 10 Jul 2025 19:32:51 +0800 Subject: [PATCH 148/246] feat: codeblock dot language (#6783) * feat(CodeBlock): support dot language in code block - render DOT using @viz-js/viz - highlight DOT using @viz-js/lang-dot (CodeEditor only) - extract a special view map, update file structure - extract and reuse the PreviewError component across special views - update dependencies, fix peer dependencies * chore: prepare for merge --- package.json | 4 + src/renderer/src/assets/styles/markdown.scss | 4 +- .../components/CodeBlockView/CodePreview.tsx | 8 +- .../CodeBlockView/GraphvizPreview.tsx | 102 +++++++++++++++ .../CodeBlockView/MermaidPreview.tsx | 22 +--- .../CodeBlockView/PlantUmlPreview.tsx | 13 +- .../components/CodeBlockView/PreviewError.tsx | 14 ++ .../components/CodeBlockView/SvgPreview.tsx | 11 +- .../src/components/CodeBlockView/constants.ts | 20 +++ .../src/components/CodeBlockView/index.ts | 2 + .../src/components/CodeBlockView/types.ts | 14 ++ .../CodeBlockView/{index.tsx => view.tsx} | 31 ++--- .../src/components/CodeEditor/hooks.ts | 122 ++++++++++++++---- .../src/context/CodeStyleProvider.tsx | 3 +- .../src/pages/home/Markdown/CodeBlock.tsx | 2 +- yarn.lock | 32 ++++- 16 files changed, 314 insertions(+), 90 deletions(-) create mode 100644 src/renderer/src/components/CodeBlockView/GraphvizPreview.tsx create mode 100644 src/renderer/src/components/CodeBlockView/PreviewError.tsx create mode 100644 src/renderer/src/components/CodeBlockView/constants.ts create mode 100644 src/renderer/src/components/CodeBlockView/index.ts create mode 100644 src/renderer/src/components/CodeBlockView/types.ts rename src/renderer/src/components/CodeBlockView/{index.tsx => view.tsx} (91%) diff --git a/package.json b/package.json index e56b1e261c..c718dce1a7 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "@cherrystudio/embedjs-loader-xml": "^0.1.31", "@cherrystudio/embedjs-ollama": "^0.1.31", "@cherrystudio/embedjs-openai": "^0.1.31", + "@codemirror/view": "^6.0.0", "@electron-toolkit/eslint-config-prettier": "^3.0.0", "@electron-toolkit/eslint-config-ts": "^3.0.0", "@electron-toolkit/preload": "^3.0.0", @@ -141,6 +142,8 @@ "@vitest/coverage-v8": "^3.1.4", "@vitest/ui": "^3.1.4", "@vitest/web-worker": "^3.1.4", + "@viz-js/lang-dot": "^1.0.5", + "@viz-js/viz": "^3.14.0", "@xyflow/react": "^12.4.4", "antd": "patch:antd@npm%3A5.24.7#~/.yarn/patches/antd-npm-5.24.7-356a553ae5.patch", "archiver": "^7.0.1", @@ -225,6 +228,7 @@ "tiny-pinyin": "^1.3.2", "tokenx": "^1.1.0", "typescript": "^5.6.2", + "unified": "^11.0.5", "uuid": "^10.0.0", "vite": "6.2.6", "vitest": "^3.1.4", diff --git a/src/renderer/src/assets/styles/markdown.scss b/src/renderer/src/assets/styles/markdown.scss index 19e10df41f..e34f649129 100644 --- a/src/renderer/src/assets/styles/markdown.scss +++ b/src/renderer/src/assets/styles/markdown.scss @@ -129,9 +129,7 @@ overflow-x: auto; font-family: 'Fira Code', 'Courier New', Courier, monospace; background-color: var(--color-background-mute); - &:has(.mermaid), - &:has(.plantuml-preview), - &:has(.svg-preview) { + &:has(.special-preview) { background-color: transparent; } &:not(pre pre) { diff --git a/src/renderer/src/components/CodeBlockView/CodePreview.tsx b/src/renderer/src/components/CodeBlockView/CodePreview.tsx index 3df9491e13..b4da2d4eee 100644 --- a/src/renderer/src/components/CodeBlockView/CodePreview.tsx +++ b/src/renderer/src/components/CodeBlockView/CodePreview.tsx @@ -1,4 +1,4 @@ -import { CodeTool, TOOL_SPECS, useCodeTool } from '@renderer/components/CodeToolbar' +import { TOOL_SPECS, useCodeTool } from '@renderer/components/CodeToolbar' import { useCodeStyle } from '@renderer/context/CodeStyleProvider' import { useCodeHighlight } from '@renderer/hooks/useCodeHighlight' import { useSettings } from '@renderer/hooks/useSettings' @@ -12,10 +12,10 @@ import { useTranslation } from 'react-i18next' import { ThemedToken } from 'shiki/core' import styled from 'styled-components' -interface CodePreviewProps { - children: string +import { BasicPreviewProps } from './types' + +interface CodePreviewProps extends BasicPreviewProps { language: string - setTools?: (value: React.SetStateAction) => void } const MAX_COLLAPSE_HEIGHT = 350 diff --git a/src/renderer/src/components/CodeBlockView/GraphvizPreview.tsx b/src/renderer/src/components/CodeBlockView/GraphvizPreview.tsx new file mode 100644 index 0000000000..452ed1261b --- /dev/null +++ b/src/renderer/src/components/CodeBlockView/GraphvizPreview.tsx @@ -0,0 +1,102 @@ +import { usePreviewToolHandlers, usePreviewTools } from '@renderer/components/CodeToolbar' +import SvgSpinners180Ring from '@renderer/components/Icons/SvgSpinners180Ring' +import { AsyncInitializer } from '@renderer/utils/asyncInitializer' +import { Flex, Spin } from 'antd' +import { debounce } from 'lodash' +import React, { memo, startTransition, useCallback, useEffect, useMemo, useRef, useState } from 'react' +import styled from 'styled-components' + +import PreviewError from './PreviewError' +import { BasicPreviewProps } from './types' + +// 管理 viz 实例 +const vizInitializer = new AsyncInitializer(async () => { + const module = await import('@viz-js/viz') + return await module.instance() +}) + +/** 预览 Graphviz 图表 + * 通过防抖渲染提供比较统一的体验,减少闪烁。 + */ +const GraphvizPreview: React.FC = ({ children, setTools }) => { + const graphvizRef = useRef(null) + const [error, setError] = useState(null) + const [isLoading, setIsLoading] = useState(false) + + // 使用通用图像工具 + const { handleZoom, handleCopyImage, handleDownload } = usePreviewToolHandlers(graphvizRef, { + imgSelector: 'svg', + prefix: 'graphviz', + enableWheelZoom: true + }) + + // 使用工具栏 + usePreviewTools({ + setTools, + handleZoom, + handleCopyImage, + handleDownload + }) + + // 实际的渲染函数 + const renderGraphviz = useCallback(async (content: string) => { + if (!content || !graphvizRef.current) return + + try { + setIsLoading(true) + + const viz = await vizInitializer.get() + const svgElement = viz.renderSVGElement(content) + + // 清空容器并添加新的 SVG + graphvizRef.current.innerHTML = '' + graphvizRef.current.appendChild(svgElement) + + // 渲染成功,清除错误记录 + setError(null) + } catch (error) { + setError((error as Error).message || 'DOT syntax error or rendering failed') + } finally { + setIsLoading(false) + } + }, []) + + // debounce 渲染 + const debouncedRender = useMemo( + () => + debounce((content: string) => { + startTransition(() => renderGraphviz(content)) + }, 300), + [renderGraphviz] + ) + + // 触发渲染 + useEffect(() => { + if (children) { + setIsLoading(true) + debouncedRender(children) + } else { + debouncedRender.cancel() + setIsLoading(false) + } + + return () => { + debouncedRender.cancel() + } + }, [children, debouncedRender]) + + return ( + }> + + {error && {error}} + + + + ) +} + +const StyledGraphviz = styled.div` + overflow: auto; +` + +export default memo(GraphvizPreview) diff --git a/src/renderer/src/components/CodeBlockView/MermaidPreview.tsx b/src/renderer/src/components/CodeBlockView/MermaidPreview.tsx index d461b2899c..be3e0b7e08 100644 --- a/src/renderer/src/components/CodeBlockView/MermaidPreview.tsx +++ b/src/renderer/src/components/CodeBlockView/MermaidPreview.tsx @@ -1,5 +1,5 @@ import { nanoid } from '@reduxjs/toolkit' -import { CodeTool, usePreviewToolHandlers, usePreviewTools } from '@renderer/components/CodeToolbar' +import { usePreviewToolHandlers, usePreviewTools } from '@renderer/components/CodeToolbar' import SvgSpinners180Ring from '@renderer/components/Icons/SvgSpinners180Ring' import { useMermaid } from '@renderer/hooks/useMermaid' import { Flex, Spin } from 'antd' @@ -7,16 +7,14 @@ import { debounce } from 'lodash' import React, { memo, startTransition, useCallback, useEffect, useMemo, useRef, useState } from 'react' import styled from 'styled-components' -interface Props { - children: string - setTools?: (value: React.SetStateAction) => void -} +import PreviewError from './PreviewError' +import { BasicPreviewProps } from './types' /** 预览 Mermaid 图表 * 通过防抖渲染提供比较统一的体验,减少闪烁。 * FIXME: 等将来容易判断代码块结束位置时再重构。 */ -const MermaidPreview: React.FC = ({ children, setTools }) => { +const MermaidPreview: React.FC = ({ children, setTools }) => { const { mermaid, isLoading: isLoadingMermaid, error: mermaidError } = useMermaid() const mermaidRef = useRef(null) const diagramId = useRef(`mermaid-${nanoid(6)}`).current @@ -143,7 +141,7 @@ const MermaidPreview: React.FC = ({ children, setTools }) => { return ( }> - {(mermaidError || error) && {mermaidError || error}} + {(mermaidError || error) && {mermaidError || error}} @@ -154,14 +152,4 @@ const StyledMermaid = styled.div` overflow: auto; ` -const StyledError = styled.div` - overflow: auto; - padding: 16px; - color: #ff4d4f; - border: 1px solid #ff4d4f; - border-radius: 4px; - word-wrap: break-word; - white-space: pre-wrap; -` - export default memo(MermaidPreview) diff --git a/src/renderer/src/components/CodeBlockView/PlantUmlPreview.tsx b/src/renderer/src/components/CodeBlockView/PlantUmlPreview.tsx index 35ef90e12e..0916056039 100644 --- a/src/renderer/src/components/CodeBlockView/PlantUmlPreview.tsx +++ b/src/renderer/src/components/CodeBlockView/PlantUmlPreview.tsx @@ -1,11 +1,13 @@ import { LoadingOutlined } from '@ant-design/icons' -import { CodeTool, usePreviewToolHandlers, usePreviewTools } from '@renderer/components/CodeToolbar' +import { usePreviewToolHandlers, usePreviewTools } from '@renderer/components/CodeToolbar' import { Spin } from 'antd' import pako from 'pako' import React, { memo, useCallback, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import styled from 'styled-components' +import { BasicPreviewProps } from './types' + const PlantUMLServer = 'https://www.plantuml.com/plantuml' function encode64(data: Uint8Array) { let r = '' @@ -132,12 +134,7 @@ const PlantUMLServerImage: React.FC = ({ format, diagr ) } -interface PlantUMLProps { - children: string - setTools?: (value: React.SetStateAction) => void -} - -const PlantUmlPreview: React.FC = ({ children, setTools }) => { +const PlantUmlPreview: React.FC = ({ children, setTools }) => { const { t } = useTranslation() const containerRef = useRef(null) @@ -174,7 +171,7 @@ const PlantUmlPreview: React.FC = ({ children, setTools }) => { return (
- +
) } diff --git a/src/renderer/src/components/CodeBlockView/PreviewError.tsx b/src/renderer/src/components/CodeBlockView/PreviewError.tsx new file mode 100644 index 0000000000..1139dea7ff --- /dev/null +++ b/src/renderer/src/components/CodeBlockView/PreviewError.tsx @@ -0,0 +1,14 @@ +import { memo } from 'react' +import { styled } from 'styled-components' + +const PreviewError = styled.div` + overflow: auto; + padding: 16px; + color: #ff4d4f; + border: 1px solid #ff4d4f; + border-radius: 4px; + word-wrap: break-word; + white-space: pre-wrap; +` + +export default memo(PreviewError) diff --git a/src/renderer/src/components/CodeBlockView/SvgPreview.tsx b/src/renderer/src/components/CodeBlockView/SvgPreview.tsx index 9180aef297..fe60101519 100644 --- a/src/renderer/src/components/CodeBlockView/SvgPreview.tsx +++ b/src/renderer/src/components/CodeBlockView/SvgPreview.tsx @@ -1,15 +1,12 @@ -import { CodeTool, usePreviewToolHandlers, usePreviewTools } from '@renderer/components/CodeToolbar' +import { usePreviewToolHandlers, usePreviewTools } from '@renderer/components/CodeToolbar' import { memo, useEffect, useRef } from 'react' -interface Props { - children: string - setTools?: (value: React.SetStateAction) => void -} +import { BasicPreviewProps } from './types' /** * 使用 Shadow DOM 渲染 SVG */ -const SvgPreview: React.FC = ({ children, setTools }) => { +const SvgPreview: React.FC = ({ children, setTools }) => { const svgContainerRef = useRef(null) useEffect(() => { @@ -58,7 +55,7 @@ const SvgPreview: React.FC = ({ children, setTools }) => { handleDownload }) - return
+ return
} export default memo(SvgPreview) diff --git a/src/renderer/src/components/CodeBlockView/constants.ts b/src/renderer/src/components/CodeBlockView/constants.ts new file mode 100644 index 0000000000..fc6687d5f1 --- /dev/null +++ b/src/renderer/src/components/CodeBlockView/constants.ts @@ -0,0 +1,20 @@ +import GraphvizPreview from './GraphvizPreview' +import MermaidPreview from './MermaidPreview' +import PlantUmlPreview from './PlantUmlPreview' +import SvgPreview from './SvgPreview' + +/** + * 特殊视图语言列表 + */ +export const SPECIAL_VIEWS = ['mermaid', 'plantuml', 'svg', 'dot', 'graphviz'] + +/** + * 特殊视图组件映射表 + */ +export const SPECIAL_VIEW_COMPONENTS = { + mermaid: MermaidPreview, + plantuml: PlantUmlPreview, + svg: SvgPreview, + dot: GraphvizPreview, + graphviz: GraphvizPreview +} as const diff --git a/src/renderer/src/components/CodeBlockView/index.ts b/src/renderer/src/components/CodeBlockView/index.ts new file mode 100644 index 0000000000..dfb88d252d --- /dev/null +++ b/src/renderer/src/components/CodeBlockView/index.ts @@ -0,0 +1,2 @@ +export * from './types' +export * from './view' diff --git a/src/renderer/src/components/CodeBlockView/types.ts b/src/renderer/src/components/CodeBlockView/types.ts new file mode 100644 index 0000000000..5ec413658f --- /dev/null +++ b/src/renderer/src/components/CodeBlockView/types.ts @@ -0,0 +1,14 @@ +import { CodeTool } from '@renderer/components/CodeToolbar' + +/** + * 预览组件的基本 props + */ +export interface BasicPreviewProps { + children: string + setTools?: (value: React.SetStateAction) => void +} + +/** + * 视图模式 + */ +export type ViewMode = 'source' | 'special' | 'split' diff --git a/src/renderer/src/components/CodeBlockView/index.tsx b/src/renderer/src/components/CodeBlockView/view.tsx similarity index 91% rename from src/renderer/src/components/CodeBlockView/index.tsx rename to src/renderer/src/components/CodeBlockView/view.tsx index 0a03b68754..7d557d9247 100644 --- a/src/renderer/src/components/CodeBlockView/index.tsx +++ b/src/renderer/src/components/CodeBlockView/view.tsx @@ -12,13 +12,10 @@ import { useTranslation } from 'react-i18next' import styled from 'styled-components' import CodePreview from './CodePreview' +import { SPECIAL_VIEW_COMPONENTS, SPECIAL_VIEWS } from './constants' import HtmlArtifactsCard from './HtmlArtifactsCard' -import MermaidPreview from './MermaidPreview' -import PlantUmlPreview from './PlantUmlPreview' import StatusBar from './StatusBar' -import SvgPreview from './SvgPreview' - -type ViewMode = 'source' | 'special' | 'split' +import { ViewMode } from './types' interface Props { children: string @@ -42,7 +39,7 @@ interface Props { * - quick 工具 * - core 工具 */ -const CodeBlockView: React.FC = ({ children, language, onSave }) => { +export const CodeBlockView: React.FC = memo(({ children, language, onSave }) => { const { t } = useTranslation() const { codeEditor, codeExecution } = useSettings() @@ -57,7 +54,7 @@ const CodeBlockView: React.FC = ({ children, language, onSave }) => { return codeExecution.enabled && language === 'python' }, [codeExecution.enabled, language]) - const hasSpecialView = useMemo(() => ['mermaid', 'plantuml', 'svg'].includes(language), [language]) + const hasSpecialView = useMemo(() => SPECIAL_VIEWS.includes(language), [language]) const isInSpecialView = useMemo(() => { return hasSpecialView && viewMode === 'special' @@ -201,14 +198,16 @@ const CodeBlockView: React.FC = ({ children, language, onSave }) => { // 特殊视图组件映射 const specialView = useMemo(() => { - if (language === 'mermaid') { - return {children} - } else if (language === 'plantuml' && isValidPlantUML(children)) { - return {children} - } else if (language === 'svg') { - return {children} + const SpecialView = SPECIAL_VIEW_COMPONENTS[language as keyof typeof SPECIAL_VIEW_COMPONENTS] + + if (!SpecialView) return null + + // PlantUML 语法验证 + if (language === 'plantuml' && !isValidPlantUML(children)) { + return null } - return null + + return {children} }, [children, language]) const renderHeader = useMemo(() => { @@ -242,7 +241,7 @@ const CodeBlockView: React.FC = ({ children, language, onSave }) => { {isExecutable && output && {output}} ) -} +}) const CodeBlockWrapper = styled.div<{ $isInSpecialView: boolean }>` position: relative; @@ -293,5 +292,3 @@ const SplitViewWrapper = styled.div` overflow: hidden; } ` - -export default memo(CodeBlockView) diff --git a/src/renderer/src/components/CodeEditor/hooks.ts b/src/renderer/src/components/CodeEditor/hooks.ts index 71d74ca3a5..5a04b2178d 100644 --- a/src/renderer/src/components/CodeEditor/hooks.ts +++ b/src/renderer/src/components/CodeEditor/hooks.ts @@ -12,45 +12,111 @@ const linterLoaders: Record Promise> = { } } +/** + * 特殊语言加载器 + */ +const specialLanguageLoaders: Record Promise> = { + dot: async () => { + const mod = await import('@viz-js/lang-dot') + return mod.dot() + } +} + +/** + * 加载语言扩展 + */ +async function loadLanguageExtension(language: string, languageMap: Record): Promise { + let normalizedLang = languageMap[language as keyof typeof languageMap] || language.toLowerCase() + + // 如果语言名包含 `-`,转换为驼峰命名法 + if (normalizedLang.includes('-')) { + normalizedLang = normalizedLang.replace(/-([a-z])/g, (_, char) => char.toUpperCase()) + } + + // 尝试加载特殊语言 + const specialLoader = specialLanguageLoaders[normalizedLang] + if (specialLoader) { + try { + return await specialLoader() + } catch (error) { + console.debug(`Failed to load language ${normalizedLang}`, error) + return null + } + } + + // 回退到 uiw/codemirror 包含的语言 + try { + const { loadLanguage } = await import('@uiw/codemirror-extensions-langs') + const extension = loadLanguage(normalizedLang as any) + return extension || null + } catch (error) { + console.debug(`Failed to load language ${normalizedLang}`, error) + return null + } +} + +/** + * 加载 linter 扩展 + */ +async function loadLinterExtension(language: string): Promise { + const loader = linterLoaders[language] + if (!loader) return null + + try { + return await loader() + } catch (error) { + console.debug(`Failed to load linter for ${language}`, error) + return null + } +} + +/** + * 加载语言相关扩展 + */ export const useLanguageExtensions = (language: string, lint?: boolean) => { const { languageMap } = useCodeStyle() const [extensions, setExtensions] = useState([]) - // 加载语言 useEffect(() => { - let normalizedLang = languageMap[language as keyof typeof languageMap] || language.toLowerCase() + let cancelled = false - // 如果语言名包含 `-`,转换为驼峰命名法 - if (normalizedLang.includes('-')) { - normalizedLang = normalizedLang.replace(/-([a-z])/g, (_, char) => char.toUpperCase()) - } + const loadAllExtensions = async () => { + try { + // 加载所有扩展 + const [languageResult, linterResult] = await Promise.allSettled([ + loadLanguageExtension(language, languageMap), + lint ? loadLinterExtension(language) : Promise.resolve(null) + ]) - import('@uiw/codemirror-extensions-langs') - .then(({ loadLanguage }) => { - const extension = loadLanguage(normalizedLang as any) - if (extension) { - setExtensions((prev) => [...prev, extension]) + if (cancelled) return + + const results: Extension[] = [] + + // 语言扩展 + if (languageResult.status === 'fulfilled' && languageResult.value) { + results.push(languageResult.value) } - }) - .catch((error) => { - console.debug(`Failed to load language: ${normalizedLang}`, error) - }) - }, [language, languageMap]) - useEffect(() => { - if (!lint) return + // linter 扩展 + if (linterResult.status === 'fulfilled' && linterResult.value) { + results.push(linterResult.value) + } - const loader = linterLoaders[language] - if (loader) { - loader() - .then((extension) => { - setExtensions((prev) => [...prev, extension]) - }) - .catch((error) => { - console.error(`Failed to load linter for ${language}`, error) - }) + setExtensions(results) + } catch (error) { + if (!cancelled) { + console.debug('Failed to load language extensions:', error) + setExtensions([]) + } + } } - }, [language, lint]) + + loadAllExtensions() + + return () => { + cancelled = true + } + }, [language, lint, languageMap]) return extensions } diff --git a/src/renderer/src/context/CodeStyleProvider.tsx b/src/renderer/src/context/CodeStyleProvider.tsx index e702d4847d..c14364b7b0 100644 --- a/src/renderer/src/context/CodeStyleProvider.tsx +++ b/src/renderer/src/context/CodeStyleProvider.tsx @@ -99,7 +99,8 @@ export const CodeStyleProvider: React.FC = ({ children }) => bash: 'shell', 'objective-c++': 'objective-cpp', svg: 'xml', - vab: 'vb' + vab: 'vb', + graphviz: 'dot' } as Record }, []) diff --git a/src/renderer/src/pages/home/Markdown/CodeBlock.tsx b/src/renderer/src/pages/home/Markdown/CodeBlock.tsx index f6a2905448..a496706cbb 100644 --- a/src/renderer/src/pages/home/Markdown/CodeBlock.tsx +++ b/src/renderer/src/pages/home/Markdown/CodeBlock.tsx @@ -1,4 +1,4 @@ -import CodeBlockView from '@renderer/components/CodeBlockView' +import { CodeBlockView } from '@renderer/components/CodeBlockView' import React, { memo, useCallback } from 'react' interface Props { diff --git a/yarn.lock b/yarn.lock index 3514bc0850..e2a45ec2ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3412,7 +3412,7 @@ __metadata: languageName: node linkType: hard -"@lezer/common@npm:^1.0.0, @lezer/common@npm:^1.0.2, @lezer/common@npm:^1.1.0, @lezer/common@npm:^1.2.0, @lezer/common@npm:^1.2.1": +"@lezer/common@npm:^1.0.0, @lezer/common@npm:^1.0.2, @lezer/common@npm:^1.0.3, @lezer/common@npm:^1.1.0, @lezer/common@npm:^1.2.0, @lezer/common@npm:^1.2.1": version: 1.2.3 resolution: "@lezer/common@npm:1.2.3" checksum: 10c0/fe9f8e111080ef94037a34ca2af1221c8d01c1763ba5ecf708a286185c76119509a5d19d924c8842172716716ddce22d7834394670c4a9432f0ba9f3b7c0f50d @@ -3515,7 +3515,7 @@ __metadata: languageName: node linkType: hard -"@lezer/lr@npm:^1.0.0, @lezer/lr@npm:^1.1.0, @lezer/lr@npm:^1.3.0, @lezer/lr@npm:^1.3.1, @lezer/lr@npm:^1.3.10, @lezer/lr@npm:^1.3.3, @lezer/lr@npm:^1.4.0": +"@lezer/lr@npm:^1.0.0, @lezer/lr@npm:^1.1.0, @lezer/lr@npm:^1.3.0, @lezer/lr@npm:^1.3.1, @lezer/lr@npm:^1.3.10, @lezer/lr@npm:^1.3.3, @lezer/lr@npm:^1.4.0, @lezer/lr@npm:^1.4.2": version: 1.4.2 resolution: "@lezer/lr@npm:1.4.2" dependencies: @@ -3578,7 +3578,7 @@ __metadata: languageName: node linkType: hard -"@lezer/xml@npm:^1.0.0": +"@lezer/xml@npm:^1.0.0, @lezer/xml@npm:^1.0.2": version: 1.0.6 resolution: "@lezer/xml@npm:1.0.6" dependencies: @@ -6962,6 +6962,26 @@ __metadata: languageName: node linkType: hard +"@viz-js/lang-dot@npm:^1.0.5": + version: 1.0.5 + resolution: "@viz-js/lang-dot@npm:1.0.5" + dependencies: + "@codemirror/language": "npm:^6.8.0" + "@lezer/common": "npm:^1.0.3" + "@lezer/highlight": "npm:^1.1.6" + "@lezer/lr": "npm:^1.4.2" + "@lezer/xml": "npm:^1.0.2" + checksum: 10c0/86e81bf077e0a6f418fe2d5cfd8d7f7a7c032bdec13e5dfe3d21620c548e674832f6c9b300eeaad7b0842a3c4044d4ce33d5af9e359ae1efeda0a84d772b77a4 + languageName: node + linkType: hard + +"@viz-js/viz@npm:^3.14.0": + version: 3.14.0 + resolution: "@viz-js/viz@npm:3.14.0" + checksum: 10c0/901afa2d99e8f33cc4abf352f1559e0c16958e01f0750a65a33799aebfe175a18d74f6945f1ff93f64b53b69976dc3d07d39d65c58dda955abd0979dacc4294c + languageName: node + linkType: hard + "@vue/compiler-core@npm:3.5.17": version: 3.5.17 resolution: "@vue/compiler-core@npm:3.5.17" @@ -7075,6 +7095,7 @@ __metadata: "@cherrystudio/embedjs-openai": "npm:^0.1.31" "@cherrystudio/mac-system-ocr": "npm:^0.2.2" "@cherrystudio/pdf-to-img-napi": "npm:^0.0.1" + "@codemirror/view": "npm:^6.0.0" "@electron-toolkit/eslint-config-prettier": "npm:^3.0.0" "@electron-toolkit/eslint-config-ts": "npm:^3.0.0" "@electron-toolkit/preload": "npm:^3.0.0" @@ -7127,6 +7148,8 @@ __metadata: "@vitest/coverage-v8": "npm:^3.1.4" "@vitest/ui": "npm:^3.1.4" "@vitest/web-worker": "npm:^3.1.4" + "@viz-js/lang-dot": "npm:^1.0.5" + "@viz-js/viz": "npm:^3.14.0" "@xyflow/react": "npm:^12.4.4" antd: "patch:antd@npm%3A5.24.7#~/.yarn/patches/antd-npm-5.24.7-356a553ae5.patch" archiver: "npm:^7.0.1" @@ -7221,6 +7244,7 @@ __metadata: tokenx: "npm:^1.1.0" turndown: "npm:7.2.0" typescript: "npm:^5.6.2" + unified: "npm:^11.0.5" uuid: "npm:^10.0.0" vite: "npm:6.2.6" vitest: "npm:^3.1.4" @@ -19565,7 +19589,7 @@ __metadata: languageName: node linkType: hard -"unified@npm:^11.0.0": +"unified@npm:^11.0.0, unified@npm:^11.0.5": version: 11.0.5 resolution: "unified@npm:11.0.5" dependencies: From 92be3c0f568d7e6cc67b8d1fa15751131bfbb90a Mon Sep 17 00:00:00 2001 From: one Date: Thu, 10 Jul 2025 19:34:57 +0800 Subject: [PATCH 149/246] chore: update vscode settings (#7974) * chore: update vscode settings * refactor: add editorconfig to extensions --- .vscode/extensions.json | 2 +- .vscode/settings.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 940260d856..ef0b29b6a6 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["dbaeumer.vscode-eslint"] + "recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "editorconfig.editorconfig"] } diff --git a/.vscode/settings.json b/.vscode/settings.json index ef4dc3954a..edf514d5ef 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,6 +4,7 @@ "source.fixAll.eslint": "explicit", "source.organizeImports": "never" }, + "files.eol": "\n", "search.exclude": { "**/dist/**": true, ".yarn/releases/**": true From 855499681f1425fea824e114d3fd18a2e9480867 Mon Sep 17 00:00:00 2001 From: Konv Suu <2583695112@qq.com> Date: Thu, 10 Jul 2025 19:37:18 +0800 Subject: [PATCH 150/246] feat: add confirm for unsaved content in creating agent (#7965) --- src/renderer/src/i18n/locales/en-us.json | 1 + src/renderer/src/i18n/locales/ja-jp.json | 1 + src/renderer/src/i18n/locales/ru-ru.json | 1 + src/renderer/src/i18n/locales/zh-cn.json | 1 + src/renderer/src/i18n/locales/zh-tw.json | 1 + .../pages/agents/components/AddAgentPopup.tsx | 35 ++++++++++++++++--- 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json index 5f27ecefed..1d22b73878 100644 --- a/src/renderer/src/i18n/locales/en-us.json +++ b/src/renderer/src/i18n/locales/en-us.json @@ -13,6 +13,7 @@ "title": "Available variables" }, "add.title": "Create Agent", + "add.unsaved_changes_warning": "You have unsaved changes. Are you sure you want to close?", "delete.popup.content": "Are you sure you want to delete this agent?", "edit.model.select.title": "Select Model", "edit.title": "Edit Agent", diff --git a/src/renderer/src/i18n/locales/ja-jp.json b/src/renderer/src/i18n/locales/ja-jp.json index a803e2a081..f76623aec0 100644 --- a/src/renderer/src/i18n/locales/ja-jp.json +++ b/src/renderer/src/i18n/locales/ja-jp.json @@ -13,6 +13,7 @@ "title": "利用可能な変数" }, "add.title": "エージェントを作成", + "add.unsaved_changes_warning": "未保存の変更があります。続行しますか?", "delete.popup.content": "このエージェントを削除してもよろしいですか?", "edit.model.select.title": "モデルを選択", "edit.title": "エージェントを編集", diff --git a/src/renderer/src/i18n/locales/ru-ru.json b/src/renderer/src/i18n/locales/ru-ru.json index 6fd32362a1..445a6c8cda 100644 --- a/src/renderer/src/i18n/locales/ru-ru.json +++ b/src/renderer/src/i18n/locales/ru-ru.json @@ -13,6 +13,7 @@ "title": "Доступные переменные" }, "add.title": "Создать агента", + "add.unsaved_changes_warning": "У вас есть несохраненные изменения. Вы уверены, что хотите закрыть?", "delete.popup.content": "Вы уверены, что хотите удалить этого агента?", "edit.model.select.title": "Выбрать модель", "edit.title": "Редактировать агента", diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index d8503085fd..6bfb3d71bf 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -13,6 +13,7 @@ "title": "可用的变量" }, "add.title": "创建智能体", + "add.unsaved_changes_warning": "你有未保存的内容,确定要关闭吗?", "delete.popup.content": "确定要删除此智能体吗?", "edit.model.select.title": "选择模型", "edit.title": "编辑智能体", diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index 55759eca01..480edf41e2 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -13,6 +13,7 @@ "title": "可用的變數" }, "add.title": "建立智慧代理人", + "add.unsaved_changes_warning": "有未保存的變更,確定要關閉嗎?", "delete.popup.content": "確定要刪除此智慧代理人嗎?", "edit.model.select.title": "選擇模型", "edit.title": "編輯智慧代理人", diff --git a/src/renderer/src/pages/agents/components/AddAgentPopup.tsx b/src/renderer/src/pages/agents/components/AddAgentPopup.tsx index 108052a701..c213614d35 100644 --- a/src/renderer/src/pages/agents/components/AddAgentPopup.tsx +++ b/src/renderer/src/pages/agents/components/AddAgentPopup.tsx @@ -41,6 +41,7 @@ const PopupContainer: React.FC = ({ resolve }) => { const [showUndoButton, setShowUndoButton] = useState(false) const [originalPrompt, setOriginalPrompt] = useState('') const [tokenCount, setTokenCount] = useState(0) + const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false) const knowledgeState = useAppSelector((state) => state.knowledge) const showKnowledgeIcon = useSidebarIconShow('knowledge') const knowledgeOptions: SelectProps['options'] = [] @@ -92,8 +93,21 @@ const PopupContainer: React.FC = ({ resolve }) => { setOpen(false) } - const onCancel = () => { - setOpen(false) + const handleCancel = () => { + if (hasUnsavedChanges) { + window.modal.confirm({ + title: t('common.confirm'), + content: t('agents.add.unsaved_changes_warning'), + okText: t('common.confirm'), + cancelText: t('common.cancel'), + centered: true, + onOk: () => { + setOpen(false) + } + }) + } else { + setOpen(false) + } } const onClose = () => { @@ -124,6 +138,7 @@ const PopupContainer: React.FC = ({ resolve }) => { form.setFieldsValue({ prompt: generatedText }) setShowUndoButton(true) setOriginalPrompt(content) + setHasUnsavedChanges(true) } catch (error) { console.error('Error fetching data:', error) } @@ -146,7 +161,7 @@ const PopupContainer: React.FC = ({ resolve }) => { title={t('agents.add.title')} open={open} onOk={() => formRef.current?.submit()} - onCancel={onCancel} + onCancel={handleCancel} maskClosable={false} afterClose={onClose} okText={t('agents.add.title')} @@ -167,9 +182,21 @@ const PopupContainer: React.FC = ({ resolve }) => { setTokenCount(count) setShowUndoButton(false) } + + const currentValues = form.getFieldsValue() + setHasUnsavedChanges(currentValues.name?.trim() || currentValues.prompt?.trim() || emoji) }}> - } arrow> + { + setEmoji(selectedEmoji) + setHasUnsavedChanges(true) + }} + /> + } + arrow> From 7c6db809bb294f3fad39b02cc7a401670a394da3 Mon Sep 17 00:00:00 2001 From: fullex <106392080+0xfullex@users.noreply.github.com> Date: Thu, 10 Jul 2025 20:41:01 +0800 Subject: [PATCH 151/246] fix(SelectionAssistant): [macOS] show actionWindow on fullscreen app (#8004) * feat(SelectionService): enhance action window handling for macOS fullscreen mode - Updated processAction and showActionWindow methods to support fullscreen mode on macOS. - Added isFullScreen parameter to manage action window visibility and positioning. - Improved action window positioning logic to ensure it remains within screen boundaries. - Adjusted IPC channel to pass fullscreen state from the renderer to the service. - Updated SelectionToolbar to track fullscreen state and pass it to the action processing function. * chore(deps): update selection-hook to version 1.0.6 in package.json and yarn.lock * fix(SelectionService): improve macOS fullscreen handling and action window focus - Added app import to manage dock visibility on macOS. - Enhanced fullscreen handling logic to ensure the dock icon is restored correctly. - Updated action window focus behavior to prevent unintended hiding when blurred. - Refactored SelectionActionApp to streamline auto pinning logic and remove redundant useEffect. - Cleaned up SelectionToolbar by removing unnecessary window size updates when demo is false. * refactor(SelectionService): remove commented-out code for clarity * refactor(SelectionService): streamline macOS handling and improve code clarity --- package.json | 2 +- src/main/services/SelectionService.ts | 235 +++++++++++------- src/preload/index.ts | 3 +- .../selection/action/SelectionActionApp.tsx | 22 +- .../selection/toolbar/SelectionToolbar.tsx | 8 +- yarn.lock | 10 +- 6 files changed, 177 insertions(+), 103 deletions(-) diff --git a/package.json b/package.json index c718dce1a7..b5073b4b2c 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "notion-helper": "^1.3.22", "os-proxy-config": "^1.1.2", "pdfjs-dist": "4.10.38", - "selection-hook": "^1.0.5", + "selection-hook": "^1.0.6", "turndown": "7.2.0" }, "devDependencies": { diff --git a/src/main/services/SelectionService.ts b/src/main/services/SelectionService.ts index 3be2d5a95a..718025cd89 100644 --- a/src/main/services/SelectionService.ts +++ b/src/main/services/SelectionService.ts @@ -1,7 +1,7 @@ import { SELECTION_FINETUNED_LIST, SELECTION_PREDEFINED_BLACKLIST } from '@main/configs/SelectionConfig' import { isDev, isMac, isWin } from '@main/constant' import { IpcChannel } from '@shared/IpcChannel' -import { BrowserWindow, ipcMain, screen, systemPreferences } from 'electron' +import { app, BrowserWindow, ipcMain, screen, systemPreferences } from 'electron' import Logger from 'electron-log' import { join } from 'path' import type { @@ -509,54 +509,55 @@ export class SelectionService { //should set every time the window is shown this.toolbarWindow!.setAlwaysOnTop(true, 'screen-saver') - // [macOS] a series of hacky ways only for macOS - if (isMac) { - // [macOS] a hacky way - // when set `skipTransformProcessType: true`, if the selection is in self app, it will make the selection canceled after toolbar showing - // so we just don't set `skipTransformProcessType: true` when in self app - const isSelf = ['com.github.Electron', 'com.kangfenmao.CherryStudio'].includes(programName) - - if (!isSelf) { - // [macOS] an ugly hacky way - // `focusable: true` will make mainWindow disappeared when `setVisibleOnAllWorkspaces` - // so we set `focusable: true` before showing, and then set false after showing - this.toolbarWindow!.setFocusable(false) - - // [macOS] - // force `setVisibleOnAllWorkspaces: true` to let toolbar show in all workspaces. And we MUST not set it to false again - // set `skipTransformProcessType: true` to avoid dock icon spinning when `setVisibleOnAllWorkspaces` - this.toolbarWindow!.setVisibleOnAllWorkspaces(true, { - visibleOnFullScreen: true, - skipTransformProcessType: true - }) - } - - // [macOS] MUST use `showInactive()` to prevent other windows bring to front together - // [Windows] is OK for both `show()` and `showInactive()` because of `focusable: false` - this.toolbarWindow!.showInactive() - - // [macOS] restore the focusable status - this.toolbarWindow!.setFocusable(true) - + if (!isMac) { + this.toolbarWindow!.show() + /** + * [Windows] + * In Windows 10, setOpacity(1) will make the window completely transparent + * It's a strange behavior, so we don't use it for compatibility + */ + // this.toolbarWindow!.setOpacity(1) this.startHideByMouseKeyListener() - return } - /** - * The following is for Windows - */ + /************************************************ + * [macOS] the following code is only for macOS + * + * WARNING: + * DO NOT MODIFY THESE CODES, UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!!!! + *************************************************/ - this.toolbarWindow!.show() + // [macOS] a hacky way + // when set `skipTransformProcessType: true`, if the selection is in self app, it will make the selection canceled after toolbar showing + // so we just don't set `skipTransformProcessType: true` when in self app + const isSelf = ['com.github.Electron', 'com.kangfenmao.CherryStudio'].includes(programName) - /** - * [Windows] - * In Windows 10, setOpacity(1) will make the window completely transparent - * It's a strange behavior, so we don't use it for compatibility - */ - // this.toolbarWindow!.setOpacity(1) + if (!isSelf) { + // [macOS] an ugly hacky way + // `focusable: true` will make mainWindow disappeared when `setVisibleOnAllWorkspaces` + // so we set `focusable: true` before showing, and then set false after showing + this.toolbarWindow!.setFocusable(false) + + // [macOS] + // force `setVisibleOnAllWorkspaces: true` to let toolbar show in all workspaces. And we MUST not set it to false again + // set `skipTransformProcessType: true` to avoid dock icon spinning when `setVisibleOnAllWorkspaces` + this.toolbarWindow!.setVisibleOnAllWorkspaces(true, { + visibleOnFullScreen: true, + skipTransformProcessType: true + }) + } + + // [macOS] MUST use `showInactive()` to prevent other windows bring to front together + // [Windows] is OK for both `show()` and `showInactive()` because of `focusable: false` + this.toolbarWindow!.showInactive() + + // [macOS] restore the focusable status + this.toolbarWindow!.setFocusable(true) this.startHideByMouseKeyListener() + + return } /** @@ -911,6 +912,7 @@ export class SelectionService { refPoint = { x: Math.round(refPoint.x), y: Math.round(refPoint.y) } } + // [macOS] isFullscreen is only available on macOS this.showToolbarAtPosition(refPoint, refOrientation, selectionData.programName) this.toolbarWindow!.webContents.send(IpcChannel.Selection_TextSelected, selectionData) } @@ -1218,20 +1220,26 @@ export class SelectionService { return actionWindow } - public processAction(actionItem: ActionItem): void { + /** + * Process action item + * @param actionItem Action item to process + * @param isFullScreen [macOS] only macOS has the available isFullscreen mode + */ + public processAction(actionItem: ActionItem, isFullScreen: boolean = false): void { const actionWindow = this.popActionWindow() actionWindow.webContents.send(IpcChannel.Selection_UpdateActionData, actionItem) - this.showActionWindow(actionWindow) + this.showActionWindow(actionWindow, isFullScreen) } /** * Show action window with proper positioning relative to toolbar * Ensures window stays within screen boundaries * @param actionWindow Window to position and show + * @param isFullScreen [macOS] only macOS has the available isFullscreen mode */ - private showActionWindow(actionWindow: BrowserWindow): void { + private showActionWindow(actionWindow: BrowserWindow, isFullScreen: boolean = false): void { let actionWindowWidth = this.ACTION_WINDOW_WIDTH let actionWindowHeight = this.ACTION_WINDOW_HEIGHT @@ -1241,11 +1249,14 @@ export class SelectionService { actionWindowHeight = this.lastActionWindowSize.height } - //center way - if (!this.isFollowToolbar || !this.toolbarWindow) { - const display = screen.getDisplayNearestPoint(screen.getCursorScreenPoint()) - const workArea = display.workArea + /******************************************** + * Setting the position of the action window + ********************************************/ + const display = screen.getDisplayNearestPoint(screen.getCursorScreenPoint()) + const workArea = display.workArea + // Center of the screen + if (!this.isFollowToolbar || !this.toolbarWindow) { const centerX = workArea.x + (workArea.width - actionWindowWidth) / 2 const centerY = workArea.y + (workArea.height - actionWindowHeight) / 2 @@ -1255,54 +1266,107 @@ export class SelectionService { x: Math.round(centerX), y: Math.round(centerY) }) + } else { + // Follow toolbar position + const toolbarBounds = this.toolbarWindow!.getBounds() + const GAP = 6 // 6px gap from screen edges + //make sure action window is inside screen + if (actionWindowWidth > workArea.width - 2 * GAP) { + actionWindowWidth = workArea.width - 2 * GAP + } + + if (actionWindowHeight > workArea.height - 2 * GAP) { + actionWindowHeight = workArea.height - 2 * GAP + } + + // Calculate initial position to center action window horizontally below toolbar + let posX = Math.round(toolbarBounds.x + (toolbarBounds.width - actionWindowWidth) / 2) + let posY = Math.round(toolbarBounds.y) + + // Ensure action window stays within screen boundaries with a small gap + if (posX + actionWindowWidth > workArea.x + workArea.width) { + posX = workArea.x + workArea.width - actionWindowWidth - GAP + } else if (posX < workArea.x) { + posX = workArea.x + GAP + } + if (posY + actionWindowHeight > workArea.y + workArea.height) { + // If window would go below screen, try to position it above toolbar + posY = workArea.y + workArea.height - actionWindowHeight - GAP + } else if (posY < workArea.y) { + posY = workArea.y + GAP + } + + actionWindow.setPosition(posX, posY, false) + //KEY to make window not resize + actionWindow.setBounds({ + width: actionWindowWidth, + height: actionWindowHeight, + x: posX, + y: posY + }) + } + + if (!isMac) { actionWindow.show() - return } - //follow toolbar - const toolbarBounds = this.toolbarWindow!.getBounds() - const display = screen.getDisplayNearestPoint(screen.getCursorScreenPoint()) - const workArea = display.workArea - const GAP = 6 // 6px gap from screen edges + /************************************************ + * [macOS] the following code is only for macOS + * + * WARNING: + * DO NOT MODIFY THESE CODES, UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!!!! + *************************************************/ - //make sure action window is inside screen - if (actionWindowWidth > workArea.width - 2 * GAP) { - actionWindowWidth = workArea.width - 2 * GAP + // act normally when the app is not in fullscreen mode + if (!isFullScreen) { + actionWindow.show() + return } - if (actionWindowHeight > workArea.height - 2 * GAP) { - actionWindowHeight = workArea.height - 2 * GAP - } + // [macOS] an UGLY HACKY way for fullscreen override settings - // Calculate initial position to center action window horizontally below toolbar - let posX = Math.round(toolbarBounds.x + (toolbarBounds.width - actionWindowWidth) / 2) - let posY = Math.round(toolbarBounds.y) + // FIXME sometimes the dock will be shown when the action window is shown + // FIXME if actionWindow show on the fullscreen app, switch to other space will cause the mainWindow to be shown + // FIXME When setVisibleOnAllWorkspaces is true, docker icon disappeared when the first action window is shown on the fullscreen app + // use app.dock.show() to show the dock again will cause the action window to be closed when auto hide on blur is enabled - // Ensure action window stays within screen boundaries with a small gap - if (posX + actionWindowWidth > workArea.x + workArea.width) { - posX = workArea.x + workArea.width - actionWindowWidth - GAP - } else if (posX < workArea.x) { - posX = workArea.x + GAP - } - if (posY + actionWindowHeight > workArea.y + workArea.height) { - // If window would go below screen, try to position it above toolbar - posY = workArea.y + workArea.height - actionWindowHeight - GAP - } else if (posY < workArea.y) { - posY = workArea.y + GAP - } + // setFocusable(false) to prevent the action window hide when blur (if auto hide on blur is enabled) + actionWindow.setFocusable(false) + actionWindow.setAlwaysOnTop(true, 'floating') - actionWindow.setPosition(posX, posY, false) - //KEY to make window not resize - actionWindow.setBounds({ - width: actionWindowWidth, - height: actionWindowHeight, - x: posX, - y: posY + // `setVisibleOnAllWorkspaces(true)` will cause the dock icon disappeared + // just store the dock icon status, and show it again + const isDockShown = app.dock?.isVisible() + + // DO NOT set `skipTransformProcessType: true`, + // it will cause the action window to be shown on other space + actionWindow.setVisibleOnAllWorkspaces(true, { + visibleOnFullScreen: true }) - actionWindow.show() + actionWindow.showInactive() + + // show the dock again if last time it was shown + // do not put it after `actionWindow.focus()`, will cause the action window to be closed when auto hide on blur is enabled + if (!app.dock?.isVisible() && isDockShown) { + app.dock?.show() + } + + // unset everything + setTimeout(() => { + actionWindow.setVisibleOnAllWorkspaces(false, { + visibleOnFullScreen: true, + skipTransformProcessType: true + }) + actionWindow.setAlwaysOnTop(false) + + actionWindow.setFocusable(true) + + // regain the focus when all the works done + actionWindow.focus() + }, 50) } public closeActionWindow(actionWindow: BrowserWindow): void { @@ -1408,8 +1472,9 @@ export class SelectionService { configManager.setSelectionAssistantFilterList(filterList) }) - ipcMain.handle(IpcChannel.Selection_ProcessAction, (_, actionItem: ActionItem) => { - selectionService?.processAction(actionItem) + // [macOS] only macOS has the available isFullscreen mode + ipcMain.handle(IpcChannel.Selection_ProcessAction, (_, actionItem: ActionItem, isFullScreen: boolean = false) => { + selectionService?.processAction(actionItem, isFullScreen) }) ipcMain.handle(IpcChannel.Selection_ActionWindowClose, (event) => { diff --git a/src/preload/index.ts b/src/preload/index.ts index ea1a2897f9..5221761dfb 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -309,7 +309,8 @@ const api = { ipcRenderer.invoke(IpcChannel.Selection_SetRemeberWinSize, isRemeberWinSize), setFilterMode: (filterMode: string) => ipcRenderer.invoke(IpcChannel.Selection_SetFilterMode, filterMode), setFilterList: (filterList: string[]) => ipcRenderer.invoke(IpcChannel.Selection_SetFilterList, filterList), - processAction: (actionItem: ActionItem) => ipcRenderer.invoke(IpcChannel.Selection_ProcessAction, actionItem), + processAction: (actionItem: ActionItem, isFullScreen: boolean = false) => + ipcRenderer.invoke(IpcChannel.Selection_ProcessAction, actionItem, isFullScreen), closeActionWindow: () => ipcRenderer.invoke(IpcChannel.Selection_ActionWindowClose), minimizeActionWindow: () => ipcRenderer.invoke(IpcChannel.Selection_ActionWindowMinimize), pinActionWindow: (isPinned: boolean) => ipcRenderer.invoke(IpcChannel.Selection_ActionWindowPin, isPinned) diff --git a/src/renderer/src/windows/selection/action/SelectionActionApp.tsx b/src/renderer/src/windows/selection/action/SelectionActionApp.tsx index 94c1c575ea..5112caf945 100644 --- a/src/renderer/src/windows/selection/action/SelectionActionApp.tsx +++ b/src/renderer/src/windows/selection/action/SelectionActionApp.tsx @@ -36,10 +36,6 @@ const SelectionActionApp: FC = () => { const lastScrollHeight = useRef(0) useEffect(() => { - if (isAutoPin) { - window.api.selection.pinActionWindow(true) - } - const actionListenRemover = window.electron?.ipcRenderer.on( IpcChannel.Selection_UpdateActionData, (_, actionItem: ActionItem) => { @@ -60,6 +56,20 @@ const SelectionActionApp: FC = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []) + useEffect(() => { + if (isAutoPin) { + window.api.selection.pinActionWindow(true) + setIsPinned(true) + } else if (!isActionLoaded.current) { + window.api.selection.pinActionWindow(false) + setIsPinned(false) + } + }, [isAutoPin]) + + useEffect(() => { + shouldCloseWhenBlur.current = isAutoClose && !isPinned + }, [isAutoClose, isPinned]) + useEffect(() => { i18n.changeLanguage(language || navigator.language || defaultLanguage) }, [language]) @@ -100,10 +110,6 @@ const SelectionActionApp: FC = () => { } }, [action, t]) - useEffect(() => { - shouldCloseWhenBlur.current = isAutoClose && !isPinned - }, [isAutoClose, isPinned]) - useEffect(() => { //if the action is loaded, we should not set the opacity update from settings if (!isActionLoaded.current) { diff --git a/src/renderer/src/windows/selection/toolbar/SelectionToolbar.tsx b/src/renderer/src/windows/selection/toolbar/SelectionToolbar.tsx index 49b3c2fcf9..342e4122a7 100644 --- a/src/renderer/src/windows/selection/toolbar/SelectionToolbar.tsx +++ b/src/renderer/src/windows/selection/toolbar/SelectionToolbar.tsx @@ -107,6 +107,8 @@ const SelectionToolbar: FC<{ demo?: boolean }> = ({ demo = false }) => { }, [actionItems]) const selectedText = useRef('') + // [macOS] only macOS has the fullscreen mode + const isFullScreen = useRef(false) // listen to selectionService events useEffect(() => { @@ -115,6 +117,7 @@ const SelectionToolbar: FC<{ demo?: boolean }> = ({ demo = false }) => { IpcChannel.Selection_TextSelected, (_, selectionData: TextSelectionData) => { selectedText.current = selectionData.text + isFullScreen.current = selectionData.isFullscreen ?? false setTimeout(() => { //make sure the animation is active setAnimateKey((prev) => prev + 1) @@ -133,8 +136,6 @@ const SelectionToolbar: FC<{ demo?: boolean }> = ({ demo = false }) => { } ) - if (!demo) updateWindowSize() - return () => { textSelectionListenRemover() toolbarVisibilityChangeListenRemover() @@ -234,7 +235,8 @@ const SelectionToolbar: FC<{ demo?: boolean }> = ({ demo = false }) => { } const handleDefaultAction = (action: ActionItem) => { - window.api?.selection.processAction(action) + // [macOS] only macOS has the available isFullscreen mode + window.api?.selection.processAction(action, isFullScreen.current) window.api?.selection.hideToolbar() } diff --git a/yarn.lock b/yarn.lock index e2a45ec2ac..bbaadab77c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7235,7 +7235,7 @@ __metadata: remove-markdown: "npm:^0.6.2" rollup-plugin-visualizer: "npm:^5.12.0" sass: "npm:^1.88.0" - selection-hook: "npm:^1.0.5" + selection-hook: "npm:^1.0.6" shiki: "npm:^3.7.0" string-width: "npm:^7.2.0" styled-components: "npm:^6.1.11" @@ -18229,14 +18229,14 @@ __metadata: languageName: node linkType: hard -"selection-hook@npm:^1.0.5": - version: 1.0.5 - resolution: "selection-hook@npm:1.0.5" +"selection-hook@npm:^1.0.6": + version: 1.0.6 + resolution: "selection-hook@npm:1.0.6" dependencies: node-addon-api: "npm:^8.4.0" node-gyp: "npm:latest" node-gyp-build: "npm:^4.8.4" - checksum: 10c0/d188e2bafa6d820779e57a721bd2480dc1fde3f9daa2e3f92f1b69712637079e5fd9443575bc8624c98a057608f867d82fb2abf2d0796777db1f18ea50ea0028 + checksum: 10c0/c7d28db51fc16b5648530344cbe1d5b72a7469cfb7edbb9c56d7be4bea2d93ddd01993fb27b344e44865f9eb0f3211b1be638caaacd0f9165b2bc03bada7c360 languageName: node linkType: hard From ba742b7b1fd900186b3ead99dce256480b676fb5 Mon Sep 17 00:00:00 2001 From: one Date: Thu, 10 Jul 2025 21:34:01 +0800 Subject: [PATCH 152/246] feat: save to knowledge (#7528) * feat: save to knowledge * refactor: simplify checkbox * feat(i18n): add 'Save to Local File' translation key for multiple languages --------- Co-authored-by: suyao --- .../Popups/SaveToKnowledgePopup.tsx | 353 ++++++++++++++++++ src/renderer/src/i18n/locales/en-us.json | 29 ++ src/renderer/src/i18n/locales/ja-jp.json | 31 +- src/renderer/src/i18n/locales/ru-ru.json | 31 +- src/renderer/src/i18n/locales/zh-cn.json | 29 ++ src/renderer/src/i18n/locales/zh-tw.json | 33 +- .../pages/home/Messages/MessageMenubar.tsx | 32 +- src/renderer/src/utils/knowledge.ts | 269 +++++++++++++ 8 files changed, 794 insertions(+), 13 deletions(-) create mode 100644 src/renderer/src/components/Popups/SaveToKnowledgePopup.tsx create mode 100644 src/renderer/src/utils/knowledge.ts diff --git a/src/renderer/src/components/Popups/SaveToKnowledgePopup.tsx b/src/renderer/src/components/Popups/SaveToKnowledgePopup.tsx new file mode 100644 index 0000000000..b6f0577c4f --- /dev/null +++ b/src/renderer/src/components/Popups/SaveToKnowledgePopup.tsx @@ -0,0 +1,353 @@ +import CustomTag from '@renderer/components/CustomTag' +import { TopView } from '@renderer/components/TopView' +import Logger from '@renderer/config/logger' +import { useKnowledge, useKnowledgeBases } from '@renderer/hooks/useKnowledge' +import { Message } from '@renderer/types/newMessage' +import { + analyzeMessageContent, + CONTENT_TYPES, + ContentType, + MessageContentStats, + processMessageContent +} from '@renderer/utils/knowledge' +import { Flex, Form, Modal, Select, Tooltip, Typography } from 'antd' +import { Check, CircleHelp } from 'lucide-react' +import { useEffect, useMemo, useState } from 'react' +import { useTranslation } from 'react-i18next' +import styled from 'styled-components' + +const { Text } = Typography + +// 内容类型配置 +const CONTENT_TYPE_CONFIG = { + [CONTENT_TYPES.TEXT]: { + label: 'chat.save.knowledge.content.maintext.title', + description: 'chat.save.knowledge.content.maintext.description' + }, + [CONTENT_TYPES.CODE]: { + label: 'chat.save.knowledge.content.code.title', + description: 'chat.save.knowledge.content.code.description' + }, + [CONTENT_TYPES.THINKING]: { + label: 'chat.save.knowledge.content.thinking.title', + description: 'chat.save.knowledge.content.thinking.description' + }, + [CONTENT_TYPES.TOOL_USE]: { + label: 'chat.save.knowledge.content.tool_use.title', + description: 'chat.save.knowledge.content.tool_use.description' + }, + [CONTENT_TYPES.CITATION]: { + label: 'chat.save.knowledge.content.citation.title', + description: 'chat.save.knowledge.content.citation.description' + }, + [CONTENT_TYPES.TRANSLATION]: { + label: 'chat.save.knowledge.content.translation.title', + description: 'chat.save.knowledge.content.translation.description' + }, + [CONTENT_TYPES.ERROR]: { + label: 'chat.save.knowledge.content.error.title', + description: 'chat.save.knowledge.content.error.description' + }, + [CONTENT_TYPES.FILE]: { + label: 'chat.save.knowledge.content.file.title', + description: 'chat.save.knowledge.content.file.description' + } +} as const + +// Tag 颜色常量 +const TAG_COLORS = { + SELECTED: '#008001', + UNSELECTED: '#8c8c8c' +} as const + +interface ContentTypeOption { + type: ContentType + label: string + count: number + enabled: boolean + description?: string +} + +interface ShowParams { + message: Message + title?: string +} + +interface SaveResult { + success: boolean + savedCount: number +} + +interface Props extends ShowParams { + resolve: (data: SaveResult | null) => void +} + +const PopupContainer: React.FC = ({ message, title, resolve }) => { + const [open, setOpen] = useState(true) + const [loading, setLoading] = useState(false) + const [selectedBaseId, setSelectedBaseId] = useState() + const [selectedTypes, setSelectedTypes] = useState([]) + const [hasInitialized, setHasInitialized] = useState(false) + const { bases } = useKnowledgeBases() + const { addNote, addFiles } = useKnowledge(selectedBaseId || '') + const { t } = useTranslation() + + // 分析消息内容统计 + const contentStats = useMemo(() => analyzeMessageContent(message), [message]) + + // 生成内容类型选项(只显示有内容的类型) + const contentTypeOptions: ContentTypeOption[] = useMemo(() => { + return Object.entries(CONTENT_TYPE_CONFIG) + .map(([type, config]) => { + const contentType = type as ContentType + const count = contentStats[contentType as keyof MessageContentStats] || 0 + return { + type: contentType, + count, + enabled: count > 0, + label: t(config.label), + description: t(config.description) + } + }) + .filter((option) => option.enabled) // 只显示有内容的类型 + }, [contentStats, t]) + + // 知识库选项 + const knowledgeBaseOptions = useMemo( + () => + bases.map((base) => ({ + label: base.name, + value: base.id, + disabled: !base.version // 如果知识库没有配置好就禁用 + })), + [bases] + ) + + // 合并状态计算 + const formState = useMemo(() => { + const hasValidBase = selectedBaseId && bases.find((base) => base.id === selectedBaseId)?.version + const hasContent = contentTypeOptions.length > 0 + const selectedCount = contentTypeOptions + .filter((option) => selectedTypes.includes(option.type)) + .reduce((sum, option) => sum + option.count, 0) + + return { + hasValidBase, + hasContent, + canSubmit: hasValidBase && selectedTypes.length > 0 && hasContent, + selectedCount, + hasNoSelection: selectedTypes.length === 0 && hasContent + } + }, [selectedBaseId, bases, contentTypeOptions, selectedTypes]) + + // 默认选择第一个可用的知识库 + useEffect(() => { + if (!selectedBaseId) { + const firstAvailableBase = bases.find((base) => base.version) + if (firstAvailableBase) { + setSelectedBaseId(firstAvailableBase.id) + } + } + }, [bases, selectedBaseId]) + + // 默认选择所有可用的内容类型(仅在初始化时) + useEffect(() => { + if (!hasInitialized && contentTypeOptions.length > 0) { + const availableTypes = contentTypeOptions.map((option) => option.type) + setSelectedTypes(availableTypes) + setHasInitialized(true) + } + }, [contentTypeOptions, hasInitialized]) + + // 计算UI状态 + const uiState = useMemo(() => { + if (!formState.hasContent) { + return { type: 'empty', message: t('chat.save.knowledge.empty.no_content') } + } + if (bases.length === 0) { + return { type: 'empty', message: t('chat.save.knowledge.empty.no_knowledge_base') } + } + return { type: 'form' } + }, [formState.hasContent, bases.length, t]) + + // 处理内容类型选择切换 + const handleContentTypeToggle = (type: ContentType) => { + setSelectedTypes((prev) => (prev.includes(type) ? prev.filter((t) => t !== type) : [...prev, type])) + } + + const onOk = async () => { + if (!formState.canSubmit) { + return + } + + setLoading(true) + let savedCount = 0 + + try { + const result = processMessageContent(message, selectedTypes) + + // 保存文本内容 + if (result.text.trim() && selectedTypes.some((type) => type !== CONTENT_TYPES.FILE)) { + await addNote(result.text) + savedCount++ + } + + // 保存文件 + if (result.files.length > 0 && selectedTypes.includes(CONTENT_TYPES.FILE)) { + addFiles(result.files) + savedCount += result.files.length + } + + setOpen(false) + resolve({ success: true, savedCount }) + } catch (error) { + Logger.error('[SaveToKnowledgePopup] save failed:', error) + window.message.error(t('chat.save.knowledge.error.save_failed')) + setLoading(false) + } + } + + const onCancel = () => { + setOpen(false) + } + + const onClose = () => { + resolve(null) + } + + // 渲染空状态 + const renderEmptyState = () => ( + + {uiState.message} + + ) + + // 渲染表单内容 + const renderFormContent = () => ( + <> +
+ + onSyncIntervalChange(value as number)} + onChange={onSyncIntervalChange} disabled={!localBackupDir} - style={{ minWidth: 120 }}> - {t('settings.data.local.autoSync.off')} - {t('settings.data.local.minute_interval', { count: 1 })} - {t('settings.data.local.minute_interval', { count: 5 })} - {t('settings.data.local.minute_interval', { count: 15 })} - {t('settings.data.local.minute_interval', { count: 30 })} - {t('settings.data.local.hour_interval', { count: 1 })} - {t('settings.data.local.hour_interval', { count: 2 })} - {t('settings.data.local.hour_interval', { count: 6 })} - {t('settings.data.local.hour_interval', { count: 12 })} - {t('settings.data.local.hour_interval', { count: 24 })} - + options={[ + { label: t('settings.data.local.autoSync.off'), value: 0 }, + { label: t('settings.data.local.minute_interval', { count: 1 }), value: 1 }, + { label: t('settings.data.local.minute_interval', { count: 5 }), value: 5 }, + { label: t('settings.data.local.minute_interval', { count: 15 }), value: 15 }, + { label: t('settings.data.local.minute_interval', { count: 30 }), value: 30 }, + { label: t('settings.data.local.hour_interval', { count: 1 }), value: 60 }, + { label: t('settings.data.local.hour_interval', { count: 2 }), value: 120 }, + { label: t('settings.data.local.hour_interval', { count: 6 }), value: 360 }, + { label: t('settings.data.local.hour_interval', { count: 12 }), value: 720 }, + { label: t('settings.data.local.hour_interval', { count: 24 }), value: 1440 } + ]} + /> {t('settings.data.local.maxBackups')} - + options={[ + { label: t('settings.data.local.maxBackups.unlimited'), value: 0 }, + { label: '1', value: 1 }, + { label: '3', value: 3 }, + { label: '5', value: 5 }, + { label: '10', value: 10 }, + { label: '20', value: 20 }, + { label: '50', value: 50 } + ]} + /> diff --git a/src/renderer/src/pages/settings/DataSettings/S3Settings.tsx b/src/renderer/src/pages/settings/DataSettings/S3Settings.tsx index c261c5b736..c24d67cd44 100644 --- a/src/renderer/src/pages/settings/DataSettings/S3Settings.tsx +++ b/src/renderer/src/pages/settings/DataSettings/S3Settings.tsx @@ -2,6 +2,7 @@ import { FolderOpenOutlined, InfoCircleOutlined, SaveOutlined, SyncOutlined, War import { HStack } from '@renderer/components/Layout' import { S3BackupManager } from '@renderer/components/S3BackupManager' import { S3BackupModal, useS3BackupModal } from '@renderer/components/S3Modals' +import Selector from '@renderer/components/Selector' import { useTheme } from '@renderer/context/ThemeProvider' import { useMinappPopup } from '@renderer/hooks/useMinappPopup' import { useSettings } from '@renderer/hooks/useSettings' @@ -9,7 +10,7 @@ import { startAutoSync, stopAutoSync } from '@renderer/services/BackupService' import { useAppDispatch, useAppSelector } from '@renderer/store' import { setS3Partial } from '@renderer/store/settings' import { S3Config } from '@renderer/types' -import { Button, Input, Select, Switch, Tooltip } from 'antd' +import { Button, Input, Switch, Tooltip } from 'antd' import dayjs from 'dayjs' import { FC, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -54,9 +55,9 @@ const S3Settings: FC = () => { setSyncInterval(value) dispatch(setS3Partial({ syncInterval: value, autoSync: value !== 0 })) if (value === 0) { - stopAutoSync() + stopAutoSync('s3') } else { - startAutoSync() + startAutoSync(false, 's3') } } @@ -211,39 +212,43 @@ const S3Settings: FC = () => { {t('settings.data.s3.autoSync')} - + options={[ + { label: t('settings.data.s3.autoSync.off'), value: 0 }, + { label: t('settings.data.s3.autoSync.minute', { count: 1 }), value: 1 }, + { label: t('settings.data.s3.autoSync.minute', { count: 5 }), value: 5 }, + { label: t('settings.data.s3.autoSync.minute', { count: 15 }), value: 15 }, + { label: t('settings.data.s3.autoSync.minute', { count: 30 }), value: 30 }, + { label: t('settings.data.s3.autoSync.hour', { count: 1 }), value: 60 }, + { label: t('settings.data.s3.autoSync.hour', { count: 2 }), value: 120 }, + { label: t('settings.data.s3.autoSync.hour', { count: 6 }), value: 360 }, + { label: t('settings.data.s3.autoSync.hour', { count: 12 }), value: 720 }, + { label: t('settings.data.s3.autoSync.hour', { count: 24 }), value: 1440 } + ]} + /> {t('settings.data.s3.maxBackups')} - + options={[ + { label: t('settings.data.s3.maxBackups.unlimited'), value: 0 }, + { label: '1', value: 1 }, + { label: '3', value: 3 }, + { label: '5', value: 5 }, + { label: '10', value: 10 }, + { label: '20', value: 20 }, + { label: '50', value: 50 } + ]} + /> diff --git a/src/renderer/src/pages/settings/DataSettings/WebDavSettings.tsx b/src/renderer/src/pages/settings/DataSettings/WebDavSettings.tsx index 977c5c1329..7f42c9fe30 100644 --- a/src/renderer/src/pages/settings/DataSettings/WebDavSettings.tsx +++ b/src/renderer/src/pages/settings/DataSettings/WebDavSettings.tsx @@ -59,10 +59,10 @@ const WebDavSettings: FC = () => { dispatch(_setWebdavSyncInterval(value)) if (value === 0) { dispatch(setWebdavAutoSync(false)) - stopAutoSync() + stopAutoSync('webdav') } else { dispatch(setWebdavAutoSync(true)) - startAutoSync() + startAutoSync(false, 'webdav') } } diff --git a/src/renderer/src/services/BackupService.ts b/src/renderer/src/services/BackupService.ts index bf5fea3c5a..9e594f85c2 100644 --- a/src/renderer/src/services/BackupService.ts +++ b/src/renderer/src/services/BackupService.ts @@ -444,85 +444,144 @@ export async function restoreFromS3(fileName?: string) { }) const data = JSON.parse(restoreData) await handleData(data) - store.dispatch( - setS3SyncState({ - lastSyncTime: Date.now(), - syncing: false, - lastSyncError: null - }) - ) } } -let autoSyncStarted = false -let syncTimeout: NodeJS.Timeout | null = null -let isAutoBackupRunning = false let isManualBackupRunning = false -export function startAutoSync(immediate = false) { - if (autoSyncStarted) { - return - } +// 为每种备份类型维护独立的状态 +let webdavAutoSyncStarted = false +let webdavSyncTimeout: NodeJS.Timeout | null = null +let isWebdavAutoBackupRunning = false - const settings = store.getState().settings - const { webdavAutoSync, webdavHost } = settings - const s3Settings = settings.s3 +let s3AutoSyncStarted = false +let s3SyncTimeout: NodeJS.Timeout | null = null +let isS3AutoBackupRunning = false - const s3AutoSync = s3Settings?.autoSync - const s3Endpoint = s3Settings?.endpoint +let localAutoSyncStarted = false +let localSyncTimeout: NodeJS.Timeout | null = null +let isLocalAutoBackupRunning = false - const localBackupAutoSync = settings.localBackupAutoSync - const localBackupDir = settings.localBackupDir - - // 检查WebDAV或S3自动同步配置 - const hasWebdavConfig = webdavAutoSync && webdavHost - const hasS3Config = s3AutoSync && s3Endpoint - const hasLocalConfig = localBackupAutoSync && localBackupDir - - if (!hasWebdavConfig && !hasS3Config && !hasLocalConfig) { - Logger.log('[AutoSync] Invalid sync settings, auto sync disabled') - return - } - - autoSyncStarted = true - - stopAutoSync() - - scheduleNextBackup(immediate ? 'immediate' : 'fromLastSyncTime') - - /** - * @param type 'immediate' | 'fromLastSyncTime' | 'fromNow' - * 'immediate', first backup right now - * 'fromLastSyncTime', schedule next backup from last sync time - * 'fromNow', schedule next backup from now - */ - function scheduleNextBackup(type: 'immediate' | 'fromLastSyncTime' | 'fromNow' = 'fromLastSyncTime') { - if (syncTimeout) { - clearTimeout(syncTimeout) - syncTimeout = null - } +type BackupType = 'webdav' | 's3' | 'local' +export function startAutoSync(immediate = false, type?: BackupType) { + // 如果没有指定类型,启动所有配置的自动同步 + if (!type) { const settings = store.getState().settings - const _webdavSyncInterval = settings.webdavSyncInterval - const _s3SyncInterval = settings.s3?.syncInterval - const { webdavSync, s3Sync } = store.getState().backup + const { webdavAutoSync, webdavHost, localBackupAutoSync, localBackupDir } = settings + const s3Settings = settings.s3 - // 使用当前激活的同步配置 - const syncInterval = hasWebdavConfig ? _webdavSyncInterval : _s3SyncInterval - const lastSyncTime = hasWebdavConfig ? webdavSync?.lastSyncTime : s3Sync?.lastSyncTime + if (webdavAutoSync && webdavHost) { + startAutoSync(immediate, 'webdav') + } + if (s3Settings?.autoSync && s3Settings?.endpoint) { + startAutoSync(immediate, 's3') + } + if (localBackupAutoSync && localBackupDir) { + startAutoSync(immediate, 'local') + } + return + } - if (!syncInterval || syncInterval <= 0) { - Logger.log('[AutoSync] Invalid sync interval, auto sync disabled') - stopAutoSync() + // 根据类型启动特定的自动同步 + if (type === 'webdav') { + if (webdavAutoSyncStarted) { return } - // 用户指定的自动备份时间间隔(毫秒) - const requiredInterval = syncInterval * 60 * 1000 + const settings = store.getState().settings + const { webdavAutoSync, webdavHost } = settings - let timeUntilNextSync = 1000 //also immediate - switch (type) { - case 'fromLastSyncTime': // 如果存在最后一次同步的时间,以它为参考计算下一次同步的时间 + if (!webdavAutoSync || !webdavHost) { + Logger.log('[WebdavAutoSync] Invalid sync settings, auto sync disabled') + return + } + + webdavAutoSyncStarted = true + stopAutoSync('webdav') + scheduleNextBackup(immediate ? 'immediate' : 'fromLastSyncTime', 'webdav') + } else if (type === 's3') { + if (s3AutoSyncStarted) { + return + } + + const settings = store.getState().settings + const s3Settings = settings.s3 + + if (!s3Settings?.autoSync || !s3Settings?.endpoint) { + Logger.log('[S3AutoSync] Invalid sync settings, auto sync disabled') + return + } + + s3AutoSyncStarted = true + stopAutoSync('s3') + scheduleNextBackup(immediate ? 'immediate' : 'fromLastSyncTime', 's3') + } else if (type === 'local') { + if (localAutoSyncStarted) { + return + } + + const settings = store.getState().settings + const { localBackupAutoSync, localBackupDir } = settings + + if (!localBackupAutoSync || !localBackupDir) { + Logger.log('[LocalAutoSync] Invalid sync settings, auto sync disabled') + return + } + + localAutoSyncStarted = true + stopAutoSync('local') + scheduleNextBackup(immediate ? 'immediate' : 'fromLastSyncTime', 'local') + } + + function scheduleNextBackup(scheduleType: 'immediate' | 'fromLastSyncTime' | 'fromNow', backupType: BackupType) { + let syncInterval: number + let lastSyncTime: number | undefined + let logPrefix: string + + // 根据备份类型获取相应的配置和状态 + const settings = store.getState().settings + const backup = store.getState().backup + + if (backupType === 'webdav') { + if (webdavSyncTimeout) { + clearTimeout(webdavSyncTimeout) + webdavSyncTimeout = null + } + syncInterval = settings.webdavSyncInterval + lastSyncTime = backup.webdavSync?.lastSyncTime || undefined + logPrefix = '[WebdavAutoSync]' + } else if (backupType === 's3') { + if (s3SyncTimeout) { + clearTimeout(s3SyncTimeout) + s3SyncTimeout = null + } + syncInterval = settings.s3?.syncInterval || 0 + lastSyncTime = backup.s3Sync?.lastSyncTime || undefined + logPrefix = '[S3AutoSync]' + } else if (backupType === 'local') { + if (localSyncTimeout) { + clearTimeout(localSyncTimeout) + localSyncTimeout = null + } + syncInterval = settings.localBackupSyncInterval + lastSyncTime = backup.localBackupSync?.lastSyncTime || undefined + logPrefix = '[LocalAutoSync]' + } else { + return + } + + if (!syncInterval || syncInterval <= 0) { + Logger.log(`${logPrefix} Invalid sync interval, auto sync disabled`) + stopAutoSync(backupType) + return + } + + const requiredInterval = syncInterval * 60 * 1000 + let timeUntilNextSync = 1000 + + switch (scheduleType) { + case 'fromLastSyncTime': timeUntilNextSync = Math.max(1000, (lastSyncTime || 0) + requiredInterval - Date.now()) break case 'fromNow': @@ -530,33 +589,64 @@ export function startAutoSync(immediate = false) { break } - syncTimeout = setTimeout(performAutoBackup, timeUntilNextSync) + const timeout = setTimeout(() => performAutoBackup(backupType), timeUntilNextSync) + + // 保存对应类型的 timeout + if (backupType === 'webdav') { + webdavSyncTimeout = timeout + } else if (backupType === 's3') { + s3SyncTimeout = timeout + } else if (backupType === 'local') { + localSyncTimeout = timeout + } - const backupType = hasWebdavConfig ? 'WebDAV' : 'S3' Logger.log( - `[AutoSync] Next ${backupType} sync scheduled in ${Math.floor(timeUntilNextSync / 1000 / 60)} minutes ${Math.floor( + `${logPrefix} Next sync scheduled in ${Math.floor(timeUntilNextSync / 1000 / 60)} minutes ${Math.floor( (timeUntilNextSync / 1000) % 60 )} seconds` ) } - async function performAutoBackup() { - if (isAutoBackupRunning || isManualBackupRunning) { - Logger.log('[AutoSync] Backup already in progress, rescheduling') - scheduleNextBackup() + async function performAutoBackup(backupType: BackupType) { + let isRunning: boolean + let logPrefix: string + + if (backupType === 'webdav') { + isRunning = isWebdavAutoBackupRunning + logPrefix = '[WebdavAutoSync]' + } else if (backupType === 's3') { + isRunning = isS3AutoBackupRunning + logPrefix = '[S3AutoSync]' + } else if (backupType === 'local') { + isRunning = isLocalAutoBackupRunning + logPrefix = '[LocalAutoSync]' + } else { return } - isAutoBackupRunning = true + if (isRunning || isManualBackupRunning) { + Logger.log(`${logPrefix} Backup already in progress, rescheduling`) + scheduleNextBackup('fromNow', backupType) + return + } + + // 设置运行状态 + if (backupType === 'webdav') { + isWebdavAutoBackupRunning = true + } else if (backupType === 's3') { + isS3AutoBackupRunning = true + } else if (backupType === 'local') { + isLocalAutoBackupRunning = true + } + const maxRetries = 4 let retryCount = 0 while (retryCount < maxRetries) { try { - const backupType = hasWebdavConfig ? 'WebDAV' : 'S3' - Logger.log(`[AutoSync] Starting auto ${backupType} backup... (attempt ${retryCount + 1}/${maxRetries})`) + Logger.log(`${logPrefix} Starting auto backup... (attempt ${retryCount + 1}/${maxRetries})`) - if (hasWebdavConfig) { + if (backupType === 'webdav') { await backupToWebdav({ autoBackupProcess: true }) store.dispatch( setWebDAVSyncState({ @@ -565,7 +655,7 @@ export function startAutoSync(immediate = false) { syncing: false }) ) - } else if (hasS3Config) { + } else if (backupType === 's3') { await backupToS3({ autoBackupProcess: true }) store.dispatch( setS3SyncState({ @@ -574,19 +664,34 @@ export function startAutoSync(immediate = false) { syncing: false }) ) + } else if (backupType === 'local') { + await backupToLocal({ autoBackupProcess: true }) + store.dispatch( + setLocalBackupSyncState({ + lastSyncError: null, + lastSyncTime: Date.now(), + syncing: false + }) + ) } - isAutoBackupRunning = false - scheduleNextBackup() + // 重置运行状态 + if (backupType === 'webdav') { + isWebdavAutoBackupRunning = false + } else if (backupType === 's3') { + isS3AutoBackupRunning = false + } else if (backupType === 'local') { + isLocalAutoBackupRunning = false + } + scheduleNextBackup('fromNow', backupType) break } catch (error: any) { retryCount++ if (retryCount === maxRetries) { - const backupType = hasWebdavConfig ? 'WebDAV' : 'S3' - Logger.error(`[AutoSync] Auto ${backupType} backup failed after all retries:`, error) + Logger.error(`${logPrefix} Auto backup failed after all retries:`, error) - if (hasWebdavConfig) { + if (backupType === 'webdav') { store.dispatch( setWebDAVSyncState({ lastSyncError: 'Auto backup failed', @@ -594,7 +699,7 @@ export function startAutoSync(immediate = false) { syncing: false }) ) - } else if (hasS3Config) { + } else if (backupType === 's3') { store.dispatch( setS3SyncState({ lastSyncError: 'Auto backup failed', @@ -602,26 +707,49 @@ export function startAutoSync(immediate = false) { syncing: false }) ) + } else if (backupType === 'local') { + store.dispatch( + setLocalBackupSyncState({ + lastSyncError: 'Auto backup failed', + lastSyncTime: Date.now(), + syncing: false + }) + ) } - //only show 1 time error modal, and autoback stopped until user click ok await window.modal.error({ title: i18n.t('message.backup.failed'), - content: `[${backupType} Auto Backup] ${new Date().toLocaleString()} ` + error.message + content: `${logPrefix} ${new Date().toLocaleString()} ` + error.message }) - scheduleNextBackup('fromNow') - isAutoBackupRunning = false + scheduleNextBackup('fromNow', backupType) + + // 重置运行状态 + if (backupType === 'webdav') { + isWebdavAutoBackupRunning = false + } else if (backupType === 's3') { + isS3AutoBackupRunning = false + } else if (backupType === 'local') { + isLocalAutoBackupRunning = false + } } else { - //Exponential Backoff with Base 2: 7s、17s、37s const backoffDelay = Math.pow(2, retryCount - 1) * 10000 - 3000 - Logger.log(`[AutoSync] Failed, retry ${retryCount}/${maxRetries} after ${backoffDelay / 1000}s`) + Logger.log(`${logPrefix} Failed, retry ${retryCount}/${maxRetries} after ${backoffDelay / 1000}s`) await new Promise((resolve) => setTimeout(resolve, backoffDelay)) - //in case auto backup is stopped by user - if (!isAutoBackupRunning) { - Logger.log('[AutoSync] retry cancelled by user, exit') + // 检查是否被用户停止 + let currentRunning: boolean + if (backupType === 'webdav') { + currentRunning = isWebdavAutoBackupRunning + } else if (backupType === 's3') { + currentRunning = isS3AutoBackupRunning + } else { + currentRunning = isLocalAutoBackupRunning + } + + if (!currentRunning) { + Logger.log(`${logPrefix} retry cancelled by user, exit`) break } } @@ -630,14 +758,40 @@ export function startAutoSync(immediate = false) { } } -export function stopAutoSync() { - if (syncTimeout) { - Logger.log('[AutoSync] Stopping auto sync') - clearTimeout(syncTimeout) - syncTimeout = null +export function stopAutoSync(type?: BackupType) { + // 如果没有指定类型,停止所有自动同步 + if (!type) { + stopAutoSync('webdav') + stopAutoSync('s3') + stopAutoSync('local') + return + } + + if (type === 'webdav') { + if (webdavSyncTimeout) { + Logger.log('[WebdavAutoSync] Stopping auto sync') + clearTimeout(webdavSyncTimeout) + webdavSyncTimeout = null + } + isWebdavAutoBackupRunning = false + webdavAutoSyncStarted = false + } else if (type === 's3') { + if (s3SyncTimeout) { + Logger.log('[S3AutoSync] Stopping auto sync') + clearTimeout(s3SyncTimeout) + s3SyncTimeout = null + } + isS3AutoBackupRunning = false + s3AutoSyncStarted = false + } else if (type === 'local') { + if (localSyncTimeout) { + Logger.log('[LocalAutoSync] Stopping auto sync') + clearTimeout(localSyncTimeout) + localSyncTimeout = null + } + isLocalAutoBackupRunning = false + localAutoSyncStarted = false } - isAutoBackupRunning = false - autoSyncStarted = false } export async function getBackupData() { @@ -727,7 +881,7 @@ async function clearDatabase() { /** * Backup to local directory */ -export async function backupToLocalDir({ +export async function backupToLocal({ showMessage = false, customFileName = '', autoBackupProcess = false @@ -812,10 +966,31 @@ export async function backupToLocalDir({ Logger.error('[LocalBackup] Failed to clean up old backups:', error) } } + } else { + if (autoBackupProcess) { + throw new Error(i18n.t('message.backup.failed')) + } + + store.dispatch( + setLocalBackupSyncState({ + lastSyncError: 'Backup failed' + }) + ) + + if (showMessage) { + window.modal.error({ + title: i18n.t('message.backup.failed'), + content: 'Backup failed' + }) + } } return result } catch (error: any) { + if (autoBackupProcess) { + throw error + } + Logger.error('[LocalBackup] Backup failed:', error) store.dispatch( @@ -845,157 +1020,18 @@ export async function backupToLocalDir({ } } -export async function restoreFromLocalBackup(fileName: string) { +export async function restoreFromLocal(fileName: string) { + const { localBackupDir } = store.getState().settings + try { - const { localBackupDir } = store.getState().settings - await window.api.backup.restoreFromLocalBackup(fileName, localBackupDir) + const restoreData = await window.api.backup.restoreFromLocalBackup(fileName, localBackupDir) + const data = JSON.parse(restoreData) + await handleData(data) + return true } catch (error) { Logger.error('[LocalBackup] Restore failed:', error) + window.message.error({ content: i18n.t('error.backup.file_format'), key: 'restore' }) throw error } } - -// Local backup auto sync -let localBackupAutoSyncStarted = false -let localBackupSyncTimeout: NodeJS.Timeout | null = null -let isLocalBackupAutoRunning = false - -export function startLocalBackupAutoSync(immediate = false) { - if (localBackupAutoSyncStarted) { - return - } - - const { localBackupAutoSync, localBackupDir } = store.getState().settings - - if (!localBackupAutoSync || !localBackupDir) { - Logger.log('[LocalBackupAutoSync] Invalid sync settings, auto sync disabled') - return - } - - localBackupAutoSyncStarted = true - - stopLocalBackupAutoSync() - - scheduleNextBackup(immediate ? 'immediate' : 'fromLastSyncTime') - - /** - * @param type 'immediate' | 'fromLastSyncTime' | 'fromNow' - * 'immediate', first backup right now - * 'fromLastSyncTime', schedule next backup from last sync time - * 'fromNow', schedule next backup from now - */ - function scheduleNextBackup(type: 'immediate' | 'fromLastSyncTime' | 'fromNow' = 'fromLastSyncTime') { - if (localBackupSyncTimeout) { - clearTimeout(localBackupSyncTimeout) - localBackupSyncTimeout = null - } - - const { localBackupSyncInterval } = store.getState().settings - const { localBackupSync } = store.getState().backup - - if (localBackupSyncInterval <= 0) { - Logger.log('[LocalBackupAutoSync] Invalid sync interval, auto sync disabled') - stopLocalBackupAutoSync() - return - } - - // User specified auto backup interval (milliseconds) - const requiredInterval = localBackupSyncInterval * 60 * 1000 - - let timeUntilNextSync = 1000 // immediate by default - switch (type) { - case 'fromLastSyncTime': // If last sync time exists, use it as reference - timeUntilNextSync = Math.max(1000, (localBackupSync?.lastSyncTime || 0) + requiredInterval - Date.now()) - break - case 'fromNow': - timeUntilNextSync = requiredInterval - break - } - - localBackupSyncTimeout = setTimeout(performAutoBackup, timeUntilNextSync) - - Logger.log( - `[LocalBackupAutoSync] Next sync scheduled in ${Math.floor(timeUntilNextSync / 1000 / 60)} minutes ${Math.floor( - (timeUntilNextSync / 1000) % 60 - )} seconds` - ) - } - - async function performAutoBackup() { - if (isLocalBackupAutoRunning || isManualBackupRunning) { - Logger.log('[LocalBackupAutoSync] Backup already in progress, rescheduling') - scheduleNextBackup() - return - } - - isLocalBackupAutoRunning = true - const maxRetries = 4 - let retryCount = 0 - - while (retryCount < maxRetries) { - try { - Logger.log(`[LocalBackupAutoSync] Starting auto backup... (attempt ${retryCount + 1}/${maxRetries})`) - - await backupToLocalDir({ autoBackupProcess: true }) - - store.dispatch( - setLocalBackupSyncState({ - lastSyncError: null, - lastSyncTime: Date.now(), - syncing: false - }) - ) - - isLocalBackupAutoRunning = false - scheduleNextBackup() - - break - } catch (error: any) { - retryCount++ - if (retryCount === maxRetries) { - Logger.error('[LocalBackupAutoSync] Auto backup failed after all retries:', error) - - store.dispatch( - setLocalBackupSyncState({ - lastSyncError: 'Auto backup failed', - lastSyncTime: Date.now(), - syncing: false - }) - ) - - // Only show error modal once and wait for user acknowledgment - await window.modal.error({ - title: i18n.t('message.backup.failed'), - content: `[Local Backup Auto Backup] ${new Date().toLocaleString()} ` + error.message - }) - - scheduleNextBackup('fromNow') - isLocalBackupAutoRunning = false - } else { - // Exponential Backoff with Base 2: 7s, 17s, 37s - const backoffDelay = Math.pow(2, retryCount - 1) * 10000 - 3000 - Logger.log(`[LocalBackupAutoSync] Failed, retry ${retryCount}/${maxRetries} after ${backoffDelay / 1000}s`) - - await new Promise((resolve) => setTimeout(resolve, backoffDelay)) - - // Check if auto backup was stopped by user - if (!isLocalBackupAutoRunning) { - Logger.log('[LocalBackupAutoSync] retry cancelled by user, exit') - break - } - } - } - } - } -} - -export function stopLocalBackupAutoSync() { - if (localBackupSyncTimeout) { - Logger.log('[LocalBackupAutoSync] Stopping auto sync') - clearTimeout(localBackupSyncTimeout) - localBackupSyncTimeout = null - } - isLocalBackupAutoRunning = false - localBackupAutoSyncStarted = false -} diff --git a/src/renderer/src/services/MessagesService.ts b/src/renderer/src/services/MessagesService.ts index 615103a11d..25b822cd21 100644 --- a/src/renderer/src/services/MessagesService.ts +++ b/src/renderer/src/services/MessagesService.ts @@ -248,7 +248,7 @@ export async function getMessageTitle(message: Message, length = 30): Promise Date: Fri, 11 Jul 2025 22:50:13 +0800 Subject: [PATCH 175/246] refactor: improve environment variable handling in electron.vite.config.ts - Introduced `isDev` and `isProd` constants for clearer environment checks. - Simplified sourcemap and noDiscovery settings based on environment. - Enhanced esbuild configuration for production to drop console and debugger statements. --- electron.vite.config.ts | 42 +++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/electron.vite.config.ts b/electron.vite.config.ts index 2b4c5e6b92..b867f4e989 100644 --- a/electron.vite.config.ts +++ b/electron.vite.config.ts @@ -8,6 +8,9 @@ const visualizerPlugin = (type: 'renderer' | 'main') => { return process.env[`VISUALIZER_${type.toUpperCase()}`] ? [visualizer({ open: true })] : [] } +const isDev = process.env.NODE_ENV === 'development' +const isProd = process.env.NODE_ENV === 'production' + export default defineConfig({ main: { plugins: [externalizeDepsPlugin(), ...visualizerPlugin('main')], @@ -21,17 +24,21 @@ export default defineConfig({ build: { rollupOptions: { external: ['@libsql/client', 'bufferutil', 'utf-8-validate', '@cherrystudio/mac-system-ocr'], - output: { - // 彻底禁用代码分割 - 返回 null 强制单文件打包 - manualChunks: undefined, - // 内联所有动态导入,这是关键配置 - inlineDynamicImports: true - } + output: isProd + ? { + manualChunks: undefined, // 彻底禁用代码分割 - 返回 null 强制单文件打包 + inlineDynamicImports: true // 内联所有动态导入,这是关键配置 + } + : {} }, - sourcemap: process.env.NODE_ENV === 'development' + sourcemap: isDev + }, + esbuild: { + drop: ['console', 'debugger'], + legalComments: 'none' }, optimizeDeps: { - noDiscovery: process.env.NODE_ENV === 'development' + noDiscovery: isDev } }, preload: { @@ -42,7 +49,7 @@ export default defineConfig({ } }, build: { - sourcemap: process.env.NODE_ENV === 'development' + sourcemap: isDev } }, renderer: { @@ -60,14 +67,7 @@ export default defineConfig({ ] ] }), - // 只在开发环境下启用 CodeInspectorPlugin - ...(process.env.NODE_ENV === 'development' - ? [ - CodeInspectorPlugin({ - bundler: 'vite' - }) - ] - : []), + ...(isDev ? [CodeInspectorPlugin({ bundler: 'vite' })] : []), // 只在开发环境下启用 CodeInspectorPlugin ...visualizerPlugin('renderer') ], resolve: { @@ -95,6 +95,12 @@ export default defineConfig({ selectionAction: resolve(__dirname, 'src/renderer/selectionAction.html') } } - } + }, + esbuild: isProd + ? { + drop: ['console', 'debugger'], + legalComments: 'none' + } + : {} } }) From bea664af0ff07ef003371633a3b5fd7571b10a62 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Fri, 11 Jul 2025 22:36:45 +0800 Subject: [PATCH 176/246] refactor: simplify HtmlArtifactsPopup component and improve preview functionality - Removed unnecessary extracted components and integrated their logic directly into HtmlArtifactsPopup. - Enhanced preview functionality with a debounced update mechanism for HTML content. - Updated styling for better layout and responsiveness, including fullscreen handling. - Adjusted view mode management for clearer code structure and improved user experience. --- .../CodeBlockView/HtmlArtifactsCard.tsx | 300 +++++-------- .../CodeBlockView/HtmlArtifactsPopup.tsx | 410 +++++++----------- .../src/pages/home/Messages/MessageHeader.tsx | 2 +- .../ProviderSettings/EditModelsPopup.tsx | 19 +- 4 files changed, 282 insertions(+), 449 deletions(-) diff --git a/src/renderer/src/components/CodeBlockView/HtmlArtifactsCard.tsx b/src/renderer/src/components/CodeBlockView/HtmlArtifactsCard.tsx index 68d75da9fd..b3389570c1 100644 --- a/src/renderer/src/components/CodeBlockView/HtmlArtifactsCard.tsx +++ b/src/renderer/src/components/CodeBlockView/HtmlArtifactsCard.tsx @@ -11,10 +11,100 @@ import styled, { keyframes } from 'styled-components' import HtmlArtifactsPopup from './HtmlArtifactsPopup' +const HTML_VOID_ELEMENTS = new Set([ + 'area', + 'base', + 'br', + 'col', + 'embed', + 'hr', + 'img', + 'input', + 'link', + 'meta', + 'param', + 'source', + 'track', + 'wbr' +]) + +const HTML_COMPLETION_PATTERNS = [ + /<\/html\s*>/i, + //i, + /<\/div\s*>/i, + /<\/script\s*>/i, + /<\/style\s*>/i +] + interface Props { html: string } +function hasUnmatchedTags(html: string): boolean { + const stack: string[] = [] + const tagRegex = /<\/?([a-zA-Z][a-zA-Z0-9]*)[^>]*>/g + let match + + while ((match = tagRegex.exec(html)) !== null) { + const [fullTag, tagName] = match + const isClosing = fullTag.startsWith('') || HTML_VOID_ELEMENTS.has(tagName.toLowerCase()) + + if (isSelfClosing) continue + + if (isClosing) { + if (stack.length === 0 || stack.pop() !== tagName.toLowerCase()) { + return true + } + } else { + stack.push(tagName.toLowerCase()) + } + } + + return stack.length > 0 +} + +function checkIsStreaming(html: string): boolean { + if (!html?.trim()) return false + + const trimmed = html.trim() + + // 快速检查:如果有明显的完成标志,直接返回false + for (const pattern of HTML_COMPLETION_PATTERNS) { + if (pattern.test(trimmed)) { + // 特殊情况:同时有DOCTYPE和 + if (trimmed.includes('/i.test(trimmed)) { + return false + } + // 如果只是以结尾,也认为是完成的 + if (/<\/html\s*>$/i.test(trimmed)) { + return false + } + } + } + + // 检查未完成的标志 + const hasIncompleteTag = /<[^>]*$/.test(trimmed) + const hasUnmatched = hasUnmatchedTags(trimmed) + + if (hasIncompleteTag || hasUnmatched) return true + + // 对于简单片段,如果长度较短且没有明显结束标志,可能还在生成 + const hasStructureTags = /<(html|body|head)[^>]*>/i.test(trimmed) + if (!hasStructureTags && trimmed.length < 500) { + return !HTML_COMPLETION_PATTERNS.some((pattern) => pattern.test(trimmed)) + } + + return false +} + +const getTerminalStyles = (theme: ThemeMode) => ({ + background: theme === 'dark' ? '#1e1e1e' : '#f0f0f0', + color: theme === 'dark' ? '#cccccc' : '#333333', + promptColor: theme === 'dark' ? '#00ff00' : '#007700' +}) + const HtmlArtifactsCard: FC = ({ html }) => { const { t } = useTranslation() const title = extractTitle(html) || 'HTML Artifacts' @@ -23,151 +113,20 @@ const HtmlArtifactsCard: FC = ({ html }) => { const htmlContent = html || '' const hasContent = htmlContent.trim().length > 0 + const isStreaming = useMemo(() => checkIsStreaming(htmlContent), [htmlContent]) - // 判断是否正在流式生成的逻辑 - const isStreaming = useMemo(() => { - if (!hasContent) return false - - const trimmedHtml = htmlContent.trim() - - // 提前检查:如果包含关键的结束标签,直接判断为完整文档 - if (/<\/html\s*>/i.test(trimmedHtml)) { - return false - } - - // 如果同时包含 DOCTYPE 和 ,通常也是完整文档 - if (//i.test(trimmedHtml)) { - return false - } - - // 检查 HTML 是否看起来是完整的 - const indicators = { - // 1. 检查常见的 HTML 结构完整性 - hasHtmlTag: /]*>/i.test(trimmedHtml), - hasClosingHtmlTag: /<\/html\s*>$/i.test(trimmedHtml), - - // 2. 检查 body 标签完整性 - hasBodyTag: /]*>/i.test(trimmedHtml), - hasClosingBodyTag: /<\/body\s*>/i.test(trimmedHtml), - - // 3. 检查是否以未闭合的标签结尾 - endsWithIncompleteTag: /<[^>]*$/.test(trimmedHtml), - - // 4. 检查是否有未配对的标签 - hasUnmatchedTags: checkUnmatchedTags(trimmedHtml), - - // 5. 检查是否以常见的"流式结束"模式结尾 - endsWithTypicalCompletion: /(<\/html>\s*|<\/body>\s*|<\/div>\s*|<\/script>\s*|<\/style>\s*)$/i.test(trimmedHtml) - } - - // 如果有明显的未完成标志,则认为正在生成 - if (indicators.endsWithIncompleteTag || indicators.hasUnmatchedTags) { - return true - } - - // 如果有 HTML 结构但不完整 - if (indicators.hasHtmlTag && !indicators.hasClosingHtmlTag) { - return true - } - - // 如果有 body 结构但不完整 - if (indicators.hasBodyTag && !indicators.hasClosingBodyTag) { - return true - } - - // 对于简单的 HTML 片段,检查是否看起来是完整的 - if (!indicators.hasHtmlTag && !indicators.hasBodyTag) { - // 如果是简单片段且没有明显的结束标志,可能还在生成 - return !indicators.endsWithTypicalCompletion && trimmedHtml.length < 500 - } - - return false - }, [htmlContent, hasContent]) - - // 检查未配对标签的辅助函数 - function checkUnmatchedTags(html: string): boolean { - const stack: string[] = [] - const tagRegex = /<\/?([a-zA-Z][a-zA-Z0-9]*)[^>]*>/g - - // HTML5 void 元素(自闭合元素)的完整列表 - const voidElements = [ - 'area', - 'base', - 'br', - 'col', - 'embed', - 'hr', - 'img', - 'input', - 'link', - 'meta', - 'param', - 'source', - 'track', - 'wbr' - ] - - let match - - while ((match = tagRegex.exec(html)) !== null) { - const [fullTag, tagName] = match - const isClosing = fullTag.startsWith('') || voidElements.includes(tagName.toLowerCase()) - - if (isSelfClosing) continue - - if (isClosing) { - if (stack.length === 0 || stack.pop() !== tagName.toLowerCase()) { - return true // 找到不匹配的闭合标签 - } - } else { - stack.push(tagName.toLowerCase()) - } - } - - return stack.length > 0 // 还有未闭合的标签 - } - - // 获取格式化的代码预览 - function getFormattedCodePreview(html: string): string { - const trimmed = html.trim() - const lines = trimmed.split('\n') - const lastFewLines = lines.slice(-3) // 显示最后3行 - return lastFewLines.join('\n') - } - - /** - * 在编辑器中打开 - */ - const handleOpenInEditor = () => { - setIsPopupOpen(true) - } - - /** - * 关闭弹窗 - */ - const handleClosePopup = () => { - setIsPopupOpen(false) - } - - /** - * 外部链接打开 - */ const handleOpenExternal = async () => { const path = await window.api.file.createTempFile('artifacts-preview.html') await window.api.file.write(path, htmlContent) const filePath = `file://${path}` - if (window.api.shell && window.api.shell.openExternal) { + if (window.api.shell?.openExternal) { window.api.shell.openExternal(filePath) } else { console.error(t('artifacts.preview.openExternal.error.content')) } } - /** - * 下载到本地 - */ const handleDownload = async () => { const fileName = `${title.replace(/[^a-zA-Z0-9\s]/g, '').replace(/\s+/g, '-') || 'html-artifact'}.html` await window.api.file.save(fileName, htmlContent) @@ -202,27 +161,27 @@ const HtmlArtifactsCard: FC = ({ html }) => { $ - {getFormattedCodePreview(htmlContent)} + {htmlContent.trim().split('\n').slice(-3).join('\n')} - ) : ( - - - @@ -230,21 +189,11 @@ const HtmlArtifactsCard: FC = ({ html }) => { - {/* 弹窗组件 */} - + setIsPopupOpen(false)} /> ) } -const shimmer = keyframes` - 0% { - background-position: -200px 0; - } - 100% { - background-position: calc(200px + 100%) 0; - } -` - const Container = styled.div<{ $isStreaming: boolean }>` background: var(--color-background); border: 1px solid var(--color-border); @@ -274,21 +223,7 @@ const Header = styled.div` padding: 20px 24px 16px; background: var(--color-background-soft); border-bottom: 1px solid var(--color-border); - position: relative; border-radius: 8px 8px 0 0; - - &::before { - content: ''; - position: absolute; - top: 0; - left: 0; - right: 0; - height: 3px; - background: linear-gradient(90deg, #3b82f6, #8b5cf6, #06b6d4); - background-size: 200% 100%; - animation: ${shimmer} 3s ease-in-out infinite; - border-radius: 8px 8px 0 0; - } ` const IconWrapper = styled.div<{ $isStreaming: boolean }>` @@ -297,18 +232,15 @@ const IconWrapper = styled.div<{ $isStreaming: boolean }>` justify-content: center; width: 40px; height: 40px; - background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); + background: ${(props) => + props.$isStreaming + ? 'linear-gradient(135deg, #f59e0b 0%, #d97706 100%)' + : 'linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)'}; border-radius: 12px; color: white; - box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3); + box-shadow: ${(props) => + props.$isStreaming ? '0 4px 6px -1px rgba(245, 158, 11, 0.3)' : '0 4px 6px -1px rgba(59, 130, 246, 0.3)'}; transition: background 0.3s ease; - - ${(props) => - props.$isStreaming && - ` - background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); /* Darker orange for loading */ - box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.3); - `} ` const TitleSection = styled.div` @@ -346,7 +278,7 @@ const Content = styled.div` ` const ButtonContainer = styled.div` - margin: 16px !important; + margin: 10px 16px !important; display: flex; flex-direction: row; gap: 8px; @@ -354,7 +286,7 @@ const ButtonContainer = styled.div` const TerminalPreview = styled.div<{ $theme: ThemeMode }>` margin: 16px; - background: ${(props) => (props.$theme === 'dark' ? '#1e1e1e' : '#f0f0f0')}; + background: ${(props) => getTerminalStyles(props.$theme).background}; border-radius: 8px; overflow: hidden; font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace; @@ -362,8 +294,8 @@ const TerminalPreview = styled.div<{ $theme: ThemeMode }>` const TerminalContent = styled.div<{ $theme: ThemeMode }>` padding: 12px; - background: ${(props) => (props.$theme === 'dark' ? '#1e1e1e' : '#f0f0f0')}; - color: ${(props) => (props.$theme === 'dark' ? '#cccccc' : '#333333')}; + background: ${(props) => getTerminalStyles(props.$theme).background}; + color: ${(props) => getTerminalStyles(props.$theme).color}; font-size: 13px; line-height: 1.4; min-height: 80px; @@ -379,25 +311,27 @@ const TerminalCodeLine = styled.span<{ $theme: ThemeMode }>` flex: 1; white-space: pre-wrap; word-break: break-word; - color: ${(props) => (props.$theme === 'dark' ? '#cccccc' : '#333333')}; + color: ${(props) => getTerminalStyles(props.$theme).color}; background-color: transparent !important; ` const TerminalPrompt = styled.span<{ $theme: ThemeMode }>` - color: ${(props) => (props.$theme === 'dark' ? '#00ff00' : '#007700')}; + color: ${(props) => getTerminalStyles(props.$theme).promptColor}; font-weight: bold; flex-shrink: 0; ` +const blinkAnimation = keyframes` + 0%, 50% { opacity: 1; } + 51%, 100% { opacity: 0; } +` + const TerminalCursor = styled.span<{ $theme: ThemeMode }>` display: inline-block; width: 2px; height: 16px; - background: ${(props) => (props.$theme === 'dark' ? '#00ff00' : '#007700')}; - animation: ${keyframes` - 0%, 50% { opacity: 1; } - 51%, 100% { opacity: 0; } - `} 1s infinite; + background: ${(props) => getTerminalStyles(props.$theme).promptColor}; + animation: ${blinkAnimation} 1s infinite; margin-left: 2px; ` diff --git a/src/renderer/src/components/CodeBlockView/HtmlArtifactsPopup.tsx b/src/renderer/src/components/CodeBlockView/HtmlArtifactsPopup.tsx index 59988a0b1e..5e491c4052 100644 --- a/src/renderer/src/components/CodeBlockView/HtmlArtifactsPopup.tsx +++ b/src/renderer/src/components/CodeBlockView/HtmlArtifactsPopup.tsx @@ -1,9 +1,9 @@ import CodeEditor from '@renderer/components/CodeEditor' -import { isMac } from '@renderer/config/constant' +import { isLinux, isMac, isWin } from '@renderer/config/constant' import { classNames } from '@renderer/utils' import { Button, Modal } from 'antd' import { Code, Maximize2, Minimize2, Monitor, MonitorSpeaker, X } from 'lucide-react' -import { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import styled from 'styled-components' @@ -16,140 +16,41 @@ interface HtmlArtifactsPopupProps { type ViewMode = 'split' | 'code' | 'preview' -// 视图模式配置 -const VIEW_MODE_CONFIG = { - split: { - key: 'split' as const, - icon: MonitorSpeaker, - i18nKey: 'html_artifacts.split' - }, - code: { - key: 'code' as const, - icon: Code, - i18nKey: 'html_artifacts.code' - }, - preview: { - key: 'preview' as const, - icon: Monitor, - i18nKey: 'html_artifacts.preview' - } -} as const - -// 抽取头部组件 -interface ModalHeaderProps { - title: string - isFullscreen: boolean - viewMode: ViewMode - onViewModeChange: (mode: ViewMode) => void - onToggleFullscreen: () => void - onCancel: () => void -} - -const ModalHeaderComponent: React.FC = ({ - title, - isFullscreen, - viewMode, - onViewModeChange, - onToggleFullscreen, - onCancel -}) => { +const HtmlArtifactsPopup: React.FC = ({ open, title, html, onClose }) => { const { t } = useTranslation() + const [viewMode, setViewMode] = useState('split') + const [currentHtml, setCurrentHtml] = useState(html) + const [isFullscreen, setIsFullscreen] = useState(false) - const viewButtons = useMemo(() => { - return Object.values(VIEW_MODE_CONFIG).map(({ key, icon: Icon, i18nKey }) => ( - } - onClick={() => onViewModeChange(key)}> - {t(i18nKey)} - - )) - }, [viewMode, onViewModeChange, t]) - - return ( - - - {title} - - - {viewButtons} - - -