Files
orca/src/shared/github/pull-request-for-branch-outcome.ts
T
Brennan Benson cca9ed5a7a fix(github): make Checks refresh start a new PR read (#36651)
* fix(github): start explicit Checks refreshes after the action

* fix(github): give explicit Checks refreshes fresh checks and comments

The same Refresh or Link click that now reads PR metadata after the
action also reads checks and comments after it: an explicit request no
longer joins or waits on a read begun before the click, in the renderer
or (for checks) the host coalescer. A superseded read's callers show the
owner's answer, so a late pre-click reply cannot repaint the panel, and
comments posted during either read are kept.

A lost IPC/RPC reply is reported only to the click that asked; polls stay
silent as before, and a later answer clears a failure older than itself.
The manual hook takes its verdict from its own lookup, the link flow's
card-read failure no longer skips checks, and the web shim forwards the
intent.

* fix(github): land the older Checks reply when a newer explicit read fails

When a click's checks or comments read fails while the read it replaced
succeeds, the click's read now lands that older reply through its owner
path instead of leaving the cache behind it. Post-write comments
refreshes (mutation events, bulk resolve) carry the explicit intent so
they cannot be answered by a read begun before the write.

* test(github): drop type assertions from the explicit-refresh tests

The RPC tests call the handlers with a real runtime service and spies,
and the panel test passes typed fixtures straight to the hooks.

* test(github): type the Checks panel fixtures for the renderer project

The renderer tests build their PR fixture locally instead of importing a
main-process harness, and the panel setter mocks take the hooks'
SetStateAction form.
2026-10-31 11:10:38 -07:00

25 lines
831 B
TypeScript

import type { PRRefreshOutcome } from './pull-request-refresh-types'
import type { PRInfo } from './pull-request-types'
export type GitHubPRForBranchResponse = PRRefreshOutcome | PRInfo | null
// Legacy hosts return PRInfo|null; current hosts return a classified refresh outcome.
export function normalizeGitHubPRForBranchOutcome(
response: GitHubPRForBranchResponse,
fetchedAt = Date.now()
): PRRefreshOutcome {
if (response && typeof response === 'object' && 'kind' in response) {
return response
}
return response ? { kind: 'found', pr: response, fetchedAt } : { kind: 'no-pr', fetchedAt }
}
export function githubPRTransportFailureOutcome(): PRRefreshOutcome {
return {
kind: 'upstream-error',
errorType: 'unknown',
message: 'GitHub pull request refresh failed.',
fetchedAt: Date.now()
}
}