Skip to content

Claim the TUI before boot and paint live markdown - #666

Closed
justrach wants to merge 3 commits into
mainfrom
cursor/tui-paint-markdown-4ffc
Closed

Claim the TUI before boot and paint live markdown#666
justrach wants to merge 3 commits into
mainfrom
cursor/tui-paint-markdown-4ffc

Conversation

@justrach

Copy link
Copy Markdown
Owner

The Zig boot phases on this tree are about 12ms. The delay is staring at the leftover shell until tui.run writes the alt-screen. Fat AGENTS.md, plugin consent, and companion spawn make that gap seconds on a real machine.

This claims the pager as soon as the command is tui or TTY repl — alt-screen + wipe only — so leftover boot happens inside the pager. Kitty/mouse/paste stay on run's single enable_seq write (they are a stack). If we never reach run, shutdown stamps and the panic/signal hooks restore the shell.

Live TUI tail (layout cache, not just scrollback.render) and zigzag graff repl pending now use the same markdown renderer as a settled assistant row. Raw bash stays plain. Line REPL already streamed markdown when color is on.

Pi / SWE-bench

Not official SWE-bench Harbor. Local suite is graff-evals --suite swe (6 DeepSWE-shaped tasks). ADR 0024 compared graff vs grok-build, not Pi: latest recorded shape is graff default rlm 5/6 at ~9M RSS / ~4 calls per task; grok-build 5/6 at ~160–177M RSS. Both miss label-sort. Pi is wired as pi / pi-codegraff in graff-evals/harnesses.json (pi -p --mode json). Opt-in A/B:

cd graff-evals && ./run.py --suite swe --harness graff-dev,pi-codegraff --model <same>

Steal from Pi is TUI-first paint (this PR). Do not steal Pi's 4-tool catalog (ADR 0024 measured fail) or a welcome essay (ADR 0021).

Verify

  • zig build tui-test 463/463
  • Term sim: live - item / **bold** paints and drops the markers
  • Hover PTY green standalone; 4-worker tuiguard pool still flakes that probe (known, not this change)
Open in Web Open in Cursor 

The Zig boot phases are ~12ms; the delay is staring at the leftover
shell until tui.run writes the alt-screen. Claim that screen at
runSubcommand for `tui`/`repl` so keys/MCP/prompt happen inside the
pager, and restore via atexit if we never reach run.

Live TUI tail and zigzag repl pending used sanitize/strip only, so
- lists and **bold** stayed raw until the turn settled. Render them
the same way a settled assistant row does; keep raw bash plain.
The pager paints through layout_cache, not scrollback.render, so the
live stream was still sanitize-only. Share liveTail. Skip a second
enable_seq after an early claim — kitty keyboard is a stack, and the
extra push failed PTY mode-balance.
Early claim pushed kitty/mouse before boot, then skipped the loop's
enable write. Hover never tinted and a second push unbalanced kitty.
Claim is now ?1049h/?25l plus a wipe; run re-asserts raw and writes
the full enable string exactly once.
@justrach

Copy link
Copy Markdown
Owner Author

Already on main via the 281 cut (#670 / ADR 0042). Closing as superseded.

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.

2 participants