fix(chat): 会话输入框改为 Enter 发送、Shift+Enter 换行
原先 Enter 换行、Ctrl+Enter 发送,不符合直觉。改为单独 Enter 发送、Shift+Enter 换行,并加 isComposing 保护避免中文输入法选字时误发(与 sessions-tab 一致)。 Claude-Session: https://claude.ai/code/session_01Bs2rrsVHUBTxRusm9espwB
This commit is contained in:
1 parent
9103ff838a
commit
28c1be735b
1 file changed
+8
-9
@@ -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<HTMLInputElement>(null);
|
||||
const atts = attachments ?? [];
|
||||
function onKeyDown(e: React.KeyboardEvent<HTMLTextAreaElement>) {
|
||||
// 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 (
|
||||
<div className="border-t p-3">
|
||||
@@ -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}
|
||||
|
||||
Reference in new issue
Block a user