You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: After a thread moves to another worktree, its next turn's diff shows the other branch, and "Revert files too" overwrites the new worktree with the old one's files #30876
I searched existing issues and did not find a duplicate.
I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
Start a thread in worktree A of a repository and send a turn that edits a file.
Move the thread to worktree B of the same repository, on another branch with its own commits and files.
Send a turn that edits one file.
Open turn 2's diff.
Choose "Edit from here?" on turn 1, then "Revert files too".
Expected behavior
Turn 2's diff lists only the file turn 2 edited.
A file revert never writes a checkpoint taken in one worktree into another. It is refused, and the conversation-only revert still works.
Actual behavior
Turn 2's diff lists every difference between A's tree and B's tree (B's branch commits and turn 1's files) as turn 2's changes.
The revert is accepted and writes A's turn-1 tree into worktree B, so B's branch-only files are deleted or reverted.
With B in another repository instead, turn 2's baseline is missing and its diff is empty or wrong.
Impact: data loss in the destination worktree (uncommitted and branch-only files) from an action the UI presents as safe.
Why, in the current code:
CheckpointService.makeRootRunScope allocates every root run's scope from the one name ROOT_CHECKPOINT_SCOPE_NAME ("root"), and writes the run's own cwd into it. A thread therefore has one root checkpoint scope, re-created by each run with that run's cwd.
Checkpoint refs are per scope and ordinal and live in the repository, which worktrees of one repository share. So turn 2 is diffed against the ref A's turn 1 left.
isCheckpointRestoreIsolated (CheckpointRestoreSafety.ts) compares the scope's cwd (now B) with the thread's worktreePath (B), so the check passes.
Related but different: #27336 reports the same diff symptom when the agent moves into a worktree of its own or switches branch, without T3 Code moving the thread.
Activity