Skip to content

Commit 856b01e

Browse files
committed
refactor(server): keep finalization refresh return void
1 parent 13d378e commit 856b01e

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ it.effect.each(["failure", "interruption", "stale-attempt", "start-guard"] as co
12881288
),
12891289
}),
12901290
Layer.succeed(RunFinalizationService.RunFinalizationObserver, {
1291-
refresh: () => Effect.succeed(null),
1291+
refresh: () => Effect.void,
12921292
refreshAfterTurn: () => Ref.update(refreshes, (count) => count + 1),
12931293
}),
12941294
),
@@ -3232,7 +3232,7 @@ function captureRootRunTermination(input: {
32323232
}),
32333233
ServerSettings.layerTest(),
32343234
Layer.succeed(RunFinalizationService.RunFinalizationObserver, {
3235-
refresh: () => Effect.succeed(null),
3235+
refresh: () => Effect.void,
32363236
refreshAfterTurn: () =>
32373237
Ref.update(observed, (current) => [...current, "pull-requests-refreshed"]).pipe(
32383238
Effect.andThen(input.refreshAfterTurn ?? Effect.void),

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ it.effect.each(
361361
Effect.gen(function* () {
362362
if (followBranch) yield* followBranch(scenario.checkedOut);
363363
followed.push(scenario.checkedOut);
364-
return scenario.checkedOut;
365364
}),
366365
refreshAfterTurn: () => Effect.void,
367366
}),

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ export class RunFinalizationRefreshError extends Schema.TaggedError<RunFinalizat
3131

3232
export class RunFinalizationObserver extends Context.Reference<{
3333
readonly refreshAfterTurn: (projectId: ProjectId) => Effect.Effect<void>;
34-
/** Resolves to the branch checked out in `cwd`, or null when detached. */
3534
readonly refresh: (input: {
3635
readonly cwd: string;
3736
readonly threadId: ThreadId;
3837
readonly runId: RunId;
3938
readonly followBranch?: (branch: string) => Effect.Effect<void>;
40-
}) => Effect.Effect<string | null, RunFinalizationRefreshError>;
39+
}) => Effect.Effect<void, RunFinalizationRefreshError>;
4140
}>("t3/orchestration-v2/RunFinalizationObserver", {
4241
defaultValue: () => ({
43-
refresh: () => Effect.succeed(null),
42+
refresh: () => Effect.void,
4443
refreshAfterTurn: () => Effect.void,
4544
}),
4645
}) {}
@@ -148,7 +147,7 @@ const make = Effect.gen(function* () {
148147
Effect.logWarning("Failed to refresh workspace after checkpoint capture", {
149148
...input,
150149
cause,
151-
}).pipe(Effect.as(null)),
150+
}),
152151
}),
153152
);
154153
}
@@ -174,12 +173,12 @@ export const layerObserver = Layer.effect(
174173
[workspaceEntries.refresh(cwd), vcsStatus.refreshLocalStatus(cwd)],
175174
{ concurrency: "unbounded" },
176175
);
177-
if (local.refName === null) return null;
176+
if (local.refName === null) return;
178177
if (followBranch) yield* followBranch(local.refName);
179-
if (local.isDefaultRef) return local.refName;
178+
if (local.isDefaultRef) return;
180179
const thread = yield* projections.getThreadShell(threadId);
181-
if (!thread || thread.branch !== local.refName) return local.refName;
182-
if (thread.activeRunId !== null && thread.activeRunId !== runId) return local.refName;
180+
if (!thread || thread.branch !== local.refName) return;
181+
if (thread.activeRunId !== null && thread.activeRunId !== runId) return;
183182
// The forge CLI can take minutes, so the next turn must not wait for it. A newer
184183
// turn's lookup replaces a running one instead of queueing behind the cwd's lock.
185184
yield* vcsStatus.refreshPullRequestStatus(cwd).pipe(
@@ -192,7 +191,6 @@ export const layerObserver = Layer.effect(
192191
),
193192
FiberMap.run(pullRequestLookups, cwd),
194193
);
195-
return local.refName;
196194
},
197195
(effect, { cwd }) =>
198196
effect.pipe(Effect.mapError((cause) => new RunFinalizationRefreshError({ cwd, cause }))),

0 commit comments

Comments
 (0)