Skip to content

Commit 823998f

Browse files
fix(server): threads launched in the project folder record its branch
A project-folder launch that names no branch (t3_thread_launch, t3 thread start) saved branch null, so its sidebar row showed no branch while a composer launch in the same folder showed one. Such launches now record the folder's checked-out branch. Fixes #31177 AI-assisted; verified with the tests and tools listed above.
1 parent ca59e0c commit 823998f

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/ThreadLaunchService.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ function makeHarness(options: HarnessOptions = {}) {
210210
options.fetchWorktreeBaseCommit ??
211211
(() => Effect.succeed({ commitSha: "remote-main-sha", remoteRefName: "origin/main" })),
212212
hasCommit: options.hasCommit ?? (() => Effect.succeed(false)),
213+
currentBranch: () => Effect.succeed(null),
213214
resolveWorktreeBaseRemote: () => Effect.succeed({ remoteName: "origin", branchName: "main" }),
214215
remoteExists: options.remoteExists ?? (() => Effect.succeed(true)),
215216
remoteBranchExists: () => Effect.succeed(true),

‎apps/server/src/orchestration-v2/ThreadLaunchService.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ const make = Effect.gen(function* () {
248248
const ids = yield* IdAllocator.IdAllocatorV2;
249249
const threads = yield* ThreadManagement.ThreadManagementService;
250250
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);
251256
const preparationScope = yield* Scope.make("sequential");
252257
const scheduledLaunches = yield* Ref.make<ReadonlySet<CommandId>>(new Set());
253258
yield* Effect.addFinalizer(() => Scope.close(preparationScope, Exit.void));
@@ -446,7 +451,7 @@ const make = Effect.gen(function* () {
446451
const uuid = yield* randomUuidV4;
447452
branch = buildTemporaryWorktreeBranchName(() => uuid.replaceAll("-", ""));
448453
} else {
449-
branch = requestedBranch ?? null;
454+
branch = yield* launchBranch(input.workspaceStrategy, project.workspaceRoot);
450455
}
451456
let worktreePath =
452457
input.workspaceStrategy.type === "existing_worktree"
@@ -988,7 +993,7 @@ const make = Effect.gen(function* () {
988993
},
989994
)
990995
: input.workspaceStrategy;
991-
const initialBranch = workspaceStrategy.branch ?? null;
996+
const initialBranch = yield* launchBranch(workspaceStrategy, project.workspaceRoot);
992997
const initialWorktreePath =
993998
workspaceStrategy.type === "existing_worktree" ? workspaceStrategy.worktreePath : null;
994999
const claimDispatch =

0 commit comments

Comments
 (0)