Skip to content

fix(input): deliver special key presses - #55

Merged
kitlangton merged 2 commits into
mainfrom
kitty-key-input
Aug 12, 2026
Merged

fix(input): deliver special key presses#55
kitlangton merged 2 commits into
mainfrom
kitty-key-input

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Make ui.press deliver named arrow keys and modified special keys to the driven OpenCode TUI while keeping command payload validation strict.

Supported examples now include:

opencode-drive send --command.ui.press '{"key":"right"}'
opencode-drive send --command.ui.press '{"key":"down","modifiers":{"meta":true}}'
opencode-drive send --command.ui.press '{"key":"tab","modifiers":{"ctrl":true}}'

meta remains the canonical terminal Alt modifier from the OpenCode simulation protocol. Unknown fields such as modifiers.alt are rejected instead of silently dropped.

Before / After

Before: ui.press forwarded semantic key names and modifier objects directly to OpenCode's mock input layer. Plain right was interpreted as the literal characters r, i, g, h, t; modified down did 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.ts encodes named arrow presses as CSI sequences, terminal Alt+Down as ESC [ 1 ; 3 B, and Ctrl+Tab as kitty ESC [ 9 ; 5 u before serializing ui.press.
  • packages/drive/src/cli/commands.ts strictly rejects excess command parameters so unsupported fields cannot report false success.
  • packages/drive/test/simulation/opencode-protocol.test.ts asserts the exact terminal sequences emitted on the wire.
  • packages/drive/test/simulation/direct-cli.test.ts covers plain Right, Alt+Down, Ctrl+Tab, and invalid alt through the CLI.
  • packages/drive/test/manual/session-switching.ts exercises Ctrl+Tab and Alt+Down against two real OpenCode session tabs and submits a unique routing probe after the switch.
  • .changeset/strict-command-params.md records 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-existing Buffer warning in src/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:

  • Opened /settings, moved from Theme to Animations with two ui.press {"key":"down"} calls, then pressed Right. The visible value changed from off to on, and the isolated project wrote .opencode/cli.json with "animations": true.
  • Created two session tabs, switched first with Ctrl+Tab and then back with Alt+Down, and submitted ALT_DOWN_ROUTE_PROBE. The server log recorded the post-switch session.input.admitted event on the second tab's aggregate ID (ses_00c3cb733...), distinct from the first tab (ses_00c3cb980...).

@kitlangton
kitlangton merged commit 3d451b5 into main Aug 12, 2026
1 check passed
@kitlangton
kitlangton deleted the kitty-key-input branch August 12, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant