From 3c7b02b9f8126197427b43493144ec85f7be2a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Tue, 15 Sep 2026 17:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=87=E6=BB=A4=20DirectProject=20=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E7=9A=84=E7=A9=BA=E7=99=BD=E5=86=85=E5=AE=B9?= =?UTF-8?q?=20part?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 跳过纯空白文本节点并合并相邻文本,避免引用后的分隔空格和换行触发 Rust 空输入校验。 --- .../ResourceReferenceInput.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx b/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx index 420180c3d..473ba4f9c 100644 --- a/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx +++ b/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx @@ -183,6 +183,17 @@ function sameDraft(left: ChatComposerDraft, right: ChatComposerDraft) { ); } +function appendInputText(content: DirectCodexUserContentPart[], text: string) { + const previous = content[content.length - 1]; + if (previous?.type === 'input_text') { + previous.text += text; + return; + } + if (text.trim()) { + content.push({ type: 'input_text', text }); + } +} + function collectDraftParts( node: LexicalNode, textParts: string[], @@ -192,12 +203,12 @@ function collectDraftParts( if ($isTextNode(node)) { const text = node.getTextContent(); textParts.push(text); - if (text) content.push({ type: 'input_text', text }); + appendInputText(content, text); return; } if ($isLineBreakNode(node)) { textParts.push('\n'); - content.push({ type: 'input_text', text: '\n' }); + appendInputText(content, '\n'); return; } if ($isResourceReferenceNode(node)) { @@ -210,7 +221,7 @@ function collectDraftParts( node.getChildren().forEach((child, index) => { if (index > 0 && node.getType() === 'root') { textParts.push('\n'); - content.push({ type: 'input_text', text: '\n' }); + appendInputText(content, '\n'); } collectDraftParts(child, textParts, references, content); });