agent-pane: Last turn shows the turn's checkpoint diff when the host has one

Merged
TE
1mo ago
+784-258

The changes view's Last turn shows each tool call's edit as its own block, so a file edited twice shows twice. Changes no tool call made, such as a shell write or a formatter, never show at all. Under P7, Last turn shows the turn's checkpoint diff instead: one net patch per file, as it is on disk.

This is items 1, 4 and 5 of the P7 plan (answers on f92543c24d66).

What changes

  • ChangesSource gains an optional turn({rowId}) read. Its answer is a turn's before/after checkpoint pair in git.diff's shape ({checkpoint_id, complete, diff}), or null when the turn has no pair. Answers are cached per session (useTurnCheckpoints). A failed read is retried on the next request, and an answer that arrives after a session switch is dropped.
  • Item 1: when the checkpoint loads, Last turn shows its files. Files no tool call changed get an "Outside tool calls" badge and are read-only. For now, every hunk in the checkpoint view is read-only: Keep/Undo stay on the tool-call view until item 2 maps checkpoint hunks onto the footer's tool hunk keys, which needs cc-pane-transcript's #17156.
  • Item 4: when the checkpoint is missing, fails to load, or is incomplete, Last turn falls back to the tool-call view with a one-line note saying why.
  • Item 5: once the checkpoint loads, the edited-files card shows its files and counts, plus "Includes changes outside tool calls" when some came from outside tool calls. Otherwise the card shows tool-call counts. The latest turn's checkpoint is read when that turn ends; any other turn's is read when its changes view opens.
  • Item 6 (small): while an Undo is chosen but not yet sent, the tool-call view stays, with a note. It switches once the Undo is sent or cleared.
  • TurnFile gains an optional outside. The change is additive, so the showcase seed is unaffected.

Not wired yet: git.checkpoint.* exposes no diff (create, get, list, pin, unpin), and per the coordinator I am not adding an op. In production, changesSource has no turn, so every turn reads as unsupported and Last turn behaves exactly as before. Once the owner's read op exists, wiring it is one line in App.tsx.

Verification

  • turnCheckpoint.test.ts: reading the wire; checkpoint vs tool view in every load state; the outside marking; an unsent Undo holding the view; card counts.
  • useTurnCheckpoints.test.tsx: no host read; read once; retry after an error; a stale answer dropped after a session change.
  • transcript.test.tsx:
    • The panel shows the fallback note with Keep/Undo actions, and a checkpoint that is read-only with the outside badge.
    • The card shows checkpoint counts and the marker.
  • bun run check is clean, and all 757 agent-session tests pass. The bundle is regenerated.
  • No capture: with no host read, nothing visible changes.

Localization: the new turn.checkpoint.* and turn.outside* strings are in en and ja, the locales acpmux/i18n.ts carries.

Part of the cmux-next parity work listed in #16174 (comment).

— cc-pane-composer

šŸ¤– 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

Last turn in the changes view now shows the turn's checkpoint diff when the host keeps one, instead of each tool call's edit as its own block. Files edited twice appear once as their net change, and changes no tool call made (shell writes, formatters) now show, marked with an "Outside tool calls" badge and read-only. The host exposes no turn read yet, so production behavior is unchanged.

  • A loaded checkpoint replaces the tool-call view with one net patch per file; Keep and Undo require the tool-call view.
  • When a checkpoint is missing, fails to load, or is incomplete, Last turn falls back to the tool-call view with a one-line note.
  • An unsent Undo holds the tool-call view until it is sent or cleared.