From c906307a333501726833383476bc2016bc15f3dc Mon Sep 17 00:00:00 2001 From: Phantom <59059173+EurFelux@users.noreply.github.com> Date: Fri, 5 Sep 2025 15:40:46 +0800 Subject: [PATCH] fix(inputbar): fix infinite state update loop (#9933) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(模型检测): 修复状态更新无限循环的问题 修复isGenerateImageModel函数中provider类型检查错误,同时优化Inputbar中图像生成功能的自动启用逻辑 --- src/renderer/src/config/models.ts | 7 +++++-- src/renderer/src/pages/home/Inputbar/Inputbar.tsx | 9 +++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/renderer/src/config/models.ts b/src/renderer/src/config/models.ts index 5324f7004e..2c251ea217 100644 --- a/src/renderer/src/config/models.ts +++ b/src/renderer/src/config/models.ts @@ -2385,8 +2385,11 @@ export function isGenerateImageModel(model: Model): boolean { const modelId = getLowerBaseModelName(model.id, '/') - if (provider && provider.type === 'openai-response') { - return OPENAI_IMAGE_GENERATION_MODELS.some((imageModel) => modelId.includes(imageModel)) + if (provider.type === 'openai-response') { + return ( + OPENAI_IMAGE_GENERATION_MODELS.some((imageModel) => modelId.includes(imageModel)) || + GENERATE_IMAGE_MODELS.some((imageModel) => modelId.includes(imageModel)) + ) } return GENERATE_IMAGE_MODELS.some((imageModel) => modelId.includes(imageModel)) diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index db787c40fd..4012b2a9c9 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -780,12 +780,13 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic, topic }) = ) { updateAssistant({ ...assistant, webSearchProviderId: undefined }) } - if (!isGenerateImageModel(model) && assistant.enableGenerateImage) { + if (isGenerateImageModel(model)) { + if (isAutoEnableImageGenerationModel(model) && !assistant.enableGenerateImage) { + updateAssistant({ ...assistant, enableGenerateImage: true }) + } + } else if (assistant.enableGenerateImage) { updateAssistant({ ...assistant, enableGenerateImage: false }) } - if (isAutoEnableImageGenerationModel(model) && !assistant.enableGenerateImage) { - updateAssistant({ ...assistant, enableGenerateImage: true }) - } }, [assistant, model, updateAssistant]) const onMentionModel = useCallback(