Repository navigation
Description
Problem
xterm.js sends a TUI's terminal replies (DA, CPR, DECRPM, XTWINOPS, OSC colour reports, focus reports) through onData, the same event as typed input. Three places need to tell the two apart, and each has its own copy of the patterns:
- Server delivery gate (
packages/codev/src/terminal/terminal-replies.ts, Issue Render gate: fuller close of the gate→write input race (R7 staleness) and input-echo-lag residual #1473): the full table, read from the pinned@xterm/[email protected]emission sites, with a version-pin test. It is the only complete one. - Web dashboard's initial-phase filter (
apps/web/src/components/Terminal.tsx,stripTerminalReplies): three regexes (DA, CPR, DECRPM), applied only whilerc.initialPhaseis true. - Mobile IME bridge (PR Fix #1883: send mobile keyboard replaces to the PTY as DELs plus new text #1884, the fix for issue Mobile terminal: autocomplete replacement re-inserts the partial word and the preceding clause (IME replace events reach the PTY as keystrokes) #1883, mobile autocomplete duplicating text): reuses those same three regexes in steady state. It needs them so that a reply arriving mid-typing does not count as foreign input and block a later autocorrect from replacing.
The web copies miss the rest of the server table (XTWINOPS, DSR ESC[0n, focus reports, DECRQSS, OSC colour reports). So for those replies, the IME bridge still treats a mid-typing reply as input. The failure is loud (a [Terminal IME #1883] console error), not silent, but it is avoidable.
Proposal
Move the reply table (the patterns and a pure stripTerminalReplies) into @cluesmith/codev-types. The types package carries runtime constants and is the only package both server and client may import (see the server/client isolation boundary, #1189). Then:
packages/codev/src/terminal/terminal-replies.tsimports it; its version-pin test stays with it.apps/web/src/components/Terminal.tsxreplaces its three inline regexes with the shared function, for both the initial-phase filter and the IME bridge's foreign-input skip.
Care point, from the server module's own notes: the server table treats over-stripping as the safe direction. The IME bridge is the opposite: over-stripping a real keystroke would let a later replace delete into it. The shared table must stay anchored one shape at a time (it already is) and keep its keystroke-survival tests.
Found during the integration review of PR #1884 (mobile IME replace fix).
Activity