Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): treat symlinked worktree paths as the same directory #9247

ClosedMnigos(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/9247/headopened View on GitHub

Showing 2 changed files with 90 additions and 5 deletions.

x
0 of 2 viewed, 2 left
72 additions and 0 deletionsapps/server/src/orchestration/Layers/CheckpointReactor.test.tsModified
View file
@@ -303,6 +303,8 @@
readonly threadWorktreePath?: string | null;
readonly threadBranch?: string | null;
readonly secondThreadSharingWorktree?: boolean;
+ // Spells the shared worktree differently for the second thread, e.g. through
+ // a symlink to the first thread's directory.
readonly secondThreadWorktreePath?: (cwd: string) => string;
readonly localStatusRefName?: string | null;
readonly providerSessionCwd?: string;
@@ -1322,6 +1324,76 @@
+ it("does not adopt a drifted checkout when another thread spells the worktree via a symlink", async () => {
+ const linkParent = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-checkpoint-link-"));
+ tempDirs.push(linkParent);
+ const harness = await createHarness({
+ seedFilesystemCheckpoints: false,
+ threadBranch: "t3code/original-branch",
+ localStatusRefName: "t3code/renamed-by-agent",
+ secondThreadSharingWorktree: true,
+ secondThreadWorktreePath: (cwd) => {
+ const link = NodePath.join(linkParent, "worktree");
+ // A junction needs no symlink privilege on Windows; POSIX ignores the type.
+ NodeFS.symlinkSync(cwd, link, "junction");
+ return link;
+ },
+ });
+​