Skip to content

feat(pull-requests): act with the viewer's own GitHub login, never the host's - #8799

Merged
saddlepaddle merged 1 commit into
mainfrom
superset/pr-viewer-credentials
Oct 28, 2026
Merged

saddlepaddle merged 1 commit into
mainfrom
superset/pr-viewer-credentials

Conversation

@saddlepaddle

@saddlepaddle saddlepaddle commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

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:

  1. The GitHub login on this machine (GH_TOKEN, a git credential helper, or gh). The GitHub calls run in a new main-process router, viewerGithub, through LocalGitCredentialProvider, so the token never reaches the renderer. Browser-pane guests have no preload and can't reach it.
  2. Otherwise the API with their Superset GitHub connection.
  3. 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)
  • fromHostPullRequestContent
  • combinePullRequestReadErrors
  • fetchPullRequestDetail / fetchPullRequestDiff
  • the optional-everything detail type
  • the "mergeability present ⇒ can write" guess. Actions now gate on GitHub's per-viewer capabilities; this adds update to 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 gh acting 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)
  • tsc clean 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/core and @superset/host-service/git-credentials
  • In the app with gh logged in: PR pane reads, comments and merges are attributed to you in a cloud workspace too
  • In the app with gh logged 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 gh acting for the viewer.
  • A refusal from GitHub is final — nothing retries under another identity.
  • Actions gate on GitHub's per-viewer capabilities instead of the old "mergeability present ⇒ can write" guess; the shared read gains an additive update field.
  • 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 getPullRequestDiff keeps 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.

View guided diff Turn on auto-fix

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b82d870b-498e-4aa8-aa21-bd3e6230f2a7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[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.

Findings

  1. P2 Connection button is missing ▶
  2. P2 Merge response loses a field ▶
  3. P2 Thread failures lose their cause ▶
Fix 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.

Summary

This 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.

  • Desktop pull-request pages use the viewer’s GitHub login, not the host’s.
  • The desktop and API use one set of GitHub pull-request operations.
  • Pull-request controls follow the viewer’s GitHub permissions.

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]
Loading

Reviews (1) · Last reviewed commit: "feat(pull-requests): act with the viewer..." · Reviewed by Greptile

Comment on lines +197 to +201
/** 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";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

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.

Comment on lines +92 to +96
return onGithub("GitHub refused the merge.", () =>
pr.merge({
mergeMethod: input.mergeMethod,
commitMessage: input.commitMessage,
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

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.

Comment on lines +92 to +95
} catch {
// Empty rather than an error, so the diff still shows when only
// its comments failed.
return { reviewThreads: [], fetchFailed: true };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

@saddlepaddle
saddlepaddle force-pushed the superset/pr-cleanup-host-callers branch from 134d32f to 318a285 Compare October 27, 2026 22:26
@saddlepaddle
saddlepaddle force-pushed the superset/pr-viewer-credentials branch from 2f4becf to 1e367c2 Compare October 27, 2026 22:26
@saddlepaddle
saddlepaddle force-pushed the superset/pr-cleanup-host-callers branch from 318a285 to 23d82f5 Compare October 28, 2026 01:12
@saddlepaddle
saddlepaddle force-pushed the superset/pr-viewer-credentials branch from 1e367c2 to 7e10066 Compare October 28, 2026 01:12
@saddlepaddle
saddlepaddle force-pushed the superset/pr-cleanup-host-callers branch from 23d82f5 to a300d30 Compare October 28, 2026 02:51
@saddlepaddle
saddlepaddle force-pushed the superset/pr-viewer-credentials branch from 7e10066 to d5fe261 Compare October 28, 2026 02:51
@saddlepaddle
saddlepaddle force-pushed the superset/pr-cleanup-host-callers branch from a300d30 to 487740d Compare October 28, 2026 02:57
@saddlepaddle
saddlepaddle force-pushed the superset/pr-viewer-credentials branch from d5fe261 to 209263d Compare October 28, 2026 02:57
@saddlepaddle
saddlepaddle force-pushed the superset/pr-cleanup-host-callers branch from 487740d to bc4cdb3 Compare October 28, 2026 03:13
…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.
@saddlepaddle
saddlepaddle force-pushed the superset/pr-viewer-credentials branch from 209263d to ef193c3 Compare October 28, 2026 03:14
@saddlepaddle
saddlepaddle changed the base branch from superset/pr-cleanup-host-callers to main October 28, 2026 03:14
@saddlepaddle
saddlepaddle merged commit 0e6bc2c into main Oct 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant