Give the web suggestion deck the keyboard once it is opened - #1197
Merged
Conversation
The web deck was mouse-only: chips carried tabindex="-1", every render path force-restored the caret, and the sole key it listened for was Escape. So after `C-x .` the letters you typed went straight into the terminal, and the history stack — up to 50 verbatim prompts — could only be searched by eye and scrollbar. The TUI deck has had fuzzy type-ahead on its History row since it shipped. Opening the deck deliberately (the chord, or the orb) is an unambiguous request to work with suggestions, so from that point the open deck routes keys until it is dismissed. Typing a printable character from any surface lands in the history type-ahead; arrows / C-n / C-p walk the rows; Enter runs the highlighted row's own action; Escape or C-g dismisses. The standing focus rule is untouched, and deliberately so: DOM focus never moves. The deck routes keys while the caret stays in xterm or the composer, which is why handing the keyboard back is a no-op rather than a restore, and why chips keep tabindex="-1". Only plain keys are claimed — Meta/Alt and every Ctrl key except C-g/C-n/C-p fall through, so `C-x` chords still work while the deck is open, including `C-x .` to toggle it shut. Narrow layouts keep the old behavior: a phone's composer and virtual keyboard are the point of that layout, and diverting characters out of a half-written message would cost more than the recall saves. The scorer is a port of the TUI's, verified against the same fixtures, so recall ranks identically in both clients: exact, prefix, substring, then a subsequence that decays with match span, ties newest-first.
Contributor
Author
|
Both frames are e2e artifacts from Typing filters history. Arrow keys walk the matches. The keyboard cursor is a tinted row with a left edge marker — readable without a pointer, and without a focus ring, since focus is still in the terminal behind the deck. The |
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.


What
In the web UI, after
C-x .(or clicking the orb), typing now searches your prompt history — the same gesture the TUI deck has always had. Arrows walk the matches, Enter takes one, Escape orC-ggives the keyboard back.Before this, the deck was mouse-only: chips carried
tabindex="-1", every render path force-restored the caret, and the only key it listened for was Escape. Letters typed after the chord went into the terminal, and the history stack — up to 50 verbatim prompts — could only be searched by eye and scrollbar.The rule this follows
"Focus stays in the terminal" is untouched, and deliberately so. DOM focus never moves. The deck routes keys while the caret stays in xterm or the composer, which is why handing the keyboard back is a no-op rather than a restore, and why chips keep
tabindex="-1". What changed is only that opening the deck deliberately — the chord, or the orb — is treated as an unambiguous request to work with suggestions, so the open deck claims plain keystrokes until dismissed.Keys deliberately not claimed:
C-g/C-n/C-p. SoC-xchords keep working while the deck is open, includingC-x .to toggle it shut.Narrow layouts keep the old behavior: a phone's composer and virtual keyboard are the point of that layout, and diverting characters out of a half-written message would cost more than the recall saves.
Behavior
Backspace↑↓C-pC-nEnter/→←Esc/C-gThe fuzzy scorer is a port of the TUI's, checked against the same fixtures, so recall ranks identically in both clients: exact, prefix, substring, then a subsequence that decays with match span, ties newest-first.
Tests
web_keymap_suggestion_deck_takes_the_keyboard_once_openeddrives real key events through a browser and asserts the keystrokes are actually consumed (dispatchEventreturning false is the difference between "the deck took it" and "it fell through to the terminal"), that the caret never moves, thatC-gand Escape both release, that reopening starts a clean search, and that a narrow viewport leaves typing to the composer.Full workspace suite green.
Spec
Spec 0109 previously described type-ahead as TUI-only and said of the web UI only that it "follows the same on-demand rule". Amended with the keyboard-ownership decision, the focus invariant it must not disturb, and the narrow-layout exception.