Repository navigation
feat: input parser probe-response recognition → CapabilityEvent - #132
natemoo-re wants to merge 8 commits into
Conversation
Changeset suggestionThe current changeset no longer matches this PR. This review contains a corrected replacement. Why: Changeset package scope does not match the affected packages confidently. Changeset bump does not match the consumer-visible impact. View the proposed changeset---
'@bomb.sh/tty': minor
---
Adds `CapabilityEvent` to `InputEvent` and changes `InputOptions.terminfo` to accept a `TerminalInfo`.
`scan()` now parses terminal probe responses — OSC 10/11/12 theme colors, OSC 21 kitty color protocol, OSC 22 pointer shape, XTGETTCAP (`DCS`), kitty graphics (`APC`), kitty keyboard (`CSI ?…u`), synchronized output (`DECRPM`), and DA1 — and surfaces them as typed `CapabilityEvent` objects with keys `foreground-color`, `background-color`, `cursor-color`, `colordepth`, `sync-output`, `kitty-keyboard`, `kitty-graphics`, and `pointer-shape`.
`InputOptions.terminfo` now takes the `TerminalInfo` returned by `detectTerminal()` instead of raw compiled terminfo bytes. It seeds the key-sequence trie from `terminfo.keys` and uses `terminfo.capabilities.colors` to resolve colordepth denial events to the correct tier (`"16"` vs `"256"`). Raw bytes now go to `detectTerminal({ entry })`.
#### Migration
```diff
- import { createInput } from "@bomb.sh/tty";
+ import { createInput, detectTerminal } from "@bomb.sh/tty";
- const input = await createInput({ terminfo: myTerminfoBinary });
+ const terminfo = await detectTerminal({ env: process.env, entry: myTerminfoBinary });
+ const input = await createInput({ terminfo });
```
Omit `terminfo` entirely to keep the xterm default key sequences.Review this changeset manually If this draft is correct, react with 🚀 and Cooper will commit it to this branch.
|
commit: |
|
Size Increased — +6.7 KB 118.3 KB unpacked |
Merging this PR will degrade performance by 24.09%
Performance Changes
Comparing |
ff3f7c4 to
299df82
Compare
4b430b6 to
fb273f9
Compare
fb273f9 to
a2a08b1
Compare
a2a08b1 to
aeb96df
Compare
|
I consider the performance regression here acceptable for the capability we're gaining, but we may want to do a dedicated performance optimization pass once we're comfortable with the feature set. |
| @@ -0,0 +1,22 @@ | |||
| --- | |||
There was a problem hiding this comment.
Changeset needs revision.
Changeset package scope does not match the affected packages confidently. Changeset bump does not match the consumer-visible impact.
View the proposed replacement
---
'@bomb.sh/tty': minor
---
Adds `CapabilityEvent` to `InputEvent` and changes `InputOptions.terminfo` to accept a `TerminalInfo`.
`scan()` now parses terminal probe responses — OSC 10/11/12 theme colors, OSC 21 kitty color protocol, OSC 22 pointer shape, XTGETTCAP (`DCS`), kitty graphics (`APC`), kitty keyboard (`CSI ?…u`), synchronized output (`DECRPM`), and DA1 — and surfaces them as typed `CapabilityEvent` objects with keys `foreground-color`, `background-color`, `cursor-color`, `colordepth`, `sync-output`, `kitty-keyboard`, `kitty-graphics`, and `pointer-shape`.
`InputOptions.terminfo` now takes the `TerminalInfo` returned by `detectTerminal()` instead of raw compiled terminfo bytes. It seeds the key-sequence trie from `terminfo.keys` and uses `terminfo.capabilities.colors` to resolve colordepth denial events to the correct tier (`"16"` vs `"256"`). Raw bytes now go to `detectTerminal({ entry })`.
#### Migration
```diff
- import { createInput } from "@bomb.sh/tty";
+ import { createInput, detectTerminal } from "@bomb.sh/tty";
- const input = await createInput({ terminfo: myTerminfoBinary });
+ const terminfo = await detectTerminal({ env: process.env, entry: myTerminfoBinary });
+ const input = await createInput({ terminfo });
```
Omit `terminfo` entirely to keep the xterm default key sequences.Revert the `terminfo` -> `detection` option rename. The option keeps its
name and changes format instead: it takes the `Detection` returned by
`detectTerminal()` rather than raw compiled terminfo bytes, which now go to
`detectTerminal({ terminfo })`. Specs updated for both `createInput` and
`createTerm` so the stack converges on one option name.
Changeset rewritten as a breaking-change note and fixed to target
`@bomb.sh/tty` (it referenced a nonexistent `@bombshell/input`).
`terminfo` now means one thing across the public API: the resolved `TerminalInfo` passed to `createInput`/`createTerm`. The raw compiled bytes move from `DetectOptions.terminfo` to `DetectOptions.entry` (ncurses' term for one compiled description), and `MAX_TERMINFO` becomes `MAX_TERMINFO_ENTRY` to match. `Detection` named how the value was made rather than what it holds. None of these have shipped yet.
Match createInput: the renderer option is `terminfo`, typed `TerminalInfo`. Adds the first test that seeds createTerm from a detected TerminalInfo (previously untested; test/caps.ts helpers were unused). The stack changeset now covers only what this PR and #131 add — detectTerminal/TerminalInfo, createTerm's option, term.capabilities, and the update() signature change — since #132 carries its own changeset for the input side.
The spec said detectTerminal() never rejects, but an `entry` over MAX_TERMINFO_ENTRY has always thrown a RangeError (and is tested). Keep that behavior and say why: it is caller error. Environmental conditions — missing, malformed, or oversized files on the search path — still resolve to the baseline. Adds the missing test for skipping an oversized file found on the search path.
Match createInput: the renderer option is `terminfo`, typed `TerminalInfo`. Adds the first test that seeds createTerm from a detected TerminalInfo (previously untested; test/caps.ts helpers were unused). The stack changeset now covers only what this PR and #131 add — detectTerminal/TerminalInfo, createTerm's option, term.capabilities, and the update() signature change — since #132 carries its own changeset for the input side.
Part 3/4 of the terminfo foundation stack. Requires #131.
src/input.{c,h}: the input parser seeds its escape-sequence trie from the terminfokeystable and recognizes probe responses (OSC 10/11/12/21/22, XTGETTCAP, DECRPM 2026, kitty keyboard/graphics APC, DA1 fence)input.ts:scan()surfaces those responses asCapabilityEventvalues alongside key and mouse events, ready to hand toterm.update()createInput({ terminfo })keeps its name but now takes theTerminalInfofromdetectTerminal()instead of raw bytesDetectionis renamedTerminalInfo; raw terminfo bytes move todetectTerminal({ entry })soterminfomeans one thing everywhere (MAX_TERMINFO→MAX_TERMINFO_ENTRY); none of these have shipped yet