Skip to content

feat: input parser probe-response recognition → CapabilityEvent - #132

Open
natemoo-re wants to merge 8 commits into
mainfrom
feat/input-probe-events
Open

natemoo-re wants to merge 8 commits into
mainfrom
feat/input-probe-events

Conversation

@natemoo-re

@natemoo-re natemoo-re commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Part 3/4 of the terminfo foundation stack. Requires #131.

  • src/input.{c,h}: the input parser seeds its escape-sequence trie from the terminfo keys table 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 as CapabilityEvent values alongside key and mouse events, ready to hand to term.update()
  • Breaking: createInput({ terminfo }) keeps its name but now takes the TerminalInfo from detectTerminal() instead of raw bytes
  • Detection is renamed TerminalInfo; raw terminfo bytes move to detectTerminal({ entry }) so terminfo means one thing everywhere (MAX_TERMINFO → MAX_TERMINFO_ENTRY); none of these have shipped yet
  • Specs updated to match; tests cover response recognition per input-spec §6

@natemoo-re
natemoo-re added this pull request to stack #134 September 19, 2026 04:29
@bombshell-cooper

bombshell-cooper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Changeset suggestion

The 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.

Draft updated. Remove and re-add your 🚀 reaction to approve this version.

@pkg-pr-new

pkg-pr-new Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@bomb.sh/tty@132

commit: 0d1f019

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Size Increased — +6.7 KB

118.3 KB unpacked

@natemoo-re natemoo-re changed the title feat/input probe events feat: input parser probe-response recognition → CapabilityEvent Sep 19, 2026
@codspeed

codspeed Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 24.09%

❌ 1 (👁 1) regressed benchmark
✅ 9 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
👁 createInput 272.7 ms 359.2 ms -24.09%

Comparing feat/input-probe-events (0d1f019) with main (00aee53)

Open in CodSpeed

@natemoo-re
natemoo-re force-pushed the feat/input-probe-events branch from ff3f7c4 to 299df82 Compare September 30, 2026 01:50
@natemoo-re
natemoo-re force-pushed the feat/input-probe-events branch 3 times, most recently from 4b430b6 to fb273f9 Compare September 30, 2026 15:11
@natemoo-re
natemoo-re marked this pull request as ready for review September 30, 2026 15:12
@natemoo-re
natemoo-re force-pushed the feat/input-probe-events branch from fb273f9 to a2a08b1 Compare October 6, 2026 00:34
Base automatically changed from feat/terminfo-core to main October 6, 2026 01:04
@natemoo-re
natemoo-re force-pushed the feat/input-probe-events branch from a2a08b1 to aeb96df Compare October 6, 2026 01:04
@natemoo-re

Copy link
Copy Markdown
Member Author

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 @@
---

@bombshell-cooper bombshell-cooper Bot Oct 6, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .changeset/cooper-approved-132.md
natemoo-re and others added 2 commits October 5, 2026 21:49
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.
natemoo-re added a commit that referenced this pull request Oct 6, 2026
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.
natemoo-re added a commit that referenced this pull request Oct 6, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant