cmux link sync push: a file the machine changed since the last push stays as the machine has it

Closed
TE
3d ago
+56-10

HOLD: abandoned by its owner (Codex BLOCK at 69faa93; the fix belongs in cloud.startChat, #28111). To be closed; do not land.

cmux link sync push: a file the machine changed since the last push now stays as the machine has it. Before, the push wrote this Mac's copy over it.

Why

A second push of the same folder to the same copy on a machine silently discarded the first chat's edits there, even in files this Mac never touched. That happens on Move to Cloud again, and on a second Cloud chat from the same folder (cloud.startChat, #28111). The Codex review of #28111 found it: "A second Cloud chat from that folder reuses the machine and directory. sync_cli.rs:368–381 overwrites remotely modified files with local contents, silently discarding the earlier chat's edits."

What changes

  • The push's delete pass already spared a file the machine changed. Its write pass now does too: when the record lists a file and the machine's revision no longer matches, the file is left as the machine has it and counted as kept, a new field in the summary JSON.
  • The record keeps the last push's entry for a kept file. Bring Back Local's three-way pull still sees both sides' changes against that base, so a file both sides changed comes back as a conflict, never a silent pick.
  • A cmux link access share (push_kept) is this Mac's folder as this Mac has it, and is still written again.
  • Files the machine never changed behave as before: written when this Mac's copy changed, otherwise unchanged.

Tests

cmux-tui/crates/cmux-tui/tests/link_sync.rs a_second_push_keeps_the_files_the_machine_changed_since_the_first. After a push:

  • the machine edits notes.txt (which this Mac never changes);
  • both sides edit src/a.txt;
  • this Mac edits other.txt.

A second push keeps both machine edits, writes other.txt, and reports kept: 2. A pull then names src/a.txt as the conflict.

Red/green: the test is committed before the fix (f651ab7796e), then ./scripts/verify-cmux-tui-hosted.sh --filter a_second_push_keeps_the_files_the_machine_changed_since_the_first runs at each commit. Results are added below.

Observed / Not run

  • Observed: rustfmt (the repo's config) is clean on both files.
  • Not run locally: cargo (cmux-tui runs hosted only).

Changelog

Fixed: Moving a chat to Cloud again, or starting another Cloud chat from the same folder, no longer writes over what an earlier chat changed on the machine.

Risk: normal. It changes only which files a repeat push writes. It never deletes anything, and the first push to a fresh copy is unchanged.

Agent session: agent session

šŸ¤– Generated with Claude Code