Skip to content

refactor(eve): share the TUI's terminal control sequences - #1471

Draft
chadhietala wants to merge 1 commit into
mainfrom
simplify-commit-review-ansi
Draft

refactor(eve): share the TUI's terminal control sequences#1471
chadhietala wants to merge 1 commit into
mainfrom
simplify-commit-review-ansi

Conversation

@chadhietala

Copy link
Copy Markdown
Contributor

Found

  • cli/ui/alt-screen.ts and cli/ui/live-region.ts each declare their own copy of the same seven control sequences: ESC, HIDE_CURSOR, SHOW_CURSOR, CLEAR_TO_END, CURSOR_HOME, SYNC_START, SYNC_END.
  • Both also export a structurally identical write(chunk: string): boolean interface (AltScreenOutput, LiveRegionOutput) that nothing imports.

Did
New cli/ui/ansi.ts owns the shared sequences and one TerminalWriteTarget; single-engine sequences (alt-buffer, mouse tracking, scrollback erase, bracketed paste) stay put. +25/−24 across 3 files — flat by line count, but a third painting surface can no longer disagree about what "hide the cursor" is.

Validated
1010 CLI unit tests pass unmodified, including alt-screen.test.ts and live-region.test.ts, which assert the exact emitted byte strings. Every TUI smoke script that runs in this sandbox passes (tui-traces all 9 scenarios, plus log-modes, loglevel, rebuild-status, server-logs, transport-error). No test changed. tsc --noEmit, lint, fmt, guard:invariants clean.

`alt-screen.ts` and `live-region.ts` are the only two modules that paint
raw escape sequences, and each declared its own copy of the seven they
both need: `ESC`, `HIDE_CURSOR`, `SHOW_CURSOR`, `CLEAR_TO_END`,
`CURSOR_HOME`, `SYNC_START`, `SYNC_END`. Both also exported a
structurally identical `write(chunk: string): boolean` output interface
(`AltScreenOutput`, `LiveRegionOutput`), neither of which anything
imported — callers pass a structurally compatible terminal.

A new `cli/ui/ansi.ts` owns the shared vocabulary plus one
`TerminalWriteTarget`, and carries the comment explaining why both
engines capture `write` at construction. Sequences only one engine uses
stay where they are: alt-buffer and mouse-tracking toggles in
`alt-screen.ts`, screen/scrollback erase, bracketed paste, and
cursor-previous-line in `live-region.ts`.

Line count is roughly flat — the point is that a third painting surface
cannot silently disagree about what "hide the cursor" is.

Signed-off-by: Chad Hietala <chadhietala@gmail.com>
@chadhietala chadhietala added the simplify-devbox Simplification found by the automated devbox code review label Jul 31, 2026
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
eve-docs Ready Ready Preview Jul 31, 2026 3:51pm
eve-docs-4759 Ready Ready Preview, v0 Jul 31, 2026 3:51pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

simplify-devbox Simplification found by the automated devbox code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant