Skip to content

Commit dad16a3

Browse files
committed
feat: change interrupt stream keybind to Ctrl+C
1 parent 5006273 commit dad16a3

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/components/AIView.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,18 @@ const AIViewInner: React.FC<AIViewProps> = ({
281281
} else if (matchesKeybind(e, KEYBINDS.OPEN_TERMINAL)) {
282282
e.preventDefault();
283283
handleOpenTerminal();
284+
} else if (matchesKeybind(e, KEYBINDS.INTERRUPT_STREAM)) {
285+
// Only interrupt if there's an active stream
286+
if (canInterrupt) {
287+
e.preventDefault();
288+
void window.api.workspace.sendMessage(workspaceId, "");
289+
}
284290
}
285291
};
286292

287293
window.addEventListener("keydown", handleKeyDown);
288294
return () => window.removeEventListener("keydown", handleKeyDown);
289-
}, [jumpToBottom, handleOpenTerminal]);
295+
}, [jumpToBottom, handleOpenTerminal, workspaceId, canInterrupt]);
290296

291297
if (loading) {
292298
return (
@@ -375,8 +381,8 @@ const AIViewInner: React.FC<AIViewProps> = ({
375381
<StreamingBarrier
376382
text={
377383
isCompacting
378-
? "compacting... hit Esc to cancel"
379-
: `${getModelName(currentModel)} streaming... hit Esc to cancel`
384+
? `compacting... hit ${formatKeybind(KEYBINDS.INTERRUPT_STREAM)} to cancel`
385+
: `${getModelName(currentModel)} streaming... hit ${formatKeybind(KEYBINDS.INTERRUPT_STREAM)} to cancel`
380386
}
381387
/>
382388
)}

src/components/ChatInput.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -640,12 +640,9 @@ export const ChatInput: React.FC<ChatInputProps> = ({
640640
const isFocused = document.activeElement === inputRef.current;
641641
e.preventDefault();
642642

643-
// Priority 1: Cancel editing if in edit mode
643+
// Cancel editing if in edit mode
644644
if (editingMessage && onCancelEdit) {
645645
onCancelEdit();
646-
} else if (canInterrupt) {
647-
// Priority 2: Interrupt streaming if active
648-
void window.api.workspace.sendMessage(workspaceId, "");
649646
}
650647

651648
if (isFocused) {
@@ -680,7 +677,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({
680677
// Build placeholder text based on current state
681678
const placeholder = (() => {
682679
if (editingMessage) {
683-
return `Edit your message... (${formatKeybind(KEYBINDS.CANCEL)} to cancel, ${formatKeybind(KEYBINDS.SEND_MESSAGE)} to send)`;
680+
return `Edit your message... (${formatKeybind(KEYBINDS.CANCEL)} to cancel edit, ${formatKeybind(KEYBINDS.SEND_MESSAGE)} to send)`;
684681
}
685682
if (isCompacting) {
686683
return "Compacting conversation...";
@@ -689,7 +686,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({
689686
// Build hints for normal input
690687
const hints: string[] = [];
691688
if (canInterrupt) {
692-
hints.push(`${formatKeybind(KEYBINDS.CANCEL)} to interrupt`);
689+
hints.push(`${formatKeybind(KEYBINDS.INTERRUPT_STREAM)} to interrupt`);
693690
}
694691
hints.push(`${formatKeybind(KEYBINDS.SEND_MESSAGE)} to send`);
695692
hints.push(`${formatKeybind(KEYBINDS.OPEN_MODEL_SELECTOR)} to change model`);

src/utils/ui/keybinds.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,12 @@ export const KEYBINDS = {
121121
/** Insert newline in text input */
122122
NEW_LINE: { key: "Enter", shift: true },
123123

124-
/** Cancel current action / Close modal / Interrupt streaming */
124+
/** Cancel current action / Close modal (excludes stream interruption) */
125125
CANCEL: { key: "Escape" },
126126

127+
/** Interrupt active stream (destructive - stops AI generation) */
128+
INTERRUPT_STREAM: { key: "c", ctrl: true },
129+
127130
/** Focus chat input */
128131
FOCUS_INPUT_I: { key: "i" },
129132

0 commit comments

Comments
 (0)