Reduce PR refresh queued indicator noise

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo-H
2026-05-14 02:49:16 -04:00
co-authored by Orca
parent 7612ee31ad
commit 62f465e5bf
2 changed files with 9 additions and 7 deletions
@@ -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)
})
+7 -4
View File
@@ -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()