Skip to content

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

Open
natemoo-re wants to merge 2 commits into
feat/terminfo-corefrom
feat/input-probe-events
Open

natemoo-re wants to merge 2 commits into
feat/terminfo-corefrom
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; draft until the spec (#130) is approved.

What this adds

  • 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 (mode 2026), kitty keyboard/graphics APC, and the DA1 completion fence — emitting typed capability records alongside key/mouse events.
  • input-native.ts / input.ts: createInput({ detection }) wires the detection in; scan() surfaces probe responses as CapabilityEvent values interleaved with key and mouse events, ready to route to term.update().
  • test/input.test.ts (+ test/caps.ts helpers): response recognition per input-spec §6.

Breaking change

InputOptions.terminfo (raw compiled bytes) is replaced by InputOptions.detection, per terminfo-spec §2. Covered by the changeset on the final PR of the stack.

@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

This PR changes published packages but has no changeset.

View the proposed changeset
---
---

Adds `CapabilityEvent` to `InputEvent` and the `detection` option to `createInput()`.

`scan()` now recognises terminal probe responses — OSC 10/11/12 theme colors, OSC 21/22 Kitty color and pointer-shape reports, XTGETTCAP (`DCS +r`) truecolor replies, DECRPM synchronized-output status, Kitty keyboard flags, and Kitty graphics APC replies — 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`.

Passing a `Detection` from `detectTerminal()` to `createInput({ detection })` seeds the key-sequence trie from the terminfo entry and primes the color-depth baseline used when emitting denial events.

The `terminfo` option on `InputOptions` is replaced by `detection`. The exported constant `MAX_TERMINFO` is removed.

#### Migration

```diff
-import { createInput } from "…/input.ts";
+import { createInput } from "…/input.ts";
+import { detectTerminal } from "…/terminfo.ts";

-const input = await createInput({ terminfo: myTerminfoBinary });
+const detection = await detectTerminal({ env: process.env });
+const input = await createInput({ detection });
```

If you referenced `MAX_TERMINFO` to validate a buffer, remove that check — the limit is now enforced internally.

Add this changeset manually

If this draft is correct, react with 🚀 and Cooper will commit it to this branch.

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

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Size Increased — +15.2 KB

118.0 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.37%

❌ 1 regressed benchmark
✅ 9 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ createInput 271.8 ms 359.4 ms -24.37%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/input-probe-events (fb273f9) with feat/terminfo-core (cfe133e)

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 2 times, most recently from 74c6281 to 4b430b6 Compare September 30, 2026 02:03
@natemoo-re
natemoo-re force-pushed the feat/input-probe-events branch 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
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