mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
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:
@@ -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' }
|
||||
|
||||
@@ -37,9 +37,11 @@ export function registerGitHubHandlers(store: Store): void {
|
||||
|
||||
ipcMain.handle(
|
||||
'gh:prChecks',
|
||||
(_event, args: { repoPath: string; prNumber: number; branch?: string }) => {
|
||||
(_event, args: { repoPath: string; prNumber: number; branch?: string; noCache?: boolean }) => {
|
||||
const repoPath = assertRegisteredRepoPath(args.repoPath, store)
|
||||
return getPRChecks(repoPath, args.prNumber, args.branch)
|
||||
return getPRChecks(repoPath, args.prNumber, args.branch, {
|
||||
noCache: args.noCache
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Vendored
+1
@@ -71,6 +71,7 @@ type GhApi = {
|
||||
repoPath: string
|
||||
prNumber: number
|
||||
branch?: string
|
||||
noCache?: boolean
|
||||
}) => Promise<PRCheckDetail[]>
|
||||
updatePRTitle: (args: { repoPath: string; prNumber: number; title: string }) => Promise<boolean>
|
||||
mergePR: (args: {
|
||||
|
||||
@@ -186,8 +186,12 @@ const api = {
|
||||
listIssues: (args: { repoPath: string; limit?: number }): Promise<unknown[]> =>
|
||||
ipcRenderer.invoke('gh:listIssues', args),
|
||||
|
||||
prChecks: (args: { repoPath: string; prNumber: number; branch?: string }): Promise<unknown[]> =>
|
||||
ipcRenderer.invoke('gh:prChecks', args),
|
||||
prChecks: (args: {
|
||||
repoPath: string
|
||||
prNumber: number
|
||||
branch?: string
|
||||
noCache?: boolean
|
||||
}): Promise<unknown[]> => ipcRenderer.invoke('gh:prChecks', args),
|
||||
|
||||
updatePRTitle: (args: {
|
||||
repoPath: string
|
||||
|
||||
@@ -193,7 +193,8 @@ export const createGitHubSlice: StateCreator<AppState, [], [], GitHubSlice> = (s
|
||||
const checks = (await window.api.gh.prChecks({
|
||||
repoPath,
|
||||
prNumber,
|
||||
branch
|
||||
branch,
|
||||
noCache: options?.force
|
||||
})) as PRCheckDetail[]
|
||||
set((s) => {
|
||||
const nextState: Partial<AppState> = {
|
||||
|
||||
Reference in New Issue
Block a user