Skip to content

Commit 361b516

Browse files
committed
Fix settings error escaping error handlers in branch rename
Move serverSettingsService.getSettings into the Effect chain using Effect.flatMap so that if the settings fetch fails, the error is caught by the downstream .pipe(Effect.catch(...), Effect.catchCause(...)) handlers instead of escaping the generator before those handlers are applied.
1 parent 9d390e3 commit 361b516

File tree

1 file changed

+44
-40
lines changed

1 file changed

+44
-40
lines changed

apps/server/src/orchestration/Layers/ProviderCommandReactor.ts

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -424,48 +424,52 @@ const make = Effect.gen(function* () {
424424
const oldBranch = input.branch;
425425
const cwd = input.worktreePath;
426426
const attachments = input.attachments ?? [];
427-
yield* textGeneration
428-
.generateBranchName({
429-
cwd,
430-
message: input.messageText,
431-
...(attachments.length > 0 ? { attachments } : {}),
432-
modelSelection: yield* Effect.map(
433-
serverSettingsService.getSettings,
434-
(settings) => settings.textGenerationModelSelection,
435-
),
436-
})
437-
.pipe(
438-
Effect.catch((error) =>
439-
Effect.logWarning(
440-
"provider command reactor failed to generate worktree branch name; skipping rename",
441-
{ threadId: input.threadId, cwd, oldBranch, reason: error.message },
442-
),
443-
),
444-
Effect.flatMap((generated) => {
445-
if (!generated) return Effect.void;
446-
447-
const targetBranch = buildGeneratedWorktreeBranchName(generated.branch);
448-
if (targetBranch === oldBranch) return Effect.void;
449-
450-
return Effect.flatMap(
451-
git.renameBranch({ cwd, oldBranch, newBranch: targetBranch }),
452-
(renamed) =>
453-
orchestrationEngine.dispatch({
454-
type: "thread.meta.update",
455-
commandId: serverCommandId("worktree-branch-rename"),
456-
threadId: input.threadId,
457-
branch: renamed.branch,
458-
worktreePath: cwd,
459-
}),
460-
);
427+
yield* Effect.flatMap(
428+
Effect.map(
429+
serverSettingsService.getSettings,
430+
(settings) => settings.textGenerationModelSelection,
431+
),
432+
(modelSelection) =>
433+
textGeneration.generateBranchName({
434+
cwd,
435+
message: input.messageText,
436+
...(attachments.length > 0 ? { attachments } : {}),
437+
modelSelection,
461438
}),
462-
Effect.catchCause((cause) =>
463-
Effect.logWarning(
464-
"provider command reactor failed to generate or rename worktree branch",
465-
{ threadId: input.threadId, cwd, oldBranch, cause: Cause.pretty(cause) },
466-
),
439+
).pipe(
440+
Effect.catch((error) =>
441+
Effect.logWarning(
442+
"provider command reactor failed to generate worktree branch name; skipping rename",
443+
{ threadId: input.threadId, cwd, oldBranch, reason: error.message },
467444
),
468-
);
445+
),
446+
Effect.flatMap((generated) => {
447+
if (!generated) return Effect.void;
448+
449+
const targetBranch = buildGeneratedWorktreeBranchName(generated.branch);
450+
if (targetBranch === oldBranch) return Effect.void;
451+
452+
return Effect.flatMap(
453+
git.renameBranch({ cwd, oldBranch, newBranch: targetBranch }),
454+
(renamed) =>
455+
orchestrationEngine.dispatch({
456+
type: "thread.meta.update",
457+
commandId: serverCommandId("worktree-branch-rename"),
458+
threadId: input.threadId,
459+
branch: renamed.branch,
460+
worktreePath: cwd,
461+
}),
462+
);
463+
}),
464+
Effect.catchCause((cause) =>
465+
Effect.logWarning("provider command reactor failed to generate or rename worktree branch", {
466+
threadId: input.threadId,
467+
cwd,
468+
oldBranch,
469+
cause: Cause.pretty(cause),
470+
}),
471+
),
472+
);
469473
});
470474

471475
const processTurnStartRequested = Effect.fnUntraced(function* (

0 commit comments

Comments
 (0)