Skip to content

Commit db97824

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 edacb01 commit db97824

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
@@ -1039,6 +1039,48 @@ describe("ThreadSettlementServiceV2 worker", () => {
10391039
),
10401040
);
10411041

1042+
it.effect(
1043+
"skips the branch recheck for an inactive linked thread under the without-pr scope",
1044+
() =>
1045+
Effect.scoped(
1046+
Effect.gen(function* () {
1047+
yield* TestClock.setTime(Date.parse(NOW));
1048+
const fixture = yield* makeHarness({
1049+
snapshot: makeSnapshot([
1050+
makeThread("resumed-inactive", {
1051+
branch: "main",
1052+
linkedPullRequest: {
1053+
projectId: PROJECT_ID,
1054+
repository: "owner/repository",
1055+
number: 1,
1056+
url: "https://example.test/owner/repository/pull/1",
1057+
},
1058+
}),
1059+
]),
1060+
settings: {
1061+
...DEFAULT_SERVER_SETTINGS,
1062+
sidebarAutoSettleAfterDays: 2,
1063+
sidebarAutoSettleScope: "without-pr",
1064+
},
1065+
branchPullRequest: () => Effect.succeed(makeBranchPullRequest("open")),
1066+
// Merged before the user's last message, so the merge settles nothing.
1067+
pullRequestSummary: (input) =>
1068+
Effect.succeed({
1069+
...makePullRequestSummary({ ...input, state: "merged" }),
1070+
mergedAt: "2026-08-10T00:00:00.000Z",
1071+
}),
1072+
});
1073+
yield* Effect.gen(function* () {
1074+
const reactor = yield* ThreadSettlementService.ThreadSettlementServiceV2;
1075+
yield* startHarness(reactor, fixture.activation, fixture.snapshotReads);
1076+
assert.deepStrictEqual(yield* Ref.get(fixture.commands), []);
1077+
assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 1);
1078+
assert.deepStrictEqual(yield* Ref.get(fixture.branchCalls), []);
1079+
}).pipe(Effect.provide(fixture.layer));
1080+
}),
1081+
),
1082+
);
1083+
10421084
it.effect("reevaluates immediately after a pull request merge", () =>
10431085
Effect.scoped(
10441086
Effect.gen(function* () {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ export const make = Effect.gen(function* () {
470470
nowMs: DateTime.toEpochMillis(decisionNow),
471471
autoSettleAfterDays: settings.sidebarAutoSettleAfterDays,
472472
autoSettleOnMerge: settings.sidebarAutoSettleOnMerge,
473+
autoSettleScope: settings.sidebarAutoSettleScope,
473474
}) !== null
474475
);
475476
});

0 commit comments

Comments
 (0)