fix(desktop): keep Escape inside compose instead of exiting the stream #294
Reference in New Issue
Block a user
Delete Branch "claude/escape-key-compose-review-a496b2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
While recording or reviewing a compose, Escape both cancelled the compose
and exited the stream. The stream's window-level navigation handler skips
keys when an input is focused (isTypingTarget), which is why the text path
was unaffected, but recording/reviewing have no focused input so Escape
leaked through to the exit handler.
Fix it at the compose layer rather than teaching the navigation pipe about
compose: the compose key handler now consumes (preventDefault +
stopPropagation) any key it handles and listens in the capture phase, so it
reliably wins over the stream's bubble-phase navigation/action handlers
regardless of listener registration order. Pure pause states (hold-space)
are untouched, so Escape still exits the stream there.
This leaves the typing/task/configuring paths equivalent (their onCancel is
the same cancel() the handler invokes) while ⌘+Enter / ⌘+M still fall
through to the text editor.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01DapjFX1MhYPZeJv4s56K5L
Summary by CodeRabbit
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Free
Run ID:
cb414d9c-f26b-4f7e-86ff-17aa8dcfbebd📥 Commits
Reviewing files that changed from the base of the PR and between
bfe53b46cfand4f7fee538b.📒 Files selected for processing (1)
js/desktop/src/features/compose/compose-overlay.tsx📝 Walkthrough
Walkthrough
ComposeOverlay's keydown handler gains a localconsume()helper (preventDefault+stopPropagation) applied to all compose-state shortcut paths. The listener is now registered in the capture phase so compose receives key events before any bubble-phase window handlers.Changes
ComposeOverlay keyboard event propagation
consume()helper and per-state key handlingjs/desktop/src/features/compose/compose-overlay.tsxconsume()function and applies it to Escape/cancel in early compose steps, idle shortcuts (`,S,T,D), and recording/reviewing controls (Q/Escape cancel,`/Sstop,Entersend).js/desktop/src/features/compose/compose-overlay.tsxwindow.addEventListener('keydown', ..., true)and the matchingremoveEventListenerto capture phase, ensuring compose's handler fires before bubble-phase handlers.Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Comment
@coderabbitai helpto get the list of available commands and usage tips.