From 0fdeb27e06413a2c99c9ceeb368a82eadeafc52d Mon Sep 17 00:00:00 2001 From: MT-Mint <798521692@qq.com> Date: Mon, 1 Jun 2026 17:55:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(workspace):=20=E4=BC=98=E5=8C=96=E6=AC=A2?= =?UTF-8?q?=E8=BF=8E=E5=BB=BA=E8=AE=AE=E5=B8=83=E5=B1=80=E5=B9=B6=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E8=BE=93=E5=85=A5=E6=A1=86=E6=8F=90=E4=BA=A4=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ai-elements/suggestion.tsx | 11 +++- .../workspace/input-box-submit.test.ts | 39 +++++++++++ .../components/workspace/input-box-submit.ts | 15 +++++ .../src/components/workspace/input-box.tsx | 11 +++- frontend/src/core/i18n/locales/zh-CN.ts | 65 +++++++++++++------ 5 files changed, 116 insertions(+), 25 deletions(-) create mode 100644 frontend/src/components/workspace/input-box-submit.test.ts create mode 100644 frontend/src/components/workspace/input-box-submit.ts diff --git a/frontend/src/components/ai-elements/suggestion.tsx b/frontend/src/components/ai-elements/suggestion.tsx index acdad064..89986fd9 100644 --- a/frontend/src/components/ai-elements/suggestion.tsx +++ b/frontend/src/components/ai-elements/suggestion.tsx @@ -17,8 +17,13 @@ export const Suggestions = ({ children, ...props }: SuggestionsProps) => ( - -
+ +
{Children.map(children, (child, index) => child != null ? ( { + assert.equal( + canSubmitInputBoxMessage({ + text: " ", + attachmentCount: 0, + referenceCount: 0, + }), + false, + ); +}); + +void test("allows empty-text submits when new attachments are present", () => { + assert.equal( + canSubmitInputBoxMessage({ + text: " ", + attachmentCount: 1, + referenceCount: 0, + }), + true, + ); +}); + +void test("allows empty-text submits when existing references are present", () => { + assert.equal( + canSubmitInputBoxMessage({ + text: " ", + attachmentCount: 0, + referenceCount: 1, + }), + true, + ); +}); diff --git a/frontend/src/components/workspace/input-box-submit.ts b/frontend/src/components/workspace/input-box-submit.ts new file mode 100644 index 00000000..fc6bc0df --- /dev/null +++ b/frontend/src/components/workspace/input-box-submit.ts @@ -0,0 +1,15 @@ +type CanSubmitInputBoxMessageOptions = { + text: string; + attachmentCount: number; + referenceCount: number; +}; + +export function canSubmitInputBoxMessage({ + text, + attachmentCount, + referenceCount, +}: CanSubmitInputBoxMessageOptions) { + return ( + text.trim().length > 0 || attachmentCount > 0 || referenceCount > 0 + ); +} diff --git a/frontend/src/components/workspace/input-box.tsx b/frontend/src/components/workspace/input-box.tsx index 8393e007..dad7f713 100644 --- a/frontend/src/components/workspace/input-box.tsx +++ b/frontend/src/components/workspace/input-box.tsx @@ -100,6 +100,7 @@ import { ScrollArea } from "../ui/scroll-area"; import { ModeHoverGuide } from "./mode-hover-guide"; import { ThreadMemoryPanel } from "./thread-memory-panel"; import { Tooltip } from "./tooltip"; +import { canSubmitInputBoxMessage } from "./input-box-submit"; const MAX_REFERENCES_PER_MESSAGE = 10; @@ -511,7 +512,13 @@ export function InputBox({ onStop?.(); return; } - if (!message.text && references.length === 0) { + if ( + !canSubmitInputBoxMessage({ + text: message.text, + attachmentCount: message.files?.length ?? 0, + referenceCount: references.length, + }) + ) { return; } setIsFocused(false); @@ -1227,7 +1234,7 @@ function SuggestionList({ ); return ( {promptSuggestions.map((suggestion) => ( diff --git a/frontend/src/core/i18n/locales/zh-CN.ts b/frontend/src/core/i18n/locales/zh-CN.ts index a802cefe..0d1e87ab 100644 --- a/frontend/src/core/i18n/locales/zh-CN.ts +++ b/frontend/src/core/i18n/locales/zh-CN.ts @@ -130,44 +130,69 @@ export const zhCN: Translations = { prompt: "为[主题/产品]撰写吸引人的自媒体文案,包括标题、正文和话题标签。", icon: PenLineIcon, - children: [{ id: "6057", name: "生辰解语" }], + children: [{ id: "6057", name: "八字命理" }], + }, + { + suggestion: "张雪峰・升学就业心智", + prompt: "编写[项目/功能]的需求文档,包含功能描述、用户故事和验收标准。", + icon: CompassIcon, + children: [{ id: "6094", name: "张雪峰・升学就业心智" }], + }, + { + suggestion: "塔罗牌", + prompt: "编写[产品/功能]的使用指南,包含操作步骤、注意事项和常见问题。", + icon: GraduationCapIcon, + children: [{ id: "6133", name: "塔罗牌" }], }, { suggestion: "GPT-Image-2", - prompt: "编写[项目/功能]的需求文档,包含功能描述、用户故事和验收标准。", - icon: CompassIcon, + prompt: "对[Excel文件/数据]进行分析,生成数据洞察和可视化建议。", + icon: MicroscopeIcon, children: [{ id: "6130", name: "GPT-Image-2" }], }, { suggestion: "音乐生成", - prompt: "编写[产品/功能]的使用指南,包含操作步骤、注意事项和常见问题。", - icon: GraduationCapIcon, - children: [{ id: "6133", name: "音乐生成器" }], + prompt: "对[word文件/数据]进行分析", + icon: MicroscopeIcon, + children: [{ id: "6133", name: "音乐生成" }], }, { - suggestion: "excel填表神器", - prompt: "对[Excel文件/数据]进行分析,生成数据洞察和可视化建议。", - icon: MicroscopeIcon, - children: [{ id: "17", name: "Excel处理" }], + suggestion: "微信公众号攥写", + prompt: "针对[行业/产品]进行市场调研,分析市场规模、竞品和趋势。", + icon: ShapesIcon, + children: [{ id: "6134", name: "微信公众号攥写" }], }, { suggestion: "word填表神器", - prompt: "对[word文件/数据]进行分析", - icon: MicroscopeIcon, - children: [{ id: "6195", name: "docx表格填充器" }], - }, - { - suggestion: "微信文章撰写", prompt: "针对[行业/产品]进行市场调研,分析市场规模、竞品和趋势。", icon: ShapesIcon, - children: [{ id: "6134", name: "微信文章撰写" }], + children: [{ id: "6195", name: "word填表神器" }], }, - { - suggestion: "精美ppt制作", + { + suggestion: "excel填表神器", prompt: "针对[行业/产品]进行市场调研,分析市场规模、竞品和趋势。", icon: ShapesIcon, - children: [{ id: "6192", name: "精美ppt制作" }], + children: [{ id: "17", name: "excel填表神器" }], }, + { + suggestion: "精美ppt生成", + prompt: "针对[行业/产品]进行市场调研,分析市场规模、竞品和趋势。", + icon: ShapesIcon, + children: [{ id: "6129 ", name: "精美ppt生成" }], + }, + { + suggestion: "论文撰写", + prompt: "针对[行业/产品]进行市场调研,分析市场规模、竞品和趋势。", + icon: ShapesIcon, + children: [{ id: "6250", name: "论文撰写" }], + }, + { + suggestion: "专利交底书编写", + prompt: "针对[行业/产品]进行市场调研,分析市场规模、竞品和趋势。", + icon: ShapesIcon, + children: [{ id: "6000", name: "专利交底书编写" }], + }, + ], suggestionsCreate: [ {