Skip to content

Commit ebd9879

Browse files
committed
fix(server): the branch recheck respects the inactivity scope
Under the without-pr scope a linked thread with a terminal pull request can never settle for inactivity, but the recheck prediction ignored the scope and refreshed the branch lookup on every sweep. Pass the scope in so the prediction matches the final decision.
1 parent 473cf23 commit ebd9879

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,48 @@ describe("ThreadSettlementServiceV2 worker", () => {
10191019
),
10201020
);
10211021

1022+
it.effect(
1023+
"skips the branch recheck for an inactive linked thread under the without-pr scope",
1024+
() =>
1025+
Effect.scoped(
1026+
Effect.gen(function* () {
1027+
yield* TestClock.setTime(Date.parse(NOW));
1028+
const fixture = yield* makeHarness({
1029+
snapshot: makeSnapshot([
1030+
makeThread("resumed-inactive", {
1031+
branch: "main",
1032+
linkedPullRequest: {
1033+
projectId: PROJECT_ID,
1034+
repository: "owner/repository",
1035+
number: 1,
1036+
url: "https://example.test/owner/repository/pull/1",
1037+
},
1038+
}),
1039+
]),
1040+
settings: {
1041+
...DEFAULT_SERVER_SETTINGS,
1042+
sidebarAutoSettleAfterDays: 2,
1043+
sidebarAutoSettleScope: "without-pr",
1044+
},
1045+
branchPullRequest: () => Effect.succeed(makeBranchPullRequest("open")),
1046+
// Merged before the user's last message, so the merge settles nothing.
1047+
pullRequestSummary: (input) =>
1048+
Effect.succeed({
1049+
...makePullRequestSummary({ ...input, state: "merged" }),
1050+
mergedAt: "2026-08-10T00:00:00.000Z",
1051+
}),
1052+
});
1053+
yield* Effect.gen(function* () {
1054+
const reactor = yield* ThreadSettlementService.ThreadSettlementServiceV2;
1055+
yield* startHarness(reactor, fixture.activation, fixture.snapshotReads);
1056+
assert.deepStrictEqual(yield* Ref.get(fixture.commands), []);
1057+
assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 1);
1058+
assert.deepStrictEqual(yield* Ref.get(fixture.branchCalls), []);
1059+
}).pipe(Effect.provide(fixture.layer));
1060+
}),
1061+
),
1062+
);
1063+
10221064
it.effect("reevaluates immediately after a pull request merge", () =>
10231065
Effect.scoped(
10241066
Effect.gen(function* () {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ export const make = Effect.gen(function* () {
464464
nowMs: DateTime.toEpochMillis(decisionNow),
465465
autoSettleAfterDays: settings.sidebarAutoSettleAfterDays,
466466
autoSettleOnMerge: settings.sidebarAutoSettleOnMerge,
467+
autoSettleScope: settings.sidebarAutoSettleScope,
467468
}) !== null
468469
);
469470
});

0 commit comments

Comments
 (0)