From 361b51678a98e90a6357ba106f81febc88e67e68 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 26 Mar 2026 06:16:33 +0000 Subject: [PATCH] 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. --- .../Layers/ProviderCommandReactor.ts | 84 ++++++++++--------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts b/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts index 3a4468beb8..0bebc65a7a 100644 --- a/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts +++ b/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts @@ -424,48 +424,52 @@ const make = Effect.gen(function* () { const oldBranch = input.branch; const cwd = input.worktreePath; const attachments = input.attachments ?? []; - yield* textGeneration - .generateBranchName({ - cwd, - message: input.messageText, - ...(attachments.length > 0 ? { attachments } : {}), - modelSelection: yield* Effect.map( - serverSettingsService.getSettings, - (settings) => settings.textGenerationModelSelection, - ), - }) - .pipe( - Effect.catch((error) => - Effect.logWarning( - "provider command reactor failed to generate worktree branch name; skipping rename", - { threadId: input.threadId, cwd, oldBranch, reason: error.message }, - ), - ), - Effect.flatMap((generated) => { - if (!generated) return Effect.void; - - const targetBranch = buildGeneratedWorktreeBranchName(generated.branch); - if (targetBranch === oldBranch) return Effect.void; - - return Effect.flatMap( - git.renameBranch({ cwd, oldBranch, newBranch: targetBranch }), - (renamed) => - orchestrationEngine.dispatch({ - type: "thread.meta.update", - commandId: serverCommandId("worktree-branch-rename"), - threadId: input.threadId, - branch: renamed.branch, - worktreePath: cwd, - }), - ); + yield* Effect.flatMap( + Effect.map( + serverSettingsService.getSettings, + (settings) => settings.textGenerationModelSelection, + ), + (modelSelection) => + textGeneration.generateBranchName({ + cwd, + message: input.messageText, + ...(attachments.length > 0 ? { attachments } : {}), + modelSelection, }), - Effect.catchCause((cause) => - Effect.logWarning( - "provider command reactor failed to generate or rename worktree branch", - { threadId: input.threadId, cwd, oldBranch, cause: Cause.pretty(cause) }, - ), + ).pipe( + Effect.catch((error) => + Effect.logWarning( + "provider command reactor failed to generate worktree branch name; skipping rename", + { threadId: input.threadId, cwd, oldBranch, reason: error.message }, ), - ); + ), + Effect.flatMap((generated) => { + if (!generated) return Effect.void; + + const targetBranch = buildGeneratedWorktreeBranchName(generated.branch); + if (targetBranch === oldBranch) return Effect.void; + + return Effect.flatMap( + git.renameBranch({ cwd, oldBranch, newBranch: targetBranch }), + (renamed) => + orchestrationEngine.dispatch({ + type: "thread.meta.update", + commandId: serverCommandId("worktree-branch-rename"), + threadId: input.threadId, + branch: renamed.branch, + worktreePath: cwd, + }), + ); + }), + Effect.catchCause((cause) => + Effect.logWarning("provider command reactor failed to generate or rename worktree branch", { + threadId: input.threadId, + cwd, + oldBranch, + cause: Cause.pretty(cause), + }), + ), + ); }); const processTurnStartRequested = Effect.fnUntraced(function* (