Pin Cloud panes to the daemon's terminal grid

Merged
LA
2mo ago
+102-21

A Cloud terminal pane parsed the daemon's byte stream at its own view size. A replay authored for the daemon's 80×24 grid wraps at column 80 and moves the cursor to absolute rows, so in a wider or taller pane text landed in the wrong place, and #15203's bounds overlay drew over those misplaced cells.

The pane now pins Ghostty to the grid of each vt-state or resized replay before parsing it, with setAssignedGrid, the mechanism remote tmux mirrors already use; the view letterboxes or clips the difference and #15203's overlay draws the bounds around it. The pane keeps reporting its own view grid to the daemon: TerminalSurface.viewSizingSample() derives it from the view's pixels while the grid is pinned, and a view resize that changes no pinned size re-reports through onNaturalGridInputsChanged. The replay-fidelity tracker still sees the grid Ghostty holds.

Built on #15203 (now in main) and includes #15533 (replay pending sequence), which merges first.

Testing

  • CloudRestoreReplayGridTests/paneParsesTheReplayAtTheDaemonGridNotItsViewGrid (real manual-I/O Ghostty surface through CloudTuiManualMirrorSession, vt-state and resized): a 40×10 replay must leave Ghostty at 40×10, put an edge-clamped X in column 40 and BOTTOM on row 10, and keep the view grid larger than the pin.
    • Red: the same test on the unpinned #15533 head (0013cd3, probe branch tmp-gridpin-red, app-host rerun) times out waiting for the 40×10 grid in both cases. The view-grid assertion was dropped there because naturalGridSize() exists only on #15203.
    • Green: passes in the changed-suites run on cf91daf.
  • replayParsedAtAHiddenGridIsRefetchedOnceTheGridsMatch (from #15116) asserted that a replay parsed at the hidden bootstrap grid is refetched. With the pin the replay is parsed at the daemon's grid at once, so it is renamed replayForAHiddenPaneIsPinnedToTheDaemonGrid and asserts the rows are right with no refetch connection (passes). The refetch mechanism and its package tests are unchanged.
  • The only other failure in that run is PaneDropZoneOverlayAnimationTests ("A portal refresh during a tab drag keeps the terminal drop zone shown"), which this PR does not touch.
  • Rust on a Blacksmith Testbox at 134f3c1: cargo fmt --check, cargo clippy --all-targets -D warnings, ghostty-vt and focused cmux-tui-core/cmux-tui tests pass except the three that also fail on main.
  • Live: tagged build gpin-v1 (fleet job a04bcec5883fdf7d64efcb5f) on a dev Cloud machine whose daemon was upgraded in place to this commit's published cmux-tui. With the shared size fixed at 70×20 in a 108×45 native Cloud pane, a 90-character line wraps at column 70, LASTROW lands on row 20, and the rest of the pane shows #15203's hatch and 70×20 · Fixed chip. The cmux vm open pane (the vm-tui-connect bridge in a local PTY) is a different path and is not pinned.

Changelog

Fixed: Cloud terminal text no longer lands in the wrong place when the pane is larger or smaller than the shared terminal grid

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Cloud-restored terminal sessions now preserve the reported grid size during replay, keeping cursor movement and screen content consistent even when the pane has different dimensions.
    • Hidden panes display the correct replay when revealed, without requiring another replay fetch.
    • Terminal sizing stays aligned with assigned grid dimensions as the view changes.