Repository navigation
Conversation
A bare Escape in the focused prompt box runs the same Stop protocol as the Stop button (soft cancel, then force kill on a deliberate second press after the arm window). A shared precedence gate (useComposerStopKey) yields to an open picker, a recording or draining dictation, a pending approval or its nudge, IME composition, and any other Escape owner found by the shared anotherEscapeOwnerIsOpen() probe. A held Escape never escalates. The gate is wired into both composer editors: the textarea's keydown and the rich-text (Lexical) editor's KEY_ESCAPE_COMMAND, so the binding also works with "Style Markdown While Typing" on. Each editor supplies its own IME verdict from its own latch. The notification banner is not an Escape owner: it already skips an Escape whose defaultPrevented is set, and the composer's claimants preventDefault, so a pending card no longer disables Escape-to-stop or dictation discard. Refs #22315
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: the diff only adds an Escape key binding and DOM markers that aren't visible. It adds or changes no visible control, string or state, so no screenshots are needed. Notes
[UX-REVIEWED] c83208d Description read[DESCRIPTION-READ] f6be917816f51bf84a48397b50c9f002bf8812e8d0ddcb36bd64a023e6a8b63d That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this adds a key binding behind one shared precedence gate. It renders nothing new and removes nothing. Notes
[DESIGN-REVIEWED] c83208d Description read[DESCRIPTION-READ] 4fb8444ea6179f391b79d0faf234b7bf3818cd3e70405f587f2563a7126333ad That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. One rider changes dictation-discard behaviour beyond the stop binding. Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: stop a running turn from the keyboard by pressing Escape in the focused prompt box, as the CLI allows (#22315). ADDITION.
The patch also carries the [FIRST-PRINCIPLES-REVIEWED] c83208d Description read[DESCRIPTION-READ] 1ac3f246e4c0fa698dd587458db3b8988be0e9325dc73a4395e47e39a74511ec That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — 🔴 changes requested (blocking)GPT 6.1 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- website/src/components/chat-input/escapeOwners.ts:55 -- Unmarked Escape owners also cancel the running turn
[BLOCK-MERGE] c83208d Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 stays blocking. The harm is at the LOW-to-MEDIUM rung, and the fix is small. F1 (MEDIUM/LOW):
False positive or not applicable? A repository writer can comment: |
With auto-speak on, the reply is read aloud while the turn streams, and Escape is the stop-speaking shortcut. Its capture-phase listener does not preventDefault, so the same keydown reached the composer's Escape-to-stop gate and also soft-cancelled the turn; a second press to silence the next sentence was read as a force kill. Stopping speech clears voicePlaying synchronously, so the gate cannot ask the store. The stop-speaking listener now marks the keydown it spent (utils/speechStopKey.ts) and the gate yields on a marked event, in both the textarea and the rich-text editor. Refs #22315
Fixes #22315
Problem / Motivation
Goal: Pressing Escape in the focused prompt box stops the running turn, matching the CLI's cancel-streaming binding.
Enhancement: the dashboard had only the Stop button and no keyboard way to stop a turn; the CLI binds Esc to cancel the streaming turn.
Why it matters
Stopping a runaway or mis-aimed turn is a frequent, time-sensitive action. Reaching for the mouse to hit Stop is slower than the Escape every CLI user already has muscle memory for, and keyboard users had no equivalent at all.
Not a goal
DEFAULT_SHORTCUTSentry with a Stop-button tooltip (Escape in the composer should stop the running turn, like the CLI's cancel-streaming binding #22315 item 5). Tracked in Escape-to-stop: double-tap setting and rebindable stop-turn shortcut (follow-up to #22315) #23462.What changed (motivation → approach → change)
useComposerStopKey(chat-input/stopKey.ts) returns a callback(event, { native, composing }) => boolean. It claims the key only when a turn is running on this slot and no picker, dictation, approval, approval nudge, IME composition, voice read-back or other Escape owner has it, then runs the sameonStopprotocol the Stop button runs (first press soft-cancels, a deliberate second press after the arm window force-kills). A held (auto-repeat) Escape is swallowed and never escalates.Each editor supplies its own composition verdict from its own IME latch, so an Escape that only cancels a candidate window never stops the turn in either editor. The Lexical command ignores a modified Escape and is registered at
COMMAND_PRIORITY_HIGHwith the editor's other key commands.preventDefault, and stopping speech clearsvoicePlayingsynchronously, so by the time the same keydown reaches the composer the store no longer shows speech playing. The listener now records the keydown it spent in aWeakSet(utils/speechStopKey.ts:noteEscapeStoppedSpeech/escapeStoppedSpeech), and the gate yields on a marked event. So the press that silences speech never also cancels the turn, and a second press for the next sentence can't force-kill it. The next unmarked Escape stops the turn as usual. This narrows Escape in the composer should stop the running turn, like the CLI's cancel-streaming binding #22315 item 4, which let read-aloud stop share the press: it still does, but the turn is no longer the second thing that press acts on.anotherEscapeOwnerIsOpen()(chat-input/escapeOwners.ts) is the single rule both the stop gate andvoice.ts's dictation discard consult, so the two cannot drift. It yields to:[role="dialog"]surfaces (command bar, snip overlay, confirms, and the non-modalSessionControlHost, which lets Escape propagate unstopped by design and relies on this probe), except one carryingdata-escape-passthrough.ComputerUseLiveView, a read-only live-desktop panel open alongside a focused composer that never steals focus or claims Escape, carries that attribute, so Escape still stops the turn while it is up.[data-escape-owner]: a non-dialog surface whose own document-level handler closes on Escape whether or not the event was already handled (it does not readdefaultPrevented), so without the marker one Escape would both close it and stop the turn. Carried while open by the embedded file preview (MarkdownPanelviaDetailPanel's opt-inescapeOwnerprop), the message-search bar (SearchBar), and the paste-preview tooltip (PastePreviewTooltipvia an opt-inescapeOwner, set byPasteHoverLayerandPastedChip).voice.tsused to yield only to[role="dialog"]; it now asks the same shared probe. So while the file preview, the message-search bar or the paste-preview tooltip is open, Escape closes that surface and keeps the dictation (before, one Escape closed the surface and also discarded the dictation). And while the read-only live-desktop view is open, Escape now discards a dictation (before, that view'srole="dialog"made Escape do nothing to it).defaultPreventedis set, and both composer claimants (stop gate, dictation discard)preventDefaultthe Escape they take before it bubbles todocument. So with the composer focused, Escape stops the turn or discards the dictation and the pending card stays; with nothing running, Escape dismisses the card as today. Marking the banner would have made any pending card silently disable both composer bindings.ImeEnterClaimRatchet.test.tskeeps its original predicate. The gate takes the caller's composition verdict as a parameter and folds it into its opening compound condition, so it never presents the bare composition-decline-return shape the ratchet pins.Backwards compatibility
Compatible: Escape still does all of its existing composer jobs first (closes a picker, discards a recording or draining dictation, dismisses a pending approval or its nudge, cancels IME composition, closes a dialog). It only falls through to stop when none of those apply and a turn is running.
Removes nothing: the diff adds a key binding, two opt-in DOM markers, three optional props (
DetailPanel.escapeOwner,PastePreviewTooltip.escapeOwner,LexicalComposerInput.onEscapeStop) and a per-event speech mark the stop-speaking listener writes without changing what it does; no key, prop, record or public function is removed or renamed.Tests
composerStopKey.test.ts(new): 13 cases pinning the gate's precedence matrix. Fires when running and clear; yields for not-running, noonStop, IME composing (nopreventDefaulteither), an Escape already marked as having stopped speech (and stops on the next unmarked one), picker open, recording, draining, approval, nudge, openrole="dialog", and an opendata-escape-ownersurface; stops the turn when the open dialog opts out withdata-escape-passthrough; swallows a held Escape without escalating.ChatInput.lexicalKeys.test.tsx: three new cases on the real Lexical composer. A bare Escape while a turn runs callsonStopand a Shift+Escape does not; an Escape marked by the stop-speaking listener leaves the turn running; Escape does nothing with no turn running and on a keyCode-229 (post-composition) keydown. The first case fails with theonEscapeStopwiring removed fromChatInput(checked locally).ChatInput.escapeStop.test.tsx(new): the same wiring on the mounted textarea composer. Bare Escape stops, Shift+Escape doesn't, nothing with no turn running, and a speech-marked Escape leaves the turn running.useKeyboardShortcuts.test.tsx: two new cases. The stop-speaking listener marks the Escape it spent, and only that one; it marks nothing when no speech is playing.escapeStoppedSpeechcheck removed (checked locally).NotificationBanner.test.tsx: new case. An Escape alreadydefaultPreventedby a focused surface leaves the pending card in place.ComputerUseLiveView.test.tsx: asserts the rendered dialog carriesdata-escape-passthrough.ImeEnterClaimRatchet.test.ts: all 22 cases pass against the unmodified ratchet.tsc -p tsconfig.app.jsonclean,eslintclean on every changed file, and the related vitest subset (ChatInput, Lexical, NotificationBanner, SearchBar, MarkdownPanel, DetailPanel, voice/Dictation, Paste, composer, ratchets, i18n, ComputerUse, keyboard shortcuts) 257 files / 4647 tests passing.Manual verification
Behavior is covered at the gate and on the mounted Lexical composer. A full live check (press Escape mid-turn in the dashboard and confirm the turn stops, while a picker, dictation or approval still takes Escape first) needs a running gateway with an active turn (and auto-speak for the read-back case), which the sandbox this was built in cannot provision.
Screenshots / video
Why no screenshot: no rendered surface changes; the change binds a key to the existing Stop protocol, and the composer, Stop button and pickers look identical.
Related Issues
Fixes #22315. Deferred items 3 and 5 are tracked in #23462. Supersedes fork PR #22410.
Checklist
Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.