feat(pull-requests): act as the viewer, by PR identity; chat PR badges open the pane
Summary
Chat PR badges open the PR pane. parseGithubWorkItemUrl renders …/pull/123/files, …#discussion_r… and www.github.com links as "PR #123" chips, but runUrlLinkAction only opened the pane for a bare URL, so those chips landed in a browser pane; and the chat consulted the "URL links" preference before noticing a PR at all (with 2-tier collapsing, no modifier could reach GitHub). New runChatPullRequestLink: plain click → PR pane (right pane when one exists), ⌘/Ctrl-click → GitHub. Terminal rule unchanged.
The PR pane acts as the signed-in user, by PR identity. The pane used to go host-first (gh pr view as whoever the box is — in a sandbox the workspace creator's token, or the App's) and needed a project with a matching repo for threads, comments, merge/close/draft.
packages/trpc— new additiveintegration.githubprocedures keyed on{organizationId, repoFullName, number}: one read,getPullRequestDetail(mergeability, checks, reviewers and the viewer's capabilities; withactivity: true, also the conversation, commits, labels and author the desktop page shows),getPullRequestThreads,addPullRequestComment,replyToPullRequestThread,setPullRequestThreadResolution,mergePullRequest,setPullRequestState,setPullRequestDraft. Reads use the viewer's token (githubUserTokenFor) with the App installation as fallback; writes require the viewer's token (PRECONDITION_FAILED"Connect GitHub in Settings…" otherwise).getPullRequestDiffprefers the viewer's token too; output unchanged. No existing procedure changed shape.@superset/shared— the host's PR detail read and the review-thread query moved here, so host-service and the API run one implementation;PullRequestActivitytypes added. The write procedures share oneasViewerhelper and onegithubRequestErrormapper.- Desktop —
pullRequestClientwith aPullRequestTarget; every read and write goes cloud-first and falls back to the host'sghonly when the cloud could not act at all (procedure missing on an older API, or no GitHub connection), never when GitHub itself refused. Pane, dashboard PR page, Code tab, actions, composer, draft toggle and comment card use it. Threads/comments/actions no longer require the workspace's project; only pages and "open in diff" stay linked-PR-only.
Notes for review
trpc-compat: additive only; the desktop degrades to the host when a procedure is missing, so one PR is safe, but the API deploy still lands before any client that benefits.- Open: whether to drop the host write fallback entirely (it still acts as the box for a viewer with no GitHub connection) in favour of a "Connect GitHub" prompt.
Mobile acts as the viewer too. The PR screen, merge and the card's actions (mark ready, update branch, reopen, dequeue) call the cloud instead of the workspace host's gh — so a PR loads even when the host is offline. The host's getPullRequestDetail read moved into @superset/shared/pull-request-detail (host re-uses it; the cloud also gained updatePullRequestBranch, dequeuePullRequest). No host fallback on mobile: a missing GitHub connection shows "Connect GitHub" (in-app browser to the App's OAuth, then re-read), NOT_FOUND/FORBIDDEN reads as "no access on GitHub", and Settings gets a Connections → GitHub row to connect/disconnect. WorkspaceScreen now hands the PR's own owner/repo to the route so it no longer depends on the host's project to resolve the repository. Still on the host: the PR list sheet's per-row diffstat and "ask an agent", which need the box.
Test plan
-
bun test— desktop 8604/8604, trpc 688/688, shared 1439/1439, host-service 2622 pass (1 pre-existing failure,health.check … sandbox mode, fails on a clean tree too) -
tsc --noEmitclean in trpc, shared, host-service, api, web; desktop clean in touched areas (remaining errors are the ungeneratedrouteTree.gen.ts) -
check:i18npasses with translations for the two new strings in all locales; biome, sherif clean - In the app with a connected GitHub account: open a PR pane for a PR outside the workspace's project, read threads, post a comment, toggle draft — attributed to the viewer
- Click a
…/pull/N/fileschip in chat → PR pane; ⌘-click → GitHub - Mobile:
bun test233/233;tschas 188 pre-existing errors on the clean tree's 190 (host-service type inference in this checkout), none in touched files - Mobile, in the simulator: open a PR with no GitHub connection → "Connect GitHub" → authorize → PR loads; merge/mark-ready attributed to the viewer; Settings → Connections shows the login
Summary by CodeRabbit
- New Features
- Pull-request details, comments, reviews, and actions—including merging and resolving review threads—can use your connected GitHub account across desktop and mobile, with host-based access available when applicable.
- Mobile Settings now includes GitHub connection controls. Prompts explain when connecting GitHub is needed to continue an action.
- Pull-request links opened from chat can navigate directly to the pull-request pane, including links from
www.github.com.
- Bug Fixes
- Improved pull-request access and loading errors, including clearer messages for missing access or unavailable pull requests.
- Review-thread comments can be displayed when conversation comments are unavailable.
Stack and cleanup path
Merge in order: #8765 → #8771 → #8799 → #8980. Each PR passes CI on its own. This one never reads through a host after GitHub refuses the viewer, so it's safe to deploy first.
After the stack lands, the PR viewer has:
- one GitHub implementation, in
@superset/shared/pull-request-github, run by the API and by the desktop main process - one client that picks the identity once: local login, then Superset connection, then a "Connect GitHub" prompt
- one threads cache across the PR pane, the diff pane and the Review tab
Cleanup, in order:
- Merge the twin thread components. The diff pane's
CommentThreadand the Code tab'sPullRequestCommentThreadare now the same component with injected actions. - Add a
PullRequestProvider. It replaces the ~30 threadedtarget/projectId/hostId/hostUrlprops in the PR page and pane. Only agent and workspace features need the host values. - Render the shared read directly. Remove
toPullRequestDetailand the desktopPullRequestDetailtype by renderingPullRequestDetailRead. - Inject the client into
useReviewThreadActions, so "resolve all refreshes once" gets a regression test without mocking modules. - Product decision: unconnected reads. Today someone with no local login and no connection can still read through the org's GitHub App. Decide whether to prompt for those too.
- Remove the deprecated host procedures (21 across
pullRequests.*,github.*,git.*Thread*, plus the cloudintegration.github.getPullRequest). Followtrpc-compatstep 4: wait until the oldest live desktop release includes #8980 and PostHog shows no calls for 30 days. Then delete them and the host code only they use (fetch-pull-request-content, the content cache,getDiff*).
Steps 1–4 are small refactors with no behaviour change. Step 5 needs a call. Step 6 is gated on usage evidence, not code.