thing-tui: live terminal host (cut 8b) #26

Merged
eureka merged 19 commits from hands/thing2-tui-host into main 2026-11-29 01:54:21 +00:00
Owner

Thing 2.0 cut 8b (thing2:cut_spec:cut-tui-host.r2), the first live TUI surface.

  • Terminal<W>: guard (raw mode, alternate screen, hidden cursor, mouse, focus, bracketed paste with Unsupported tolerated) restored on Drop and by a chained panic hook; draw(&[Op]) writes one synchronized update per frame, truecolor, nothing for no ops.
  • translate(&Event) -> Vec<InputEvent>: pure, Key-then-Text, Release dropped, cell-centre pointer, Lines wheel.
  • examples/fixture.rs: the reference host (the loop and the clock are the host's); cargo run -p thing-tui --example fixture -- f01-swarm-dashboard, q or Ctrl+C quits.
  • crossterm =0.29.0 (events, windows, bracketed-paste), no default features.

Tests: workspace 370 green on the verify image; thing-tui also green natively on Windows. The example was driven through a pty on Yggdrasil (enter, first frame, idle, resize, click, q, Ctrl+C, termios restored). cargo-mutants over the new files: 56 tested, 42 caught, 12 unviable, 2 survived (an equivalent |/^ on distinct flags, and install_panic_hook body, which needs a real terminal).

Core does not route input yet, so a click or scroll reaches frame and changes nothing.

🤖 Generated with Claude Code

Thing 2.0 cut 8b (`thing2:cut_spec:cut-tui-host.r2`), the first live TUI surface. - `Terminal<W>`: guard (raw mode, alternate screen, hidden cursor, mouse, focus, bracketed paste with Unsupported tolerated) restored on Drop and by a chained panic hook; `draw(&[Op])` writes one synchronized update per frame, truecolor, nothing for no ops. - `translate(&Event) -> Vec<InputEvent>`: pure, Key-then-Text, Release dropped, cell-centre pointer, Lines wheel. - `examples/fixture.rs`: the reference host (the loop and the clock are the host's); `cargo run -p thing-tui --example fixture -- f01-swarm-dashboard`, q or Ctrl+C quits. - crossterm =0.29.0 (events, windows, bracketed-paste), no default features. Tests: workspace 370 green on the verify image; thing-tui also green natively on Windows. The example was driven through a pty on Yggdrasil (enter, first frame, idle, resize, click, q, Ctrl+C, termios restored). cargo-mutants over the new files: 56 tested, 42 caught, 12 unviable, 2 survived (an equivalent `|`/`^` on distinct flags, and `install_panic_hook` body, which needs a real terminal). Core does not route input yet, so a click or scroll reaches `frame` and changes nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thing-tui: pin tolerate and the meta modifiers
All checks were successful
Portable Eve contracts and browser lowering / ubuntu-latest eve-browser-lowering (pull_request) Successful in 2m25s
Portable Eve contracts and browser lowering / ubuntu-latest eve-contracts (pull_request) Successful in 2m38s
482fdd42cf
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A guard registers when entered and unregisters on drop; the hook restores through the
registered guard's own writer, claims the restore once so unwinding does not repeat it, and
leaves a panic on any other thread, or after the drop, to the previous hook. Every
constructor that enters installs the hook.

Per the steward's decision on thing2:finding:cut-tui-host.s1.panic-hook-owner-blind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per the steward's decision on thing2:finding:cut-tui-host.s1.panic-hook-install-untested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
write_enter, write_restore and enter_without_raw_mode leave the public API; their tests are
unit tests in the crate. Every constructor that enters (enter, stdout) installs the hook. The
seams are pinned out of the API by compile_fail doctests.

Per the steward's decision on thing2:finding:cut-tui-host.s1.public-api-test-seams.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per the steward's decision on thing2:finding:cut-tui-host.s1.restore-leaves-sync-update-open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per the steward's decision on thing2:finding:cut-tui-host.s1.report-overclaims-and-misses-estimate;
the estimate is explained in the report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thing-tui: pin that a drop unregisters only its own guard
All checks were successful
Portable Eve contracts and browser lowering / ubuntu-latest eve-browser-lowering (pull_request) Successful in 2m18s
Portable Eve contracts and browser lowering / ubuntu-latest eve-contracts (pull_request) Successful in 2m4s
e333cb8f9c
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing unwinds to Drop there, so the owner-only rule left a worker's panic to abort the process
with the terminal still raw. Unwind builds keep the owner-thread rule.

Per the steward's decision on thing2:finding:cut-tui-host.s2.abort-profile-worker-panic-leaves-raw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per the steward's decision on thing2:finding:cut-tui-host.s2.restore-skipped-under-lock-leaves-raw;
the double-panic case is run in a pty (red before this commit, green after).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A guard moved to a render thread follows its user: that thread's panic restores before its
message, and a panic on the thread that gave it away leaves it to the owner.

Per the steward's decision on thing2:finding:cut-tui-host.s2.guard-owner-is-the-constructing-thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thing-tui: one live terminal guard per process
All checks were successful
Portable Eve contracts and browser lowering / ubuntu-latest eve-browser-lowering (pull_request) Successful in 4m4s
Portable Eve contracts and browser lowering / ubuntu-latest eve-contracts (pull_request) Successful in 2m19s
997ac1b2c3
A second enter or stdout() while one is alive fails with AlreadyExists, so nested and cross-thread
guards are impossible and no guard can take the terminal from another. The registry becomes one
slot; the several-guards unregistering and its test go. The refusal is pinned in their place, and
every test that builds a guard takes a lock so the suite's threads do not collide.

Per the steward's decision on thing2:finding:cut-tui-host.s2.guards-share-global-modes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A main-thread panic ends the process without running a guard held by a render thread, so the
owner-only rule left the terminal raw. restores_here takes is_main as well as abort, owner and here.

Per thing2:ruling:tui-panic-restore-rule and thing2:finding:cut-tui-host.s3.main-panic-with-guard-on-worker-leaves-raw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hook, in every build, claims the restore once, writes it to a fresh io::stdout() handle and
turns raw mode off; Drop then has nothing left to write. Proven by pty probes (unwind with and
without a destructor panic, and an abort build): red before, green after.

Per thing2:ruling:tui-panic-restore-rule and thing2:finding:cut-tui-host.s3.abort-lock-held-leaves-screen-modes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thing-tui: Drop restores first, then frees the one-guard slot
All checks were successful
Portable Eve contracts and browser lowering / ubuntu-latest eve-browser-lowering (pull_request) Successful in 2m24s
Portable Eve contracts and browser lowering / ubuntu-latest eve-contracts (pull_request) Successful in 43s
f25ac958c1
An enter racing a drop is refused until the terminal is given back. The race is forced with a
barrier inside the old guard's restore write, not a timing assumption.

Per thing2:ruling:tui-panic-restore-rule and thing2:finding:cut-tui-host.s3.drop-unregisters-before-restoring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eureka merged commit f532f6bb6a into main 2026-11-29 01:54:21 +00:00
eureka deleted branch hands/thing2-tui-host 2026-11-29 01:54:21 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
GameCult/Thing!26
No description provided.