Repository navigation
Conversation
xterm encodes F-keys, Ctrl+digit and (on Windows/Linux) Alt chords as terminal input and stops their propagation, so core's window keydown dispatcher never saw them while a terminal had focus. The terminal's key handler now asks the command registry first, except for the keys a shell reads: keys without Ctrl/Alt/Cmd and plain Ctrl+letter, Ctrl+Space, Ctrl+[ ] \ /. Those stay with the shell even when bound, so Mod+K/W/J on Windows/Linux keep reaching readline. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The app command dispatcher ignores key repeats, so after a bound key ran its command from a focused terminal, the auto-repeat keydowns fell through to xterm and reached the shell (holding F5 sent ^[[15~ per repeat). The terminal handler now swallows repeats of the key whose press ran a command, and prevents their default so a held F5 cannot reload the page. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/let-bound-commands-through-a-focused-terminal-thr_yvwjtawd4g
branch
November 20, 2026 18:30
lanjak
added a commit
to lanjak/bb
that referenced
this pull request
Nov 24, 2026
get-bb#7888 added an app command key handler to the terminal that reads the dispatcher through a ref of the view that created the terminal. A parked terminal outlives that view, so the handler is wired through the runtime's live bindings, which each remounted view replaces. This test fails when the handler keeps the dispatcher ref of the first view.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
With a terminal focused, xterm turns every key it can encode into terminal input, then calls
preventDefaultandstopPropagation. That covers F-keys, Ctrl+letter, Ctrl+3–8, and on Windows/Linux Alt and Ctrl+Alt chords. Core's command dispatcher listens onwindowin the bubble phase (AppCommandProvider.tsx), so commands bound to those keys never fired while a terminal had focus, whether core or plugin. The composer already asks the registry first throughdispatchAppCommandKey. The terminal never did. (API audit finding C2, kill-test 4.3.)What changed
The terminal's xterm key handler now asks core's command registry first, except for the keys a shell reads (
apps/app/src/components/thread/terminal/terminal-app-command-keys.ts, wired inThreadTerminalView.tsxafter the clipboard handler). The panel terminal and the onboarding terminal both mount through this view. Keyboard dispatch uses core's owndispatchAppCommandKey, so each binding'swhencontext (terminalFocus,modalOpen, …) applies unchanged.The rule. A focused terminal keeps these keys, even when a command is bound to them:
Every other bound key runs its command from the terminal: F-keys, Ctrl+Shift, Alt and Cmd chords, and Ctrl+digit.
Why all Ctrl+letters. On Windows/Linux,
Modis Ctrl. A shortlist such as C/D/R/L would let core's ownMod+W(close tab),Mod+K,Mod+P,Mod+JandMod+Ttake delete-word, kill-line, history, newline and transpose from readline, and Ctrl+B from tmux. The existing test "leaves Ctrl+letter shell keys to the shell on Linux" and the CLI guide already promised this.Consequence: Ctrl+J stays with the shell. It is a newline (LF), so a command rebound to Ctrl+J still won't fire from a focused terminal. Use a Ctrl+Shift, Alt or Cmd chord, or a function key.
Tradeoff: Alt+letter on Windows/Linux is not reserved. xterm sends it as Meta, so a bound Alt+letter now beats readline's Meta-b/f/d. No core default and no community-plugin default uses plain Alt+letter. Reserving those keys would regress macOS, where Option chords already reach commands.
Community plugins whose defaults now fire with a terminal focused (grep of 503 community plugin repos):
nicolay-i/bb-plugin-tabs: F2 rename (all platforms); Mod+Alt+1–9/P/S/W (Windows/Linux)Johannes-Berggren/bb-plugin-jb-flow: nine Alt+Shift+letter commands (Windows/Linux)wy3z/bb-cursor-suiteui-tweaks andvburojevic/bb-plugin-prompts: Alt+digit (Windows/Linux)tarasenko-by/bb-plugin-spaces: Ctrl+Alt+digit (Windows/Linux)kalindudc/bb-marketplaceswitchboard (Mod+Alt+F/J),chug2k/bb-plugin-retitle(Mod+Alt+R) andjonnik-bb-plugins/bb-plugin-bang-shell(Mod+Alt+Enter), all on Windows/LinuxUnchanged:
[data-app-terminal]stays on the panel section that themes and plugins select.Docs:
docs/configuration.md(Keyboard Shortcuts), thebb guide customizationchapter, and the bb-plugin-authoring frontend-renderer-slots reference now state the rule. No plugin SDK or wire change.How you verified
ThreadTerminalView.commands.test.tsx: a key table run against a real xterm, on both macOS and Linux.\n,\x03,\x1b,\x1b) and run nothing.ran: []). With the fix, all 103 terminal tests pass.src/components/commands,composer-commands.test.tsxandapp-keybindings.test.tspass.turbo run typecheck lint --filter=@bb/appandturbo run test --filter=@bb/templatespass.pnpm start:worktree, headless Chrome, a real zsh runningcat -v.sidebar.togglebound to F5,panel.fullScreen.togglebound to Ctrl+J.x^[[15~y, the sidebar stayed open, and the window keydown listener never saw F5. Ctrl+J was a newline.aria-expandedtrue → false), the shell line readxy, and focus stayed in the terminal. Ctrl+J and Ctrl+C still went to the shell.navigator.platformemulated as Linux: Ctrl+K opened no search, Ctrl+W deleted a word in zsh instead of closing the tab, and F5 toggled the sidebar.