From ca2c5e45a97dcad275f1c181ddf1b1c2a4af5b8d Mon Sep 17 00:00:00 2001 From: Autumn-27 <53844290+Autumn-27@users.noreply.github.com> Date: Wed, 19 Aug 2026 11:12:21 -0400 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E5=AF=B9=E8=AF=9D=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=20Enter=20=E6=8D=A2=E8=A1=8C,Ctrl/Cmd+Enter?= =?UTF-8?q?=20=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 会话界面共享 Composer 与任务详情主 Agent 输入框统一改为回车换行,避免长消息 误发。任务详情原本是单行 Input(根本无法换行),换成 Textarea 并对齐 Composer 的自动增高样式(rows=1 + max-h-40)。 --- web/src/app/(main)/chat/page.tsx | 11 ++++++----- .../function/tasks/detail/_tabs/sessions-tab.tsx | 16 +++++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/web/src/app/(main)/chat/page.tsx b/web/src/app/(main)/chat/page.tsx index aa7fea4..2b6a7fb 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 sends, -// Shift+Enter newlines) — the same affordance across DraftChat and ChatView. +// Composer is the shared bottom input (textarea grows to a cap, Enter newlines, +// Ctrl/Cmd+Enter sends) — the same affordance across DraftChat and ChatView. function Composer({ value, onChange, @@ -112,7 +112,8 @@ function Composer({ const fileInputRef = React.useRef(null); const atts = attachments ?? []; function onKeyDown(e: React.KeyboardEvent) { - if (e.key === "Enter" && !e.shiftKey) { + // Enter 换行;只有 Ctrl/Cmd+Enter 才发送(避免长消息误发)。 + if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { e.preventDefault(); onSend(); } @@ -363,7 +364,7 @@ function DraftChat({ onChange={setInput} onSend={send} disabled={sending || uploading || !agentKey} - placeholder="输入消息,Enter 发送,Shift+Enter 换行" + placeholder="输入消息,Enter 换行,Ctrl+Enter 发送" leftSlot={agentPicker} onPickFiles={pickFiles} uploading={uploading} @@ -691,7 +692,7 @@ function ChatView({ onChange={setInput} onSend={send} disabled={running} - placeholder={running ? "Agent 正在回复…" : "输入消息,Enter 发送,Shift+Enter 换行"} + placeholder={running ? "Agent 正在回复…" : "输入消息,Enter 换行,Ctrl+Enter 发送"} running={running} onStop={stop} stopDisabled={stopping} diff --git a/web/src/app/(main)/function/tasks/detail/_tabs/sessions-tab.tsx b/web/src/app/(main)/function/tasks/detail/_tabs/sessions-tab.tsx index 5a225e9..1365089 100644 --- a/web/src/app/(main)/function/tasks/detail/_tabs/sessions-tab.tsx +++ b/web/src/app/(main)/function/tasks/detail/_tabs/sessions-tab.tsx @@ -24,7 +24,7 @@ import { cn } from "@/lib/utils"; import { Transcript } from "@/components/transcript"; import { TodoPopover } from "@/components/todo-popover"; import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; +import { Textarea } from "@/components/ui/textarea"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Tooltip, @@ -1070,7 +1070,7 @@ export function SessionsTab({ taskId }: { taskId: string }) { ))} )} -
+
{uploading ? : } - setInput(e.target.value)} onKeyDown={(e) => { - if (e.key === "Enter" && !mainLive) send(); + // Enter 换行;只有 Ctrl/Cmd+Enter 才发送。 + if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { + e.preventDefault(); + if (!mainLive) send(); + } }} disabled={mainLive} />