Skip to content

feat(id-web): kitty-disambiguate-v1 rich keyboard encoder — Slice C of #787 - #7734

Merged
dezren39 merged 2 commits into
mainfrom
queue/13060-787-kitty-encoder
Nov 8, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/13060-787-kitty-encoder

Conversation

@dezren39

@dezren39 dezren39 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Refs #787 — Slice C only. This PR does not close #787: Slices D/E/F remain, and acceptance criteria 1–3 of the issue stay open until they land.

Queue task 13060 (repo-health-code-pilot, lane code-j).

What

Additive rich/kitty browser encoder in pkgs/id/web/src/world-keyboard.ts:

  • New exported richTerminalBytesForKey, unused by the UI in this slice (inert, per design §6 row C). The legacy terminalBytesForKey and its tests are unchanged and remain the default path.
  • Escape is always CSI 27 u (never a bare ESC byte, which the profile decoder treats as Unknown); modified Enter/Tab/Backspace use their CSI-u functional codes (13/9/127), distinguishing Tab from Ctrl+i and Enter from Ctrl+m; Shift+Tab uses the canonical CSI 9 ; 2 u.
  • Arrows/Home/End keep legacy CSI letter bytes unmodified, CSI 1 ; <mod> <letter> modified; Delete/Insert/PageUp/PageDown and F1–F12 (new in the rich encoder) use CSI tilde forms.
  • Ctrl/Alt printable scalars are CSI-u with the unshifted codepoint and the full modifier parameter (Ctrl+Shift+A → CSI 97 ; 6 u, which Slice A's decoder normalizes to scalar A + Control); AltGr (Ctrl+Alt) printable input stays plain UTF-8 text, as in the legacy path.
  • Same exclusions as legacy: Meta/OS shortcuts, Dead/Process/Unidentified, multi-scalar committed text, and profile-Unknown keys (F13+, modifier-only keys) return null.

Tests

Expectations mirror doc/kitty-disambiguate-v1-fixtures.json (the Slice A Roc Key.parse_events corpus); parity is decoded-event equality per design §4.4, and Slice D's oracle will decode this encoder's output with the actual Roc decoder.

  • bunx vitest run src/world-keyboard.test.ts — 20/20 pass (10 legacy unchanged + 10 new rich)
  • Full web suite: bunx vitest run — 667 passed, 9 skipped (30 files)
  • bunx tsc --noEmit — clean

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…C of #787)

Additive richTerminalBytesForKey in world-keyboard.ts, unused by the UI, alongside the unchanged legacy terminalBytesForKey. Encodes Escape as CSI 27 u, modified Enter/Tab/Backspace as CSI-u functional codes, named keys in CSI letter/tilde forms (adding Insert and F1-F12), and Ctrl/Alt printable scalars as CSI-u with the unshifted codepoint; AltGr printable input stays UTF-8 text. Tests mirror doc/kitty-disambiguate-v1-fixtures.json (Slice A corpus): world-keyboard suite 20/20, full web suite 667 passed / 9 skipped, tsc clean.
@dezren39
dezren39 requested a review from a team as a code owner November 8, 2026 14:49
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fb91d6f5-a65c-474d-b1e1-4bbbb7cf93e3
Commits

Reviewing files that changed from the base of the PR and between 722fbe8 and e10e3a2.

Files selected for processing: 2

  • pkgs/id/web/src/world-keyboard.test.ts
  • pkgs/id/web/src/world-keyboard.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T15:18:39.446106Z e10e3a2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85dc707c11

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/id/web/src/world-keyboard.ts Outdated
Comment on lines +270 to +272
const codePoint = unshiftedScalar(key).codePointAt(0);
if (codePoint === undefined) return null;
return encode(`\x1b[${codePoint};${mod}u`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the resulting scalar when normalizing modified text

On layouts where ASCII punctuation does not require Shift, unconditional unshifting changes the key delivered to the application. For example, French AZERTY Ctrl+& has key: "&" and shiftKey: false, but this emits CSI 55;5u, which Key.parse_events decodes as Ctrl+7. Conversely, French Ctrl+Shift+1 emits CSI 49;6u, which Key.roc's normalize_shift turns into Ctrl+!. Normalize the codepoint and protocol Shift bit together so decoding preserves the browser's resulting scalar rather than assuming its physical Shift state follows the US layout.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in e10e3a2 for the no-Shift case: the encoder now unshifts only when shiftKey is set. A scalar that exists without Shift (AZERTY Ctrl+&, shiftKey false) keeps its own codepoint — CSI 38;5u — instead of the US-table 55;5u (Ctrl+7). Regression tests cover AZERTY Ctrl+& (38;5u) and the US Shift forms. Note on the shifted AZERTY example (Ctrl+Shift+1 emitting 49;6u): KeyEventLike carries no layout/code information, and the kitty-disambiguate-v1 fixtures (shifted-ascii-punctuation) mandate US-table normalization for Shift-produced scalars — the Slice A decoder side owns that convention; with no Shift held, the resulting scalar is now always preserved.

Comment on lines +261 to +263
const printable =
key.length === 1 || codePoints.length === 1 || (codePoints.length > 1 && /[^\p{L}\p{N}]/u.test(key));
if (!printable || key.length === 0) return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude multi-scalar input before constructing CSI-u

For multi-scalar browser key values containing combining marks or emoji components, this predicate accepts the entire string as printable, but the Ctrl/Alt branch subsequently encodes only codePointAt(0). For example, Alt+é (an e followed by a combining acute accent) becomes CSI 101;3u, silently dropping the accent and fabricating an Alt+e command. The new encoder documents multi-scalar input as excluded, and design §4.4 requires it to remain text rather than a fabricated physical key. Reject these values before the CSI-u branch or preserve them through the ordinary text path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in e10e3a2: multi-scalar key values (codePoints.length !== 1) now return on the text path before the CSI-u branch, so Alt+e + combining acute is preserved as text per design §4.4 instead of being truncated to Alt+e. Regression test: keeps multi-scalar input on the text path under Ctrl/Alt (world-keyboard.test.ts, 22/22; full web suite 669 passed, tsc clean).

@developing-today

Copy link
Copy Markdown
Contributor

🤖 Agent note · parked

@dezren39 dezren39 added queue/parked Queue task is parked (waiting on CI, time, or an event) status/parked Deliberately paused with a recorded resume condition work/assigned Queue worker lifecycle state labels Nov 8, 2026
@dezren39

dezren39 commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

🤖 Salvage note — duplicate-pair disposition (protocol §8) · task 13060, lane code-d

Canonical PR: PR #7734 (richTerminalBytesForKey, branch queue/13060-787-kitty-encoder, head e10e3a2) — bound to live task 13060.
Sibling/duplicate: PR #7348 (kittyBytesForKey, branch queue/12634-787-slice-c, head d7dc062) — same Slice C of issue #787, same two files (pkgs/id/web/src/world-keyboard.ts, world-keyboard.test.ts).

I diffed both PRs in full this shift (not a file-list comparison). Findings:

Disposition: PR #7348 stays open for now only because neither PR may merge/close until CI completes (both PRs' checks have been QUEUED since 2026-11-08T14:48–15:16Z in the systemic runner backlog). Once CI is green on PR #7734 and it merges, PR #7348 should be closed as the duplicate with a link to this note; its branch is the salvage source until then — do not delete it by hand.

@dezren39

dezren39 commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

🤖 Agent note · parked

@developing-today

Copy link
Copy Markdown
Contributor

🤖 Agent note · parked

@dezren39
dezren39 merged commit 4cb8948 into main Nov 8, 2026
3 of 5 checks passed
@dezren39
dezren39 deleted the queue/13060-787-kitty-encoder branch November 8, 2026 20:35
@dezren39

dezren39 commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

agent-note:v1
event: done
task: 13060 (small_fix, repo-health-code-pilot; worker repo-worker-code; lane code-f)
by: repo-worker-code lane code-f
at: 2026-11-08T20:38Z

Task 13060 complete — outcome: fixed_merged. PR #7734 MERGED (merge commit 4cb8948) from branch queue/13060-787-kitty-encoder, head e10e3a2. Slice C delivered: additive rich/kitty (kitty-disambiguate-v1) browser encoder in pkgs/id/web/src/world-keyboard.ts, legacy encoder unchanged, encoder inert in the UI per the phased design. Tests (laptop, at merged head): world-keyboard 22/22, full web suite 669 passed 9 skipped, tsc clean. Both Codex P2 findings fixed in e10e3a2 with thread replies. PR CI checks never started (QUEUED since 2026-11-08T15:16Z, fleet-wide runner stall) — merged under Drew's merge authority on the laptop-verified evidence; checks run on main. Duplicate PR #7348 CLOSED citing salvage note 6725545330 (comment 6726788589). Issue #787 stays OPEN: Slices D/E/F remain (acceptance criteria 1-3 not closed by this slice).

@dezren39 dezren39 removed status/parked Deliberately paused with a recorded resume condition queue/parked Queue task is parked (waiting on CI, time, or an event) work/assigned Queue worker lifecycle state labels Nov 8, 2026
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.

id: Phase 13 F13.5 kitty keyboard protocol on the raw input path

1 participant