Commit 014e0cc
authored
🤖 Allow interrupt (Ctrl+C) in ChatInput when no text selected (#405)
## Problem
Currently, `Ctrl+C` (or `Cmd+C` on Mac) to interrupt the stream only
works when focus is outside editable elements. This means users cannot
interrupt while ChatInput is focused, requiring them to click elsewhere
first.
## Solution
Modified the interrupt handler in `useAIViewKeybinds` to check for text
selection:
- **No selection** → Interrupt stream (allows interrupting from
ChatInput)
- **Has selection** → Browser handles copy (preserves existing behavior)
The logic now allows interrupt in editable elements as long as there's
no active text selection, preventing conflict with the copy keybind.
## Changes
- Updated `useAIViewKeybinds.ts` interrupt handler to check
`window.getSelection()`
- When in editable element with no selection: prevent default and
interrupt
- When in editable element with selection: let browser handle copy
## Testing
Manual testing scenarios:
- ChatInput focused, no selection, Ctrl+C → should interrupt ✅
- ChatInput focused, text selected, Ctrl+C → should copy text ✅
- Other input focused, no selection, Ctrl+C → should interrupt ✅
- Not in input, Ctrl+C → should interrupt ✅
_Generated with `cmux`_1 parent 4c70f5b commit 014e0cc
1 file changed
+20
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
72 | 89 | | |
73 | 90 | | |
74 | 91 | | |
75 | 92 | | |
76 | 93 | | |
77 | 94 | | |
78 | | - | |
| 95 | + | |
79 | 96 | | |
80 | 97 | | |
81 | 98 | | |
| |||
0 commit comments