Skip to content

Commit 0b03754

Browse files
yaacovcorcosclaude
andcommitted
fix(github): count only merge queue removals in the watch fingerprint
timelineItems totalCount ignores itemTypes and counts every timeline item: on a pull request with no removals it read 1, then 2 once the pull request was queued. The cheap watch poll therefore forced a full read on any timeline event. filteredCount honours the filter. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2cebedd commit 0b03754

4 files changed

Lines changed: 20 additions & 8 deletions

File tree

‎packages/source-control-github/src/server/gitHubPullRequestJson.test.ts‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,14 +1703,15 @@ describe("pull request watch fingerprints", () => {
17031703
readonly commentEditedAt: string | null;
17041704
readonly reviews: number;
17051705
readonly removals: number;
1706+
readonly timelineItems: number;
17061707
}) => ({
17071708
state: "OPEN",
17081709
mergeable: "MERGEABLE",
17091710
headRefOid: "abc123",
17101711
comments: { totalCount: 1, nodes: [{ lastEditedAt: input.commentEditedAt }] },
17111712
reviews: { totalCount: input.reviews, nodes: [] },
17121713
reviewThreads: { totalCount: 0 },
1713-
mergeQueueRemovals: { totalCount: input.removals },
1714+
mergeQueueRemovals: { totalCount: input.timelineItems, filteredCount: input.removals },
17141715
commits: {
17151716
nodes: [
17161717
{
@@ -1732,7 +1733,14 @@ describe("pull request watch fingerprints", () => {
17321733
});
17331734
const fingerprint = (input: Parameters<typeof pullRequest>[0]) =>
17341735
toPullRequestWatchFingerprint(decodeWatched(pullRequest(input)));
1735-
const base = { running: 2, failed: 0, commentEditedAt: null, reviews: 1, removals: 0 };
1736+
const base = {
1737+
running: 2,
1738+
failed: 0,
1739+
commentEditedAt: null,
1740+
reviews: 1,
1741+
removals: 0,
1742+
timelineItems: 3,
1743+
};
17361744
const before = fingerprint(base);
17371745
const checkFinished = fingerprint({ ...base, running: 1, failed: 1 });
17381746
const summaryEdited = fingerprint({ ...base, commentEditedAt: "2026-10-05T23:47:43Z" });
@@ -1744,8 +1752,11 @@ describe("pull request watch fingerprints", () => {
17441752
expect(summaryEdited.status).toBe(before.status);
17451753
expect(replied.remarks).not.toBe(before.remarks);
17461754
// Queued and dropped between two passes leaves the head and its checks as they were.
1747-
const dropped = fingerprint({ ...base, removals: 1 });
1755+
const dropped = fingerprint({ ...base, removals: 1, timelineItems: 5 });
17481756
expect(dropped.status).not.toBe(before.status);
17491757
expect(dropped.remarks).toBe(before.remarks);
1758+
// GitHub's totalCount counts every timeline item, whatever itemTypes asks for.
1759+
const queued = fingerprint({ ...base, timelineItems: 4 });
1760+
expect(queued.status).toBe(before.status);
17501761
});
17511762
});

‎packages/source-control-github/src/server/gitHubPullRequestJson.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ export function toPullRequestWatchFingerprint(
995995
pr.headRefOid,
996996
stateCounts(contexts?.checkRunCountsByState ?? null),
997997
stateCounts(contexts?.statusContextCountsByState ?? null),
998-
pr.mergeQueueRemovals?.totalCount ?? 0,
998+
pr.mergeQueueRemovals?.filteredCount ?? 0,
999999
].join(" "),
10001000
remarks: [
10011001
pr.comments.totalCount,

‎packages/source-control-github/src/server/pullRequestBatches.graphql‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,10 @@ query PullRequestWatchFingerprint(
110110
reviewThreads {
111111
totalCount
112112
}
113+
# totalCount ignores itemTypes and counts every timeline item; filteredCount honours it.
113114
mergeQueueRemovals: timelineItems(itemTypes: [REMOVED_FROM_MERGE_QUEUE_EVENT])
114115
@include(if: $mergeQueue) {
115-
totalCount
116+
filteredCount
116117
}
117118
commits(last: 1) {
118119
nodes {

‎packages/source-control-github/src/server/pullRequestBatches.graphql.ts‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)