Repository navigation
mux: read-screen reports the rendered viewport (fixes the macOS smoke-attach banner divergence) - #7488
Conversation
…ewport With scrollback present and a clear-screen repaint, read-screen reported stale scrollback rows instead of the rendered viewport, diverging from what attach clients render. Test only; fix follows.
Terminal::plain_text() formats the active screen's full page list including scrollback (null-selection ScreenFormatter over .screen point space), while attach clients render the RenderState viewport. After macOS bash's zsh-advice banner scrolled rows into scrollback and the prompt repainted, read-screen reported the stale banner rows and smoke-attach's client/server comparison diverged persistently: main's test (macos) red, reproducible locally with SHELL=/bin/bash. The spec (mux/spec/commands.md) already promised read-screen output 'does not include prior scrollback', so this honors the contract. read-screen now uses a new Terminal::viewport_text(): the terminal formatter's read-only selection path over GHOSTTY_POINT_TAG_VIEWPORT (0,0)..(cols-1,rows-1) with unwrap:false, one line per visual row. RenderState::update was rejected for this because it consumes per-row dirty flags and would starve a concurrent TUI renderer's row refresh in non-headless sessions; a regression test locks in the read-only property (viewport_text_does_not_clear_render_dirty_state).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds a ChangesViewport Text Feature
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 25✅ Passed checks (25 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR updates
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "mux: read-screen reports the rendered vi..." | Re-trigger Greptile |
Fixes main's persistent
test (macos)failure inscripts/smoke-attach.py(assert_client_matches_server), which reproduces deterministically withSHELL=/bin/bash scripts/smoke-attach.py(3/3 before, 5/5 pass after).Root cause (verified in code by the /fable judge, not just observed): the attach mirror was correct; the comparison oracle was wrong.
Terminal::plain_text()formats the active screen's full page list including scrollback (null-selection ScreenFormatter over the.screenpoint space), while clients render theRenderStateviewport. When macOS bash's "default interactive shell is now zsh" banner scrolled into scrollback and\e[H\e[2Jrepainted the prompt,read-screenkept reporting the stale banner rows. The spec already promised read-screen output "does not include prior scrollback", so the old behavior violated its own contract.Fix:
read-screenuses a newTerminal::viewport_text()built on the terminal formatter's read-only selection path (GHOSTTY_POINT_TAG_VIEWPORT,(0,0)..(cols-1,rows-1),unwrap:false). A first-roundRenderState::updateapproach was rejected in review because that snapshot consumes per-row dirty flags and would starve a concurrent TUI renderer's row refresh in non-headless sessions;viewport_text_does_not_clear_render_dirty_statelocks in the read-only property.Two-commit red/green: commit 1 adds the failing socket regression (scrollback + clear-screen → viewport reporting), commit 2 the fix. No ghostty submodule changes (the formatter options already existed in the C API).
Verified: cargo fmt/clippy/test workspace-clean (121 tests), smoke-tui,
SHELL=/bin/bash smoke-attach.py5/5. /fable judge: APPROVE after one REVISE round.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
Medium Risk
Changes the observable
read-screencontract (intentionally aligning with spec); low blast radius but affects attach/smoke oracles and any client that assumed scrollback-inclusive text.Overview
read-screennow returns the rendered viewport instead ofplain_text(), which still dumps the active screen including scrollback. That mismatch caused attach/smoke comparisons to see stale rows (e.g. macOS bash banner) after content scrolled away and the screen was cleared.Adds
Terminal::viewport_text(), formatting the full viewport via the terminal formatter’s read-only selection path (GHOSTTY_POINT_TAG_VIEWPORT,unwrap: false) so inspection does not consumeRenderStatedirty flags. Selection helpers gainselection_text_with_tag_optionsfor configurable unwrap/trim;plain_text()docs now point callers atviewport_text()for viewport-only dumps.Regression coverage:
viewport_text_does_not_clear_render_dirty_stateand a control-socket test (scrollback + clear-screen → prompt on first line).Reviewed by Cursor Bugbot for commit 40347a8. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
read-screen now returns the currently rendered viewport (not scrollback). This fixes the macOS smoke-attach mismatch and aligns with the command spec.
mux-core:read-screennow callsTerminal::viewport_text()instead ofplain_text().ghostty-vt: Addedviewport_text()using the read-only formatter overGHOSTTY_POINT_TAG_VIEWPORT; it does not clear render dirty flags.viewport_text_does_not_clear_render_dirty_stateand a control socket test to verify viewport output after scrollback + clear-screen.Written for commit 40347a8. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes