Description
What happened
Rewinding a thread ("Edit from here" / revert) always takes about 20 s or more. The thread is in a project whose folder holds many git repositories.
Diagnosis
Almost all of the time is spent in CheckpointService.discardRepositorySnapshots, after the provider rollback has finished.
discardRepositorySnapshots(apps/server/src/orchestration-v2/CheckpointService.ts) runsdeleteCheckpointRefsfor every repository scope thatrepositoryScopesdiscovers in the project folder, 6 at a time (REPOSITORY_SCOPE_CONCURRENCY). In this project that is 102 repositories. The thread has checkpoints in only 25 of them.- For each repository,
GitVcsDriver.checkpoints.deleteCheckpointRefs(apps/server/src/vcs/GitVcsDriver.ts) runs, in series: aprobeWorkTreegit call during VCS detection, onegit update-ref -dper rolled-back ordinal, and thenlistSubmodules, which runsgit submodule foreach --quiet 'printf "%s\0" "$displaypath"'. git submodule foreachis the expensive part. It took 185 s of the 250 s total git process time in this rewind. None of the 102 repositories has a.gitmodulesfile, so all of that work finds nothing.- On its own,
git submodule foreachtakes about 0.4–0.5 s per repository on this machine (macOS, git 2.56.0). Inside the rewind it took about 1.9 s per repository, with 6 running in parallel and a system load average of 6–7.
The code is unchanged on main (11 commits ahead of this build).
Possible fixes:
- Delete refs only in the repository scopes where the thread actually has checkpoints (the projection already records
scope_idper checkpoint). - Skip
listSubmoduleswhen the repository has no.gitmodulesfile. - Delete all refs for a repository in one
git update-ref --stdincall instead of one process per ref.
Steps to reproduce
- Create a project whose folder (not itself a git repository) holds many git repositories (about 100, up to 3 levels deep), none with submodules.
- In a thread in that project, run two or more turns with a Claude agent.
- Rewind the thread to an earlier message.
- Rewind takes tens of seconds. In
server.trace.ndjson,CheckpointService.discardRepositorySnapshotsaccounts for almost all of theorchestrationV2.checkpointRollback.executespan, with onedeleteCheckpointRefschild per discovered repository.
Version
T3 Code Desktop 0.1.14-nightly.20261130.5465 (commit 4d01919), local server, same version. Earlier builds: unknown.
Environment
- macOS (darwin arm64, 27.2.0)
- Node v24.22.1
- git 2.56.0 (Homebrew)
- Provider: Claude
- Client surface: desktop app against the local server
Evidence
Span summary from server.trace.ndjson for one rewind:
orchestrationV2.checkpointRollback.execute 44337 ms
ClaudeAdapterV2.rollbackThread 1174 ms
CheckpointService.discardRepositorySnapshots 43099 ms
deleteCheckpointRefs x102, each 1.3–3.9 s, 6 concurrent
Cumulative span time in this trace:
VcsProcess.spawn 391 spawns 249774 ms
GitVcsDriver.listSubmodules 102 calls 185503 ms
GitVcsDriver.probeWorkTree (detect) 85 calls 15716 ms
One deleteCheckpointRefs span:
2348 ms deleteCheckpointRefs
107 ms CheckpointStore.resolveCheckpoints -> GitVcsDriver.probeWorkTree
2240 ms GitVcsDriver.checkpoints.deleteCheckpointRefs
152 ms git update-ref -d (ordinal 1)
169 ms git update-ref -d (ordinal 2)
1920 ms GitVcsDriver.listSubmodules (git submodule foreach)
Standalone timing in one of the repositories (no .gitmodules):
git update-ref -d <missing ref> 0.03 s
git submodule foreach --quiet ... 0.36–0.55 s
The retained traces cover about 4 hours and contain one rewind. The user reports that every rewind is slow (about 20 s).
Related issues
- Submodule checkpoints block follow-up messages and new threads on Windows #39714 "Submodule checkpoints block follow-up messages and new threads on Windows": same
listSubmodulescost, but in the checkpoint capture path on Windows, with real submodules. This report is about the rewind clean-up path on macOS, in repositories with no submodules, multiplied by the number of repositories in the project. - Every message runs the workspace folder scan 3 times in a row, even when
t3.jsonignores every repository #40659 "Every message runs the workspace folder scan 3 times in a row": same multi-repo project shape, different cost.
Fix applied or workaround
None applied. A possible workaround is ignoreRepositories in the project's t3.json, but rewind then no longer restores files in the ignored repositories.
Filed by
Claude Code (Claude Opus 5.5, claude-opus-5-5), via the T3 Code triage playbook.
Activity
STiFLeR7 commentedon Nov 30, 2026
I independently reproduced the Git subprocess cost on Windows with Git 2.51.0.windows.2. I ran the exact
submodule foreach --quietcommand used bylistSubmodulesover 24 empty repositories, with six concurrent workers and three runs. It took 8.51–8.90 s of wall time. An index-onlygit ls-files --stage -zprobe on the same repositories took 0.51–0.73 s. Both returned no entries. These are subprocess timings from the same machine while other builds were running, rather than end-to-end rewind timings.I also checked an initialized submodule as a control.
submodule foreachstill reportedsubafter deleting.gitmodulesfrom the working tree, and again after removing.gitmodulesfrom the index while it remained in HEAD. The index still contained the160000gitlink. That makes a working-tree.gitmodulesexistence check unsafe as a skip condition. A scoped index check for gitlinks could preserveforeachfor repositories that have submodules or where the probe fails.