fix: threads with open PRs no longer auto-settle (#5151)

This commit is contained in:
Theo Browne authored and GitHub committed 2026-07-31 15:46:15 -07:00
1 parent e5c7547067
commit 491219bf1f
2 files changed
+31 -3

No files matched your search

@@ -115,13 +115,15 @@ describe("effectiveSettled", () => {
// Settled iff nothing blocks (pending work / live session) AND
// the override says settled, or (with no override) a merged PR
// or staleness auto-settles. The "active" pin suppresses both
// auto signals.
// auto signals, and an open PR suppresses the inactivity path:
// a thread with a PR out for review is never done, however quiet.
expected:
pending === undefined &&
!running &&
(settledOverride === "settled" ||
(settledOverride === null &&
(changeRequestState === "merged" || inactivity === "stale"))),
(changeRequestState === "merged" ||
(changeRequestState !== "open" && inactivity === "stale")))),
})),
),
),
@@ -176,6 +178,26 @@ describe("effectiveSettled", () => {
}
});
it("never auto-settles a stale thread with an open change request", () => {
const stale = makeShell({ activityAt: STALE });
expect(
effectiveSettled(stale, {
now: NOW,
autoSettleAfterDays: 3,
changeRequestState: "open",
}),
).toBe(false);
// An explicit user settle still wins: open PR only blocks the auto path.
const settled = makeShell({ settledOverride: "settled", activityAt: STALE });
expect(
effectiveSettled(settled, {
now: NOW,
autoSettleAfterDays: 3,
changeRequestState: "open",
}),
).toBe(true);
});
it("keeps an explicitly un-settled merged-PR thread active", () => {
const shell = makeShell({
settledOverride: "active",
@@ -222,7 +222,8 @@ export function threadWokeAt(
* override. Past the blockers, the explicit user override (thread.settle /
* thread.unsettle commands, projected into settledOverride + settledAt)
* wins in both directions; without one, a thread auto-settles on a
* merged/closed PR immediately or on inactivity past the window. The server
* merged/closed PR immediately or on inactivity past the window — except
* that an open PR blocks the inactivity path entirely. The server
* un-settles on real activity (user message, session start, approval/
* user-input request), so an override never goes stale silently.
*/
@@ -260,6 +261,11 @@ export function effectiveSettled(
if (options.changeRequestState === "merged" || options.changeRequestState === "closed") {
return true;
}
// An open PR is unfinished business regardless of how long the thread has
// been quiet: review can take days, and hiding the thread would bury the
// work waiting on it. Only merge/close (above) or an explicit user settle
// resolves it.
if (options.changeRequestState === "open") return false;
if (options.autoSettleAfterDays === null) return false;
const lastActivityAt = threadLastActivityAt(shell);