Skip to content

Keyboard control for running threads: interrupt + edit-queued now, rewind later #1585

Description

@jshph

The gap

Thread control is mouse-only today. There's no keyboard way to stop a running turn, edit a queued follow-up, or rewind/edit a sent message. Worse, the Stop button is hidden whenever you've typed a draft (the submit slot shows Send instead), so you can't even stop-by-mouse without clearing what you typed.

We want a "terminal-style" feel, but the underlying agents (Codex, Claude Code) don't behave identically, so we shouldn't blindly bind keys to whatever each harness does natively. This issue proposes which gestures are worth a key now and which aren't, and asks for agreement on one shared decision before anyone wires bindings.

The test each gesture has to pass

A gesture only deserves a key if it's:

  1. Consistent across agents — the same keypress produces the same user-visible state transition on Codex and Claude Code.
  2. Coherent in bb's state machine — there's a clear target and the action is legal in the state you'd press it.

Per-gesture verdict

Interrupt — ship it. Both providers stop a running turn with the same observable result (turn ends, partial output kept, next turn resumes); only cost differs (Codex keeps the session warm, Claude Code respawns). Fills the real "can't stop with a draft typed" gap. → bare ESC while a turn is running = interrupt.

Edit a queued message — ship it. Queued messages are a bb server concept with zero provider branching — editing one never touches the agent, behaves identically everywhere, and is available mid-run (which is exactly when queued messages exist). Do it in-place (reuse the existing inline editor + the expectedUpdatedAt-guarded update, which is safe if the message flushes mid-edit). Give it its own keyboard entry — queue-row focus + Enter — not ESC.

Rewind / edit a sent message — defer. This one fails both tests today: on Claude Code a turn with no recorded checkpoint hard-errors (409), while Codex never does — so an identical gesture would be dark on some turns and not others. And bb has no timeline keyboard-focus model, so there's no message for a key to target, plus editing a sent message requires the thread to be idle. Making it real is a mini-project (a focus/navigation model, "why unavailable" feedback, and a decision on live-vs-idle semantics), not a binding. Out of scope here.

The one decision to ratify

Bare ESC = interrupt. Queue-editing gets its own entry (row focus + Enter). We do not overload ESC across all three gestures.

The trap we're avoiding: if ESC means "interrupt" when the queue is empty but "edit last queued" when it isn't, its meaning silently flips on invisible state. Pick one meaning for bare ESC and give the others distinct entries.

Non-goals

  • No double-ESC / key-sequence infrastructure (the binding system is single-key + modifiers only).
  • No timeline focus/navigation model.
  • Rewind/edit-sent keyboard support — deferred to its own issue.
Implementation notes (for the interrupt PR)
  • Binding registry is single base-key + flat modifiers, no sequences: packages/domain/src/app-keybindings.ts (appShortcutSchema, APP_COMMAND_IDS). Dispatch: apps/app/src/components/commands/AppCommandProvider.tsx. There's no command id for stop/steer/edit today — all three are mouse-only.
  • Interrupt path already exists end to end: stopThread → POST /v1/threads/:id/stop → daemon thread.stop → provider-native turn/interrupt (Codex) / session abort (Claude Code). UI entry: ThreadDetailPromptArea.tsx handleStopThread. Add a thread.interrupt command id + a threadRunning context key + a window-level ESC handler gated on running & not-editable-focus. Note the emergent double-ESC-to-stop: first ESC blurs the composer, second arrives unfocused → interrupts, with no sequence infra.
  • ESC is currently ad-hoc in component handlers (dismiss typeahead → blur composer → cancel voice: PromptBoxInternal.tsx), not in the registry — precedence must be specified so interrupt slots in after those.
  • Queued edit: reuse beginEditQueuedMessage (useInlineQueuedMessageEditing.ts) + updateQueuedMessage (thread-runtime-mutations.ts); target queuedMessages[len-1]. Current ESC in the queue collapses the drawer only when the drag handle is focused (QueuedMessagesList.tsx), so composer-focused ESC is free.
  • Capability-unavailable states are surfaced today by absence (control not rendered), no tooltip — keyboard triggers will need explicit "why unavailable" feedback.
  • Branch note: jpham/mods is behind Default-enable sent-message editing #1351/Improve experimental message editing #1378 (the edit-message hardening). Interrupt is independent of that, but rebase before picking up rewind.

AGENT GENERATED: by Claude Opus 4.8

Activity

  1. added
    threads
    on Aug 18, 2026
  2. benwaffle commented on Sep 15, 2026

    @benwaffle

    Data point for the "bare ESC = interrupt" decision: I have been running this on my fork for a while and it behaves the way the issue proposes.

    benwaffle@b4ad9f2 (7 lines in PromptBoxInternal.tsx plus tests)

    Behavior:

    • Escape in the composer still dismisses an open typeahead menu or cancels a sent-message edit first, exactly as today.
    • Otherwise, when a run is active and the stop button is the one showing (composer empty, not attaching, not recording), Escape calls the same onStop handler the button uses.
    • When a draft is typed, Escape keeps the existing blur behavior, so it never discards queued input by stopping the agent. That also sidesteps the "Stop is hidden behind Send" gap: clear the draft, press Escape.

    It is a composer-local handler rather than a thread.interrupt command in the registry, so it does not get a Settings → Keyboard entry; the registry version from the implementation notes would be the better final shape, and this shows the precedence order (typeahead → edit cancel → interrupt → blur) feels right in daily use.

    AGENT GENERATED

  3. kanishkaverma commented on Oct 23, 2026

    @kanishkaverma

    I'd like this in core too. Until it lands, I'm running bare Escape = interrupt as a local plugin on bb 0.46.1.

    There's no stop command in the registry, so the plugin listens for Escape on window and calls sdk.threads.stop for the thread in the focused pane. It does nothing when the thread is idle, when the @ typeahead or a dropdown is open, inside a terminal, browser tab, or dialog, or in a text field other than the composer.

    It differs from the fork commit above in one way: Escape stops the turn even when a draft is typed, and the draft stays in the composer, so there's no need to clear a draft before stopping.

    Building it as a plugin needed these workarounds:

    • The plugin command API won't accept bare Escape. defaultShortcut on app.commands.register and app.composer.experimental_registerCommand rejects a key without Command, Control, or Alt ("Use Command, Control, or Alt with a key, or a function key"), although core's own app.back is bound to bare Escape. A thread.interrupt command would need the same allowance.
    • The composer blurs itself on Escape before a bubble-phase window listener runs, so the plugin listens in the capture phase and checks for [data-promptbox-typeahead-menu] to leave the Escape that closes the typeahead alone.
    • A plugin can only learn whether a thread is running through useComposer().isRunning, so the plugin mounts an empty composer banner in every thread to read that value.

    The thread.interrupt command from the implementation notes, with bare Escape allowed as its default binding, would make the plugin unnecessary.

    AGENT GENERATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    threads

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions