Repository navigation
terminal: customizable keybindings and terminal collision fixes (#104) - #294
Merged
Merged
Conversation
bbondy
force-pushed
the
fix-issue-104
branch
from
September 14, 2026 23:16
7026e0c to
95a9250
Compare
…ller exit chord, and integration tests
The clause said bare typing characters were reserved and nothing checked for one. `is_reserved` answered for Ctrl-C, bare Enter and bare Escape only, so a settings file could hand an action a letter, and the arms that read a configured chord sit above the arm that types: under `"stash": "x"` the letter x stashed the line instead of being written, and there was then no way to type it at all. Refuse the whole unmodified half of the keyboard rather than list the keys that happen to be taken today, since every one of them is answered already: a character is typed into the line, Enter sends, Escape clears it, Tab takes what is offered, and the arrows walk the caret and the history. Shift over a character goes too, for a different reason: a terminal reports Shift-A as `A` with Shift held, so a chord written `shift-a` names an event that never arrives, and taking it would leave the action quietly dead rather than on a key that works. Ctrl-J, Shift-Enter and Ctrl-D join Ctrl-C as the rest of what INPUT-2 and INPUT-4 fix. Ctrl-S and Ctrl-O, the two chords the issue is about, are reachable under the rule. Part of brave#104
Resolving the chords one action at a time left two of them on one key. Each request was checked against the chords already taken, but an action reached later kept its default whether or not that default had just been given away, and the check meant to catch it could only decline to write a value already in the slot. So `"stash": "ctrl-o"` put stash on the scroller's chord and left the scroller there too: Ctrl-O opened the scroller, stash could not be reached by any key, and the list `?` puts up named Ctrl-O twice. That is the dead key the issue asks a fallback to avoid, arrived at by way of the fallback. Read every request first, then let an action keep its chord only where no other action still stands on it. Where one is contested both give it up, since neither asked with more right than the other and letting the first win would turn on the order the code reads them in. Giving one up puts an action back on a default a third may have been handed, so this settles rather than deciding once; with no requests left the defaults stand, and those differ. Trading two chords still works, which is what weighing a request against where the others end up rather than against the defaults is for. Part of brave#104
Three of the four shapes the parser accepted were in no clause, and one of them could not be read reliably at all. `is_chord` decided whether a JSON pair was action-to-chord or chord-to-action by looking for a hyphen, so an action a later release spells with one would be read as the chord and its chord as the action name. A `bindings` array in Claude Code's shape was accepted as well, keyed on a nested object the pull request describing it did not match, and against no fixture taken from that tool. A second file, `keybindings.json`, was read after all three settings layers, so a person's own `~/.bravebot/keybindings.json` overrode a project's `settings.local.json` and inverted the precedence every other key follows. It was also merged without being pushed onto `layers` or weighed for `contested`, so the file that decided a chord would have been reported nowhere. Keep the `keybindings` block in `settings.json` and drop the rest. brave#104 offers the separate file only as an alternative to whatever settings clause came out of brave#89, and brave#89 landed, so the block is the answer and a second file adds a precedence question for no capability. An entry that is not a string is dropped the way a malformed permission rule is, and a spelling nothing can read is still carried this far and left on its default in the interface. Restore the note on why `attribution` merges per name, which is a decision a reader cannot recover from the code, and say the chords merge that way for the same reason. Part of brave#104
The list `?` puts up was left duplicated: a static table for the tests and a second one built from the bindings for the screen. They had already drifted, so the copy on screen no longer said that Ctrl-S searches as well as stashes. One table now, taking the seven movable chords from the bindings, and the tests read the same one at their defaults. The scroller's way out named Ctrl-C among the keys while the meaning beside them already said "also ctrl-c", so the row listed one press as two. The keys name what opened the scroller and the meaning keeps Ctrl-C. Part of brave#104
Six messages had a chord written into the sentence, so a session that moved one went on being told to press the key it had moved away from: the border while an older prompt is walked back to, the keys under the prompt search, the hint that there is something to watch, the note about a picture on the clipboard, and the line saying an aside can be opened again. Each takes the chord as an argument now, in en-US and fr both, and the clipboard hint takes it from the bindings. Part of brave#104
Inside the prompt search and the delegate view the chords were still matched off the keyboard, so a moved one was read as the letter it carries: bound to alt-s, the chord that narrows the search typed an `s` into the needle instead, and bound to alt-j the chord that leaves the delegate view walked the list. Both now ask the bindings, and ahead of the arms that take a character, since those match whatever is held with it. Also drops a comment the same paragraph twice in the scroller's search keys. Part of brave#104
The rebase left it sharing an id with the clause about searching this workspace, and its count was never added to the table check-spec holds the file to. Nothing about what it says changes; the title now reads as what the clause is for. Closes brave#104
bbondy
force-pushed
the
fix-issue-104
branch
from
September 14, 2026 23:18
95a9250 to
959a208
Compare
… reads the moved search chord
Contributor
Author
|
did another pass over the keybinding flow and found two more edge cases: configured bindings could still be consumed by readline editing, and vi-mode history search was still using a hard-coded shortcut. fixed both and added regression tests. also rechecked the existing collision, precedence, and alternate-mode cases. |
bbondy
approved these changes
Sep 15, 2026
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.
Resolves #104
Summary of Changes
This change adds support for customizable keybindings in settings, resolving terminal collisions where default chords collided with terminal conventions (specifically
ctrl-sXOFF flow control andctrl-odiscard output / flush).Configurable Keybindings in Settings (
crates/config):keybindings: BTreeMap<String, String>toSettings."keybindings": { "stash": "ctrl-x", "scroller": "ctrl-u" }"bindings": [ { "chord": "ctrl-x", "action": "stash" } ]keybindings.jsonfile in~/.bravebot/keybindings.jsonand.bravebot/keybindings.json.Validation and Safety Invariants (
crates/tui):KeyChordparser incrates/tui/src/keybindings.rssupporting both-and+delimiters (e.g.ctrl-sandctrl+s).editor,watch,scroller,history,stash,trail,paste.ctrl-c,esc, bareenter, bare typing keys) are protected against remapping. Any conflicting, malformed, or reserved binding falls back safely to its default chord.Dynamic Routing and Rendering (
crates/tui):?shortcut modal dynamically renders the configured chord names.stashed_linesrow beneath the input box dynamically names the active stash chord (e.g.ctrl-x to bring it back).Specifications and Automated Tests (
docs/specs):INPUT-28todocs/specs/terminal-input.md.cc @bbondy