refactor(eve): share the TUI's terminal control sequences - #1471
Draft
chadhietala wants to merge 1 commit into
Draft
refactor(eve): share the TUI's terminal control sequences#1471chadhietala wants to merge 1 commit into
chadhietala wants to merge 1 commit into
Conversation
`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>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found
cli/ui/alt-screen.tsandcli/ui/live-region.tseach declare their own copy of the same seven control sequences:ESC,HIDE_CURSOR,SHOW_CURSOR,CLEAR_TO_END,CURSOR_HOME,SYNC_START,SYNC_END.write(chunk: string): booleaninterface (AltScreenOutput,LiveRegionOutput) that nothing imports.Did
New
cli/ui/ansi.tsowns the shared sequences and oneTerminalWriteTarget; 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.tsandlive-region.test.ts, which assert the exact emitted byte strings. Every TUI smoke script that runs in this sandbox passes (tui-tracesall 9 scenarios, plus log-modes, loglevel, rebuild-status, server-logs, transport-error). No test changed.tsc --noEmit, lint, fmt,guard:invariantsclean.