From f953029c5cb6a0617f082427ecdb5612d06162a7 Mon Sep 17 00:00:00 2001 From: A1pha-bit <542016855@qq.com> Date: Mon, 19 Jan 2026 12:58:48 +0800 Subject: [PATCH] Optimize message sending logic and add a waitlist to handle message submissions while waiting for a response. --- frontend/src/App.vue | 2 +- frontend/src/components/input/InputArea.vue | 128 ++++++++++++- frontend/src/components/input/SendButton.vue | 49 ++--- .../src/stores/chat/conversationActions.ts | 6 + frontend/src/stores/chat/state.ts | 17 +- .../src/stores/chat/streamChunkHandlers.ts | 48 ++++- frontend/src/stores/chat/toolActions.ts | 11 ++ frontend/src/stores/chat/types.ts | 26 ++- frontend/src/stores/chatStore.ts | 170 +++++++++++++++++- webview/stream/StreamAbortManager.ts | 25 ++- webview/stream/StreamRequestHandler.ts | 12 +- 11 files changed, 453 insertions(+), 41 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index fb2c68c..9937f62 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -60,7 +60,7 @@ async function handleSend(content: string, messageAttachments: Attachment[]) { } // 正常发送消息(传递附件) - await chatStore.sendMessage(content, messageAttachments) + await chatStore.submitMessage(content, messageAttachments) } catch (err) { console.error('发送失败:', err) } diff --git a/frontend/src/components/input/InputArea.vue b/frontend/src/components/input/InputArea.vue index 96f745f..539a448 100644 --- a/frontend/src/components/input/InputArea.vue +++ b/frontend/src/components/input/InputArea.vue @@ -189,20 +189,41 @@ const hasAttachments = computed(() => props.attachments && props.attachments.length > 0 ) -// 是否可以发送 - 只在等待响应或上传时禁用发送 -// 例外:当有待确认工具时允许发送(用于带批注拒绝) +// 是否可以发送 +// - 上传中禁用 +// - 等待响应期间允许"发送"(会进入候补队列) +// - 例外:当有待确认工具时,发送用于带批注拒绝 const canSend = computed(() => { const hasContent = inputValue.value.trim().length > 0 || (props.attachments && props.attachments.length > 0) + if (!hasContent) return false + if (props.uploading) return false + // 如果有待确认的工具,允许发送(作为批注拒绝) - if (chatStore.hasPendingToolConfirmation && hasContent) { + if (chatStore.hasPendingToolConfirmation) { return true } - return hasContent && !chatStore.isWaitingForResponse && !props.uploading + // 等待响应期间也允许发送(会进入候补队列) + return true }) +// 格式化候补队列消息预览 +function formatQueuedPreview(item: any): string { + const text = String(item?.content || '').trim() + if (text) { + return text.length > 60 ? text.slice(0, 60) + '…' : text + } + + const count = Array.isArray(item?.attachments) ? item.attachments.length : 0 + if (count > 0) { + return `附件(${count})` + } + + return '' +} + // 处理发送 function handleSend() { if (!canSend.value) return @@ -899,6 +920,33 @@ watch(() => settingsStore.promptModesVersion, () => { + +
+