mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 01:27:35 +00:00
Refresh only actual on-screen review cards and the selected visible review panel, with a single metadata owner per execution host. Open reviews refresh every 60 seconds when selected and 120 seconds otherwise. Settled merged reviews stop automatic refresh; pending merged checks continue, hidden rows stop, and work changes or stale re-exposure discover fresh state. Remove the polling setting. Preserve provider/SSH/runtime ownership, mixed-version cache behavior, failure backoff, bounded foreground admission, request coalescing, and mutation invalidation. Cover older persisted caches and unknown HEADs. Validated with 1,628 focused tests, typechecking, lint/code-quality gates, hidden Electron viewport checks, and parallel Codex/Claude Opus 5.5 adversarial reviews. Measurements and policy details are in PR #25788. Fixes #25746 Co-authored-by: ggbdpq <ggbdpq@gmail.com>
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { invalidateReviewLookupsAfterPRMutation } from '../../pr-mutation-review-invalidation'
|
|
import type { GitHubPullRequestStateUpdate } from '../../../../shared/issue-mutation-types'
|
|
import {
|
|
ghExecFileAsync,
|
|
acquire,
|
|
release,
|
|
classifyPullRequestUpdateError,
|
|
type LocalGitExecOptions
|
|
} from '../../gh-utils'
|
|
import { resolveGitHubRepoExecution, type GitHubApiRepository } from '../../github-api-repository'
|
|
export async function updatePRState(
|
|
repoPath: string,
|
|
prNumber: number,
|
|
updates: GitHubPullRequestStateUpdate,
|
|
connectionId?: string | null,
|
|
prRepo?: GitHubApiRepository | null,
|
|
localGitOptions: LocalGitExecOptions = {}
|
|
): Promise<{ ok: true } | { ok: false; error: string }> {
|
|
const { ownerRepo, ghOptions } = await resolveGitHubRepoExecution(
|
|
repoPath,
|
|
prRepo,
|
|
connectionId,
|
|
localGitOptions
|
|
)
|
|
if (!ownerRepo) {
|
|
return { ok: false, error: 'Could not resolve GitHub owner/repo for this repository' }
|
|
}
|
|
|
|
await acquire()
|
|
try {
|
|
const cmd = updates.state === 'closed' ? 'close' : 'reopen'
|
|
// Why: gh's PR commands use GitHub's supported reopen flow; REST state PATCH can 422 on reopen.
|
|
await ghExecFileAsync(
|
|
['pr', cmd, String(prNumber), '--repo', `${ownerRepo.owner}/${ownerRepo.repo}`],
|
|
{
|
|
...ghOptions
|
|
}
|
|
)
|
|
invalidateReviewLookupsAfterPRMutation(repoPath, connectionId)
|
|
return { ok: true }
|
|
} catch (err) {
|
|
const message =
|
|
err instanceof Error ? err.message : typeof err === 'string' ? err : 'Unknown error'
|
|
return { ok: false, error: classifyPullRequestUpdateError(message).message }
|
|
} finally {
|
|
release()
|
|
}
|
|
}
|