Repository navigation
feat(pull-requests): act with the viewer's own GitHub login, never the host's - #8799
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
[Medium impact] The changes reach pull-request reads and actions across desktop and API. The PR appears safe to merge, with non-blocking fixes recommended for connection recovery, API compatibility, and diagnostics. FindingsFix with agent prompt### Issue 1
apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts:197-201
Without a local login or Superset GitHub connection, reads use the organization's GitHub App. If the repository is outside that installation, the API returns `NOT_FOUND`. This check excludes that error, so the page offers no “Connect GitHub” button even though the viewer's own account could grant access.
Check the viewer's connection state rather than relying only on the read error code.
### Issue 2
packages/trpc/src/router/integration/github/pull-request-procedures.ts:92-96
`mergePullRequest` previously returned `{ merged, sha, message }`. It now returns the shared result directly, which drops `message`. Current callers inspected here ignore it, but removing an existing field creates an unnecessary compatibility break for other client versions.
Keep `message` in the shared result so this refactor preserves the API's existing output.
### Issue 3
packages/shared/src/pull-request-github/pull-request-github.ts:92-95
The shared `threads` catch removes the API's existing warning and discards the error. Callers receive only `fetchFailed: true`, leaving no useful detail to distinguish permission failures, rate limits, or other GitHub failures.
Preserve the warning in the API wrapper or let the shared method pass the error to a logging callback.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThis PR moves desktop pull request calls to the viewer's local GitHub login, with the Superset connection as the other source. It shares the GitHub work between desktop and API callers.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Desktop pull request operation] --> B{Local GitHub login available?}
B -->|Yes| C[Main-process viewerGithub router]
B -->|No| D[Superset API]
C --> E[Shared pullRequestOnGithub]
D --> E
E --> F[GitHub]
F --> G[Return result or refusal]
Reviews (1) · Last reviewed commit: "feat(pull-requests): act with the viewer..." · Reviewed by Greptile |
| /** The person has no GitHub login here and no Superset connection; connecting fixes it. */ | ||
| export function needsGithubConnection(error: unknown): boolean { | ||
| const data = (error as { data?: { code?: unknown } } | null | undefined) | ||
| ?.data; | ||
| return data?.code === "PRECONDITION_FAILED"; |
There was a problem hiding this comment.
Without a local login or Superset GitHub connection, reads use the organization's GitHub App. If the repository is outside that installation, the API returns NOT_FOUND. This check excludes that error, so the page offers no “Connect GitHub” button even though the viewer's own account could grant access.
Check the viewer's connection state rather than relying only on the read error code.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
Line: 197-201
Comment:
**Connection button is missing**
Without a local login or Superset GitHub connection, reads use the organization's GitHub App. If the repository is outside that installation, the API returns `NOT_FOUND`. This check excludes that error, so the page offers no “Connect GitHub” button even though the viewer's own account could grant access.
Check the viewer's connection state rather than relying only on the read error code.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| return onGithub("GitHub refused the merge.", () => | ||
| pr.merge({ | ||
| mergeMethod: input.mergeMethod, | ||
| commitMessage: input.commitMessage, | ||
| }), |
There was a problem hiding this comment.
mergePullRequest previously returned { merged, sha, message }. It now returns the shared result directly, which drops message. Current callers inspected here ignore it, but removing an existing field creates an unnecessary compatibility break for other client versions.
Keep message in the shared result so this refactor preserves the API's existing output.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/trpc/src/router/integration/github/pull-request-procedures.ts
Line: 92-96
Comment:
**Merge response loses a field**
`mergePullRequest` previously returned `{ merged, sha, message }`. It now returns the shared result directly, which drops `message`. Current callers inspected here ignore it, but removing an existing field creates an unnecessary compatibility break for other client versions.
Keep `message` in the shared result so this refactor preserves the API's existing output.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| } catch { | ||
| // Empty rather than an error, so the diff still shows when only | ||
| // its comments failed. | ||
| return { reviewThreads: [], fetchFailed: true }; |
There was a problem hiding this comment.
Thread failures lose their cause
The shared threads catch removes the API's existing warning and discards the error. Callers receive only fetchFailed: true, leaving no useful detail to distinguish permission failures, rate limits, or other GitHub failures.
Preserve the warning in the API wrapper or let the shared method pass the error to a logging callback.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/shared/src/pull-request-github/pull-request-github.ts
Line: 92-95
Comment:
**Thread failures lose their cause**
The shared `threads` catch removes the API's existing warning and discards the error. Callers receive only `fetchFailed: true`, leaving no useful detail to distinguish permission failures, rate limits, or other GitHub failures.
Preserve the warning in the API wrapper or let the shared method pass the error to a logging callback.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.134d32f to
318a285
Compare
2f4becf to
1e367c2
Compare
318a285 to
23d82f5
Compare
1e367c2 to
7e10066
Compare
23d82f5 to
a300d30
Compare
7e10066 to
d5fe261
Compare
a300d30 to
487740d
Compare
d5fe261 to
209263d
Compare
487740d to
bc4cdb3
Compare
…e host's The desktop acts on pull requests with the GitHub login on the person's own machine, in the main process, or else through the API with their Superset connection; the workspace host is no longer in the path, and a refusal is never retried under another identity. The GitHub work lives once in @superset/shared/pull-request-github and both the API and the desktop run it. Without either login the pane offers to connect GitHub.
209263d to
ef193c3
Compare
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_TOKENis the creator's or the App's; a remote host'sghis whoever set it up).Desktop picks one source, once:
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.There's no retry across sources: a refusal from GitHub is final.
One implementation of the GitHub work.
@superset/shared/pull-request-githubholdspullRequestOnGithub(client, pr): detail read, threads, diff, comment, reply, resolve, merge, state, draft, update branch, dequeue. It also holdsgithubErrorCode. The API procedures and the desktop router are now thin wrappers around it.getPullRequestDiffkeeps its old error behaviour for released desktops.Deleted from the desktop:
firstAnswer/act/cloudCannotAct)fromHostPullRequestContentcombinePullRequestReadErrorsfetchPullRequestDetail/fetchPullRequestDiffcapabilities; this addsupdateto the shared read, an additive output field.PullRequestTargetis just{organizationId, repoFullName, prNumber}.projectId/hostId/hostUrlremain only for features that really run on a host (send to agent, start workspace, linked workspace).Behaviour changes
ghacting for them.Not in this PR
The workspace's diff-pane comment threads and annotations, the sidebar Review tab and
CommentsSectionstill use the host'sgit.*Thread*procedures (tagged deprecated in #8765). That's the next step.Test plan
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@octokit/coreand@superset/host-service/git-credentialsghlogged in: PR pane reads, comments and merges are attributed to you in a cloud workspace tooghlogged out and no connection: pane shows "Connect GitHub" → OAuth → pane loadsSummary 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, orgh), 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
ghacting for the viewer.capabilitiesinstead of the old "mergeability present ⇒ can write" guess; the shared read gains an additiveupdatefield.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.Written for commit ef193c3. Summary will update on new commits.