Repository navigation
feat(projects): new worktree threads isolate every tracked repository - #35925
juliusmarminge wants to merge 1 commit into
Conversation
|
This PR changes the test suite by +35 test cases (browser 0, unit +12, server +23). Keep tests that would fail for a real reason, and test logic below the UI where it can be. See Testing. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosNo All 64 scenario measurements
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
| const blockedSinceLease = yield* blockedSinceCheck(); | ||
| if (blockedSinceLease !== null) return keep(blockedSinceLease); | ||
| // Each checkout passes the checks a single worktree does, or it stays. | ||
| const result = yield* taskFolders.remove({ |
There was a problem hiding this comment.
🟠 High src/storageCleanup.ts:1295
The task-folder path can remove checkouts after the user disables cleanup or changes its policy, because inspectCheckout and taskFolders.remove continue using the original settings after the lease wait. Re-read and validate the current cleanup settings before removal, as the ordinary-worktree path does.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/storageCleanup.ts around line 1295:
The task-folder path can remove checkouts after the user disables cleanup or changes its policy, because `inspectCheckout` and `taskFolders.remove` continue using the original `settings` after the lease wait. Re-read and validate the current cleanup settings before removal, as the ordinary-worktree path does.
| ).pipe(Effect.catch((cause) => Effect.flip(failed(target, cause)))), | ||
| { discard: true }, | ||
| ).pipe( | ||
| Effect.onError(() => |
There was a problem hiding this comment.
🟠 High orchestration-v2/CheckpointService.ts:777
When a rollback restore fails, ensuring still deletes that folder’s preRewindRef, leaving the folder partly rewound with no named snapshot of its original edits. Remove failed recovery snapshots from the cleanup list and log their refs so the edits remain recoverable.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/orchestration-v2/CheckpointService.ts around line 777:
When a rollback restore fails, `ensuring` still deletes that folder’s `preRewindRef`, leaving the folder partly rewound with no named snapshot of its original edits. Remove failed recovery snapshots from the cleanup list and log their refs so the edits remain recoverable.
| inspectCheckout(checkout.worktreePath, thread.branch, settings), | ||
| }); | ||
| for (const removedPath of result.removed) | ||
| entries.push({ |
There was a problem hiding this comment.
🟡 Medium src/storageCleanup.ts:1303
Removed task-folder checkouts are reported with bytes: null, so bytesFreed counts them as 0 and users see “0 B recovered” even when large worktrees were deleted. inspectCheckout measures each checkout but discards the byte count, and this loop spreads the original entry without setting bytes; preserve the per-checkout measurements and attach each one to its removed entry.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/storageCleanup.ts around line 1303:
Removed task-folder checkouts are reported with `bytes: null`, so `bytesFreed` counts them as 0 and users see “0 B recovered” even when large worktrees were deleted. `inspectCheckout` measures each checkout but discards the byte count, and this loop spreads the original `entry` without setting `bytes`; preserve the per-checkout measurements and attach each one to its removed entry.
| let baseRefName = baseRef; | ||
| let startedFromOrigin = false; | ||
| if (startFromOrigin) { | ||
| if (startFromOrigin && projectIsRepository) { |
There was a problem hiding this comment.
🟠 High mcp/WorktreeMcpService.ts:245
For a non-Git project with tracked repositories, the handoff response reports startedFromOrigin: false even when startFromOrigin: true makes TaskFolders.create fetch remote commits. startedFromOrigin is only set in the projectIsRepository branch, so callers are incorrectly told the handoff used a local fallback; propagate the task-folder repositories’ actual origin-start outcome into the result.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/mcp/WorktreeMcpService.ts around line 245:
For a non-Git project with tracked repositories, the handoff response reports `startedFromOrigin: false` even when `startFromOrigin: true` makes `TaskFolders.create` fetch remote commits. `startedFromOrigin` is only set in the `projectIsRepository` branch, so callers are incorrectly told the handoff used a local fallback; propagate the task-folder repositories’ actual origin-start outcome into the result.
| const preRewindRef = yield* scopeRef(target.scope.id, "pre-rewind").pipe( | ||
| Effect.provideService(Digest.Digest, crypto), | ||
| ); | ||
| yield* checkpointStore.captureCheckpoint({ |
There was a problem hiding this comment.
🟠 High orchestration-v2/CheckpointService.ts:760
If restoring a later target fails, rollback restores earlier targets' working-tree files but destroys their original staging state; staged-only versions are lost and other staged edits become unstaged. The preRewindRef snapshot captures working-tree contents, not the Git index, and restoreCheckpoint resets the scoped index to HEAD. Preserve and restore the original index alongside each recovery snapshot.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/orchestration-v2/CheckpointService.ts around line 760:
If restoring a later target fails, rollback restores earlier targets' working-tree files but destroys their original staging state; staged-only versions are lost and other staged edits become unstaged. The `preRewindRef` snapshot captures working-tree contents, not the Git index, and `restoreCheckpoint` resets the scoped index to `HEAD`. Preserve and restore the original index alongside each recovery snapshot.
| const commonAncestor = (folders: ReadonlyArray<string>) => { | ||
| let ancestor = folders[0]!; | ||
| for (const folder of folders.slice(1)) { | ||
| while (!isWithinRoot(path, folder, ancestor)) ancestor = path.dirname(ancestor); |
There was a problem hiding this comment.
🔴 Critical workspace/TaskFolders.ts:197
On Windows, plan hangs the server when the project and a tracked Git folder are on different drives. At the drive root, path.dirname(ancestor) stops changing while isWithinRoot remains false, so this synchronous loop never exits; detect the unchanged parent and reject the plan when there is no common root.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/workspace/TaskFolders.ts around line 197:
On Windows, `plan` hangs the server when the project and a tracked Git folder are on different drives. At the drive root, `path.dirname(ancestor)` stops changing while `isWithinRoot` remains false, so this synchronous loop never exits; detect the unchanged parent and reject the plan when there is no common root.
| worktreePath: taskFolder.projectPath, | ||
| repositoryPath: taskFolder.projectRoot, | ||
| }); | ||
| } else if (!(yield* exists(taskFolder.projectPath))) { |
There was a problem hiding this comment.
🟠 High workspace/TaskFolders.ts:902
restore reports success without restoring missing project links when partial cleanup leaves projectPath present—for example, after removeLocked removes AGENTS.md but keeps a dirty repository. The exists(projectPath) guard skips linkFolder for the surviving wrapper directory; run linkFolder even when the directory exists so it can recreate missing entries.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/workspace/TaskFolders.ts around line 902:
`restore` reports success without restoring missing project links when partial cleanup leaves `projectPath` present—for example, after `removeLocked` removes `AGENTS.md` but keeps a dirty repository. The `exists(projectPath)` guard skips `linkFolder` for the surviving wrapper directory; run `linkFolder` even when the directory exists so it can recreate missing entries.
| const tracksFolders = (project?.trackedFolders?.length ?? 0) > 0; | ||
| // A worktree thread reaches tracked repositories only through its own task folder. | ||
| const taskFolderQuery = useEnvironmentQuery( | ||
| props.isServerThread && props.worktreePath !== null && tracksFolders |
There was a problem hiding this comment.
🟡 Medium chat/ThreadDetailsPanel.tsx:112
Existing worktree threads lose their repository sections after the project removes its last tracked folder: this condition skips the task-folder lookup, leaving taskFolder null and making show.repositories false. Query persisted worktree threads regardless of the project's current tracked-folder list, since changing that list does not remove their task folders.
- props.isServerThread && props.worktreePath !== null && tracksFolders
+ props.isServerThread && props.worktreePath !== nullAlso found in 1 other location(s)
apps/web/src/components/Sidebar.logic.ts:177
The exemption also preserves removed ordinary worktrees whenever their project tracks any folder. For example, an existing single-repository worktree (including a PR checkout) whose checkout ceases to be a repository now retains its branch and worktree path despite
isRepo: false.SidebarThreadRowuses this returned value for the branch label, worktree indicator and tooltip, so it misleadingly continues showing a checkout that is gone. Distinguish actual task folders from ordinary worktrees rather than inferring that distinction from the project's current tracked-folder count.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/web/src/components/chat/ThreadDetailsPanel.tsx around line 112:
Existing worktree threads lose their repository sections after the project removes its last tracked folder: this condition skips the task-folder lookup, leaving `taskFolder` null and making `show.repositories` false. Query persisted worktree threads regardless of the project's current tracked-folder list, since changing that list does not remove their task folders.
Also found in 1 other location(s):
- apps/web/src/components/Sidebar.logic.ts:177 -- The exemption also preserves removed ordinary worktrees whenever their project tracks any folder. For example, an existing single-repository worktree (including a PR checkout) whose checkout ceases to be a repository now retains its branch and worktree path despite `isRepo: false`. `SidebarThreadRow` uses this returned value for the branch label, worktree indicator and tooltip, so it misleadingly continues showing a checkout that is gone. Distinguish actual task folders from ordinary worktrees rather than inferring that distinction from the project's current tracked-folder count.
| if (project === null || !tracksFolders) return NO_TRACKED_FOLDERS; | ||
| if (folders.data === null) { | ||
| // Until the folders arrive the tracked list stands in, as the checkout's Git state does. | ||
| return { choices: null, tracksGitRepositories: folders.error === null }; |
There was a problem hiding this comment.
🟠 High hooks/useWorktreeRepositoryChoices.ts:44
When listFolders fails, this returns tracksGitRepositories: false, so resolveSendEnvMode downgrades a requested worktree send to local and the turn runs against the original workspace instead of isolated worktrees. Because folders.data is still null on failure, keep tracksGitRepositories true while repository discovery is unavailable so the send preserves isolation and can be blocked or retried.
| return { choices: null, tracksGitRepositories: folders.error === null }; | |
| return { choices: null, tracksGitRepositories: true }; |
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/web/src/hooks/useWorktreeRepositoryChoices.ts around line 44:
When `listFolders` fails, this returns `tracksGitRepositories: false`, so `resolveSendEnvMode` downgrades a requested worktree send to `local` and the turn runs against the original workspace instead of isolated worktrees. Because `folders.data` is still `null` on failure, keep `tracksGitRepositories` true while repository discovery is unavailable so the send preserves isolation and can be blocked or retried.
| return first !== undefined && (first.ordinalWithinScope === targetOrdinal || first.runId === null) | ||
| ? first | ||
| : null; |
There was a problem hiding this comment.
🟠 High src/orchestrationV2.ts:1499
When an error run checkpoint lies between targetOrdinal and a later ready runless baseline, this function returns the baseline even though it includes the failed run’s edits, causing CheckpointRollbackService to restore the wrong repository contents. Since non-ready checkpoints are skipped, reject a candidate when an intervening error checkpoint has a non-null runId.
- return first !== undefined && (first.ordinalWithinScope === targetOrdinal || first.runId === null)
+ return first !== undefined &&
+ (first.ordinalWithinScope === targetOrdinal || first.runId === null) &&
+ !checkpoints.some(
+ (checkpoint) =>
+ checkpoint.status === "error" &&
+ checkpoint.runId !== null &&
+ checkpoint.ordinalWithinScope >= targetOrdinal &&
+ checkpoint.ordinalWithinScope < first.ordinalWithinScope,
+ )🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @packages/contracts/src/orchestrationV2.ts around lines 1499-1501:
When an `error` run checkpoint lies between `targetOrdinal` and a later ready runless baseline, this function returns the baseline even though it includes the failed run’s edits, causing `CheckpointRollbackService` to restore the wrong repository contents. Since non-ready checkpoints are skipped, reject a candidate when an intervening `error` checkpoint has a non-null `runId`.
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — New worktree launches now include all tracked repositories by default up to eight, while plain-folder files remain shared links. Human review is required for this product-default change, including the intended repository scope and shared-file expectations. Needs human approval because:
No code changes detected at Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |
…s, Git and worktrees for each (#12) * feat(projects): a project can track several repositories (pingdotgg/t3code#35921) Port of upstream PR pingdotgg/t3code#35921 at e60d37e8ad, without its apps/mobile changes. Upstream's 086_ProjectionProjectsTrackedFolders migration would collide with upstream's own 086, so the column comes from ensureKlinSchema, which runs after the numbered migrations and only adds what is missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(projects): turn changes and diffs cover tracked repositories (pingdotgg/t3code#35923) Port of upstream PR pingdotgg/t3code#35923 at 4abac7127c, without its apps/mobile changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(projects): Git actions and pull requests per tracked repository (pingdotgg/t3code#35924) Port of upstream PR pingdotgg/t3code#35924 at ae8fad5eef, without its apps/mobile changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(projects): new worktree threads isolate every tracked repository (pingdotgg/t3code#35925) Port of upstream PR pingdotgg/t3code#35925 at 5a89fabab8, without its apps/mobile changes. Upstream's 087_TaskFolders migration would collide with upstream's own 087, so ensureKlinSchema creates the task_folders table instead. Storage cleanup and worktree branch naming were merged with upstream's later changes to the same code (symlinked worktree paths, prefix-aware temporary branches). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(client): a thread lists its most recently changed repositories first after it loads A loaded thread lists its checkpoints by scope and then ordinal, and the ranking used each checkpoint's position in that list as its time. Repositories were ranked by scope id, so one changed in the latest turn could fold behind "Show more". Rank each repository by the ordinal of its latest run checkpoint, which is the run's ordinal, and break ties within a turn by name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(client): a repository with a backslash in its folder name links to the right folder on Linux and macOS Repository paths were split on backslashes as well as slashes everywhere, so on POSIX `/work/api\client` became `api/client`. Its name and relative path were wrong, and the changed files tree opened diffs under the wrong folder. Treat a backslash as a separator only in a Windows path, one that starts with a drive letter or a UNC prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(web): a repository folder whose name starts with ".." opens its files in the diff viewer The diff panel counted any repository whose relative path starts with ".." as outside the thread's folder, so a repository at `..api` opened its files in the external editor instead of the file viewer. The worktree repository choices used the same check and hid such a folder's place in the project. Count a relative path as leaving the folder only when it is ".." or starts with "../". `repositorySectionForPath` now returns that answer, so the panel no longer works it out itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a tracked repository on another drive no longer freezes Windows Planning a task folder walked up from the project with `path.dirname` until one folder held every tracked repository. On Windows `dirname` stops changing at a drive root, so a repository on another drive made the synchronous loop run forever and froze the server. The walk now stops at the root, and the plan fails with a message saying the tracked repositories share no folder with the project. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a task folder no longer links repositories the project does not track In a project whose folder is not a repository, the task folder linked every entry that did not lead to a tracked repository, including Git repositories the project does not track. An agent editing one through the task folder edited the original checkout. The task folder now leaves out every repository that gets no worktree, the same way it already left out tracked repositories that were not chosen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cursor): the next turn after a tracked folder change can reach the new folders Cursor fixes an agent's `local.dirs` when it opens, and the adapter reused the open agent for every later turn. After a person or an agent changed the project's tracked folders, the turn instructions named the new folders while the running agent still lacked access to them. The adapter now remembers the folders each agent was opened with and resumes the agent with the turn's folders when they differ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): concurrent project edits can no longer track a folder that holds the project ProjectService.update checked the tracked folders against the project row it read before taking the project lock, and the commit did not check again. A move and a folder edit that raced could each pass and together save a tracked folder that contains the project's new root. The containment and duplicate checks now run under the project lock, against the root and folder list the command leaves, and reject through a command receipt like other planning failures. Path normalization stays before the lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a restored task folder keeps repositories the project stopped tracking isolated Restoring a removed task folder kept out only the repositories the project tracks now. A repository the task folder recorded but the project no longer tracks was reached through a link to its original checkout, and restore took that link for the existing worktree, so the thread's edits went to the original. Restore now also keeps out every repository the task folder recorded, so each gets its own worktree back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): missing folders no longer hide real repositories from a folder scan The scan applied the 128-folder limit before it dropped folders that do not exist, so a .code-workspace file listing many missing folders could use up the limit and leave out repositories that are on disk. The scan now drops missing folders first and applies the limit to what is left. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(web): worktree threads keep their repositories after the project stops tracking folders The thread details panel looked up a worktree thread's task folder only while the project tracked at least one folder. After a project removed its last tracked folder, its existing task folder threads lost their repository sections, and a plain project folder in one was offered Git actions again. Look up the task folder for every worktree thread the server knows. This is one request for the open thread, not one per sidebar row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a folder with a long name no longer blocks tracking it A scanned folder's name comes from its .code-workspace entry or its directory name, and neither had a length limit. A project stores at most 128 characters per tracked folder name, so saving a scan's selection, `project add --track-repos` or `--track` failed for a folder with a longer name. The server now cuts scanned and CLI-made names to 128 characters, the limit the contract exports as PROJECT_TRACKED_FOLDER_NAME_MAX. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(web): a worktree send no longer runs in the project folder when its tracked folders can't be read When the tracked folder list failed to load, the composer treated a plain project folder as having no Git repository and quietly turned a "New worktree" send into a normal thread that edited the original folders. An unread folder list now leaves the worktree request as it is. The server then creates the task folder, or refuses the send with "is not a Git repository" when the project has no repository. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(web): a removed worktree no longer shows its branch in the sidebar when its project tracks folders The sidebar drops a worktree thread's branch and path once live status says its folder is no repository. It kept them whenever the project tracked any folder, to spare task folders whose plain project folder is never a repository, so an ordinary worktree whose checkout was removed still showed its branch and path. Ask the server whether the worktree is a task folder, and only for a row whose status already says it is no repository. Other rows cost no extra request. A server without task folders fails the lookup, which counts as no task folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): project add refuses more than 128 --track folders instead of dropping some `project add` cut its tracked folder list to the 128 a project allows, so with more distinct --track paths it dropped the last ones and still reported success. It now fails with an error naming the limit and the count when the --track paths alone pass the limit. Scanned folders from --track-repos still fill only the room that is left. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(acp): the next turn after a tracked folder change can reach the new folders An ACP agent gets a session's folders only when the session is set up, and the adapter kept the runtime it started with for every later turn. It also built every replacement runtime from the folders given when the session opened. After the project's tracked folders changed, the turn instructions named the new folders while the agent still had the old ones. Replacement runtimes now take the folders from the latest turn's policy. When a turn's folders differ from the running runtime's, the adapter restarts the runtime and reloads the session, provided the agent accepts folders, can reload a session, and has no background work running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): resuming a thread puts back links cleanup removed from its task folder When cleanup removed part of a task folder, for example its links but not a repository with uncommitted work, restore saw the project folder still there and skipped it. The thread came back to a folder missing files such as `AGENTS.md`, and restore reported success. Restore now always lays out the project folder. Entries that are there stay, and a real folder left from before gets its missing links, while a link is never written into. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a rewind that cannot put a folder back keeps its snapshot of the edits When a rewind across several folders failed and putting a folder back failed too, the cleanup still deleted that folder's pre-rewind snapshot ref. The folder stayed partly rewound with no named copy of the user's edits. The ref name was also fixed per folder, so the next rewind attempt overwrote any snapshot that was left. Now a snapshot is deleted only once its folder is put back, or after the rewind succeeds. A kept snapshot is logged with its ref, and each rewind attempt names its snapshots apart so a retry does not overwrite them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(web): pressing Add again while a folder is scanned no longer starts a second add Adding a folder from the command palette first scans it for repositories. A second Add or Enter during that scan started another add, which replaced the first one's pending folder choice. The first add then never finished, and the folder dialog could show the first scan's checkmarks. The palette now ignores Add, Enter and the file manager pick while an add is in progress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): two task folders created at once no longer share one folder Choosing a task folder's location only checked that the path did not exist yet. Two creations for the same project and branch could both pick it, and when one failed, its rollback removed the other's worktrees and files. The location is now reserved by creating the folder, which fails when it already exists, and the next name is tried then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(antigravity): Antigravity can read files in tracked folders outside the project T3 Code serves Antigravity's file reads itself and confines them to allowed roots. The ACP adapter passed only the turn's cwd to that handler, so a read in a tracked folder outside the project failed with "outside the session workspace". The ACP client file system hooks now receive the turn's runtime policy, and Antigravity allows reads in the thread's tracked folders as well as its cwd and attachments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(opencode): a tracked folder with * or ? in its path no longer grants other folders OpenCode grants a thread's tracked folders through `external_directory` permission patterns, and its patterns treat `*` and `?` as wildcards with no escape. A tracked `/repos/api?` granted `/repos/api1`, and `/repos/api*` granted its siblings. Both OpenCode adapters now skip the grant for a folder whose path holds `*` or `?`, so OpenCode's default rule applies to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(web): a tracked folder with a very long name no longer fails to save A project stores tracked folder names of at most 128 characters. The add-project dialog, a rescan in Settings and Add folder passed longer names through as they were, so saving the project failed for a long `.code-workspace` name or folder name. Every place that turns a scanned or typed folder into a tracked one now caps the name, as the shared selection helper already did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a symlinked tracked folder can no longer open a parent of the project to agents The check that stops a tracked folder from holding the project compared paths as typed, so a tracked symlink such as /work/app/parent-link pointing at /work passed, and WorkspaceFolders.forThread then granted /work in extraRoots. A tracked folder replaced by a symlink to / after it was saved was granted the same way, since forThread never re-checked what a path resolves to. Project validation now also compares the resolved paths of folders that exist, for both the containment and the duplicate checks. forThread leaves out a folder that resolves to a filesystem root or to a folder holding the thread's own, for tracked folders and task folder worktrees alike. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): worktrees a restart interrupted are no longer lost from their task folder A new task folder recorded its repository checkouts only after every one was made. If the server restarted partway, the record listed none of them, so removal and restore could not find the worktrees already created. The record now lists every planned checkout before the first one is made. Removal already treats a missing checkout as gone, and restore makes it. When creation fails, the record first drops the checkouts that were never made, so what the rollback keeps matches the disk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: tracked folder text says what tracking does and where a worktree thread's edits land The Repositories settings and the folder dialog said tracked repositories get "their own changes and review". The guide said the add-folder scan runs on mobile, which Klin does not ship, and that "Other repositories" brings a repository into any running thread. The text now says agents are told about tracked folders and can work in them, and that tracked Git repositories get their own changes, diffs, Git actions and pull requests. The guide now says which repositories a new worktree thread gets, that each starts from its own default branch, that the files of a plain project folder are links to the originals, and that Git repositories without a worktree are left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): folder scan and list errors keep the failure that caused them WorkspaceFoldersError had no cause, so the scan and project-read failures dropped the file system, project store and task folder errors behind them, and a permission problem looked the same as a missing folder or a database error. The error now has an optional cause, as TaskFolderError beside it and the Git errors already do, and WorkspaceFolders passes the original error through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a failed rewind puts back what each folder had staged When a later folder's restore failed, the rewind put the earlier folders' files back from their pre-rewind snapshots, but their staged changes were lost. The snapshot recorded only working-tree content, and restoring a checkpoint resets the index to HEAD, so a partly staged file also lost its staged version. A pre-rewind snapshot now also records the index, as a commit of its tree kept as the snapshot's second parent, read from a copy so the user's index stays unlocked. Putting a folder back resets its index to that commit instead of HEAD. An index Git cannot write as a tree, such as one with merge conflicts, falls back to the old behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): storage cleanup no longer removes a task folder after cleanup was turned off The task folder path of storage cleanup kept using the cleanup settings it read when the sweep started. After waiting for the workspace lease it could still remove checkouts the user had since stopped cleanup for, or under rules they had changed. Under the lease it now compares the current settings with the ones it checked against, the same comparison the ordinary worktree path makes before removal, and keeps the folder when they differ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): storage cleanup counts the space freed by removed task folder checkouts Removed task folder checkouts were reported with no size, so the cleanup report counted them as 0 B. The inspection measured each checkout before removal and then dropped the number. The inspection now returns each checkout's measured size, and the report attaches it to the checkout's removed entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(contracts): a rewind no longer restores a repository from a baseline that holds a failed run's edits repositoryRewindCheckpoint looked only at ready checkpoints. When a later run changed a tracked repository but its own snapshot failed, its error checkpoint was skipped, and the next ready baseline was returned. That baseline already held the failed run's edits, so the rewind restored the wrong contents. A runless baseline is now used only when no unrolled-back run checkpoint sits between the target and it. Otherwise the repository has no rewind target, and the rollback leaves it as it is with its usual warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): worktree handoff reports when a task folder's repositories started from origin The handoff tool set `startedFromOrigin` only from the project folder's own fetch. For a project folder that is not a repository, the task folder fetched each tracked repository from its remote while the result still said `false`. Task folder creation now reports whether a repository's checkout started from a fetched remote commit, and the handoff result includes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a turn diff stays within its size limit when the thread's own patch fills it When the thread folder's patch used the whole output budget, each changed tracked repository still ran its diff with no budget left and got the truncation marker on its own. The combined turn diff then went over CHECKPOINT_DIFF_MAX_OUTPUT_BYTES by one marker per repository, and each of those repositories cost Git processes for nothing. Repository patches now stop once the remaining budget cannot hold the marker. The thread's own patch already ends with the marker, so the cut is still visible. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a tracked repository's turn edits stay in review when Git cannot list them A checkpoint capture that failed to list the changed files recorded a ready checkpoint with an empty file list. For a tracked repository, an empty list means the run left it as it was, so the run's checkpoint was dropped. Its edits then disappeared from turn review, and a later baseline that already held them could pass for the state before the run in a rewind. A numstat larger than Git's output limit is one way to get there. The capture now reports when the file list could not be read, and a repository checkpoint is dropped only when Git listed no file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a repository a turn fully committed keeps its changes after a server restart When a turn starts on a clean tracked repository, only this process's memory notes the commit it started on; no snapshot is written until a turn changes something. A server restart mid-turn replays the turn's checkpoint capture in a new process that has lost that note. A repository the agent fully committed was then clean with no baseline snapshot, which the capture read as "unchanged", so the turn listed no files for it. A repository that missed the turn-start baseline budget had the same gap. When how the turn started is unknown and the repository is clean, the capture now asks HEAD's reflog where HEAD was when the run started. If a commit moved it since, that commit becomes the turn's baseline, dated at the run's start like a noted one. Without a reflog, nothing changes from before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(agents): say how Klin's multi-repo schema survives upstream merges Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a CLI adds Klin's multi-repo schema only while it owns the database A CLI command migrates a database only after it takes the server ownership lock, and it skips the lock when no migration is pending. Klin's startup schema step was not counted as pending, so a newer CLI could add the tracked folders column and task folder table to a database a running server owned. Missing Klin schema now counts as pending, and adding it logs the same finished line the desktop waits for after a migration starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a turn no longer shows edits made before a later turn as its own repository changes A repository's diff range ended at its last record in the range, which could be the runless baseline a later turn recorded. That baseline holds the folder as the next turn found it, so edits made between turns showed up as changes of a turn that left the repository alone. The range now ends at the last record a turn wrote itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a file rewind in a linked task folder with nothing to restore rewinds the conversation A task folder whose project folder is a plain linked folder has no snapshot of its own, so a file rewind there could only restore its repositories. When none changed after the target turn, both the Orchestrator and the rollback service refused the rewind as an invalid target. A missing project folder snapshot is now accepted for a linked task folder whatever its repositories hold. The rewind restores the repositories that changed, if any, and otherwise rewinds only the conversation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a tracked repository on another drive no longer blocks every worktree of its project A task folder lays its checkouts out around the deepest folder holding the project and every tracked Git folder. When one tracked repository shared no folder with the project, for example because it was on another Windows drive, every worktree creation failed, even one that left that repository out. The layout still covers every tracked repository where one folder holds them all, so any can be added to the thread later. Otherwise it covers the project and the repositories the task folder holds, and only a selection that itself spans drives is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a rewind recreates a task folder repository whose branch was deleted When storage cleanup removed a task folder's checkouts, a rewind put each one back by checking out the thread's branch, and failed outright when a repository no longer had that branch, for example after it was deleted once its work merged. Resuming the thread already handled this. The rewind now recreates a missing checkout with the same step the resume path uses: the thread's branch if it exists, else its pushed commit, else a new branch from where the repository is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a task folder checkout comes back over files a failed removal left Resuming or rewinding a thread puts back each checkout of its task folder that is missing. Any path without a .git counted as missing, and Git refused to check out into it when a removal that failed partway had left files there, such as build output, so the thread could not resume or rewind. Such files are now set aside while the checkout is made, deleted once it succeeds and put back if it fails, as a rewind already did for a single worktree. Both paths share that step now. A folder that still holds another live checkout of the task folder is never set aside. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): removing a task folder through a symlinked path removes all of it Removing a thread's worktree first asks whether the path is a task folder. The record is found through either spelling of a worktrees folder reached through a symlink, but the path was then compared only with the spelling the record stored. A request with the other spelling was treated as a single worktree: only the project folder's checkout went, and the repository checkouts and the record stayed behind. The comparison now resolves both sides the way the record lookup does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style(server): format the task folder tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): a new task folder never merges into the record of one cleanup removed Storage cleanup can remove a task folder's directory and keep its record, so the folder can be put back when its thread resumes. A new task folder for the same project and branch name, for example after the old branch was deleted, could be given that same directory, since only the directory was checked. Its record then merged into the old one, whose project fields the upsert never updated, so two threads shared one record. A folder name that still has a record is now skipped, and a record written again replaces every field. Failures to write the record now say so instead of reporting a failed read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(client): the rewind comment says what the server now accepts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(server): the agent context budget matches the tracked folder tool text The fixes on this branch shortened the project tools' tracked folder text by 27 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
ae8fad5 to
06c700e
Compare
5a89fab to
464b782
Compare
| }); | ||
| if (input.restoreFiles !== false) yield* checkpoints.restore({ scope, checkpoint }); | ||
| if (restoreFiles) { | ||
| yield* checkpoints.restore({ targets: restoreTargets, scopes: [scope, ...repositories] }); |
There was a problem hiding this comment.
🟠 High orchestration-v2/CheckpointRollbackService.ts:413
Restoring these repository checkpoints can rewrite files while an agent is running in a sibling repository: the rollback reservation covers only thread.worktreePath, and workspaceLease does not conflict for sibling paths. Reserve every restored repository path (or the task-folder root) before the isolation check so sibling turn starts wait for the restore.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/orchestration-v2/CheckpointRollbackService.ts around line 413:
Restoring these repository checkpoints can rewrite files while an agent is running in a sibling repository: the rollback reservation covers only `thread.worktreePath`, and `workspaceLease` does not conflict for sibling paths. Reserve every restored repository path (or the task-folder root) before the isolation check so sibling turn starts wait for the restore.
"New worktree" isolated only the project folder, and a wrapper folder that is not a Git repository could not use it at all. A worktree thread of a project that tracks repositories now gets a task folder laid out like the project: the project folder, plus one worktree per chosen repository on the thread's branch. A project folder that is not a repository becomes a directory of links to its files. The composer picks the repositories, one can be added to a running thread, removal and storage cleanup keep any repository with unsaved work, and rewind restores every repository together or none. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
464b782 to
b43a807
Compare
06c700e to
71e44ba
Compare
…series Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Layer 4 of 4 of the multi-repository rebuild (discussion #7041). Stacked on layer 3. Replaces #26254.
"New worktree" isolated only the project folder, and a wrapper folder that is not a Git repository could not use it at all.
What changed
../app, keep working.AGENTS.mdand notes. Those files are shared with the original, not copied. Nothing offers to initialize Git.t3_thread_launch,create_threads, scheduled tasks, isolateddelegate_task, worktree handoff, mobile's "create worktree", and restoring a removed worktree all go through one service.After
A worktree thread in a wrapper folder: api, web and a repository outside the folder are all worktrees on
t3/add-version.Known limits
Proof
vp run check:changed: format, lint, knip, typecheck pass; 2,820 of 2,821 tests pass (same unrelated failure).agent-context-increase).mcp-tool-useevals not run.Created with Claude Fable 5.2 in Claude Code, running in T3 Code, with subagents for the parallel build.
🤖 Generated with Claude Code