fix(input): deliver special key presses - #55
Merged
Merged
Conversation
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
Make
ui.pressdeliver named arrow keys and modified special keys to the driven OpenCode TUI while keeping command payload validation strict.Supported examples now include:
metaremains the canonical terminal Alt modifier from the OpenCode simulation protocol. Unknown fields such asmodifiers.altare rejected instead of silently dropped.Before / After
Before:
ui.pressforwarded semantic key names and modifier objects directly to OpenCode's mock input layer. Plainrightwas interpreted as the literal charactersr,i,g,h,t; modifieddowndid not become an arrow event; and endpoints without kitty-aware mock input could not represent Ctrl+Tab. The RPC still returned success because the request itself completed.After: Drive converts recognized terminal keys at its JSON-RPC compatibility boundary. Plain arrows use CSI, modified arrows use CSI modifier parameters where representable, and modified Tab uses kitty keyboard encoding. Existing character presses and leader sequences retain their previous path.
How
packages/drive/src/simulation/opencode-protocol.tsencodes named arrow presses as CSI sequences, terminal Alt+Down asESC [ 1 ; 3 B, and Ctrl+Tab as kittyESC [ 9 ; 5 ubefore serializingui.press.packages/drive/src/cli/commands.tsstrictly rejects excess command parameters so unsupported fields cannot report false success.packages/drive/test/simulation/opencode-protocol.test.tsasserts the exact terminal sequences emitted on the wire.packages/drive/test/simulation/direct-cli.test.tscovers plain Right, Alt+Down, Ctrl+Tab, and invalidaltthrough the CLI.packages/drive/test/manual/session-switching.tsexercises Ctrl+Tab and Alt+Down against two real OpenCode session tabs and submits a unique routing probe after the switch..changeset/strict-command-params.mdrecords the patch release.Testing
cd packages/drive && bun run test: 205 Effect tests and 58 CLI integration tests passed.cd packages/drive && bun run check: typecheck passed; lint has one pre-existingBufferwarning insrc/recording/encode.ts.cd apps/catalog && bun run check: catalog generation, lint, typecheck, 28 tests, and production builds passed.cd apps/catalog && bun run test: 28 tests passed.Real OpenCode V2 verification against current
origin/v2:/settings, moved from Theme to Animations with twoui.press {"key":"down"}calls, then pressed Right. The visible value changed fromofftoon, and the isolated project wrote.opencode/cli.jsonwith"animations": true.ALT_DOWN_ROUTE_PROBE. The server log recorded the post-switchsession.input.admittedevent on the second tab's aggregate ID (ses_00c3cb733...), distinct from the first tab (ses_00c3cb980...).