Skip to content

Commit e68b33b

Browse files
committed
fix(server): skip merged merge queue removals in PR watches
GitHub records a removal with reason merged when the queue lands a pull request, up to a second before it reads as merged, which woke the agent with "removed from the merge queue without merging: merged".
1 parent 19fc016 commit e68b33b

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,16 @@ describe("evaluatePullRequestWatch", () => {
592592
);
593593
});
594594

595+
it("stays quiet when the queue lets go of a pull request by merging it", () => {
596+
const watching = evaluatePullRequestWatch(watch(), detail(), noRemarks).next;
597+
const merging = detail({
598+
mergeQueueRemoval: { id: "landed", removedAt: "2026-10-02T12:10:00Z", reason: "merged" },
599+
});
600+
const read = evaluatePullRequestWatch(watching, merging, noRemarks);
601+
assert.deepEqual(read.changes, []);
602+
assert.equal(read.next.mergeQueueRemovalId, "landed");
603+
});
604+
595605
it("does not spend the comment wake limit on check results", () => {
596606
const tired = watch({ headSha: "aaaaaaaaaa", wakes: PULL_REQUEST_WATCH_WAKE_LIMIT - 1 });
597607
const result = evaluatePullRequestWatch(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ export function evaluatePullRequestWatch(
199199
const removal = detail.mergeQueueRemoval;
200200
if (
201201
removal !== undefined &&
202+
// Merging also records a removal, up to a second before the pull request reads as merged.
203+
removal.reason !== "merged" &&
202204
removal.id !== watch.mergeQueueRemovalId &&
203205
(watch.mergeQueueRemovalId !== undefined ||
204206
Date.parse(removal.removedAt) >= Math.floor(Date.parse(watch.startedAt) / 1000) * 1000)

0 commit comments

Comments
 (0)