Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): restore checkouts from leftover worktree folders #24398

Closedjuliusmarmingewants to merge 7 commits intomain fromrefs/pull/24398/headopened View on GitHub

Showing 4 changed files with 104 additions and 2 deletions (loading 1).

x
0 of 4 viewed, 4 left
59 additions and 0 deletionsapps/server/src/orchestration-v2/ProviderTurnStartService.test.tsModified
View file
@@ -1483,6 +1483,65 @@
+effectIt.effect.each([["node_modules"], ["node_modules", ".next"]])(
+ "recreates a managed worktree folder that holds only %s",
+ (leftovers) =>
+ Effect.gen(function* () {
+ const fileSystem = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const workspaceRoot = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-start-" });
+ const worktreePath = path.join(workspaceRoot, "project", "worktree");
+ // What a junction-skipping `git worktree remove` leaves behind: no `.git`, no files.
+ for (const leftover of leftovers) {
+ yield* fileSystem.makeDirectory(path.join(worktreePath, leftover), { recursive: true });
+ }
+ const harness = makeLocalCommandHarness({
+ text: "Continue",
+ worktreePath,
+ worktreesDir: workspaceRoot,
+ fileSystem,
+ failReadsAfterRunning: true,
+ });
+ // `git worktree add` refuses a non-empty target, so the leftover must be gone first.
+ harness.createWorktree.mockImplementation(() =>
+ fileSystem.exists(worktreePath).pipe(
+ Effect.tap((exists) => Effect.sync(() => expect(exists).toBe(false))),
+ Effect.as({} as never),
+ Effect.orDie,
+ ),