Fix Cloud graph freezing on daemons that send no cursor

Merged
TE
2mo ago
+92-1

Summary

A daemon that sends snapshots without a cursor (an older cmux-tui) froze its machine's graph after the first change. installSnapshotIfNewer took the equal-cursor branch whenever current.cursor == incoming.cursor, and with no cursor on either side that is nil == nil. The branch then refused every snapshot whose content had changed. Nothing re-adopted a fresh read, so the sidebar tree and every open on that machine stayed on the first graph until relaunch.

Now:

  • The equal-cursor branch requires a present cursor. Two missing cursors fall through to CloudVMStateSyncDecision.forSnapshot, which already installs a cursorless snapshot over a cursorless graph and refuses one over a journaled graph.
  • Without cursors, the install version is the only ordering. A read that started before a newer install still cannot overwrite it, which is the same guard the equal-cursor path used.

This hardens a latent path. It is not the fix for the cmux ssh open failure seen in the field: that daemon sends a cursor, and its wedge is an equal-cursor conflict between cursorful snapshots, which #15205 addresses for exited terminals' tab fields. The two PRs touch different files and compose cleanly. Found while tracing that failure (cmuxterm-hq#869, item 5).

Testing

  • New cmuxTests/CloudCursorlessSnapshotTests.swift, committed failing before the fix:
    • a changed cursorless snapshot replaces the previous cursorless graph (failed on main)
    • a cursorless read that started before a newer install is refused, and accepted once current
    • a cursorless snapshot still never replaces a journaled graph (unchanged behavior)
  • scripts/verify-local.py passes. No local native build; CI builds and runs the tests.
  • No fleet dogfood: seeing this in the app needs a daemon old enough to send no cursor, and current Cloud images and the pinned SSH install all send one. The unit tests drive the exact install path the app uses.

Changelog

Fixed: Cloud and SSH machines running an older cmux-tui no longer stop updating after their first change.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Fixes Cloud graph freezing on machines whose daemon sends snapshots without a cursor (older cmux-tui). Previously, two missing cursors compared equal (nil == nil), so the equal-cursor branch refused every snapshot with changed content and the graph stopped updating after the first change.

  • The equal-cursor branch now requires a present cursor; two missing cursors fall through to the snapshot decision, which already installs a cursorless snapshot over a cursorless graph and refuses one over a journaled graph.
  • Without cursors, the install version alone orders reads, so a read that started before a newer install is still refused.
  • Adds CloudCursorlessSnapshotTests covering a changed cursorless snapshot replacing the previous graph, a stale read being refused, and a cursorless snapshot never replacing a journaled graph.