feat(pull-requests): read pull requests only as the viewer, never through the org's GitHub App

Merged
SA
1mo ago
+72-74

Summary

Pull request reads now act only as the viewer. Someone with no GitHub login on their machine and no Superset GitHub connection is asked to connect GitHub, instead of reading through the organization's GitHub App installation.

Why: an App installation has one rate-limit budget, shared by everything the org runs (syncs, sandbox clone tokens, webhooks). Every unconnected viewer polling a PR pane every 20–30 s would spend from it. A viewer's own token has its own limit.

  • asViewer requires the viewer's token for every PR procedure; the read/write split is gone.
  • getPullRequestDiff keeps the App fallback (asViewerOrInstallation). Released desktops already call it without a connection, and trpc-compat forbids stricter auth on an existing procedure.
  • Removed: the "App couldn't see it, so ask to connect" mapping (hiddenFromApp, readAs). With no App reads, there is nothing to map.
  • Clients are unchanged:
    • desktop (PR pane, Code tab, Review tab) shows a "Connect GitHub" button on PRECONDITION_FAILED
    • mobile's PR screen shows its connect view
    • the desktop's local gh path is unaffected

Compatibility: the tightened procedures (getPullRequestDetail, getPullRequestThreads, getPullRequestDiffstat, and the writes, which already required a connection) shipped in #8765/#8980. No released desktop or mobile build calls them yet; only Canary does.

Resolves step 5 of the cleanup path in #8765.

Test plan

  • new test: without a connection, a read is refused with "Connect GitHub" and the org's installation is never looked up
  • trpc 741, shared 1500, desktop 8826, mobile 239 all passing; tsc clean in trpc, shared, api; bun run lint exits 0; check:i18n reports no new strings
  • Canary: with gh logged out and no connection, the PR pane, the Review tab and mobile's PR screen show "Connect GitHub"

Summary by cubic

Pull request reads now require the viewer's own GitHub connection instead of falling back to the organization's GitHub App installation. A viewer with no connection is asked to connect GitHub, rather than reading through the App, whose rate limit is shared by everything the organization runs.

  • asViewer now demands the viewer's token for every pull request procedure; the read/write split is gone.
  • getPullRequestDiff keeps the App fallback (asViewerOrInstallation) because released desktops already call it without a connection.
  • Removed the hiddenFromApp/readAs mapping; no reads go through the App anymore.
  • Desktop and mobile clients are unchanged: both show their connect views on PRECONDITION_FAILED.
  • The tightened procedures already shipped; no released desktop or mobile build calls them yet, only Canary.

Resolves step 5 of the cleanup path in #8765.

Summary by CodeRabbit

  • GitHub Access
    • Pull request reads now use the requesting person’s GitHub connection. People without a personal connection are prompted to connect GitHub in Settings; the organization’s GitHub App is no longer presented as a fallback for these reads.
    • Pull request detail, diff, and thread requests now report access errors directly rather than converting certain errors into a connection prompt.