Skip to content

Rewind and diff work past a run that never started; skip the files question when nothing changed - #4

Merged
ziyadakl merged 3 commits into
custom-v2from
fix/rewind-skips-cancelled-run
Oct 8, 2026
Merged

ziyadakl merged 3 commits into
custom-v2from
fix/rewind-skips-cancelled-run

Conversation

@ziyadakl

@ziyadakl ziyadakl commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Summary

A run that never starts (cancelled while queued, or steered into the run before it) gets no checkpoint. Rewind and the diff panel both looked up a checkpoint by exact run number, so the gap broke them. Both now use the newest ready checkpoint at or before that run (shared: packages/shared/src/checkpointOrdinal.ts).

 revertThreadCheckpoint(turnCount)            # packages/client-runtime/src/operations/commands.ts
-  checkpoints.findLast(c => c.appRunOrdinal === turnCount)
+  checkpointAtRunOrdinal(checkpoints, turnCount)   # newest at or before, else thread start

 CheckpointDiffQuery "from" checkpoint        # apps/server/src/checkpointing/CheckpointDiffQuery.ts
-  exact run number
+  checkpointAtRunOrdinal(...)

The "Edit from here?" dialog no longer asks about files when no files changed since the revert point:

 onRevertToTurnCount(turnCount)               # apps/web/src/components/ChatView.tsx
-  open "Edit from here?"
+  if revertTouchesFiles(turnDiffSummaries, turnCount)   # apps/web/src/session-logic.ts
+    open "Edit from here?"
+  else
+    rewind now, keep files, prompt back in composer

Evidence

Real thread: run 1 completed, run 2 cancelled before start (no checkpoint), run 3 completed. Rewind on run 3's message failed.

  • Before: commands.test.ts:280 → OrchestrationV2CheckpointUnavailableError: Rollback target run ordinal 2 is unavailable for thread thread-v2.
    After: Tests 28 passed (28)
  • Before: CheckpointDiffQuery.test.ts:199 → CheckpointRefUnavailableError: ... Checkpoint ref is unavailable for turn 2.
    After: Test Files 2 passed (2), Tests 34 passed (34)
  • Before: session-logic.test.ts:348 → TypeError: revertTouchesFiles is not a function
    After: Tests 51 passed (51)

Typecheck: packages/shared, packages/client-runtime, apps/server, apps/web exit 0.

Merge Danger

Door: two-way

Lookup and UI logic only; no data migration or stored-state change. Revert the two commits to undo.

Blast Radius: small

Touches rewind and the diff panel only. One edge: an empty changed-file list can also mean the server could not compute the diff, so the dialog is skipped and files are kept. Nothing is lost.

🤖 Generated with Claude Code

claude added 2 commits October 7, 2026 16:57
…stion when nothing changed

Rewinding to a message whose previous run was cancelled before it
started failed with "Rollback target run ordinal N is unavailable".
The client resolved the target with an exact appRunOrdinal match, but
a run that never started captures no checkpoint, so ordinals across
checkpoints are not contiguous. The resolver now takes the newest
checkpoint at or before the ordinal, or the thread-start checkpoint.

The "Edit from here?" dialog asked whether to revert files even when
no run after the revert point changed any. It now rewinds straight
away, keeping the workspace, when every later checkpoint is ready
with no changed files; missing or errored checkpoints still ask.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…n that never started

The diff panel asks for a run's changes from "its ordinal minus one".
CheckpointDiffQuery resolved that baseline with an exact appRunOrdinal
match, so when the previous run was cancelled before it started (no
checkpoint) the diff failed with "Checkpoint ref is unavailable for
turn N". The baseline now comes from the newest ready checkpoint at or
before that ordinal, or the root scope's ordinal zero before any.
The lookup is shared with the client rewind resolver through
@t3tools/shared/checkpointOrdinal.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M labels Oct 7, 2026
@ziyadakl
ziyadakl merged commit 22118e3 into custom-v2 Oct 8, 2026
25 checks passed
@ziyadakl
ziyadakl deleted the fix/rewind-skips-cancelled-run branch October 8, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants