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
+6
-7
@@ -77,8 +77,8 @@ function LiveBadge() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Composer is the shared bottom input (textarea grows to a cap, Enter newlines,
|
// Composer is the shared bottom input (textarea grows to a cap, Enter sends,
|
||||||
// Ctrl/Cmd+Enter sends) — the same affordance across DraftChat and ChatView.
|
// Shift+Enter newlines) — the same affordance across DraftChat and ChatView.
|
||||||
function Composer({
|
function Composer({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
@@ -112,12 +112,11 @@ function Composer({
|
|||||||
const fileInputRef = React.useRef<HTMLInputElement>(null);
|
const fileInputRef = React.useRef<HTMLInputElement>(null);
|
||||||
const atts = attachments ?? [];
|
const atts = attachments ?? [];
|
||||||
function onKeyDown(e: React.KeyboardEvent<HTMLTextAreaElement>) {
|
function onKeyDown(e: React.KeyboardEvent<HTMLTextAreaElement>) {
|
||||||
// Enter 换行;只有 Ctrl/Cmd+Enter 才发送(避免长消息误发)。
|
// Enter 发送;Shift+Enter 换行。isComposing 时是中文等输入法在选字,不拦截。
|
||||||
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
if (e.key !== "Enter" || e.shiftKey || e.nativeEvent.isComposing) return;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
onSend();
|
onSend();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div className="border-t p-3">
|
<div className="border-t p-3">
|
||||||
{atts.length > 0 && (
|
{atts.length > 0 && (
|
||||||
@@ -364,7 +363,7 @@ function DraftChat({
|
|||||||
onChange={setInput}
|
onChange={setInput}
|
||||||
onSend={send}
|
onSend={send}
|
||||||
disabled={sending || uploading || !agentKey}
|
disabled={sending || uploading || !agentKey}
|
||||||
placeholder="输入消息,Enter 换行,Ctrl+Enter 发送"
|
placeholder="输入消息,Enter 发送,Shift+Enter 换行"
|
||||||
leftSlot={agentPicker}
|
leftSlot={agentPicker}
|
||||||
onPickFiles={pickFiles}
|
onPickFiles={pickFiles}
|
||||||
uploading={uploading}
|
uploading={uploading}
|
||||||
@@ -692,7 +691,7 @@ function ChatView({
|
|||||||
onChange={setInput}
|
onChange={setInput}
|
||||||
onSend={send}
|
onSend={send}
|
||||||
disabled={running}
|
disabled={running}
|
||||||
placeholder={running ? "Agent 正在回复…" : "输入消息,Enter 换行,Ctrl+Enter 发送"}
|
placeholder={running ? "Agent 正在回复…" : "输入消息,Enter 发送,Shift+Enter 换行"}
|
||||||
running={running}
|
running={running}
|
||||||
onStop={stop}
|
onStop={stop}
|
||||||
stopDisabled={stopping}
|
stopDisabled={stopping}
|
||||||
|
|||||||
Reference in new issue
Block a user