The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 21:00 UTC
fix(server): threads launched in the project folder record its branch (#34812)
Julius Marminge committed
Nov 11, 2026 at 23:14 UTC
71e1f2ac512180f8976ceff8a28de84278d414c2
2 files changed
+23
-2
apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
+16
@@ -210,6 +210,7 @@ function makeHarness(options: HarnessOptions = {}) {
210
options.fetchWorktreeBaseCommit ??
211
(() => Effect.succeed({ commitSha: "remote-main-sha", remoteRefName: "origin/main" })),
212
hasCommit: options.hasCommit ?? (() => Effect.succeed(false)),
213
+ currentBranch: () => Effect.succeed(null),
214
resolveWorktreeBaseRemote: () => Effect.succeed({ remoteName: "origin", branchName: "main" }),
215
remoteExists: options.remoteExists ?? (() => Effect.succeed(true)),
216
remoteBranchExists: () => Effect.succeed(true),
@@ -981,6 +982,21 @@ function scheduledTaskInput(id: string, targetProjectId: ProjectId) {
982
};
983
}
984
985
+it.effect("records the checkout's branch on a root launch that names none", () => {
986
+ const harness = makeHarness({
987
+ git: { currentBranch: () => Effect.succeed("fix/checkout-total") },
988
+ });
989
+ return Effect.gen(function* () {
990
+ const launches = yield* ThreadLaunch.ThreadLaunchService;
991
+ const launched = yield* launches.launch(
992
+ launchInput({ command: "command:launch:root-branch", thread: "thread:launch:root-branch" }),
993
+ );
994
+ const threads = yield* ThreadManagement.ThreadManagementService;
995
+ const { thread } = yield* threads.getThreadProjection(launched.threadId);
996
+ assert.equal(thread.branch, "fix/checkout-total");
997
+ }).pipe(Effect.provide(harness.layer));
998
+});
999
+
1000
it.effect("launches a worktree request for Scratch at the root, in its own folder", () => {
1001
const harness = scratchHarness();
1002
return Effect.gen(function* () {
apps/server/src/orchestration-v2/ThreadLaunchService.ts
+7
-2
@@ -248,6 +248,11 @@ const make = Effect.gen(function* () {
248
const ids = yield* IdAllocator.IdAllocatorV2;
249
const threads = yield* ThreadManagement.ThreadManagementService;
250
const managedFolders = yield* ManagedProjectFolders.ManagedProjectFolders;
251
+ // A project-folder launch that names no branch records the folder's checkout, as the composer does.
252
+ const launchBranch = (strategy: ThreadLaunchWorkspaceStrategy, workspaceRoot: string) =>
253
+ strategy.type === "root" && strategy.branch === undefined
254
+ ? git.currentBranch(workspaceRoot).pipe(Effect.orElseSucceed(() => null))
255
+ : Effect.succeed(strategy.branch ?? null);
256
const preparationScope = yield* Scope.make("sequential");
257
const scheduledLaunches = yield* Ref.make<ReadonlySet<CommandId>>(new Set());
258
yield* Effect.addFinalizer(() => Scope.close(preparationScope, Exit.void));
@@ -446,7 +451,7 @@ const make = Effect.gen(function* () {
451
const uuid = yield* randomUuidV4;
452
branch = buildTemporaryWorktreeBranchName(() => uuid.replaceAll("-", ""));
453
} else {
449
- branch = requestedBranch ?? null;
454
+ branch = yield* launchBranch(input.workspaceStrategy, project.workspaceRoot);
455
}
456
let worktreePath =
457
input.workspaceStrategy.type === "existing_worktree"
@@ -990,7 +995,7 @@ const make = Effect.gen(function* () {
995
},
996
)
997
: input.workspaceStrategy;
993
- const initialBranch = workspaceStrategy.branch ?? null;
998
+ const initialBranch = yield* launchBranch(workspaceStrategy, project.workspaceRoot);
999
const initialWorktreePath =
1000
workspaceStrategy.type === "existing_worktree" ? workspaceStrategy.worktreePath : null;
1001
const claimDispatch =