fix: bypass gh CLI HTTP cache on manual PR checks refresh (#308)

The `gh api --cache 60s` flag caused stale check-run data even when
the user explicitly clicked refresh. Thread a `noCache` flag through
IPC so manual refreshes skip the gh CLI cache while polling still
benefits from it.
This commit is contained in:
Jinjing
2026-04-05 11:26:32 -07:00
committed by GitHub
parent 8a8826b2d6
commit 3e51000bc5
5 changed files with 19 additions and 8 deletions
+6 -3
View File
@@ -120,18 +120,21 @@ export async function getPRForBranch(repoPath: string, branch: string): Promise<
export async function getPRChecks(
repoPath: string,
prNumber: number,
branch?: string
branch?: string,
options?: { noCache?: boolean }
): Promise<PRCheckDetail[]> {
const ownerRepo = branch ? await getOwnerRepo(repoPath) : null
await acquire()
try {
if (ownerRepo && branch) {
// Why: --cache 60s saves rate-limit budget during polling, but when the
// user explicitly clicks refresh we must skip it so gh fetches fresh data.
const cacheArgs = options?.noCache ? [] : ['--cache', '60s']
const { stdout } = await execFileAsync(
'gh',
[
'api',
'--cache',
'60s',
...cacheArgs,
`repos/${ownerRepo.owner}/${ownerRepo.repo}/commits/${encodeURIComponent(branch)}/check-runs?per_page=100`
],
{ cwd: repoPath, encoding: 'utf-8' }