Keep OSC terminal titles across Cloud resizes and reattaches

Merged
LA
2mo ago
+109-10

Cloud terminal titles set by OSC 0/2 (printf '\e]2;name\a', agent tab renames) reset to the default after a resize, reconnect, or daemon reattach.

Cause: every rebuilt mirror terminal is restored from a VT replay, and Ghostty's VT formatter emits OSC 7 (pwd) but never the title. The hosted surface then copies the rebuilt terminal's empty title into pty.title (surface.rs resize, resync, and attach paths), so the sidebar and snapshots lose the name. The terminal host sends a replay on every resize, so a window resize alone was enough.

Fix: ghostty-vt appends an OSC 2 title suffix next to the existing mouse-format suffix. It is reserved in the replay budget and in preflight_vt_replay_bounded, and control characters are replaced with spaces. Every replay consumer (guest daemon mirrors, cmux-terminal-client, cmux-tui remote sessions, the Mac attach path) gets the title with no per-caller change.

Tests, two commits (red then green) on a Blacksmith Testbox:

  • ghostty-vt replay_restores_the_osc_title (full and theme-portable replay), plus suffix and preflight boundary tests.
  • cmux-tui-core tests/pty.rs attach_and_resize_replays_restore_the_osc_title: attach replay and resize replay both keep the title.
  • Full cargo test --locked --no-fail-fast: the same 31 failures on main and on this branch (they come from the box environment), none new. Clippy is clean for ghostty-vt and cmux-tui-core.

Live Cloud VM check (Freestyle, default sm image, throwaway VMs, deleted afterwards). Branch artifacts published at https://files.cmux.com/cmux-tui/549ece91c6d94983746053cf4651f6199b12d8f7/manifest.json, installed with web/scripts/upgrade-fleet-cmux-tui.ts --commit.

  • Unfixed daemon ed554c8: terminal title t3-title became '' after a daemon restart (SIGTERM, supervisor restart, host adoption).
  • Branch daemon: terminal title t6-title stayed t6-title after the same restart. Only its surface id changed.

Rollout note: a terminal keeps the host process that spawned it, and that host produces the replay. Terminals created before a machine gets this daemon keep losing their title on reattach until they are recreated. New machines after the next bake and new terminals after an in-place upgrade are fixed.

Mac GUI sidebar was not driven. It shows the daemon's title field, which is the value checked above.

🤖 Generated with Claude Code