feat(pull-requests): act with the viewer's own GitHub login, never the host's
Step 4 of the PR-pane cleanup. Stacked on #8771 (→ #8765).
Summary
Pull requests are acted on as the person looking, with credentials from their own machine — never the workspace host's (a cloud sandbox's GH_TOKEN is the creator's or the App's; a remote host's gh is whoever set it up).
Desktop picks one source, once:
- The GitHub login on this machine (
GH_TOKEN, a git credential helper, orgh). The GitHub calls run in a new main-process router,viewerGithub, throughLocalGitCredentialProvider, so the token never reaches the renderer. Browser-pane guests have no preload and can't reach it. - Otherwise the API with their Superset GitHub connection.
- Otherwise "Connect GitHub" in the pane's error state, which opens the OAuth.
There's no retry across sources: a refusal from GitHub is final.
One implementation of the GitHub work. @superset/shared/pull-request-github holds pullRequestOnGithub(client, pr): detail read, threads, diff, comment, reply, resolve, merge, state, draft, update branch, dequeue. It also holds githubErrorCode. The API procedures and the desktop router are now thin wrappers around it. getPullRequestDiff keeps its old error behaviour for released desktops.
Deleted from the desktop:
- the host fallback (
firstAnswer/act/cloudCannotAct) fromHostPullRequestContentcombinePullRequestReadErrorsfetchPullRequestDetail/fetchPullRequestDiff- the optional-everything detail type
- the "mergeability present ⇒ can write" guess. Actions now gate on GitHub's per-viewer
capabilities; this addsupdateto the shared read, an additive output field.
PullRequestTarget is just {organizationId, repoFullName, prNumber}. projectId/hostId/hostUrl remain only for features that really run on a host (send to agent, start workspace, linked workspace).
Behaviour changes
- Someone with no GitHub login on their machine and no Superset connection sees "Connect GitHub" instead of the box's
ghacting for them. - A legacy PR link that names only a project with no repository metadata can no longer be read; there's nothing to name the PR by on GitHub.
Not in this PR
The workspace's diff-pane comment threads and annotations, the sidebar Review tab and CommentsSection still use the host's git.*Thread* procedures (tagged deprecated in #8765). That's the next step.
Test plan
- tests: desktop 8601, shared 1446, trpc 686, host-service PR suites 460, mobile 233, all passing. New: shared GitHub module, the main-process router (no local login →
PRECONDITION_FAILED; GitHub refusal → its code), client source selection (local first, API otherwise, no retry) -
tscclean in trpc, shared, host-service, api, web; desktop and mobile have no errors in touched files (remaining errors are the ungenerated route tree / pre-existing) -
check:i18n,sherif - Packaged desktop build: main bundle resolves
@octokit/coreand@superset/host-service/git-credentials - In the app with
ghlogged in: PR pane reads, comments and merges are attributed to you in a cloud workspace too - In the app with
ghlogged out and no connection: pane shows "Connect GitHub" → OAuth → pane loads
Summary by cubic
Pull request views and actions now run as the person looking at them — with the GitHub login on their own machine or their Superset connection — never as the workspace host's. Desktop GitHub calls run in a new main-process router (viewerGithub) using the local login (GH_TOKEN, a git credential helper, or gh), with the token kept out of the renderer; otherwise the API acts with the viewer's Superset connection. All the GitHub work now lives once in @superset/shared/pull-request-github, shared by the API procedures and the desktop router.
Behavior changes
- Without a local login and a Superset connection, the pane shows "Connect GitHub" (OAuth) instead of the host's
ghacting for the viewer. - A refusal from GitHub is final — nothing retries under another identity.
- Actions gate on GitHub's per-viewer
capabilitiesinstead of the old "mergeability present ⇒ can write" guess; the shared read gains an additiveupdatefield. - A legacy PR link naming only a project can no longer be read, since there's no repository to name the PR by on GitHub.
- The API's
getPullRequestDiffkeeps its old error mapping so released desktops read failures as before.
Not in this PR: the workspace diff-pane threads and the sidebar Review tab still use the host's deprecated git.*Thread* procedures.