fix(desktop): say checks are unavailable when GitHub refuses them

Merged
KI
10d ago
+145-13

What and why

Customer report (desktop 2.0.8): with a fine-grained GitHub PAT that can read a private repository's pull requests and contents, the pull request preview failed with a token-access error. gh could read the PR and its diff with the same token, but gh pr view <n> --json statusCheckRollup failed. Expected: show the description and diff, and say separately that checks are unavailable.

Root cause

The detail read (packages/shared/src/pull-request-detail) asks for statusCheckRollup, and fine-grained PATs cannot read check runs, so GitHub answers with FORBIDDEN errors under that path. In 2.0.8 Octokit threw on those errors and the whole preview failed.

#9656 (shipped in 2.0.9, after the reporter's build) fixed the failure: refusals under statusCheckRollup now use GitHub's partial data. The preview loads on main. But the refused checks are dropped without a trace, so the preview shows "No checks", the same as a pull request with no CI. This PR fixes that remaining part of the report.

Fix

  • readPullRequestDetail returns checksUnavailable: true when GitHub refused any part of statusCheckRollup (main query or a check page). Any other error still fails the read, as before.
  • Desktop: toPullRequestDetail carries the flag, and the PR info checks section shows "Checks unavailable" in place of "No checks" when it has no checks to list. One new string, translated in every locale (bun run check:i18n passes).

tRPC compatibility

checksUnavailable is a new optional field on PullRequestDetailRead. Nothing is renamed or removed. The API's integration.github.getPullRequestDetail, the host-service github.getPullRequestDetail, and the desktop viewerGithub.getPullRequestDetail return it as an additional field, and released desktop and mobile builds ignore it. A new desktop that reads an older API gets no field and treats it as false. Cached details without the field also read as false.

How tested

  • New test in pull-request-detail.test.ts simulates a fine-grained PAT refusal (FORBIDDEN, "Resource not accessible by personal access token", on a CheckRun node). It checks that the read succeeds, keeps the readable status context, and sets checksUnavailable. It also checks that an unrefused read returns false. The test fails on main (Expected: true, Received: undefined) and passes with the fix.
  • bun test in packages/shared (detail, github), desktop pull-requests and viewer-github: all pass.
  • Typecheck: packages/shared, packages/trpc, apps/desktop clean. Biome clean.

Not tested against a real fine-grained PAT or in the running app. The partial-data shape comes from the existing #9656 tests and GitHub's documented GraphQL behavior.


Summary by cubic

Shows "Checks unavailable" in the pull request preview when GitHub refuses access to status checks, instead of misreporting "No checks".

Fine-grained personal access tokens can't read check runs. Since #9656 the detail read tolerates those refusals and keeps the readable checks, but the preview silently dropped the refused ones and showed "No checks" — the same as a pull request with no CI. The detail read now returns checksUnavailable: true when GitHub refused any part of statusCheckRollup, and the desktop checks section displays "Checks unavailable" when there are no checks to list.

Compatibility

  • checksUnavailable is a new optional field on PullRequestDetailRead; nothing is renamed or removed.
  • Old desktop and mobile builds ignore the field. A new desktop reading an older API gets no field and treats it as false, as do cached details.

Summary by CodeRabbit

  • Bug Fixes
    • Pull request details now distinguish checks that are unavailable from pull requests with no checks. When some checks can’t be accessed, available checks remain visible and the empty state says “Checks unavailable” instead of “No checks.”
  • Documentation
    • The updated unavailable-check message is available in the supported app languages.