From 840c043f7bbcea19b7339215f1a237a1ecf25389 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Mon, 20 Oct 2025 18:22:10 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Fix=20Ctrl+A=20and=20Ctrl+C=20in?= =?UTF-8?q?terception=20in=20text=20inputs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only intercept these keybinds when actively needed: - Ctrl+A (ACCEPT_EARLY_COMPACTION): Only during active compaction - Ctrl+C (INTERRUPT_STREAM): Only during compaction or when not in editable element Fixes issue where Ctrl+A (select all) and Ctrl+C (copy) were broken in text inputs due to premature event.preventDefault() calls. These keybinds are meant for compaction control, not general input. --- src/hooks/useAIViewKeybinds.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hooks/useAIViewKeybinds.ts b/src/hooks/useAIViewKeybinds.ts index 8dced943a..982137c85 100644 --- a/src/hooks/useAIViewKeybinds.ts +++ b/src/hooks/useAIViewKeybinds.ts @@ -53,12 +53,12 @@ export function useAIViewKeybinds({ const handleKeyDown = (e: KeyboardEvent) => { // Ctrl+C during compaction: cancel and restore command to input // (different from Ctrl+A which accepts early with [truncated]) + // Only intercept if actively compacting (otherwise allow browser default for copy) if (matchesKeybind(e, KEYBINDS.INTERRUPT_STREAM)) { - e.preventDefault(); - if (canInterrupt && isCompactingStream(aggregator)) { // Ctrl+C during compaction: restore original state and enter edit mode // Stores cancellation marker in localStorage (persists across reloads) + e.preventDefault(); void cancelCompaction(workspaceId, aggregator, (messageId, command) => { setEditingMessage({ id: messageId, content: command }); }); @@ -67,24 +67,30 @@ export function useAIViewKeybinds({ } // Normal stream interrupt (non-compaction) - if (canInterrupt || showRetryBarrier) { + // Don't intercept if user is typing in an input field + if (!isEditableElement(e.target) && (canInterrupt || showRetryBarrier)) { + e.preventDefault(); setAutoRetry(false); // User explicitly stopped - don't auto-retry void window.api.workspace.interruptStream(workspaceId); + return; } + + // Let browser handle Ctrl+C (copy) in editable elements return; } // Ctrl+A during compaction: accept early with [truncated] sentinel // (different from Ctrl+C which cancels and restores original state) + // Only intercept if actively compacting (otherwise allow browser default for select all) if (matchesKeybind(e, KEYBINDS.ACCEPT_EARLY_COMPACTION)) { - e.preventDefault(); - if (canInterrupt && isCompactingStream(aggregator)) { // Ctrl+A during compaction: perform compaction with partial summary // No flag set - handleCompactionAbort will perform compaction with [truncated] + e.preventDefault(); setAutoRetry(false); void window.api.workspace.interruptStream(workspaceId); } + // Let browser handle Ctrl+A (select all) when not compacting return; }