Skip to content

refactor(tui): move terminal I/O out of run/mod.rs - #522

Merged
mrnasil merged 1 commit into
mainfrom
refactor/tui-run-terminal
Nov 28, 2026
Merged

mrnasil merged 1 commit into
mainfrom
refactor/tui-run-terminal

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

What

Last step of splitting crates/tui/src/run/mod.rs (after #519, #520, #521). run/terminal.rs now holds the terminal the loop draws on: opening the console, raw mode and the alternate screen, reading events, drawing, the panic restore, and putting everything back (62 items: LoopIo, LoopTerm, TuiWriter and the free functions around them).

run/mod.rs drops from 2914 to 2077 lines; it was 6690 before #519. What is left is the run loop and small helpers. The loop is orchestration over shared local state and already calls helpers for nearly every step, so I am not planning to split it further.

It is a pure move

Compared line by line against main (ignoring order): the only differences are pub(super) on the moved items and on the 18 methods of LoopIo and LoopTerm, two signatures rustfmt re-wrapped, and the mod / use lines. CONSOLE_WRITE_BUFFER stays in mod.rs, where scripts/memory_budget.json pins it.

Verification

  • cargo clippy -p whycodes-tui --all-targets -- -D warnings, cargo fmt --all --check, all budget scripts: green.
  • cargo test -p whycodes-tui --lib: 1503 passed, 0 failed. cargo build -p whycodes-cli: ok.
  • Real console, A/B against main: both debug builds were driven in a Windows pseudo console (ConPTY, 120x40) with an isolated WHYCODES_HOME: first paint, Esc to skip the key dialog, typing into the prompt, /help, /exit. Both exit with status 0 and print the session summary. The rendered screens are the same apart from the rotating hint line, and the set of mode sequences is identical: alternate screen on/off (?1049), cursor hide/show (?25), bracketed paste on/off (?2004), mouse on/off (?1003;1006), focus reports (?1004), title push/pop (22;0t / 23;0t), cursor shape set and reset.
  • Still not done: looking at it in an actual terminal window. The pseudo console proves the bytes and the restore; it does not show how Windows Terminal renders them, and the other hosts in docs/tui-term-matrix.md (Unix emulators, macOS Terminal.app) were not run.

🤖 Generated with Claude Code

run/terminal.rs now holds the terminal the loop draws on: opening the
console, raw mode and the alternate screen, reading events, drawing,
the panic restore and putting everything back (62 items). run/mod.rs
drops from 2914 to 2077 lines; it was 6690 before #519. What is left
is the run loop and small helpers.

A pure move: the only textual changes are `pub(super)` on the moved
items and on the 18 methods of LoopIo and LoopTerm, plus two signatures
rustfmt re-wrapped. CONSOLE_WRITE_BUFFER stays in mod.rs, where the
memory budget pins it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@mrnasil
mrnasil merged commit 57ef075 into main Nov 28, 2026
7 checks passed
@mrnasil
mrnasil deleted the refactor/tui-run-terminal branch November 28, 2026 19:43
@mrnasil mrnasil mentioned this pull request Nov 28, 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.

1 participant