From 28c1be735b095901e73b0436a82f5ce39f12383d Mon Sep 17 00:00:00 2001 From: Autumn-27 <53844290+Autumn-27@users.noreply.github.com> Date: Thu, 20 Aug 2026 12:40:01 -0400 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=E4=BC=9A=E8=AF=9D=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=E6=94=B9=E4=B8=BA=20Enter=20=E5=8F=91?= =?UTF-8?q?=E9=80=81=E3=80=81Shift+Enter=20=E6=8D=A2=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原先 Enter 换行、Ctrl+Enter 发送,不符合直觉。改为单独 Enter 发送、Shift+Enter 换行,并加 isComposing 保护避免中文输入法选字时误发(与 sessions-tab 一致)。 Claude-Session: https://claude.ai/code/session_01Bs2rrsVHUBTxRusm9espwB --- web/src/app/(main)/chat/page.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/web/src/app/(main)/chat/page.tsx b/web/src/app/(main)/chat/page.tsx index 2b6a7fb..32ecdb2 100644 --- a/web/src/app/(main)/chat/page.tsx +++ b/web/src/app/(main)/chat/page.tsx @@ -77,8 +77,8 @@ function LiveBadge() { ); } -// Composer is the shared bottom input (textarea grows to a cap, Enter newlines, -// Ctrl/Cmd+Enter sends) — the same affordance across DraftChat and ChatView. +// Composer is the shared bottom input (textarea grows to a cap, Enter sends, +// Shift+Enter newlines) — the same affordance across DraftChat and ChatView. function Composer({ value, onChange, @@ -112,11 +112,10 @@ function Composer({ const fileInputRef = React.useRef(null); const atts = attachments ?? []; function onKeyDown(e: React.KeyboardEvent) { - // Enter 换行;只有 Ctrl/Cmd+Enter 才发送(避免长消息误发)。 - if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { - e.preventDefault(); - onSend(); - } + // Enter 发送;Shift+Enter 换行。isComposing 时是中文等输入法在选字,不拦截。 + if (e.key !== "Enter" || e.shiftKey || e.nativeEvent.isComposing) return; + e.preventDefault(); + onSend(); } return (
@@ -364,7 +363,7 @@ function DraftChat({ onChange={setInput} onSend={send} disabled={sending || uploading || !agentKey} - placeholder="输入消息,Enter 换行,Ctrl+Enter 发送" + placeholder="输入消息,Enter 发送,Shift+Enter 换行" leftSlot={agentPicker} onPickFiles={pickFiles} uploading={uploading} @@ -692,7 +691,7 @@ function ChatView({ onChange={setInput} onSend={send} disabled={running} - placeholder={running ? "Agent 正在回复…" : "输入消息,Enter 换行,Ctrl+Enter 发送"} + placeholder={running ? "Agent 正在回复…" : "输入消息,Enter 发送,Shift+Enter 换行"} running={running} onStop={stop} stopDisabled={stopping}