From 62f465e5bf76be246c5cdfe47e802326520ac2d3 Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Tue, 12 May 2026 16:22:51 -0400 Subject: [PATCH] Reduce PR refresh queued indicator noise Co-authored-by: Orca --- src/main/github/pr-refresh-coordinator.test.ts | 5 ++--- src/main/github/pr-refresh-coordinator.ts | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/github/pr-refresh-coordinator.test.ts b/src/main/github/pr-refresh-coordinator.test.ts index 72e86a6d66c..c457efdf660 100644 --- a/src/main/github/pr-refresh-coordinator.test.ts +++ b/src/main/github/pr-refresh-coordinator.test.ts @@ -78,7 +78,7 @@ describe('pr-refresh-coordinator', () => { vi.useRealTimers() }) - it('does not show a delayed visible follow-up as queued after a successful refresh', async () => { + it('does not show visible background refreshes as queued', async () => { const { reportVisiblePRRefreshCandidates } = await import('./pr-refresh-coordinator') getPRForBranchOutcomeMock.mockResolvedValueOnce({ kind: 'found', @@ -93,8 +93,7 @@ describe('pr-refresh-coordinator', () => { .map(([, event]) => event) .filter((event) => event.status === 'queued') - expect(queuedEvents).toHaveLength(1) - expect(queuedEvents[0].reason).toBe('visible') + expect(queuedEvents).toHaveLength(0) expect(getPRForBranchOutcomeMock).toHaveBeenCalledTimes(1) }) diff --git a/src/main/github/pr-refresh-coordinator.ts b/src/main/github/pr-refresh-coordinator.ts index e5bc9a3b059..a4ce93ceaff 100644 --- a/src/main/github/pr-refresh-coordinator.ts +++ b/src/main/github/pr-refresh-coordinator.ts @@ -127,7 +127,10 @@ function shouldSkipFresh( return Date.now() - candidate.cachedFetchedAt < refreshIntervalForCandidate(candidate) } -function shouldBroadcastQueued(dueAt: number): boolean { +function shouldBroadcastQueued(reason: GitHubPRRefreshReason, dueAt: number): boolean { + if (isBudgetedBackground(reason)) { + return false + } return dueAt - Date.now() <= 5_000 } @@ -399,9 +402,9 @@ export function enqueuePRRefresh( windowId }) } - // Why: freshness follow-ups can be scheduled minutes out. Only immediate - // queueing should surface in the card UI as pending work. - if (shouldBroadcastQueued(dueAt)) { + // Why: visible/SWR refreshes are background maintenance and may sit behind + // the budget queue. Only user/action-driven queueing should surface in UI. + if (shouldBroadcastQueued(reason, dueAt)) { broadcast({ aliases: [alias], reason, status: 'queued' }) } scheduleDrain()