From 2b757be0f30e159aa5194b1652e56d77305670e9 Mon Sep 17 00:00:00 2001
From: Satya Patel <14907857+saddlepaddle@users.noreply.github.com>
Date: Thu, 22 Oct 2026 02:34:33 +0000
Subject: [PATCH 1/8] feat(pull-requests): act as the viewer and open chat PR
badges in the pane
Chat PR badges open the PR pane for any PR URL; cmd-click reaches GitHub.
The PR pane reads and writes pull requests through new cloud procedures
that use the viewer's GitHub token, keyed by repo and number instead of a
project; the host's gh is only the fallback when the cloud cannot act.
---
.../lib/github/pullRequestRef.test.ts | 27 ++
.../src/renderer/lib/github/pullRequestRef.ts | 4 +-
.../$prNumber/fixtures/checks.tsx | 11 +-
.../pull-requests/$prNumber/page.tsx | 24 +-
.../PullRequestActions/PullRequestActions.tsx | 99 +++--
.../buildPullRequestTimeline.test.ts | 4 +
.../PullRequestCodeTab/PullRequestCodeTab.tsx | 62 ++--
.../fetchPullRequestDiff.test.ts | 12 -
.../fetchPullRequestDiff.ts | 63 +---
.../fetchPullRequestDiff/fixtures/checks.ts | 203 -----------
.../PullRequestConversationComposer.tsx | 38 +-
.../usePullRequestDetail.ts | 75 ++--
.../fetchPullRequestDetail.test.ts | 12 -
.../fetchPullRequestDetail.ts | 46 +--
.../fetchPullRequestDetail/fixtures/checks.ts | 328 -----------------
.../usePullRequestDraftMutation.ts | 22 +-
.../hooks/usePullRequestThreads/index.ts | 1 +
.../usePullRequestThreads.ts | 23 ++
.../buildPullRequestRepairPrompts.test.ts | 3 +
.../combinePullRequestReadErrors.ts | 36 +-
.../combinePullRequestReadErrors/index.ts | 2 +-
.../utils/pullRequestClient/index.ts | 20 +
.../pullRequestClient.test.ts | 241 ++++++++++++
.../pullRequestClient/pullRequestClient.ts | 318 ++++++++++++++++
.../normalizeThreadsToComments.ts | 19 +-
.../hooks/useOpenChatLink/useOpenChatLink.ts | 3 +
.../PullRequestPane/PullRequestPane.tsx | 78 ++--
.../PullRequestCommentCard.test.tsx | 38 +-
.../PullRequestCommentCard.tsx | 26 +-
.../PullRequestPane/fixtures/checks.tsx | 18 +-
.../fixtures/checks.tsx | 36 +-
.../buildReviewThreadEntries.test.tsx | 7 +-
.../utils/runTerminalLinkAction/index.ts | 1 +
.../runTerminalLinkAction.test.ts | 45 +++
.../runTerminalLinkAction.ts | 82 +++--
bun.lock | 1 +
docs/cloud-sandbox-mismatches.md | 5 +-
.../pull-request-mappers.ts | 139 +------
.../src/trpc/router/git/utils/graphql.ts | 94 +----
packages/i18n/locales/cs/messages.po | 6 +
packages/i18n/locales/de/messages.po | 6 +
packages/i18n/locales/en/messages.po | 6 +
packages/i18n/locales/es/messages.po | 6 +
packages/i18n/locales/fr/messages.po | 6 +
packages/i18n/locales/id/messages.po | 6 +
packages/i18n/locales/it/messages.po | 6 +
packages/i18n/locales/ja/messages.po | 6 +
packages/i18n/locales/ko/messages.po | 6 +
packages/i18n/locales/nl/messages.po | 6 +
packages/i18n/locales/pl/messages.po | 6 +
packages/i18n/locales/pt-BR/messages.po | 6 +
packages/i18n/locales/ru/messages.po | 6 +
packages/i18n/locales/tr/messages.po | 6 +
packages/i18n/locales/vi/messages.po | 6 +
packages/i18n/locales/zh-CN/messages.po | 6 +
packages/i18n/locales/zh-TW/messages.po | 6 +
packages/i18n/src/server-errors.ts | 13 +
packages/shared/package.json | 8 +
.../shared/src/pull-request-checks/index.ts | 7 +
.../pull-request-checks.ts | 130 +++++++
.../shared/src/pull-request-threads/index.ts | 8 +
.../pull-request-threads.ts | 104 ++++++
packages/shared/src/pull-request.ts | 55 +++
packages/trpc/package.json | 1 +
.../github/get-pull-request-diff.ts | 15 +-
.../github/github-request-error.test.ts | 27 ++
.../github/github-request-error.ts | 58 +++
.../src/router/integration/github/github.ts | 2 +
.../github/pull-request-content.test.ts | 185 ++++++++++
.../github/pull-request-content.ts | 344 ++++++++++++++++++
.../github/pull-request-procedures.ts | 282 ++++++++++++++
.../integration/github/viewer-octokit.ts | 43 +++
72 files changed, 2478 insertions(+), 1172 deletions(-)
create mode 100644 apps/desktop/src/renderer/lib/github/pullRequestRef.test.ts
delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fetchPullRequestDiff.test.ts
delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fixtures/checks.ts
delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fetchPullRequestDetail.test.ts
delete mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fixtures/checks.ts
create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestThreads/index.ts
create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestThreads/usePullRequestThreads.ts
create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/index.ts
create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts
create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
create mode 100644 packages/shared/src/pull-request-checks/index.ts
create mode 100644 packages/shared/src/pull-request-checks/pull-request-checks.ts
create mode 100644 packages/shared/src/pull-request-threads/index.ts
create mode 100644 packages/shared/src/pull-request-threads/pull-request-threads.ts
create mode 100644 packages/trpc/src/router/integration/github/github-request-error.test.ts
create mode 100644 packages/trpc/src/router/integration/github/github-request-error.ts
create mode 100644 packages/trpc/src/router/integration/github/pull-request-content.test.ts
create mode 100644 packages/trpc/src/router/integration/github/pull-request-content.ts
create mode 100644 packages/trpc/src/router/integration/github/pull-request-procedures.ts
create mode 100644 packages/trpc/src/router/integration/github/viewer-octokit.ts
diff --git a/apps/desktop/src/renderer/lib/github/pullRequestRef.test.ts b/apps/desktop/src/renderer/lib/github/pullRequestRef.test.ts
new file mode 100644
index 00000000000..885fd61e43d
--- /dev/null
+++ b/apps/desktop/src/renderer/lib/github/pullRequestRef.test.ts
@@ -0,0 +1,27 @@
+import { describe, expect, it } from "bun:test";
+import {
+ pullRequestRefFromBareUrl,
+ pullRequestRefFromUrl,
+} from "./pullRequestRef";
+
+const REF = { repoFullName: "superset-sh/superset", number: 8412 };
+
+describe("pullRequestRefFromUrl", () => {
+ it("reads the same pull request with or without www", () => {
+ expect(
+ pullRequestRefFromUrl(
+ "https://www.github.com/superset-sh/superset/pull/8412",
+ ),
+ ).toEqual(REF);
+ expect(
+ pullRequestRefFromBareUrl(
+ "https://www.github.com/superset-sh/superset/pull/8412",
+ ),
+ ).toEqual(REF);
+ expect(
+ pullRequestRefFromUrl(
+ "https://github.com.evil.io/superset-sh/superset/pull/1",
+ ),
+ ).toBeNull();
+ });
+});
diff --git a/apps/desktop/src/renderer/lib/github/pullRequestRef.ts b/apps/desktop/src/renderer/lib/github/pullRequestRef.ts
index 30867d28e2f..ab45844d721 100644
--- a/apps/desktop/src/renderer/lib/github/pullRequestRef.ts
+++ b/apps/desktop/src/renderer/lib/github/pullRequestRef.ts
@@ -5,7 +5,7 @@ export interface PullRequestRef {
}
const PULL_REQUEST_URL =
- /^https:\/\/github\.com\/([^/?#]+\/[^/?#]+)\/pull\/(\d+)(?:[/?#]|$)/;
+ /^https:\/\/(?:www\.)?github\.com\/([^/?#]+\/[^/?#]+)\/pull\/(\d+)(?:[/?#]|$)/;
export function pullRequestRefFromUrl(url: string): PullRequestRef | null {
const match = PULL_REQUEST_URL.exec(url);
@@ -14,7 +14,7 @@ export function pullRequestRefFromUrl(url: string): PullRequestRef | null {
}
const BARE_PULL_REQUEST_URL =
- /^https:\/\/github\.com\/[^/?#]+\/[^/?#]+\/pull\/\d+\/?(?:\?[^#]*)?$/;
+ /^https:\/\/(?:www\.)?github\.com\/[^/?#]+\/[^/?#]+\/pull\/\d+\/?(?:\?[^#]*)?$/;
export function pullRequestRefFromBareUrl(url: string): PullRequestRef | null {
return BARE_PULL_REQUEST_URL.test(url) ? pullRequestRefFromUrl(url) : null;
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/$prNumber/fixtures/checks.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/$prNumber/fixtures/checks.tsx
index ca6301f3d6c..908aee5743e 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/$prNumber/fixtures/checks.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/$prNumber/fixtures/checks.tsx
@@ -43,9 +43,16 @@ mock.module(`${root}/components/PageHeader`, () => ({
mock.module(`${root}/pull-requests/components/PullRequestListToggle`, () => ({
PullRequestListToggle: () => null,
}));
+mock.module("renderer/hooks/useActiveOrganizationId", () => ({
+ useActiveOrganizationId: () => "org",
+}));
mock.module(`${root}/pull-requests/components/PullRequestActions`, () => ({
- PullRequestActions: ({ projectId }: { projectId: string | null }) => (
-
+ PullRequestActions: ({
+ target,
+ }: {
+ target: { host: { projectId: string | null } | null } | null;
+ }) => (
+
),
}));
mock.module(
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/$prNumber/page.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/$prNumber/page.tsx
index 05fafdf0149..0f96b9d83f9 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/$prNumber/page.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/$prNumber/page.tsx
@@ -1,6 +1,7 @@
import { createFileRoute } from "@tanstack/react-router";
import { useState } from "react";
import { useHostUrl } from "renderer/hooks/host-service/useHostTargetUrl";
+import { useActiveOrganizationId } from "renderer/hooks/useActiveOrganizationId";
import { PageHeader } from "renderer/routes/_authenticated/_dashboard/components/PageHeader";
import { useProjectHost } from "renderer/routes/_authenticated/_dashboard/hooks/useProjectHost";
import { PullRequestActions } from "renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestActions";
@@ -11,6 +12,10 @@ import {
} from "renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestDetailTabs";
import { PullRequestListToggle } from "renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestListToggle";
import { usePullRequestDetail } from "renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail";
+import {
+ canActOnPullRequest,
+ type PullRequestTarget,
+} from "renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient";
import { parsePositiveIntegerParam } from "renderer/routes/_authenticated/_dashboard/utils/parsePositiveIntegerParam";
import { Route as PullRequestsLayoutRoute } from "../layout";
@@ -27,6 +32,7 @@ function PullRequestDetailPage() {
const projectId = search.project ?? null;
const { hostId } = useProjectHost(projectId);
const hostUrl = useHostUrl(hostId);
+ const organizationId = useActiveOrganizationId();
const [tabChoice, setTabChoice] = useState<{
prNumber: number | null;
tab: PullRequestDetailTab;
@@ -46,12 +52,20 @@ function PullRequestDetailPage() {
data?.additions !== undefined && data.deletions !== undefined
? { additions: data.additions, deletions: data.deletions }
: null;
+ const target: PullRequestTarget | null =
+ prNumber === null
+ ? null
+ : {
+ organizationId,
+ repoFullName: detail.repoFullName,
+ prNumber,
+ host: hostUrl ? { hostUrl, projectId: detail.projectId } : null,
+ };
// A host that predates addComment/setDraft answers the content read without
// the extended fields; it would answer the writes with "No procedure found".
- const hostSupportsWrites = data?.mergeability !== undefined;
const commentTarget =
- hostSupportsWrites && detail.projectId && hostUrl && prNumber !== null
- ? { projectId: detail.projectId, hostUrl, prNumber }
+ target && canActOnPullRequest(target) && data?.mergeability !== undefined
+ ? target
: null;
// The list pane is always visible in the split view (or reachable via the
@@ -74,10 +88,8 @@ function PullRequestDetailPage() {
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestActions/PullRequestActions.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestActions/PullRequestActions.tsx
index 4319bd1daaf..79a042f1fcd 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestActions/PullRequestActions.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestActions/PullRequestActions.tsx
@@ -37,7 +37,6 @@ import {
import { type ReactNode, useState } from "react";
import { useCopyToClipboard } from "renderer/hooks/useCopyToClipboard";
import { useOpenNewWorkspace } from "renderer/hooks/useOpenNewWorkspace";
-import { getHostServiceClientByUrl } from "renderer/lib/host-service-client";
import { normalizePRState } from "renderer/screens/main/components/PRIcon";
import {
type LinkedPR,
@@ -53,6 +52,13 @@ import {
buildFixFindingsPrompt,
buildResolveConflictsPrompt,
} from "../../utils/buildPullRequestRepairPrompts";
+import {
+ canActOnPullRequest,
+ mergePullRequest,
+ type PullRequestMergeMethod,
+ type PullRequestTarget,
+ setPullRequestState,
+} from "../../utils/pullRequestClient";
import {
PullRequestMenuContent,
PullRequestMenuItem,
@@ -62,18 +68,17 @@ import {
} from "../PullRequestMenu";
import { PullRequestSkeleton as Skeleton } from "../PullRequestSkeleton";
-type MergeMethod = "merge" | "squash" | "rebase";
+type MergeMethod = PullRequestMergeMethod;
type PendingAction =
| { kind: "close" }
| { kind: "merge"; method: MergeMethod; force?: boolean };
interface PullRequestActionsProps {
- projectId: string | null;
+ /** Null when the route param is malformed. */
+ target: PullRequestTarget | null;
+ /** The host a workspace on this pull request would start on. */
hostId: string | null;
- hostUrl: string | null;
- /** Parsed PR number; null when the route param is malformed. */
- prNumber: number | null;
data: PullRequestDetail | null | undefined;
isLoading: boolean;
/**
@@ -115,15 +120,16 @@ function IconAction({
* confirmation. Identity (title, author, state) lives in PullRequestItemHeader.
*/
export function PullRequestActions({
- projectId,
+ target,
hostId,
- hostUrl,
- prNumber,
data,
isLoading,
showStartWorkspace = true,
}: PullRequestActionsProps) {
const { t } = useLingui();
+ const projectId = target?.host?.projectId ?? null;
+ const hostUrl = target?.host?.hostUrl ?? null;
+ const prNumber = target?.prNumber ?? null;
const mergeMethodLabels: Record = {
squash: t({ message: "Squash and merge" }),
merge: t({ message: "Merge commit" }),
@@ -146,35 +152,31 @@ export function PullRequestActions({
const [mergeComment, setMergeComment] = useState("");
const { copyToClipboard: copyLink, copied: linkCopied } =
useCopyToClipboard();
- const invalidatePullRequestQueries = useInvalidatePullRequestDetail({
- projectId,
- hostUrl,
- prNumber,
- });
+ const invalidatePullRequestQueries = useInvalidatePullRequestDetail(target);
const handoff = usePullRequestAgentHandoff(
projectId && hostId && hostUrl && prNumber !== null
? { projectId, hostId, hostUrl, prNumber }
: null,
);
- const setDraft = usePullRequestDraftMutation({
- projectId: projectId ?? "",
- hostUrl: hostUrl ?? "",
- prNumber: prNumber ?? 0,
- });
+ const setDraft = usePullRequestDraftMutation(
+ target ?? {
+ organizationId: null,
+ repoFullName: null,
+ prNumber: 0,
+ host: null,
+ },
+ );
- const setPullRequestState = useMutation({
+ const setState = useMutation({
mutationFn: async (nextState: "open" | "closed") => {
- if (!hostUrl || !projectId || prNumber === null) {
+ if (!target || !canActOnPullRequest(target)) {
throw new Error(
- t({ message: "This project isn't linked to a GitHub repository." }),
+ t({
+ message: "This pull request has no GitHub access to act through.",
+ }),
);
}
- const client = getHostServiceClientByUrl(hostUrl);
- return client.pullRequests.setState.mutate({
- projectId,
- prNumber,
- state: nextState,
- });
+ return setPullRequestState(target, nextState);
},
onSuccess: invalidatePullRequestQueries,
onError: (mutationError) => {
@@ -184,26 +186,19 @@ export function PullRequestActions({
},
});
- const mergePullRequest = useMutation({
- mutationFn: async ({
- mergeMethod,
- commitMessage,
- }: {
+ const merge = useMutation({
+ mutationFn: async (merge: {
mergeMethod: MergeMethod;
commitMessage?: string;
}) => {
- if (!hostUrl || !projectId || prNumber === null) {
+ if (!target || !canActOnPullRequest(target)) {
throw new Error(
- t({ message: "This project isn't linked to a GitHub repository." }),
+ t({
+ message: "This pull request has no GitHub access to act through.",
+ }),
);
}
- const client = getHostServiceClientByUrl(hostUrl);
- return client.pullRequests.mergePR.mutate({
- projectId,
- prNumber,
- mergeMethod,
- commitMessage,
- });
+ return mergePullRequest(target, merge);
},
onSuccess: invalidatePullRequestQueries,
onError: (mutationError) => {
@@ -214,16 +209,14 @@ export function PullRequestActions({
});
const isActionPending =
- setPullRequestState.isPending ||
- mergePullRequest.isPending ||
- setDraft.isPending;
+ setState.isPending || merge.isPending || setDraft.isPending;
const handleConfirmAction = () => {
if (!pendingAction) return;
if (pendingAction.kind === "close") {
- setPullRequestState.mutate("closed");
+ setState.mutate("closed");
} else {
- mergePullRequest.mutate({
+ merge.mutate({
mergeMethod: pendingAction.method,
commitMessage: mergeComment.trim() || undefined,
});
@@ -284,7 +277,7 @@ export function PullRequestActions({
if (!data) return null;
const canMerge = data.state === "open" && !data.isDraft;
- const canAct = !!hostUrl && !!projectId && prNumber !== null;
+ const canAct = target !== null && canActOnPullRequest(target);
const canToggleDraft = canAct && data.mergeability !== undefined;
const isDraft = data.state === "open" && data.isDraft;
const mergeBlocked = data.mergeability === "conflicting";
@@ -362,19 +355,19 @@ export function PullRequestActions({
)}
disabled={isActionPending}
aria-disabled={mergeBlocked || undefined}
- aria-busy={mergePullRequest.isPending}
+ aria-busy={merge.isPending}
onClick={() => {
if (mergeBlocked) return;
setPendingAction({ kind: "merge", method: "squash" });
}}
>
- {mergePullRequest.isPending ? (
+ {merge.isPending ? (
) : (
)}
- {mergePullRequest.isPending ? (
+ {merge.isPending ? (
Merging…
) : (
Merge
@@ -533,9 +526,9 @@ export function PullRequestActions({
size="xs"
className="ml-1 h-7 rounded-full px-3"
disabled={isActionPending}
- onClick={() => setPullRequestState.mutate("open")}
+ onClick={() => setState.mutate("open")}
>
- {setPullRequestState.isPending ? (
+ {setState.isPending ? (
Reopening…
) : (
Reopen
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestActivity/utils/buildPullRequestTimeline/buildPullRequestTimeline.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestActivity/utils/buildPullRequestTimeline/buildPullRequestTimeline.test.ts
index a7c2a016819..2b6be962413 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestActivity/utils/buildPullRequestTimeline/buildPullRequestTimeline.test.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestActivity/utils/buildPullRequestTimeline/buildPullRequestTimeline.test.ts
@@ -17,6 +17,7 @@ function comment(
body: `Body ${id}`,
createdAt,
reviewState: null,
+ url: null,
...overrides,
};
}
@@ -94,16 +95,19 @@ describe("the activity timeline", () => {
kind: "review",
body: " ",
reviewState: "approved",
+ url: null,
}),
comment("batch", "2026-10-03T10:01:00Z", {
kind: "review",
body: "",
reviewState: "COMMENTED",
+ url: null,
}),
comment("noted", "2026-10-03T10:02:00Z", {
kind: "review",
body: "Looks good",
reviewState: "APPROVED",
+ url: null,
}),
comment("blank", "2026-10-03T10:03:00Z", { body: "" }),
],
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/PullRequestCodeTab.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/PullRequestCodeTab.tsx
index 54708c65ffc..f712e512e24 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/PullRequestCodeTab.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/PullRequestCodeTab.tsx
@@ -37,7 +37,14 @@ import { DiffFileHeaderName } from "renderer/screens/main/components/DiffFileHea
import { DiffViewToolbar } from "renderer/screens/main/components/DiffViewToolbar";
import { ResizablePanel } from "renderer/screens/main/components/ResizablePanel";
import { useWorkspaceCreates } from "renderer/stores/workspace-creates/useWorkspaceCreates";
+import { usePullRequestThreads } from "../../hooks/usePullRequestThreads";
import { pullRequestReadErrorMessage } from "../../utils/combinePullRequestReadErrors";
+import {
+ type PullRequestTarget,
+ pullRequestThreadsQueryKey,
+ replyToPullRequestThread,
+ setPullRequestThreadResolution,
+} from "../../utils/pullRequestClient";
import { PullRequestCommentComposer } from "./components/PullRequestCommentComposer";
import { PullRequestCommentThread } from "./components/PullRequestCommentThread";
import { fetchPullRequestDiff } from "./utils/fetchPullRequestDiff";
@@ -290,6 +297,15 @@ export function PullRequestCodeTab({
const repoFullName = pullRequestRefFromUrl(prUrl)?.repoFullName ?? null;
const canUseProject = !!projectId && !!hostUrl;
const isTabVisible = useIsTabVisible();
+ const target = useMemo(
+ () => ({
+ organizationId,
+ repoFullName,
+ prNumber,
+ host: hostUrl ? { hostUrl, projectId } : null,
+ }),
+ [organizationId, repoFullName, prNumber, hostUrl, projectId],
+ );
const { data, isLoading, error, refetch } = useQuery({
queryKey: [
@@ -313,31 +329,9 @@ export function PullRequestCodeTab({
gcTime: 10 * 60_000,
});
- const threadsQueryKey = [
- "pull-request-threads",
- projectId,
- hostUrl,
- prNumber,
- ];
- const { data: threadsData, dataUpdatedAt: threadsUpdatedAt } = useQuery({
- queryKey: threadsQueryKey,
- enabled: canUseProject && isTabVisible,
- queryFn: async () => {
- if (!projectId) return { reviewThreads: [], fetchFailed: false };
- const client = getHostServiceClientByUrl(hostUrl);
- return client.pullRequests.getThreads.query({ projectId, prNumber });
- },
- staleTime: 30_000,
- gcTime: 10 * 60_000,
- // This tab and a workspace DiffPane for the same PR read threads
- // through two different tRPC clients with two separate caches, so
- // resolving/replying in one doesn't invalidate the other. DiffPane's
- // own threads query already self-heals via a 30s refetchInterval
- // (see useDiffAnnotations) rather than relying on cross-cache
- // invalidation — matching that here keeps the two surfaces from
- // drifting for longer than DiffPane already tolerates.
- refetchInterval: 30_000,
- });
+ const threadsQueryKey = pullRequestThreadsQueryKey(target);
+ const { data: threadsData, dataUpdatedAt: threadsUpdatedAt } =
+ usePullRequestThreads(target, { enabled: isTabVisible });
// getThreads degrades a GraphQL failure to an empty list rather than
// throwing (so a comments-fetch failure doesn't block the diff view
// itself) — fetchFailed is how it tells that apart from a PR that
@@ -373,10 +367,8 @@ export function PullRequestCodeTab({
ReadonlySet
>(new Set());
const setThreadResolution = useMutation({
- mutationFn: async (input: { threadId: string; resolved: boolean }) => {
- const client = getHostServiceClientByUrl(hostUrl);
- return client.pullRequests.setThreadResolution.mutate(input);
- },
+ mutationFn: (input: { threadId: string; resolved: boolean }) =>
+ setPullRequestThreadResolution(target, input),
onMutate: (input) => {
setPendingResolveThreadIds((prev) => new Set(prev).add(input.threadId));
},
@@ -405,16 +397,8 @@ export function PullRequestCodeTab({
ReadonlySet
>(new Set());
const replyToThread = useMutation({
- mutationFn: async (input: { commentId: number; body: string }) => {
- if (!projectId)
- throw new Error("No project available to reply to a thread");
- const client = getHostServiceClientByUrl(hostUrl);
- return client.pullRequests.replyToThread.mutate({
- projectId,
- prNumber,
- ...input,
- });
- },
+ mutationFn: (input: { commentId: number; body: string }) =>
+ replyToPullRequestThread(target, input),
onMutate: (input) => {
setPendingReplyCommentIds((prev) => new Set(prev).add(input.commentId));
},
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fetchPullRequestDiff.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fetchPullRequestDiff.test.ts
deleted file mode 100644
index cbb342139de..00000000000
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fetchPullRequestDiff.test.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { expect, test } from "bun:test";
-
-test("pull request diff routing with isolated module mocks", () => {
- const result = Bun.spawnSync({
- cmd: [process.execPath, "test", `${import.meta.dir}/fixtures/checks.ts`],
- env: { ...process.env, NODE_ENV: "test" },
- });
- expect(
- result.exitCode,
- result.stdout.toString() + result.stderr.toString(),
- ).toBe(0);
-});
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fetchPullRequestDiff.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fetchPullRequestDiff.ts
index 46f17d57768..f76129f683d 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fetchPullRequestDiff.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fetchPullRequestDiff.ts
@@ -1,56 +1,23 @@
import type { PullRequestDiff } from "@superset/shared/pull-request-diff";
-import { cloudTrpcClient } from "renderer/lib/cloud-trpc";
-import { getHostServiceClientByUrl } from "renderer/lib/host-service-client";
-import { combinePullRequestReadErrors } from "../../../../utils/combinePullRequestReadErrors";
+import { readPullRequestDiff } from "../../../../utils/pullRequestClient";
-interface PullRequestDiffInput {
- projectId: string | null;
- hostUrl: string | null;
- repoFullName: string | null;
- prNumber: number;
- organizationId: string | null;
-}
-
-export async function fetchPullRequestDiff({
+export function fetchPullRequestDiff({
projectId,
hostUrl,
repoFullName,
prNumber,
organizationId,
-}: PullRequestDiffInput): Promise {
- let repositoryError: unknown;
- if (hostUrl) {
- if (projectId) {
- try {
- const client = getHostServiceClientByUrl(hostUrl);
- return await client.pullRequests.getDiff.query({ projectId, prNumber });
- } catch (error) {
- if (!repoFullName) throw error;
- }
- }
- if (repoFullName) {
- try {
- const client = getHostServiceClientByUrl(hostUrl);
- return await client.pullRequests.getDiffByRepo.query({
- repoFullName,
- prNumber,
- });
- } catch (error) {
- if (!organizationId) throw error;
- repositoryError = error;
- }
- }
- }
- if (!organizationId || !repoFullName) {
- throw new Error("No GitHub repository available to fetch the diff");
- }
- try {
- return await cloudTrpcClient.integration.github.getPullRequestDiff.query({
- organizationId,
- repoFullName,
- number: prNumber,
- });
- } catch (error) {
- throw combinePullRequestReadErrors(repositoryError, error);
- }
+}: {
+ projectId: string | null;
+ hostUrl: string | null;
+ repoFullName: string | null;
+ prNumber: number;
+ organizationId: string | null;
+}): Promise {
+ return readPullRequestDiff({
+ organizationId,
+ repoFullName,
+ prNumber,
+ host: hostUrl ? { hostUrl, projectId } : null,
+ });
}
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fixtures/checks.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fixtures/checks.ts
deleted file mode 100644
index 2d885eb717b..00000000000
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestCodeTab/utils/fetchPullRequestDiff/fixtures/checks.ts
+++ /dev/null
@@ -1,203 +0,0 @@
-import { beforeEach, describe, expect, mock, test } from "bun:test";
-
-const getDiff = mock(async (_input: unknown) => ({ patch: "project diff" }));
-const getDiffByRepo = mock(async (_input: unknown) => ({ patch: "repo diff" }));
-const getPullRequestDiff = mock(async (_input: unknown) => ({
- patch: "api diff",
-}));
-
-mock.module("renderer/lib/host-service-client", () => ({
- getHostServiceClientByUrl: () => ({
- pullRequests: {
- getDiff: { query: getDiff },
- getDiffByRepo: { query: getDiffByRepo },
- },
- }),
-}));
-mock.module("renderer/lib/cloud-trpc", () => ({
- cloudTrpcClient: {
- integration: {
- github: { getPullRequestDiff: { query: getPullRequestDiff } },
- },
- },
-}));
-
-const { fetchPullRequestDiff } = await import("../fetchPullRequestDiff");
-
-const input = {
- projectId: null,
- hostUrl: "http://host.test",
- repoFullName: "other/repo",
- prNumber: 12,
- organizationId: "org",
-};
-
-beforeEach(() => {
- getDiff.mockReset().mockResolvedValue({ patch: "project diff" });
- getDiffByRepo.mockReset().mockResolvedValue({ patch: "repo diff" });
- getPullRequestDiff.mockReset().mockResolvedValue({ patch: "api diff" });
-});
-
-describe("fetchPullRequestDiff", () => {
- test("uses the PR repository when the workspace project does not match", async () => {
- expect(await fetchPullRequestDiff(input)).toEqual({ patch: "repo diff" });
- expect(getDiffByRepo).toHaveBeenCalledWith({
- repoFullName: "other/repo",
- prNumber: 12,
- });
- expect(getDiff).not.toHaveBeenCalled();
- expect(getPullRequestDiff).not.toHaveBeenCalled();
- });
-
- test("keeps the legacy endpoint for matching projects on older hosts", async () => {
- expect(
- await fetchPullRequestDiff({ ...input, projectId: "project" }),
- ).toEqual({
- patch: "project diff",
- });
- expect(getDiff).toHaveBeenCalledWith({
- projectId: "project",
- prNumber: 12,
- });
- expect(getDiffByRepo).not.toHaveBeenCalled();
- expect(getPullRequestDiff).not.toHaveBeenCalled();
- });
-
- test("falls back when an older host does not expose the new procedure", async () => {
- getDiffByRepo.mockRejectedValue(new Error("No procedure found"));
- expect(await fetchPullRequestDiff(input)).toEqual({ patch: "api diff" });
- expect(getPullRequestDiff).toHaveBeenCalledWith({
- organizationId: "org",
- repoFullName: "other/repo",
- number: 12,
- });
- });
-
- test("fetches from the API when no host is available", async () => {
- expect(await fetchPullRequestDiff({ ...input, hostUrl: null })).toEqual({
- patch: "api diff",
- });
- expect(getDiffByRepo).not.toHaveBeenCalled();
- });
-
- test("falls back when the matching project's host is unreachable", async () => {
- getDiff.mockRejectedValue(new Error("Host offline"));
- getDiffByRepo.mockRejectedValue(new Error("Host offline"));
- expect(
- await fetchPullRequestDiff({ ...input, projectId: "project" }),
- ).toEqual({
- patch: "api diff",
- });
- });
-
- test("does not require the GitHub App when gh succeeds", async () => {
- expect(
- await fetchPullRequestDiff({ ...input, organizationId: null }),
- ).toEqual({
- patch: "repo diff",
- });
- expect(getPullRequestDiff).not.toHaveBeenCalled();
- });
-
- test("surfaces a failed fallback instead of showing an empty diff", async () => {
- getDiffByRepo.mockRejectedValue(new Error("Host offline"));
- getPullRequestDiff.mockRejectedValue(new Error("Repository access denied"));
- await expect(fetchPullRequestDiff(input)).rejects.toThrow(
- "Repository access denied",
- );
- });
-});
-
-test("tries repository gh after project lookup fails, without requiring the API", async () => {
- getDiff.mockRejectedValue(new Error("Project not set up"));
- expect(
- await fetchPullRequestDiff({
- ...input,
- projectId: "project",
- organizationId: null,
- }),
- ).toEqual({ patch: "repo diff" });
- expect(getDiff).toHaveBeenCalledTimes(1);
- expect(getDiffByRepo).toHaveBeenCalledTimes(1);
- expect(getPullRequestDiff).not.toHaveBeenCalled();
-});
-test("an empty legacy diff is success, not a reason to fall back", async () => {
- getDiff.mockResolvedValue({ patch: "" });
- expect(
- await fetchPullRequestDiff({ ...input, projectId: "project" }),
- ).toEqual({ patch: "" });
- expect(getDiffByRepo).not.toHaveBeenCalled();
- expect(getPullRequestDiff).not.toHaveBeenCalled();
-});
-test("legacy project-only requests work without repository metadata or an organization", async () => {
- expect(
- await fetchPullRequestDiff({
- ...input,
- projectId: "project",
- repoFullName: null,
- organizationId: null,
- }),
- ).toEqual({ patch: "project diff" });
- expect(getDiffByRepo).not.toHaveBeenCalled();
- expect(getPullRequestDiff).not.toHaveBeenCalled();
-});
-test("keeps the project error when no repository fallback is possible", async () => {
- const error = new Error("Project missing");
- getDiff.mockRejectedValue(error);
- await expect(
- fetchPullRequestDiff({
- ...input,
- projectId: "project",
- repoFullName: null,
- }),
- ).rejects.toBe(error);
- expect(getDiffByRepo).not.toHaveBeenCalled();
- expect(getPullRequestDiff).not.toHaveBeenCalled();
-});
-test("keeps the repository error when the organization is unavailable", async () => {
- const error = new Error("gh denied");
- getDiffByRepo.mockRejectedValue(error);
- await expect(
- fetchPullRequestDiff({ ...input, organizationId: null }),
- ).rejects.toBe(error);
- expect(getPullRequestDiff).not.toHaveBeenCalled();
-});
-test("rejects missing fallback identity without issuing an API request", async () => {
- for (const missing of [{ organizationId: null }, { repoFullName: null }]) {
- await expect(
- fetchPullRequestDiff({ ...input, hostUrl: null, ...missing }),
- ).rejects.toThrow("No GitHub repository");
- }
- expect(getPullRequestDiff).not.toHaveBeenCalled();
-});
-
-test("retains the repository gh failure when the cloud fallback also fails", async () => {
- const hostError = new Error("gh: diff exceeds the maximum number of lines");
- const cloudError = new Error("Not Found - installation access token");
- getDiffByRepo.mockRejectedValueOnce(hostError);
- getPullRequestDiff.mockRejectedValueOnce(cloudError);
- await expect(fetchPullRequestDiff(input)).rejects.toMatchObject({
- name: "AggregateError",
- message: `${hostError.message}\n${cloudError.message}`,
- errors: [hostError, cloudError],
- });
-});
-
-test("preserves the original cloud error when an older host lacks the endpoint", async () => {
- const hostError = Object.assign(new Error("Unsupported procedure"), {
- data: { code: "NOT_FOUND" },
- });
- const cloudError = new Error("Repository access denied");
- getDiffByRepo.mockRejectedValueOnce(hostError);
- getPullRequestDiff.mockRejectedValueOnce(cloudError);
- await expect(fetchPullRequestDiff(input)).rejects.toBe(cloudError);
-});
-
-test("preserves the original cloud error when no host was tried", async () => {
- const cloudError = new Error("Repository access denied");
- getPullRequestDiff.mockRejectedValueOnce(cloudError);
- await expect(fetchPullRequestDiff({ ...input, hostUrl: null })).rejects.toBe(
- cloudError,
- );
- expect(getDiffByRepo).not.toHaveBeenCalled();
-});
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestConversationComposer/PullRequestConversationComposer.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestConversationComposer/PullRequestConversationComposer.tsx
index 9a4e331c2d4..e702df1b88c 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestConversationComposer/PullRequestConversationComposer.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestConversationComposer/PullRequestConversationComposer.tsx
@@ -5,16 +5,16 @@ import { useMutation } from "@tanstack/react-query";
import { ArrowUp, X } from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { FaGithub } from "react-icons/fa";
-import { getHostServiceClientByUrl } from "renderer/lib/host-service-client";
import { useInvalidatePullRequestDetail } from "../../hooks/usePullRequestDetail";
import type { PullRequestReplyTarget } from "../../providers/PullRequestActivityReplyProvider";
import { pullRequestAuthorLabel } from "../../utils/pullRequestAuthorLabel";
+import {
+ addPullRequestComment,
+ type PullRequestTarget,
+ replyToPullRequestThread,
+} from "../../utils/pullRequestClient";
-export interface PullRequestCommentTarget {
- projectId: string;
- hostUrl: string;
- prNumber: number;
-}
+export type PullRequestCommentTarget = PullRequestTarget;
interface PullRequestConversationComposerProps {
target: PullRequestCommentTarget;
@@ -23,7 +23,7 @@ interface PullRequestConversationComposerProps {
onCancelReply?: () => void;
}
-/** The "Leave a comment" card at the end of the Activity section. Posts as the gh user;
+/** The "Leave a comment" card at the end of the Activity section. Posts as the viewer;
* Enter sends, Shift+Enter breaks a line (comments accept markdown). With a reply
* target it answers that review thread instead. */
export function PullRequestConversationComposer({
@@ -54,23 +54,13 @@ export function PullRequestConversationComposer({
if (replyCommentId !== undefined) fieldRef.current?.focus();
}, [replyCommentId]);
const post = useMutation({
- mutationFn: async (text: string) => {
- const client = getHostServiceClientByUrl(target.hostUrl);
- if (replyTo) {
- await client.pullRequests.replyToThread.mutate({
- projectId: target.projectId,
- prNumber: target.prNumber,
- commentId: replyTo.commentId,
- body: text,
- });
- return;
- }
- await client.pullRequests.addComment.mutate({
- projectId: target.projectId,
- prNumber: target.prNumber,
- body: text,
- });
- },
+ mutationFn: (text: string) =>
+ replyTo
+ ? replyToPullRequestThread(target, {
+ commentId: replyTo.commentId,
+ body: text,
+ })
+ : addPullRequestComment(target, text),
onSuccess: () => {
setBody("");
onCancelReply?.();
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/usePullRequestDetail.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/usePullRequestDetail.ts
index 43a789577e9..53ba257bcb9 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/usePullRequestDetail.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/usePullRequestDetail.ts
@@ -1,4 +1,12 @@
-import type { RouterOutputs } from "@superset/trpc";
+import type {
+ PullRequestActivity,
+ PullRequestActor,
+ PullRequestCommit,
+ PullRequestCommitAuthor,
+ PullRequestConversationComment,
+ PullRequestDetail as PullRequestDetailBase,
+ PullRequestMergeability,
+} from "@superset/shared/pull-request";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useCallback } from "react";
import { useHostProjects } from "renderer/hooks/host-projects/useHostProjects";
@@ -6,61 +14,24 @@ import { useActiveOrganizationId } from "renderer/hooks/useActiveOrganizationId"
import { electronQueryClient } from "renderer/providers/ElectronTRPCProvider/ElectronTRPCProvider";
import { DASHBOARD_SIDEBAR_PULL_REQUEST_QUERY_KEY_PREFIX } from "renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/hooks/useDashboardSidebarData/derivePullRequestQueryTargets";
import { V2_WORKSPACES_PULL_REQUEST_QUERY_KEY_PREFIX } from "renderer/routes/_authenticated/_dashboard/v2-workspaces/hooks/useAccessibleV2Workspaces/useAccessibleV2Workspaces";
+import type { PullRequestTarget } from "../../utils/pullRequestClient";
import {
type PullRequestProject,
resolvePullRequestTarget,
} from "../../utils/resolvePullRequestTarget";
import { fetchPullRequestDetail } from "./utils/fetchPullRequestDetail";
-export type PullRequestMergeability = "mergeable" | "conflicting" | "unknown";
+export type { PullRequestMergeability };
+export type PullRequestDetailActor = PullRequestActor;
+export type PullRequestDetailComment = PullRequestConversationComment;
+export type PullRequestDetailCommitAuthor = PullRequestCommitAuthor;
+export type PullRequestDetailCommit = PullRequestCommit;
-export interface PullRequestDetailActor {
- login: string;
- name: string | null;
-}
-
-export interface PullRequestDetailComment {
- id: string;
- kind: "comment" | "review";
- author: PullRequestDetailActor | null;
- body: string;
- createdAt: string;
- reviewState: string | null;
- url?: string | null;
-}
-
-export interface PullRequestDetailCommitAuthor {
- /** Null when GitHub maps the commit's email to no account. */
- login: string | null;
- name: string | null;
-}
-
-export interface PullRequestDetailCommit {
- oid: string;
- messageHeadline: string;
- committedDate: string;
- author: PullRequestDetailCommitAuthor | null;
- url: string;
-}
-
-/** What a host's `gh pr view` adds over the cloud shape. Every field is
- * optional: the cloud route and hosts older than this read leave them out. */
-export interface PullRequestDetailExtras {
- additions?: number;
- deletions?: number;
- changedFiles?: number;
- mergeability?: PullRequestMergeability;
- mergedAt?: string | null;
- closedAt?: string | null;
- reviewers?: PullRequestDetailActor[];
- comments?: PullRequestDetailComment[];
- commits?: PullRequestDetailCommit[];
- labels?: { name: string; color: string | null }[];
-}
+/** What a full read adds over the detail. Every field is optional: a host
+ * older than the extended `gh pr view` read leaves them out. */
+export type PullRequestDetailExtras = Partial;
-export type PullRequestDetail =
- RouterOutputs["integration"]["github"]["getPullRequest"] &
- PullRequestDetailExtras;
+export type PullRequestDetail = PullRequestDetailBase & PullRequestDetailExtras;
interface PullRequestDetailKey {
projectId: string | null;
@@ -154,9 +125,13 @@ export function usePullRequestDetail({
* detail refetch has landed, so a mutation that returns this stays pending
* until the header shows the new state instead of flashing the old one.
*/
-export function useInvalidatePullRequestDetail(key: PullRequestDetailKey) {
+export function useInvalidatePullRequestDetail(
+ target: PullRequestTarget | null,
+) {
const queryClient = useQueryClient();
- const { projectId, hostUrl, prNumber } = key;
+ const projectId = target?.host?.projectId ?? null;
+ const hostUrl = target?.host?.hostUrl ?? null;
+ const prNumber = target?.prNumber ?? null;
return useCallback((): Promise => {
// Inside a workspace the context client is the workspace's own; the
// list and chip queries live on the root client and are unreachable
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fetchPullRequestDetail.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fetchPullRequestDetail.test.ts
deleted file mode 100644
index 15fd1c092b9..00000000000
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fetchPullRequestDetail.test.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { expect, test } from "bun:test";
-
-test("summary routing with isolated module mocks", () => {
- const result = Bun.spawnSync({
- cmd: [process.execPath, "test", `${import.meta.dir}/fixtures/checks.ts`],
- env: { ...process.env, NODE_ENV: "test" },
- });
- expect(
- result.exitCode,
- result.stdout.toString() + result.stderr.toString(),
- ).toBe(0);
-});
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fetchPullRequestDetail.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fetchPullRequestDetail.ts
index 858a63211f2..16cfddf52a1 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fetchPullRequestDetail.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fetchPullRequestDetail.ts
@@ -1,10 +1,7 @@
-import { cloudTrpcClient } from "renderer/lib/cloud-trpc";
-import { getHostServiceClientByUrl } from "renderer/lib/host-service-client";
-import { combinePullRequestReadErrors } from "../../../../utils/combinePullRequestReadErrors";
-import { fromHostPullRequestContent } from "../../../../utils/fromHostPullRequestContent";
+import { readPullRequestContent } from "../../../../utils/pullRequestClient";
import type { PullRequestDetail } from "../../usePullRequestDetail";
-export async function fetchPullRequestDetail({
+export function fetchPullRequestDetail({
projectId,
hostUrl,
repoFullName,
@@ -17,37 +14,10 @@ export async function fetchPullRequestDetail({
organizationId: string | null;
prNumber: number;
}): Promise {
- let repositoryError: unknown;
- if (hostUrl && projectId) {
- try {
- const content = await getHostServiceClientByUrl(
- hostUrl,
- ).pullRequests.getContent.query({ projectId, prNumber });
- return fromHostPullRequestContent(content);
- } catch (error) {
- if (!repoFullName) throw error;
- }
- }
- if (hostUrl && repoFullName) {
- try {
- const content = await getHostServiceClientByUrl(
- hostUrl,
- ).pullRequests.getContentByRepo.query({ repoFullName, prNumber });
- return fromHostPullRequestContent(content);
- } catch (error) {
- if (!organizationId) throw error;
- repositoryError = error;
- }
- }
- if (!organizationId || !repoFullName)
- throw new Error("No GitHub repository available to fetch the pull request");
- try {
- return await cloudTrpcClient.integration.github.getPullRequest.query({
- organizationId,
- repoFullName,
- number: prNumber,
- });
- } catch (error) {
- throw combinePullRequestReadErrors(repositoryError, error);
- }
+ return readPullRequestContent({
+ organizationId,
+ repoFullName,
+ prNumber,
+ host: hostUrl ? { hostUrl, projectId } : null,
+ });
}
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fixtures/checks.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fixtures/checks.ts
deleted file mode 100644
index bfe64321882..00000000000
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDetail/utils/fetchPullRequestDetail/fixtures/checks.ts
+++ /dev/null
@@ -1,328 +0,0 @@
-import { beforeEach, expect, mock, test } from "bun:test";
-
-const hostContent = {
- number: 12,
- url: "https://github.com/owner/repo/pull/12",
- title: "host title",
- state: "open",
- checks: [],
-};
-const getContent = mock(async (_input: unknown) => hostContent);
-const getContentByRepo = mock(async (_input: unknown) => ({
- ...hostContent,
- title: "repository title",
-}));
-const getPullRequest = mock(async (_input: unknown) => ({
- title: "API title",
-}));
-mock.module("renderer/lib/host-service-client", () => ({
- getHostServiceClientByUrl: () => ({
- pullRequests: {
- getContent: { query: getContent },
- getContentByRepo: { query: getContentByRepo },
- },
- }),
-}));
-mock.module("renderer/lib/cloud-trpc", () => ({
- cloudTrpcClient: {
- integration: { github: { getPullRequest: { query: getPullRequest } } },
- },
-}));
-const { fetchPullRequestDetail } = await import("../fetchPullRequestDetail");
-const input = {
- projectId: null,
- hostUrl: "http://host.test",
- organizationId: "org",
- repoFullName: "owner/repo",
- prNumber: 12,
-};
-beforeEach(() => {
- getContent.mockClear();
- getContentByRepo.mockClear();
- getPullRequest.mockClear();
-});
-test("loads Summary through gh without a project", async () => {
- expect(await fetchPullRequestDetail(input)).toMatchObject({
- title: "repository title",
- });
- expect(getContent).not.toHaveBeenCalled();
- expect(getContentByRepo).toHaveBeenCalledWith({
- repoFullName: "owner/repo",
- prNumber: 12,
- });
- expect(getPullRequest).not.toHaveBeenCalled();
-});
-test("matching projects keep the existing host path", async () => {
- expect(
- (await fetchPullRequestDetail({ ...input, projectId: "project" })).title,
- ).toBe("host title");
- expect(getContentByRepo).not.toHaveBeenCalled();
- expect(getPullRequest).not.toHaveBeenCalled();
-});
-test("tries repository gh access when the matching project path fails", async () => {
- getContent.mockRejectedValueOnce(new Error("offline"));
- expect(
- await fetchPullRequestDetail({ ...input, projectId: "project" }),
- ).toMatchObject({ title: "repository title" });
- expect(getPullRequest).not.toHaveBeenCalled();
-});
-test("falls back when the host is absent", async () => {
- expect(
- await fetchPullRequestDetail({
- ...input,
- projectId: "project",
- hostUrl: null,
- }),
- ).toMatchObject({ title: "API title" });
- expect(getContent).not.toHaveBeenCalled();
-});
-test("preserves repository host failures if cloud fallback is unavailable", async () => {
- getContent.mockRejectedValueOnce(new Error("project unavailable"));
- getContentByRepo.mockRejectedValueOnce(new Error("offline"));
- await expect(
- fetchPullRequestDetail({
- ...input,
- projectId: "project",
- organizationId: null,
- }),
- ).rejects.toThrow("offline");
-});
-
-test("legacy project-only Summary works without metadata or GitHub App access", async () => {
- expect(
- (
- await fetchPullRequestDetail({
- ...input,
- projectId: "project",
- repoFullName: null,
- organizationId: null,
- })
- ).title,
- ).toBe("host title");
- expect(getPullRequest).not.toHaveBeenCalled();
-});
-test("Summary does not race the API against a pending host request", async () => {
- let resolve!: (value: Awaited>) => void;
- getContent.mockImplementationOnce(
- () =>
- new Promise((done) => {
- resolve = done;
- }),
- );
- const request = fetchPullRequestDetail({ ...input, projectId: "project" });
- expect(getPullRequest).not.toHaveBeenCalled();
- resolve({
- number: 12,
- url: "https://github.com/owner/repo/pull/12",
- title: "host title",
- state: "open",
- checks: [],
- });
- expect((await request).title).toBe("host title");
- expect(getPullRequest).not.toHaveBeenCalled();
-});
-test("Summary surfaces a cloud failure instead of returning empty content", async () => {
- getContentByRepo.mockRejectedValueOnce(new Error("gh unavailable"));
- getPullRequest.mockRejectedValueOnce(new Error("Access denied"));
- await expect(fetchPullRequestDetail(input)).rejects.toThrow("Access denied");
-});
-
-test("an older host without the repository endpoint falls back to the API", async () => {
- getContent.mockRejectedValueOnce(new Error("project unavailable"));
- getContentByRepo.mockRejectedValueOnce(
- new Error('No procedure found on path "pullRequests.getContentByRepo"'),
- );
- expect(
- await fetchPullRequestDetail({ ...input, projectId: "project" }),
- ).toMatchObject({ title: "API title" });
- expect(getPullRequest).toHaveBeenCalledWith({
- organizationId: "org",
- repoFullName: "owner/repo",
- number: 12,
- });
-});
-
-test("repository gh access does not require an organization or GitHub App", async () => {
- expect(
- await fetchPullRequestDetail({ ...input, organizationId: null }),
- ).toMatchObject({ title: "repository title" });
- expect(getPullRequest).not.toHaveBeenCalled();
-});
-
-test("preserves legacy project failures when no repository identity is available", async () => {
- getContent.mockRejectedValueOnce(new Error("project unavailable"));
- await expect(
- fetchPullRequestDetail({
- ...input,
- projectId: "project",
- repoFullName: null,
- }),
- ).rejects.toThrow("project unavailable");
- expect(getContentByRepo).not.toHaveBeenCalled();
- expect(getPullRequest).not.toHaveBeenCalled();
-});
-
-test("Summary waits for repository gh access before using the API", async () => {
- let resolve!: (value: Awaited>) => void;
- getContentByRepo.mockImplementationOnce(
- () =>
- new Promise((done) => {
- resolve = done;
- }),
- );
- const request = fetchPullRequestDetail(input);
- expect(getPullRequest).not.toHaveBeenCalled();
- resolve({ ...hostContent, title: "repository title" });
- expect((await request).title).toBe("repository title");
- expect(getPullRequest).not.toHaveBeenCalled();
-});
-
-const { GlobalRegistrator } = await import("@happy-dom/global-registrator");
-if (!GlobalRegistrator.isRegistered) GlobalRegistrator.register();
-const { renderHook, waitFor, cleanup } = await import("@testing-library/react");
-const { createElement } = await import("react");
-const { QueryClient, QueryClientProvider } = await import(
- "@tanstack/react-query"
-);
-const { afterEach } = await import("bun:test");
-afterEach(cleanup);
-let hostProjects: {
- projects: Array<{
- id: string;
- projectKey: string;
- repoOwner?: string;
- repoName?: string;
- }>;
- isReady: boolean;
-} = { projects: [], isReady: false };
-mock.module("renderer/hooks/host-projects/useHostProjects", () => ({
- useHostProjects: () => hostProjects,
-}));
-mock.module("renderer/hooks/useActiveOrganizationId", () => ({
- useActiveOrganizationId: () => "org",
-}));
-mock.module(
- "renderer/providers/ElectronTRPCProvider/ElectronTRPCProvider",
- () => ({ electronQueryClient: new QueryClient() }),
-);
-mock.module(
- "renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/hooks/useDashboardSidebarData/derivePullRequestQueryTargets",
- () => ({ DASHBOARD_SIDEBAR_PULL_REQUEST_QUERY_KEY_PREFIX: ["sidebar-prs"] }),
-);
-mock.module(
- "renderer/routes/_authenticated/_dashboard/v2-workspaces/hooks/useAccessibleV2Workspaces/useAccessibleV2Workspaces",
- () => ({ V2_WORKSPACES_PULL_REQUEST_QUERY_KEY_PREFIX: ["workspace-prs"] }),
-);
-const { usePullRequestDetail } = await import("../../../usePullRequestDetail");
-function mountDetail(
- repoFullName: string | null,
- hostUrl: string | null = "http://host.test",
-) {
- const client = new QueryClient({
- defaultOptions: { queries: { retry: false } },
- });
- return renderHook(
- () =>
- usePullRequestDetail({
- projectId: "project",
- repoFullName,
- hostUrl,
- prNumber: 12,
- }),
- {
- wrapper: ({ children }) =>
- createElement(QueryClientProvider, { client }, children),
- },
- );
-}
-
-test("waits for project discovery, then uses the original matching host path", async () => {
- hostProjects = { projects: [], isReady: false };
- const view = mountDetail("owner/repo");
- expect(view.result.current.isResolvingProject).toBe(true);
- expect(getContent).not.toHaveBeenCalled();
- expect(getPullRequest).not.toHaveBeenCalled();
- hostProjects = {
- projects: [
- {
- id: "project",
- projectKey: "project",
- repoOwner: "owner",
- repoName: "repo",
- },
- ],
- isReady: true,
- };
- view.rerender();
- await waitFor(() =>
- expect(view.result.current.data?.title).toBe("host title"),
- );
- expect(getPullRequest).not.toHaveBeenCalled();
-});
-
-test("project-only links derive repository identity from the host response when metadata is missing", async () => {
- hostProjects = {
- projects: [{ id: "project", projectKey: "project" }],
- isReady: true,
- };
- const view = mountDetail(null);
- await waitFor(() =>
- expect(view.result.current.data?.title).toBe("host title"),
- );
- expect(view.result.current.repoFullName).toBe("owner/repo");
- expect(view.result.current.projectId).toBe("project");
- expect(getPullRequest).not.toHaveBeenCalled();
-});
-
-test("uses repository gh access after project discovery confirms the project is absent", async () => {
- hostProjects = { projects: [], isReady: true };
- const view = mountDetail("owner/repo");
- await waitFor(() =>
- expect(view.result.current.data?.title).toBe("repository title"),
- );
- expect(getContent).not.toHaveBeenCalled();
- expect(view.result.current.projectId).toBeNull();
-});
-
-test("a legacy link with no host or repository fails instead of loading forever", async () => {
- hostProjects = {
- projects: [{ id: "project", projectKey: "project" }],
- isReady: true,
- };
- const view = mountDetail(null, null);
- await waitFor(() => expect(view.result.current.isError).toBe(true));
- expect(view.result.current.isLoading).toBe(false);
- expect(getContent).not.toHaveBeenCalled();
- expect(getPullRequest).not.toHaveBeenCalled();
-});
-
-test("retains the repository gh failure when the cloud fallback also fails", async () => {
- const hostError = new Error("gh: diff exceeds the maximum number of lines");
- const cloudError = new Error("Not Found - installation access token");
- getContentByRepo.mockRejectedValueOnce(hostError);
- getPullRequest.mockRejectedValueOnce(cloudError);
- await expect(fetchPullRequestDetail(input)).rejects.toMatchObject({
- name: "AggregateError",
- message: `${hostError.message}\n${cloudError.message}`,
- errors: [hostError, cloudError],
- });
-});
-
-test("preserves the original cloud error when an older host lacks the endpoint", async () => {
- const hostError = Object.assign(new Error("Unsupported procedure"), {
- data: { code: "NOT_FOUND" },
- });
- const cloudError = new Error("Repository access denied");
- getContentByRepo.mockRejectedValueOnce(hostError);
- getPullRequest.mockRejectedValueOnce(cloudError);
- await expect(fetchPullRequestDetail(input)).rejects.toBe(cloudError);
-});
-
-test("preserves the original cloud error when no host was tried", async () => {
- const cloudError = new Error("Repository access denied");
- getPullRequest.mockRejectedValueOnce(cloudError);
- await expect(
- fetchPullRequestDetail({ ...input, hostUrl: null }),
- ).rejects.toBe(cloudError);
- expect(getContentByRepo).not.toHaveBeenCalled();
-});
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDraftMutation/usePullRequestDraftMutation.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDraftMutation/usePullRequestDraftMutation.ts
index 36e19a608f3..12018b31c15 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDraftMutation/usePullRequestDraftMutation.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestDraftMutation/usePullRequestDraftMutation.ts
@@ -2,26 +2,20 @@ import { useLingui } from "@lingui/react/macro";
import { errorMessage } from "@superset/i18n/errors";
import { toast } from "@superset/ui/sonner";
import { useMutation } from "@tanstack/react-query";
-import { getHostServiceClientByUrl } from "renderer/lib/host-service-client";
+import {
+ type PullRequestTarget,
+ setPullRequestDraft,
+} from "../../utils/pullRequestClient";
import { useInvalidatePullRequestDetail } from "../usePullRequestDetail";
-export interface PullRequestActionTarget {
- projectId: string;
- hostUrl: string;
- prNumber: number;
-}
+export type PullRequestActionTarget = PullRequestTarget;
-/** Flips a pull request between draft and ready for review through the host. */
-export function usePullRequestDraftMutation(target: PullRequestActionTarget) {
+/** Flips a pull request between draft and ready for review, as the viewer. */
+export function usePullRequestDraftMutation(target: PullRequestTarget) {
const { t } = useLingui();
const invalidate = useInvalidatePullRequestDetail(target);
return useMutation({
- mutationFn: (draft: boolean) =>
- getHostServiceClientByUrl(target.hostUrl).pullRequests.setDraft.mutate({
- projectId: target.projectId,
- prNumber: target.prNumber,
- draft,
- }),
+ mutationFn: (draft: boolean) => setPullRequestDraft(target, draft),
onSuccess: invalidate,
onError: (error, draft) => {
toast.error(
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestThreads/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestThreads/index.ts
new file mode 100644
index 00000000000..15b2d243cc8
--- /dev/null
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestThreads/index.ts
@@ -0,0 +1 @@
+export { usePullRequestThreads } from "./usePullRequestThreads";
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestThreads/usePullRequestThreads.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestThreads/usePullRequestThreads.ts
new file mode 100644
index 00000000000..08588226721
--- /dev/null
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestThreads/usePullRequestThreads.ts
@@ -0,0 +1,23 @@
+import { useQuery } from "@tanstack/react-query";
+import {
+ canActOnPullRequest,
+ type PullRequestTarget,
+ pullRequestThreadsQueryKey,
+ readPullRequestThreads,
+} from "../../utils/pullRequestClient";
+
+/** The pull request's review threads, polled so a reply made elsewhere shows within the half minute. */
+export function usePullRequestThreads(
+ target: PullRequestTarget,
+ options: { enabled?: boolean } = {},
+) {
+ return useQuery({
+ queryKey: pullRequestThreadsQueryKey(target),
+ queryFn: () => readPullRequestThreads(target),
+ enabled: (options.enabled ?? true) && canActOnPullRequest(target),
+ staleTime: 30_000,
+ gcTime: 10 * 60_000,
+ refetchInterval: 30_000,
+ refetchOnWindowFocus: true,
+ });
+}
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/buildPullRequestRepairPrompts/buildPullRequestRepairPrompts.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/buildPullRequestRepairPrompts/buildPullRequestRepairPrompts.test.ts
index debc5738446..b8a76e57666 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/buildPullRequestRepairPrompts/buildPullRequestRepairPrompts.test.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/buildPullRequestRepairPrompts/buildPullRequestRepairPrompts.test.ts
@@ -22,6 +22,7 @@ const detail = {
body: "nice",
createdAt: "2026-10-01T10:00:00Z",
reviewState: null,
+ url: null,
},
{
id: "r1",
@@ -59,6 +60,7 @@ describe("buildFixFindingsPrompt", () => {
body: "LGTM",
createdAt: "2026-10-03T10:00:00Z",
reviewState: "APPROVED",
+ url: null,
},
{
id: "c2",
@@ -67,6 +69,7 @@ describe("buildFixFindingsPrompt", () => {
body: "### Unused import\n\nLow severity\n\nDrop it.",
createdAt: "2026-10-04T10:00:00Z",
reviewState: null,
+ url: null,
},
],
});
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/combinePullRequestReadErrors/combinePullRequestReadErrors.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/combinePullRequestReadErrors/combinePullRequestReadErrors.ts
index 82e25039dab..443fc491abd 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/combinePullRequestReadErrors/combinePullRequestReadErrors.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/combinePullRequestReadErrors/combinePullRequestReadErrors.ts
@@ -1,22 +1,30 @@
import { errorMessage, rawErrorMessage } from "@superset/i18n/errors";
import { isMissingProcedureError } from "@superset/shared/missing-procedure-error";
-export function combinePullRequestReadErrors(
- hostError: unknown,
- cloudError: unknown,
-): unknown {
- const data = (hostError as { data?: { code?: unknown } } | null | undefined)
+function trpcErrorCode(error: unknown): string | undefined {
+ const data = (error as { data?: { code?: unknown } } | null | undefined)
?.data;
- if (
- hostError === undefined ||
- data?.code === "NOT_FOUND" ||
- isMissingProcedureError(hostError)
- )
- return cloudError;
- const errors = [hostError, cloudError];
+ return typeof data?.code === "string" ? data.code : undefined;
+}
+
+/** An answer of "not here", which the next source may still have had. */
+function isQuiet(error: unknown): boolean {
+ const code = trpcErrorCode(error);
+ return (
+ isMissingProcedureError(error) ||
+ code === "NOT_FOUND" ||
+ code === "PRECONDITION_FAILED"
+ );
+}
+
+/** What to show when every source failed: the real failures, or the last miss when that is all there was. */
+export function combinePullRequestErrors(errors: unknown[]): unknown {
+ const loud = errors.filter((error) => !isQuiet(error));
+ const kept = loud.length > 0 ? loud : errors.slice(-1);
+ if (kept.length === 1) return kept[0];
return new AggregateError(
- errors,
- errors.map(rawErrorMessage).filter(Boolean).join("\n"),
+ kept,
+ kept.map(rawErrorMessage).filter(Boolean).join("\n"),
);
}
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/combinePullRequestReadErrors/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/combinePullRequestReadErrors/index.ts
index a8ab1732bea..a42b273ffce 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/combinePullRequestReadErrors/index.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/combinePullRequestReadErrors/index.ts
@@ -1,4 +1,4 @@
export {
- combinePullRequestReadErrors,
+ combinePullRequestErrors,
pullRequestReadErrorMessage,
} from "./combinePullRequestReadErrors";
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/index.ts
new file mode 100644
index 00000000000..35818e7ec56
--- /dev/null
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/index.ts
@@ -0,0 +1,20 @@
+export {
+ addPullRequestComment,
+ canActOnPullRequest,
+ cloudCannotAct,
+ mergePullRequest,
+ type PullRequestGateways,
+ type PullRequestHostTarget,
+ type PullRequestMergeMethod,
+ type PullRequestTarget,
+ type PullRequestThreads,
+ pullRequestThreadsQueryKey,
+ reachesCloud,
+ readPullRequestContent,
+ readPullRequestDiff,
+ readPullRequestThreads,
+ replyToPullRequestThread,
+ setPullRequestDraft,
+ setPullRequestState,
+ setPullRequestThreadResolution,
+} from "./pullRequestClient";
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts
new file mode 100644
index 00000000000..bcba443d362
--- /dev/null
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts
@@ -0,0 +1,241 @@
+import { beforeEach, describe, expect, mock, test } from "bun:test";
+import {
+ addPullRequestComment,
+ canActOnPullRequest,
+ mergePullRequest,
+ type PullRequestGateways,
+ type PullRequestTarget,
+ readPullRequestContent,
+ readPullRequestDiff,
+ readPullRequestThreads,
+ setPullRequestThreadResolution,
+} from "./pullRequestClient";
+
+const hostContent = {
+ number: 12,
+ url: "https://github.com/owner/repo/pull/12",
+ title: "host title",
+ state: "open",
+ checks: [],
+};
+const cloud = {
+ getPullRequestContent: {
+ query: mock(async () => ({ title: "cloud title" })),
+ },
+ getPullRequestThreads: {
+ query: mock(async () => ({ reviewThreads: [], fetchFailed: false })),
+ },
+ getPullRequestDiff: { query: mock(async () => ({ patch: "cloud diff" })) },
+ addPullRequestComment: { mutate: mock(async () => ({ id: 1 })) },
+ mergePullRequest: { mutate: mock(async () => ({ merged: true })) },
+ setPullRequestThreadResolution: {
+ mutate: mock(async () => ({ isResolved: true })),
+ },
+};
+const host = {
+ getContent: { query: mock(async () => hostContent) },
+ getContentByRepo: {
+ query: mock(async () => ({ ...hostContent, title: "repository title" })),
+ },
+ getThreads: {
+ query: mock(async () => ({ reviewThreads: [], fetchFailed: true })),
+ },
+ getDiff: { query: mock(async () => ({ patch: "project diff" })) },
+ getDiffByRepo: { query: mock(async () => ({ patch: "repo diff" })) },
+ addComment: { mutate: mock(async () => ({ ok: true })) },
+ mergePR: { mutate: mock(async () => ({})) },
+ setThreadResolution: { mutate: mock(async () => ({})) },
+};
+const hostFor = mock((_hostUrl: string) => host);
+const deps = {
+ cloud: () => cloud,
+ host: hostFor,
+} as unknown as PullRequestGateways;
+
+const target: PullRequestTarget = {
+ organizationId: "org",
+ repoFullName: "owner/repo",
+ prNumber: 12,
+ host: { hostUrl: "http://host.test", projectId: "project" },
+};
+const cannotAct = Object.assign(new Error("Connect GitHub"), {
+ data: { code: "PRECONDITION_FAILED" },
+});
+const refused = Object.assign(new Error("not mergeable"), {
+ data: { code: "CONFLICT" },
+});
+
+beforeEach(() => {
+ for (const gateway of [cloud, host]) {
+ for (const procedure of Object.values(gateway)) {
+ for (const call of Object.values(procedure) as { mockClear(): void }[])
+ call.mockClear();
+ }
+ }
+ hostFor.mockClear();
+});
+
+describe("reads", () => {
+ test("the cloud answers first, as the viewer, without touching the host", async () => {
+ expect(await readPullRequestContent(target, deps)).toMatchObject({
+ title: "cloud title",
+ });
+ expect(cloud.getPullRequestContent.query).toHaveBeenCalledWith({
+ organizationId: "org",
+ repoFullName: "owner/repo",
+ number: 12,
+ });
+ expect(hostFor).not.toHaveBeenCalled();
+ });
+
+ test("a cloud that cannot act yields to the project's host, then the repository", async () => {
+ cloud.getPullRequestContent.query.mockRejectedValueOnce(cannotAct);
+ expect(await readPullRequestContent(target, deps)).toMatchObject({
+ title: "host title",
+ });
+ expect(host.getContent.query).toHaveBeenCalledWith({
+ projectId: "project",
+ prNumber: 12,
+ });
+
+ cloud.getPullRequestContent.query.mockRejectedValueOnce(
+ new Error(
+ 'No procedure found on path "integration.github.getPullRequestContent"',
+ ),
+ );
+ expect(
+ await readPullRequestContent(
+ { ...target, host: { hostUrl: "http://host.test", projectId: null } },
+ deps,
+ ),
+ ).toMatchObject({ title: "repository title" });
+ expect(host.getContentByRepo.query).toHaveBeenCalledWith({
+ repoFullName: "owner/repo",
+ prNumber: 12,
+ });
+ });
+
+ test("without an organization the host is the only source", async () => {
+ expect(
+ await readPullRequestContent({ ...target, organizationId: null }, deps),
+ ).toMatchObject({ title: "host title" });
+ expect(cloud.getPullRequestContent.query).not.toHaveBeenCalled();
+ });
+
+ test("a quiet cloud miss is dropped from the error; two real failures are both reported", async () => {
+ cloud.getPullRequestContent.query.mockRejectedValueOnce(cannotAct);
+ host.getContent.query.mockRejectedValueOnce(new Error("gh offline"));
+ host.getContentByRepo.query.mockRejectedValueOnce(new Error("gh offline"));
+ await expect(readPullRequestContent(target, deps)).rejects.toThrow(
+ "gh offline",
+ );
+
+ cloud.getPullRequestContent.query.mockRejectedValueOnce(
+ new Error("Access denied"),
+ );
+ host.getContent.query.mockRejectedValueOnce(new Error("gh offline"));
+ host.getContentByRepo.query.mockRejectedValueOnce(new Error("gh offline"));
+ const error = await readPullRequestContent(target, deps).catch((e) => e);
+ expect(error).toBeInstanceOf(AggregateError);
+ expect(error.message).toBe("Access denied\ngh offline\ngh offline");
+ });
+
+ test("nothing to read from is an error, not empty content", async () => {
+ await expect(
+ readPullRequestContent(
+ {
+ organizationId: null,
+ repoFullName: "owner/repo",
+ prNumber: 12,
+ host: null,
+ },
+ deps,
+ ),
+ ).rejects.toThrow("No GitHub repository available");
+ });
+
+ test("threads and diff follow the same order", async () => {
+ expect(await readPullRequestThreads(target, deps)).toEqual({
+ reviewThreads: [],
+ fetchFailed: false,
+ });
+ expect(await readPullRequestDiff(target, deps)).toEqual({
+ patch: "cloud diff",
+ });
+ cloud.getPullRequestThreads.query.mockRejectedValueOnce(cannotAct);
+ cloud.getPullRequestDiff.query.mockRejectedValueOnce(cannotAct);
+ expect(await readPullRequestThreads(target, deps)).toEqual({
+ reviewThreads: [],
+ fetchFailed: true,
+ });
+ expect(await readPullRequestDiff(target, deps)).toEqual({
+ patch: "project diff",
+ });
+ });
+});
+
+describe("writes", () => {
+ test("post as the viewer through the cloud", async () => {
+ await addPullRequestComment(target, "hello", deps);
+ expect(cloud.addPullRequestComment.mutate).toHaveBeenCalledWith({
+ organizationId: "org",
+ repoFullName: "owner/repo",
+ number: 12,
+ body: "hello",
+ });
+ expect(host.addComment.mutate).not.toHaveBeenCalled();
+ });
+
+ test("fall back to the host's gh only when the cloud could not act at all", async () => {
+ cloud.mergePullRequest.mutate.mockRejectedValueOnce(cannotAct);
+ await mergePullRequest(target, { mergeMethod: "squash" }, deps);
+ expect(host.mergePR.mutate).toHaveBeenCalledWith({
+ projectId: "project",
+ prNumber: 12,
+ mergeMethod: "squash",
+ });
+
+ cloud.mergePullRequest.mutate.mockRejectedValueOnce(refused);
+ await expect(
+ mergePullRequest(target, { mergeMethod: "squash" }, deps),
+ ).rejects.toBe(refused);
+ expect(host.mergePR.mutate).toHaveBeenCalledTimes(1);
+ });
+
+ test("a host without the project cannot stand in, except for thread resolution", async () => {
+ const noProject = {
+ ...target,
+ host: { hostUrl: "http://host.test", projectId: null },
+ };
+ cloud.addPullRequestComment.mutate.mockRejectedValueOnce(cannotAct);
+ await expect(addPullRequestComment(noProject, "x", deps)).rejects.toBe(
+ cannotAct,
+ );
+ cloud.setPullRequestThreadResolution.mutate.mockRejectedValueOnce(
+ cannotAct,
+ );
+ await setPullRequestThreadResolution(
+ noProject,
+ { threadId: "T1", resolved: true },
+ deps,
+ );
+ expect(host.setThreadResolution.mutate).toHaveBeenCalledWith({
+ threadId: "T1",
+ resolved: true,
+ });
+ });
+
+ test("acting needs a repository the cloud can name or a project on a host", () => {
+ expect(canActOnPullRequest(target)).toBe(true);
+ expect(
+ canActOnPullRequest({ ...target, organizationId: null, host: null }),
+ ).toBe(false);
+ expect(
+ canActOnPullRequest({
+ ...target,
+ organizationId: null,
+ host: { hostUrl: "http://host.test", projectId: "project" },
+ }),
+ ).toBe(true);
+ });
+});
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
new file mode 100644
index 00000000000..6a6e849be01
--- /dev/null
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
@@ -0,0 +1,318 @@
+import { isMissingProcedureError } from "@superset/shared/missing-procedure-error";
+import type { PullRequestDiff } from "@superset/shared/pull-request-diff";
+import type { PullRequestReviewThread } from "@superset/shared/pull-request-threads";
+import { cloudTrpcClient } from "renderer/lib/cloud-trpc";
+import { getHostServiceClientByUrl } from "renderer/lib/host-service-client";
+import type { PullRequestDetail } from "../../hooks/usePullRequestDetail";
+import { combinePullRequestErrors } from "../combinePullRequestReadErrors";
+import { fromHostPullRequestContent } from "../fromHostPullRequestContent";
+
+/** A host with the repository checked out, for `gh` when the cloud cannot act. */
+export interface PullRequestHostTarget {
+ hostUrl: string;
+ projectId: string | null;
+}
+
+/**
+ * A pull request by its own identity. The cloud reads and writes it as the
+ * signed-in person whenever the repository and organization are known; the
+ * host is only the fallback, since its `gh` acts as whoever the box is.
+ */
+export interface PullRequestTarget {
+ organizationId: string | null;
+ repoFullName: string | null;
+ prNumber: number;
+ host: PullRequestHostTarget | null;
+}
+
+export interface PullRequestThreads {
+ reviewThreads: PullRequestReviewThread[];
+ fetchFailed: boolean;
+}
+
+export type PullRequestMergeMethod = "merge" | "squash" | "rebase";
+
+type CloudGateway = typeof cloudTrpcClient.integration.github;
+type HostGateway = ReturnType["pullRequests"];
+
+export interface PullRequestGateways {
+ cloud: () => CloudGateway;
+ host: (hostUrl: string) => HostGateway;
+}
+
+const gateways: PullRequestGateways = {
+ cloud: () => cloudTrpcClient.integration.github,
+ host: (hostUrl) => getHostServiceClientByUrl(hostUrl).pullRequests,
+};
+
+function trpcErrorCode(error: unknown): string | undefined {
+ const data = (error as { data?: { code?: unknown } } | null | undefined)
+ ?.data;
+ return typeof data?.code === "string" ? data.code : undefined;
+}
+
+/**
+ * The cloud never reached GitHub: an API without the procedure yet, or a
+ * viewer with neither a GitHub connection nor an App installation. Anything
+ * GitHub itself answered is final — retrying it through the host would act
+ * as someone else.
+ */
+export function cloudCannotAct(error: unknown): boolean {
+ return (
+ isMissingProcedureError(error) ||
+ trpcErrorCode(error) === "PRECONDITION_FAILED"
+ );
+}
+
+export function reachesCloud(target: PullRequestTarget): boolean {
+ return Boolean(target.organizationId && target.repoFullName);
+}
+
+export function canActOnPullRequest(target: PullRequestTarget): boolean {
+ return reachesCloud(target) || Boolean(target.host?.projectId);
+}
+
+export function pullRequestThreadsQueryKey(target: PullRequestTarget) {
+ return [
+ "pull-request-threads",
+ target.repoFullName?.toLowerCase() ?? target.host?.projectId ?? null,
+ target.prNumber,
+ ] as const;
+}
+
+function cloudInput(target: PullRequestTarget) {
+ if (!target.organizationId || !target.repoFullName) {
+ throw new Error("The pull request's repository is unknown");
+ }
+ return {
+ organizationId: target.organizationId,
+ repoFullName: target.repoFullName,
+ number: target.prNumber,
+ };
+}
+
+type Attempt = (() => Promise) | null | false | undefined | "";
+
+async function firstAnswer(
+ attempts: Attempt[],
+ none: string,
+): Promise {
+ const errors: unknown[] = [];
+ for (const attempt of attempts) {
+ if (!attempt) continue;
+ try {
+ return await attempt();
+ } catch (error) {
+ errors.push(error);
+ }
+ }
+ if (errors.length === 0) throw new Error(none);
+ throw combinePullRequestErrors(errors);
+}
+
+export function readPullRequestContent(
+ target: PullRequestTarget,
+ deps: PullRequestGateways = gateways,
+): Promise {
+ const { host, prNumber, repoFullName } = target;
+ const projectId = host?.projectId ?? null;
+ return firstAnswer(
+ [
+ reachesCloud(target) &&
+ (() => deps.cloud().getPullRequestContent.query(cloudInput(target))),
+ host &&
+ projectId &&
+ (() =>
+ deps
+ .host(host.hostUrl)
+ .getContent.query({ projectId, prNumber })
+ .then(fromHostPullRequestContent)),
+ host &&
+ repoFullName &&
+ (() =>
+ deps
+ .host(host.hostUrl)
+ .getContentByRepo.query({ repoFullName, prNumber })
+ .then(fromHostPullRequestContent)),
+ ],
+ "No GitHub repository available to fetch the pull request",
+ );
+}
+
+export function readPullRequestThreads(
+ target: PullRequestTarget,
+ deps: PullRequestGateways = gateways,
+): Promise {
+ const { host, prNumber } = target;
+ const projectId = host?.projectId ?? null;
+ return firstAnswer(
+ [
+ reachesCloud(target) &&
+ (() => deps.cloud().getPullRequestThreads.query(cloudInput(target))),
+ host &&
+ projectId &&
+ (() =>
+ deps.host(host.hostUrl).getThreads.query({ projectId, prNumber })),
+ ],
+ "No GitHub repository available to fetch review threads",
+ );
+}
+
+export function readPullRequestDiff(
+ target: PullRequestTarget,
+ deps: PullRequestGateways = gateways,
+): Promise {
+ const { host, prNumber, repoFullName } = target;
+ const projectId = host?.projectId ?? null;
+ return firstAnswer(
+ [
+ reachesCloud(target) &&
+ (() => deps.cloud().getPullRequestDiff.query(cloudInput(target))),
+ host &&
+ projectId &&
+ (() => deps.host(host.hostUrl).getDiff.query({ projectId, prNumber })),
+ host &&
+ repoFullName &&
+ (() =>
+ deps
+ .host(host.hostUrl)
+ .getDiffByRepo.query({ repoFullName, prNumber })),
+ ],
+ "No GitHub repository available to fetch the diff",
+ );
+}
+
+async function act(
+ target: PullRequestTarget,
+ deps: PullRequestGateways,
+ cloud: (github: CloudGateway) => Promise,
+ host: ((pullRequests: HostGateway) => Promise) | null,
+): Promise {
+ const hostUrl = target.host?.hostUrl;
+ const viaHost = host && hostUrl ? () => host(deps.host(hostUrl)) : null;
+ if (reachesCloud(target)) {
+ try {
+ await cloud(deps.cloud());
+ return;
+ } catch (error) {
+ if (!viaHost || !cloudCannotAct(error)) throw error;
+ }
+ }
+ if (!viaHost) throw new Error("No GitHub access for this pull request");
+ await viaHost();
+}
+
+export function addPullRequestComment(
+ target: PullRequestTarget,
+ body: string,
+ deps: PullRequestGateways = gateways,
+): Promise {
+ const { prNumber } = target;
+ const projectId = target.host?.projectId;
+ return act(
+ target,
+ deps,
+ (github) =>
+ github.addPullRequestComment.mutate({ ...cloudInput(target), body }),
+ projectId
+ ? (pullRequests) =>
+ pullRequests.addComment.mutate({ projectId, prNumber, body })
+ : null,
+ );
+}
+
+export function replyToPullRequestThread(
+ target: PullRequestTarget,
+ reply: { commentId: number; body: string },
+ deps: PullRequestGateways = gateways,
+): Promise {
+ const { prNumber } = target;
+ const projectId = target.host?.projectId;
+ return act(
+ target,
+ deps,
+ (github) =>
+ github.replyToPullRequestThread.mutate({
+ ...cloudInput(target),
+ ...reply,
+ }),
+ projectId
+ ? (pullRequests) =>
+ pullRequests.replyToThread.mutate({ projectId, prNumber, ...reply })
+ : null,
+ );
+}
+
+export function setPullRequestThreadResolution(
+ target: PullRequestTarget,
+ thread: { threadId: string; resolved: boolean },
+ deps: PullRequestGateways = gateways,
+): Promise {
+ return act(
+ target,
+ deps,
+ (github) =>
+ github.setPullRequestThreadResolution.mutate({
+ ...cloudInput(target),
+ ...thread,
+ }),
+ (pullRequests) => pullRequests.setThreadResolution.mutate(thread),
+ );
+}
+
+export function mergePullRequest(
+ target: PullRequestTarget,
+ merge: { mergeMethod: PullRequestMergeMethod; commitMessage?: string },
+ deps: PullRequestGateways = gateways,
+): Promise {
+ const { prNumber } = target;
+ const projectId = target.host?.projectId;
+ return act(
+ target,
+ deps,
+ (github) =>
+ github.mergePullRequest.mutate({ ...cloudInput(target), ...merge }),
+ projectId
+ ? (pullRequests) =>
+ pullRequests.mergePR.mutate({ projectId, prNumber, ...merge })
+ : null,
+ );
+}
+
+export function setPullRequestState(
+ target: PullRequestTarget,
+ state: "open" | "closed",
+ deps: PullRequestGateways = gateways,
+): Promise {
+ const { prNumber } = target;
+ const projectId = target.host?.projectId;
+ return act(
+ target,
+ deps,
+ (github) =>
+ github.setPullRequestState.mutate({ ...cloudInput(target), state }),
+ projectId
+ ? (pullRequests) =>
+ pullRequests.setState.mutate({ projectId, prNumber, state })
+ : null,
+ );
+}
+
+export function setPullRequestDraft(
+ target: PullRequestTarget,
+ draft: boolean,
+ deps: PullRequestGateways = gateways,
+): Promise {
+ const { prNumber } = target;
+ const projectId = target.host?.projectId;
+ return act(
+ target,
+ deps,
+ (github) =>
+ github.setPullRequestDraft.mutate({ ...cloudInput(target), draft }),
+ projectId
+ ? (pullRequests) =>
+ pullRequests.setDraft.mutate({ projectId, prNumber, draft })
+ : null,
+ );
+}
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/CommentsSection/utils/normalizeThreadsToComments/normalizeThreadsToComments.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/CommentsSection/utils/normalizeThreadsToComments/normalizeThreadsToComments.ts
index f98a2ca08da..4033e57461e 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/CommentsSection/utils/normalizeThreadsToComments/normalizeThreadsToComments.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/CommentsSection/utils/normalizeThreadsToComments/normalizeThreadsToComments.ts
@@ -1,12 +1,19 @@
-import type { AppRouter } from "@superset/host-service";
-import type { inferRouterOutputs } from "@trpc/server";
+import type { PullRequestReviewThread } from "@superset/shared/pull-request-threads";
import type { NormalizedComment } from "../../types";
-type V2ThreadsData =
- inferRouterOutputs["git"]["getPullRequestThreads"];
+interface ThreadsData {
+ reviewThreads: PullRequestReviewThread[];
+ conversationComments?: {
+ id: number;
+ user: { login: string; avatarUrl: string };
+ body: string;
+ createdAt: string;
+ htmlUrl: string;
+ }[];
+}
export function normalizeThreadsToComments(
- data: V2ThreadsData,
+ data: ThreadsData,
prUrl?: string,
): NormalizedComment[] {
const comments: NormalizedComment[] = [];
@@ -35,7 +42,7 @@ export function normalizeThreadsToComments(
}
}
- for (const c of data.conversationComments) {
+ for (const c of data.conversationComments ?? []) {
comments.push({
id: String(c.id),
authorLogin: c.user.login,
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useOpenChatLink/useOpenChatLink.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useOpenChatLink/useOpenChatLink.ts
index c6a918d9ce8..db47b5ddf3c 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useOpenChatLink/useOpenChatLink.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useOpenChatLink/useOpenChatLink.ts
@@ -18,6 +18,7 @@ import type {
PaneViewerData,
} from "renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types";
import {
+ runChatPullRequestLink,
runFileLinkAction,
runFolderLinkAction,
runUrlLinkAction,
@@ -92,6 +93,8 @@ export function useOpenChatLink({
(href, event, chosen) => {
const isPlain = tierFor(event, "2-tier") === "plain";
if (WEB_URL.test(href)) {
+ if (runChatPullRequestLink(depsRef.current, href, event, chosen))
+ return true;
const action =
chosen ?? getUrlAction(event, href) ?? (isPlain ? "pane" : null);
if (action === null) showHint(event.clientX, event.clientY);
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/PullRequestPane.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/PullRequestPane.tsx
index d0d1cd0f5d8..b3890da9f25 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/PullRequestPane.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/PullRequestPane.tsx
@@ -2,6 +2,7 @@ import { useIsTabVisible } from "@superset/panes";
import { workspaceTrpc } from "@superset/workspace-client";
import { useNavigate } from "@tanstack/react-router";
import { useMemo, useState } from "react";
+import { useActiveOrganizationId } from "renderer/hooks/useActiveOrganizationId";
import {
isSamePullRequest,
pullRequestRefFromUrl,
@@ -13,6 +14,11 @@ import {
type PullRequestDetailTab,
PullRequestDetailTabs,
} from "renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestDetailTabs";
+import { usePullRequestThreads } from "renderer/routes/_authenticated/_dashboard/pull-requests/hooks/usePullRequestThreads";
+import {
+ canActOnPullRequest,
+ type PullRequestTarget,
+} from "renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient";
import { useWorkspace } from "renderer/routes/_authenticated/_dashboard/v2-workspace/providers/WorkspaceProvider";
import { normalizeThreadsToComments } from "../../../../components/CommentsSection/utils/normalizeThreadsToComments";
import type { PagePaneData, PullRequestPaneData } from "../../../../types";
@@ -38,13 +44,22 @@ export function PullRequestPane({
}: PullRequestPaneProps) {
const navigate = useNavigate();
const [activeTab, setActiveTab] = useState("summary");
- const { workspace, hostUrl: workspaceHostUrl } = useWorkspace();
+ const { workspace, hostUrl } = useWorkspace();
+ const organizationId = useActiveOrganizationId();
const detail = usePullRequestPaneDetail(data);
const isTabVisible = useIsTabVisible();
+ const target = useMemo(
+ () => ({
+ organizationId,
+ repoFullName: data.repoFullName,
+ prNumber: data.number,
+ host: hostUrl ? { hostUrl, projectId: detail.projectId } : null,
+ }),
+ [organizationId, data.repoFullName, data.number, hostUrl, detail.projectId],
+ );
- // Review threads and the header's actions still go through the host that
- // pushed the PR, so they exist only when this workspace's linked PR is
- // the one on screen.
+ // Pages and "open in diff" belong to the workspace, so they exist only
+ // when this workspace's linked PR is the one on screen.
const linkedPR = workspaceTrpc.git.getPullRequest.useQuery({
workspaceId: workspace.id,
});
@@ -56,57 +71,46 @@ export function PullRequestPane({
workspace.id,
isLinkedPR && activeTab === "summary" && isTabVisible,
);
- const threads = workspaceTrpc.git.getPullRequestThreads.useQuery(
- { workspaceId: workspace.id },
- {
- enabled: isLinkedPR && isTabVisible,
- refetchInterval: 30_000,
- refetchOnWindowFocus: true,
- },
- );
+ const threads = usePullRequestThreads(target, { enabled: isTabVisible });
const onOpenInDiff = useReviewCommentNavigation(workspace.id, onOpenDiff);
- // The host's content read already carries the conversation; the threads
- // query's copy of it only fills in for a host too old to send one.
- const hasConversation = detail.data?.comments !== undefined;
+ const prUrl =
+ detail.data?.url ??
+ `https://github.com/${data.repoFullName}/pull/${data.number}`;
const activityThreads = useMemo<
PullRequestActivityThreads | undefined
>(() => {
- if (!isLinkedPR) return undefined;
- const comments = (
- threads.data
- ? normalizeThreadsToComments(threads.data, linkedPR.data?.url)
- : []
- ).filter((comment) => comment.kind === "review" || !hasConversation);
+ if (!canActOnPullRequest(target)) return undefined;
+ const comments = threads.data
+ ? normalizeThreadsToComments(threads.data, prUrl)
+ : [];
return {
entries: buildReviewThreadEntries({
comments,
- workspaceId: workspace.id,
- onOpenInDiff,
+ target,
+ onOpenInDiff: isLinkedPR ? onOpenInDiff : undefined,
}),
commentCount: comments.length,
isLoading: threads.isLoading,
- isError: threads.isError,
+ isError: threads.isError || Boolean(threads.data?.fetchFailed),
};
}, [
- isLinkedPR,
+ target,
threads.data,
threads.isLoading,
threads.isError,
- linkedPR.data?.url,
- hasConversation,
- workspace.id,
+ prUrl,
+ isLinkedPR,
onOpenInDiff,
]);
- const projectId = isLinkedPR ? workspace.projectId : null;
- const hostId = isLinkedPR ? workspace.hostId : null;
- const hostUrl = isLinkedPR ? workspaceHostUrl : null;
const diffStat =
detail.data?.additions !== undefined && detail.data.deletions !== undefined
? { additions: detail.data.additions, deletions: detail.data.deletions }
: null;
+ // A host that predates the extended read answers without `mergeability`;
+ // it would answer the writes with "No procedure found".
const commentTarget =
- projectId && hostUrl && detail.data?.mergeability !== undefined
- ? { projectId, hostUrl, prNumber: data.number }
+ canActOnPullRequest(target) && detail.data?.mergeability !== undefined
+ ? target
: null;
return (
@@ -121,10 +125,8 @@ export function PullRequestPane({
,
requestReply: ((target: { commentId: number }) => void) | null = null,
) {
+ const queryClient = new QueryClient();
return render(
-
-
-
-
- ,
+
+
+
+
+
+
+ ,
);
}
afterEach(cleanup);
@@ -121,9 +133,11 @@ describe("review cards", () => {
const client = workspaceTrpc.createClient({ links: [] });
const queryClient = new QueryClient();
const card = (next: typeof resolved) => (
-
-
-
+
+
+
+
+
);
const view = render(card(resolved));
fireEvent.click(view.getByRole("button", { name: /Expand/ }));
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/components/PullRequestCommentCard/PullRequestCommentCard.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/components/PullRequestCommentCard/PullRequestCommentCard.tsx
index 84386cf04c1..51ac28bfb30 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/components/PullRequestCommentCard/PullRequestCommentCard.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/components/PullRequestCommentCard/PullRequestCommentCard.tsx
@@ -2,6 +2,7 @@ import { Trans, useLingui } from "@lingui/react/macro";
import { Button } from "@superset/ui/button";
import { toast } from "@superset/ui/sonner";
import { workspaceTrpc } from "@superset/workspace-client";
+import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useEffect, useState } from "react";
import {
LuArrowUpRight,
@@ -15,6 +16,11 @@ import { PullRequestActivityCard } from "renderer/routes/_authenticated/_dashboa
import { PullRequestMarkdown } from "renderer/routes/_authenticated/_dashboard/pull-requests/components/PullRequestMarkdown";
import { usePullRequestActivityLayout } from "renderer/routes/_authenticated/_dashboard/pull-requests/providers/PullRequestActivityLayoutProvider";
import { usePullRequestActivityReply } from "renderer/routes/_authenticated/_dashboard/pull-requests/providers/PullRequestActivityReplyProvider";
+import {
+ type PullRequestTarget,
+ pullRequestThreadsQueryKey,
+ setPullRequestThreadResolution,
+} from "renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient";
import type { NormalizedComment } from "../../../../../../components/CommentsSection/types";
import type { DiffFocusSide } from "../../../../../../types";
import { PullRequestCommentReply } from "./components/PullRequestCommentReply";
@@ -24,7 +30,7 @@ const REPLY_CLASS_NAME =
"rounded px-1.5 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground";
export interface PullRequestCommentCardProps {
- workspaceId: string;
+ target: PullRequestTarget;
comment: NormalizedComment;
/** Later comments in the same thread. */
replies?: NormalizedComment[];
@@ -38,7 +44,7 @@ export interface PullRequestCommentCardProps {
/** A review thread on the activity rail: file and state in the header, copy and Reply beside them, replies under the body, resolve and open-in-diff in the footer. */
export function PullRequestCommentCard({
- workspaceId,
+ target,
comment,
replies = [],
onOpenInDiff,
@@ -55,11 +61,20 @@ export function PullRequestCommentCard({
if (foldable) setExpanded(false);
}
const collapsed = foldable && !expanded;
+ const queryClient = useQueryClient();
const utils = workspaceTrpc.useUtils();
- const resolve = workspaceTrpc.git.setReviewThreadResolution.useMutation({
- // Returned so the button stays pending until the refetched thread shows the new state.
+ const resolve = useMutation({
+ mutationFn: (thread: { threadId: string; resolved: boolean }) =>
+ setPullRequestThreadResolution(target, thread),
+ // Returned so the button stays pending until the refetched thread shows
+ // the new state; the workspace's diff annotations read the same threads.
onSuccess: () =>
- utils.git.getPullRequestThreads.invalidate({ workspaceId }),
+ Promise.all([
+ queryClient.invalidateQueries({
+ queryKey: pullRequestThreadsQueryKey(target),
+ }),
+ utils.git.getPullRequestThreads.invalidate(),
+ ]),
onError: () => {
toast.error(t({ message: "Couldn't update thread" }));
},
@@ -185,7 +200,6 @@ export function PullRequestCommentCard({
onClick={() => {
if (comment.threadId)
resolve.mutate({
- workspaceId,
threadId: comment.threadId,
resolved: !comment.isResolved,
});
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/fixtures/checks.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/fixtures/checks.tsx
index c5e084c1b44..78199e5da11 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/fixtures/checks.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/fixtures/checks.tsx
@@ -26,12 +26,22 @@ mock.module(`${pane}/hooks/usePullRequestPaneDetail`, () => ({
}));
mock.module("@superset/workspace-client", () => ({
workspaceTrpc: {
- git: {
- getPullRequest: { useQuery: () => ({ data: null }) },
- getPullRequestThreads: { useQuery: () => ({ data: null }) },
- },
+ git: { getPullRequest: { useQuery: () => ({ data: null }) } },
},
}));
+mock.module(`${root}/pull-requests/hooks/usePullRequestThreads`, () => ({
+ usePullRequestThreads: () => ({
+ data: undefined,
+ isLoading: false,
+ isError: false,
+ }),
+}));
+mock.module("renderer/hooks/useActiveOrganizationId", () => ({
+ useActiveOrganizationId: () => "org",
+}));
+mock.module("renderer/lib/host-service-client", () => ({
+ getHostServiceClientByUrl: () => ({}),
+}));
mock.module(
`${root}/v2-workspace/$workspaceId/hooks/useReviewCommentNavigation`,
() => ({ useReviewCommentNavigation: () => mock() }),
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/hooks/usePullRequestPaneDetail/fixtures/checks.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/hooks/usePullRequestPaneDetail/fixtures/checks.tsx
index fe3960740f1..285420dc22b 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/hooks/usePullRequestPaneDetail/fixtures/checks.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/hooks/usePullRequestPaneDetail/fixtures/checks.tsx
@@ -25,9 +25,14 @@ const getContentByRepo = mock(async (_input: unknown) => ({
...hostContent,
title: "repository title",
}));
-const getPullRequest = mock(async (_input: unknown) => ({
- title: "API title",
-}));
+const cannotAct = Object.assign(new Error("Connect GitHub"), {
+ data: { code: "PRECONDITION_FAILED" },
+});
+const getPullRequestContent = mock(
+ async (_input: unknown): Promise => {
+ throw cannotAct;
+ },
+);
const root = "renderer/routes/_authenticated/_dashboard";
mock.module("@superset/workspace-client", () => ({
workspaceTrpc: {
@@ -56,7 +61,9 @@ mock.module("renderer/lib/host-service-client", () => ({
}));
mock.module("renderer/lib/cloud-trpc", () => ({
cloudTrpcClient: {
- integration: { github: { getPullRequest: { query: getPullRequest } } },
+ integration: {
+ github: { getPullRequestContent: { query: getPullRequestContent } },
+ },
},
}));
mock.module(
@@ -88,7 +95,7 @@ beforeEach(() => {
workspaceProjectQuery.mockClear();
getContent.mockClear();
getContentByRepo.mockClear();
- getPullRequest.mockClear();
+ getPullRequestContent.mockClear();
});
function mountDetail(
@@ -105,7 +112,22 @@ function mountDetail(
});
}
-test("cloud projects keep the original host path without desktop discovery", async () => {
+test("the cloud reads the pull request as the viewer before any host path", async () => {
+ getPullRequestContent.mockResolvedValueOnce({ title: "viewer title" });
+ const view = mountDetail();
+ await waitFor(() =>
+ expect(view.result.current.data?.title).toBe("viewer title"),
+ );
+ expect(getPullRequestContent).toHaveBeenCalledWith({
+ organizationId: "org",
+ repoFullName: "owner/repo",
+ number: 12,
+ });
+ expect(getContent).not.toHaveBeenCalled();
+ expect(getContentByRepo).not.toHaveBeenCalled();
+});
+
+test("a cloud that cannot act yields to the workspace host's project path", async () => {
const view = mountDetail();
await waitFor(() =>
expect(view.result.current.data?.title).toBe("host title"),
@@ -121,7 +143,6 @@ test("cloud projects keep the original host path without desktop discovery", asy
prNumber: 12,
});
expect(getContentByRepo).not.toHaveBeenCalled();
- expect(getPullRequest).not.toHaveBeenCalled();
});
test("waits for the workspace project even if desktop discovery has a match", async () => {
@@ -144,7 +165,6 @@ test("waits for the workspace project even if desktop discovery has a match", as
);
expect(view.result.current.projectId).toBeNull();
expect(getContent).not.toHaveBeenCalled();
- expect(getPullRequest).not.toHaveBeenCalled();
});
for (const data of [undefined, null]) {
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/utils/buildReviewThreadEntries/buildReviewThreadEntries.test.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/utils/buildReviewThreadEntries/buildReviewThreadEntries.test.tsx
index fc1593f9aae..6fa03287f23 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/utils/buildReviewThreadEntries/buildReviewThreadEntries.test.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/utils/buildReviewThreadEntries/buildReviewThreadEntries.test.tsx
@@ -24,7 +24,12 @@ function comment(
describe("review thread entries", () => {
test("one entry per thread, keyed by its root with the replies folded in", () => {
const entries = buildReviewThreadEntries({
- workspaceId: "ws",
+ target: {
+ organizationId: "org",
+ repoFullName: "owner/repo",
+ prNumber: 1,
+ host: null,
+ },
comments: [
comment("a1", { threadId: "A", authorLogin: "maya", avatarUrl: "x" }),
comment("b1", { threadId: "B", createdAt: "2026-10-03T11:00:00Z" }),
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/index.ts
index cc4107f8618..5e131db19d6 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/index.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/index.ts
@@ -1,4 +1,5 @@
export {
+ runChatPullRequestLink,
runFileLinkAction,
runFolderLinkAction,
runUrlLinkAction,
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/runTerminalLinkAction.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/runTerminalLinkAction.test.ts
index 401499475c3..22c6d92f2a1 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/runTerminalLinkAction.test.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/runTerminalLinkAction.test.ts
@@ -7,6 +7,7 @@ import {
import type { StoreApi } from "zustand/vanilla";
import type { PaneViewerData } from "../../../../types";
import {
+ runChatPullRequestLink,
runUrlLinkAction,
terminalPullRequestLinkAction,
} from "./runTerminalLinkAction";
@@ -135,6 +136,50 @@ describe("runUrlLinkAction", () => {
});
});
+describe("runChatPullRequestLink", () => {
+ const click = { metaKey: false, ctrlKey: false, shiftKey: false };
+
+ it("opens the PR pane for a badge whose URL names a file or a comment", () => {
+ for (const url of [
+ PR_URL,
+ `${PR_URL}/files?diff=split`,
+ `${PR_URL}#discussion_r123`,
+ "https://www.github.com/superset-sh/superset/pull/8412",
+ ]) {
+ const store = createWorkspaceStore({
+ initialState: workspaceState(),
+ });
+
+ expect(runChatPullRequestLink({ store }, url, click)).toBe(true);
+
+ expect(panesOfKind(store, "browser")).toHaveLength(0);
+ expect(
+ panesOfKind(store, "pull-request").map((pane) => pane.data),
+ ).toEqual([{ repoFullName: "superset-sh/superset", number: 8412 }]);
+ }
+ });
+
+ it("sends a cmd-click to GitHub and leaves other URLs to the link settings", () => {
+ const store = createWorkspaceStore({
+ initialState: workspaceState(),
+ });
+
+ expect(
+ runChatPullRequestLink({ store }, PR_URL, { ...click, metaKey: true }),
+ ).toBe(true);
+ expect(panesOfKind(store, "pull-request")).toHaveLength(0);
+ expect(panesOfKind(store, "browser")).toHaveLength(0);
+
+ expect(
+ runChatPullRequestLink(
+ { store },
+ "https://github.com/superset-sh/superset/issues/1",
+ click,
+ ),
+ ).toBe(false);
+ });
+});
+
describe("terminalPullRequestLinkAction", () => {
const click = { metaKey: false, ctrlKey: false, shiftKey: false };
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/runTerminalLinkAction.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/runTerminalLinkAction.ts
index 15934798ab2..818c6fb9b4b 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/runTerminalLinkAction.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/utils/runTerminalLinkAction/runTerminalLinkAction.ts
@@ -1,11 +1,17 @@
import type { WorkspaceStore } from "@superset/panes";
import { env } from "renderer/env.renderer";
-import type {
- FolderLinkAction,
- LinkAction,
- ModifierEvent,
+import {
+ type FolderLinkAction,
+ type LinkAction,
+ type ModifierEvent,
+ PULL_REQUEST_LINKS,
+ tierFor,
} from "renderer/lib/clickPolicy";
-import { pullRequestRefFromBareUrl } from "renderer/lib/github/pullRequestRef";
+import {
+ type PullRequestRef,
+ pullRequestRefFromBareUrl,
+ pullRequestRefFromUrl,
+} from "renderer/lib/github/pullRequestRef";
import { parseSupersetPageUrl } from "renderer/lib/parseSupersetPageUrl";
import { electronTrpcClient } from "renderer/lib/trpc-client";
import type { RightPaneLinkTarget } from "renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/providers/RightPaneLinkTargetProvider";
@@ -47,29 +53,71 @@ export function terminalPullRequestLinkAction(
return event.shiftKey ? "external" : "pane";
}
+/**
+ * Chat shows every pull request URL as a badge, so the badge opens the pane
+ * even when the URL names a file or a comment; a modifier click reaches
+ * GitHub, where that anchor still works. Terminals keep those deep links in
+ * a browser pane: there the URL is all the reader sees.
+ */
+export function runChatPullRequestLink(
+ deps: Pick,
+ url: string,
+ event: ModifierEvent,
+ chosen?: LinkAction,
+): boolean {
+ const pullRequest = pullRequestRefFromUrl(url);
+ if (!pullRequest) return false;
+ const action =
+ chosen ?? PULL_REQUEST_LINKS[tierFor(event, "2-tier")] ?? "pane";
+ if (action === "external") openUrlExternally(url);
+ else openPullRequestPane(deps, pullRequest, action);
+ return true;
+}
+
+function openUrlExternally(url: string): void {
+ electronTrpcClient.external.openUrl.mutate(url).catch((error) => {
+ console.error("[v2 Terminal] Failed to open URL:", url, error);
+ });
+}
+
+function openPullRequestPane(
+ deps: Pick,
+ pullRequest: PullRequestRef,
+ action: Exclude,
+): void {
+ if (deps.rightPane) {
+ deps.rightPane.reveal();
+ openPullRequestPaneInStore(deps.rightPane.store, pullRequest);
+ return;
+ }
+ openPullRequestPaneInStore(
+ deps.store,
+ pullRequest,
+ action === "newTab" ? "tab" : "split",
+ );
+}
+
export function runUrlLinkAction(
deps: Pick,
url: string,
action: LinkAction,
): void {
if (action === "external") {
- electronTrpcClient.external.openUrl.mutate(url).catch((error) => {
- console.error("[v2 Terminal] Failed to open URL:", url, error);
- });
+ openUrlExternally(url);
return;
}
- const pageSlug = parseSupersetPageUrl(url, env.NEXT_PUBLIC_WEB_URL);
const pullRequest = pullRequestRefFromBareUrl(url);
+ if (pullRequest) {
+ openPullRequestPane(deps, pullRequest, action);
+ return;
+ }
+ const pageSlug = parseSupersetPageUrl(url, env.NEXT_PUBLIC_WEB_URL);
if (deps.rightPane) {
deps.rightPane.reveal();
if (pageSlug) {
openPagePaneInStore(deps.rightPane.store, { slug: pageSlug }, "tab");
return;
}
- if (pullRequest) {
- openPullRequestPaneInStore(deps.rightPane.store, pullRequest);
- return;
- }
openUrlInRightPane(deps.rightPane.store, url);
return;
}
@@ -81,14 +129,6 @@ export function runUrlLinkAction(
);
return;
}
- if (pullRequest) {
- openPullRequestPaneInStore(
- deps.store,
- pullRequest,
- action === "newTab" ? "tab" : "split",
- );
- return;
- }
openUrlInV2Workspace({
store: deps.store,
target: action === "newTab" ? "new-tab" : "current-tab",
diff --git a/bun.lock b/bun.lock
index 453258a98a6..2e513b162c9 100644
--- a/bun.lock
+++ b/bun.lock
@@ -1267,6 +1267,7 @@
"@modelcontextprotocol/sdk": "1.31.0",
"@notionhq/client": "5.25.2",
"@octokit/app": "16.1.2",
+ "@octokit/core": "7.0.8",
"@sentry/core": "10.68.0",
"@slack/web-api": "7.15.0",
"@superset/agent-harness": "workspace:*",
diff --git a/docs/cloud-sandbox-mismatches.md b/docs/cloud-sandbox-mismatches.md
index b68eaa4643b..45a39fc6b24 100644
--- a/docs/cloud-sandbox-mismatches.md
+++ b/docs/cloud-sandbox-mismatches.md
@@ -277,7 +277,10 @@ fails its first content read with a gh auth error. **What we did:** the review
run wrote a temporary `~/.config/gh/hosts.yml` from the token and deleted it
afterwards. The durable fix is for `getToolEnvironment()` to carry `GH_TOKEN`
(and `GITHUB_TOKEN`) through from the host-service process when the shell did
-not provide one.
+not provide one. Since 2026-10-22 the PR pane no longer depends on it: it reads
+and writes through the API's `integration.github.*PullRequest*` procedures as
+the signed-in person (`githubUserTokenFor`), and only falls back to the host's
+`gh` when the API cannot act at all.
## Runtime environment
diff --git a/packages/host-service/src/runtime/pull-requests/utils/pull-request-mappers/pull-request-mappers.ts b/packages/host-service/src/runtime/pull-requests/utils/pull-request-mappers/pull-request-mappers.ts
index 77a2c86fc30..dede41e771f 100644
--- a/packages/host-service/src/runtime/pull-requests/utils/pull-request-mappers/pull-request-mappers.ts
+++ b/packages/host-service/src/runtime/pull-requests/utils/pull-request-mappers/pull-request-mappers.ts
@@ -1,9 +1,15 @@
+import type { PullRequestCheck } from "@superset/shared/pull-request";
import type {
- GitHubCheckContextNode,
GitHubPullRequestNode,
GitHubPullRequestReviewDecision,
} from "../github-query";
+export {
+ computeChecksStatus,
+ parseCheckContexts,
+} from "@superset/shared/pull-request-checks";
+export type { PullRequestCheck };
+
export type PullRequestState =
| "open"
| "draft"
@@ -16,13 +22,6 @@ export type ReviewDecision =
| "pending"
| null;
export type ChecksStatus = "success" | "failure" | "pending" | "none";
-type CheckStatus = "success" | "failure" | "pending" | "skipped" | "cancelled";
-
-export interface PullRequestCheck {
- name: string;
- status: CheckStatus;
- url: string | null;
-}
export function mapPullRequestState(
state: GitHubPullRequestNode["state"],
@@ -45,64 +44,6 @@ export function mapReviewDecision(
return null;
}
-export function parseCheckContexts(
- nodes: GitHubCheckContextNode[],
-): PullRequestCheck[] {
- const checks = nodes
- .filter(
- (node): node is NonNullable => node !== null,
- )
- .map((node) => {
- if (node.__typename === "CheckRun") {
- return {
- name: node.name,
- status: mapCheckRunStatus(node.status, node.conclusion),
- url: node.detailsUrl,
- recency: getCheckRunRecency(node),
- };
- }
-
- return {
- name: node.context,
- status: mapStatusContextState(node.state),
- url: node.targetUrl,
- recency: getStatusContextRecency(node),
- };
- });
-
- const dedupedChecks = new Map<
- string,
- PullRequestCheck & {
- recency: number;
- }
- >();
- for (const check of checks) {
- const existing = dedupedChecks.get(check.name);
- if (!existing || check.recency > existing.recency) {
- dedupedChecks.set(check.name, check);
- }
- }
-
- return [...dedupedChecks.values()].map(
- ({ recency: _recency, ...check }) => check,
- );
-}
-
-export function computeChecksStatus(checks: PullRequestCheck[]): ChecksStatus {
- if (checks.length === 0) return "none";
- // A cancelled run never produced a real verdict — treat it as a failure
- // rather than falling through to "success".
- if (
- checks.some(
- (check) => check.status === "failure" || check.status === "cancelled",
- )
- ) {
- return "failure";
- }
- if (checks.some((check) => check.status === "pending")) return "pending";
- return "success";
-}
-
export function coercePullRequestState(value: string | null): PullRequestState {
if (
value === "merged" ||
@@ -152,69 +93,3 @@ export function parseChecksJson(value: string | null): PullRequestCheck[] {
return [];
}
}
-
-function mapCheckRunStatus(
- status: string,
- conclusion: string | null,
-): CheckStatus {
- if (status !== "COMPLETED") return "pending";
-
- switch (conclusion) {
- case "SUCCESS":
- return "success";
- case "FAILURE":
- case "TIMED_OUT":
- case "ACTION_REQUIRED":
- return "failure";
- case "CANCELLED":
- return "cancelled";
- case "SKIPPED":
- case "NEUTRAL":
- return "skipped";
- default:
- return "pending";
- }
-}
-
-function mapStatusContextState(state: string): CheckStatus {
- switch (state) {
- case "SUCCESS":
- return "success";
- case "FAILURE":
- case "ERROR":
- return "failure";
- case "EXPECTED":
- case "PENDING":
- return "pending";
- default:
- return "pending";
- }
-}
-
-function getCheckRunRecency(
- node: Extract,
-): number {
- const workflowRunId = node.checkSuite?.workflowRun?.databaseId;
- if (typeof workflowRunId === "number") {
- return workflowRunId;
- }
-
- const timestamp = node.completedAt ?? node.startedAt;
- if (!timestamp) {
- return 0;
- }
-
- const time = Date.parse(timestamp);
- return Number.isNaN(time) ? 0 : time;
-}
-
-function getStatusContextRecency(
- node: Extract,
-): number {
- if (!node.createdAt) {
- return 0;
- }
-
- const time = Date.parse(node.createdAt);
- return Number.isNaN(time) ? 0 : time;
-}
diff --git a/packages/host-service/src/trpc/router/git/utils/graphql.ts b/packages/host-service/src/trpc/router/git/utils/graphql.ts
index b75d16b22f6..172129a6285 100644
--- a/packages/host-service/src/trpc/router/git/utils/graphql.ts
+++ b/packages/host-service/src/trpc/router/git/utils/graphql.ts
@@ -1,89 +1,5 @@
-import type {
- DiffSide,
- PullRequestReviewComment,
- PullRequestReviewThread,
-} from "../types";
-
-export const REVIEW_THREADS_QUERY = `
- query($owner: String!, $name: String!, $prNumber: Int!) {
- repository(owner: $owner, name: $name) {
- pullRequest(number: $prNumber) {
- reviewThreads(first: 100) {
- nodes {
- id
- isResolved
- diffSide
- comments(first: 100) {
- nodes {
- id
- databaseId
- author { login avatarUrl }
- body
- createdAt
- path
- line
- originalLine
- }
- }
- }
- }
- }
- }
- }
-`;
-
-export interface GraphQLThreadsResult {
- repository: {
- pullRequest: {
- reviewThreads: {
- nodes: Array<{
- id: string;
- isResolved: boolean;
- diffSide: string;
- comments: {
- nodes: Array<{
- id: string;
- databaseId: number;
- author: { login: string; avatarUrl: string } | null;
- body: string;
- createdAt: string;
- path: string;
- line: number | null;
- originalLine: number | null;
- }>;
- };
- }>;
- };
- };
- };
-}
-
-export function parseGraphQLThreads(
- result: GraphQLThreadsResult,
-): PullRequestReviewThread[] {
- return result.repository.pullRequest.reviewThreads.nodes.map((thread) => {
- const firstComment = thread.comments.nodes[0];
- // GitHub clears `line` (keeping only `originalLine`) when a thread's
- // anchor moved or was rewritten in a later commit — that's the
- // "Outdated" signal in the Files Changed view.
- const isOutdated =
- firstComment?.line == null && firstComment?.originalLine != null;
- return {
- id: thread.id,
- isResolved: thread.isResolved,
- isOutdated,
- diffSide: (thread.diffSide === "LEFT" ? "LEFT" : "RIGHT") as DiffSide,
- line: firstComment?.line ?? firstComment?.originalLine ?? null,
- path: firstComment?.path ?? "",
- comments: thread.comments.nodes.map(
- (c): PullRequestReviewComment => ({
- id: c.id,
- databaseId: c.databaseId,
- author: c.author ?? { login: "ghost", avatarUrl: "" },
- body: c.body,
- createdAt: c.createdAt,
- }),
- ),
- };
- });
-}
+export {
+ parseReviewThreads as parseGraphQLThreads,
+ REVIEW_THREADS_QUERY,
+ type ReviewThreadsQueryResult as GraphQLThreadsResult,
+} from "@superset/shared/pull-request-threads";
diff --git a/packages/i18n/locales/cs/messages.po b/packages/i18n/locales/cs/messages.po
index 1f23f21a3e9..b8829b81c6e 100644
--- a/packages/i18n/locales/cs/messages.po
+++ b/packages/i18n/locales/cs/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Připojte externí služby a synchronizujte data."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Připojte GitHub v Integracích a přidejte {repositoryFullName}."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Připojte GitHub v Nastavení, abyste s pull requesty pracovali sami za sebe"
+
msgid "Connect GitHub…"
msgstr "Připojit GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "Tento projekt stále používá starší config.json. Dál funguje; pře
msgid "This project's host is offline"
msgstr "Host tohoto projektu je offline"
+msgid "This pull request has no GitHub access to act through."
+msgstr "K tomuto pull requestu není žádný přístup ke GitHubu, přes který by šlo jednat."
+
msgid "This pull request has no host to act through"
msgstr "Tento pull request nemá hostitele, přes kterého by bylo možné jednat"
diff --git a/packages/i18n/locales/de/messages.po b/packages/i18n/locales/de/messages.po
index eab8a483b03..303f0d1d003 100644
--- a/packages/i18n/locales/de/messages.po
+++ b/packages/i18n/locales/de/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Verbinde externe Dienste, um Daten zu synchronisieren."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Verbinde GitHub unter Integrationen, um {repositoryFullName} hinzuzufügen."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Verbinde GitHub in den Einstellungen, um Pull Requests als du selbst zu bearbeiten"
+
msgid "Connect GitHub…"
msgstr "GitHub verbinden…"
@@ -18830,6 +18833,9 @@ msgstr "Dieses Projekt verwendet noch die ältere config.json. Sie funktioniert
msgid "This project's host is offline"
msgstr "Der Host dieses Projekts ist offline"
+msgid "This pull request has no GitHub access to act through."
+msgstr "Für diesen Pull Request gibt es keinen GitHub-Zugang, über den gehandelt werden kann."
+
msgid "This pull request has no host to act through"
msgstr "Für diesen Pull Request gibt es keinen Host, über den gehandelt werden kann"
diff --git a/packages/i18n/locales/en/messages.po b/packages/i18n/locales/en/messages.po
index d1ead775843..07349a2b200 100644
--- a/packages/i18n/locales/en/messages.po
+++ b/packages/i18n/locales/en/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Connect external services to sync data."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Connect GitHub in Integrations to add {repositoryFullName}."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Connect GitHub in Settings to act on pull requests as yourself"
+
msgid "Connect GitHub…"
msgstr "Connect GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "This project still uses the older config.json. It keeps working; convert
msgid "This project's host is offline"
msgstr "This project's host is offline"
+msgid "This pull request has no GitHub access to act through."
+msgstr "This pull request has no GitHub access to act through."
+
msgid "This pull request has no host to act through"
msgstr "This pull request has no host to act through"
diff --git a/packages/i18n/locales/es/messages.po b/packages/i18n/locales/es/messages.po
index eaeab27a7a2..49e08d74866 100644
--- a/packages/i18n/locales/es/messages.po
+++ b/packages/i18n/locales/es/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Conecta servicios externos para sincronizar datos."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Conecta GitHub en Integraciones para añadir {repositoryFullName}."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Conecta GitHub en Configuración para actuar en las pull requests como tú mismo"
+
msgid "Connect GitHub…"
msgstr "Conectar GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "Este proyecto aún usa el antiguo config.json. Sigue funcionando; convi
msgid "This project's host is offline"
msgstr "El host de este proyecto está sin conexión"
+msgid "This pull request has no GitHub access to act through."
+msgstr "Esta pull request no tiene acceso a GitHub a través del cual actuar."
+
msgid "This pull request has no host to act through"
msgstr "Este pull request no tiene ningún host a través del cual actuar"
diff --git a/packages/i18n/locales/fr/messages.po b/packages/i18n/locales/fr/messages.po
index 32de3ce9274..65b14be8072 100644
--- a/packages/i18n/locales/fr/messages.po
+++ b/packages/i18n/locales/fr/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Connectez des services externes pour synchroniser vos données."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Connectez GitHub dans Intégrations pour ajouter {repositoryFullName}."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Connectez GitHub dans les Paramètres pour agir sur les pull requests en votre nom"
+
msgid "Connect GitHub…"
msgstr "Connecter GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "Ce projet utilise encore l'ancien config.json. Il fonctionne toujours ;
msgid "This project's host is offline"
msgstr "L'hôte de ce projet est hors ligne"
+msgid "This pull request has no GitHub access to act through."
+msgstr "Aucun accès GitHub ne permet d'agir sur cette pull request."
+
msgid "This pull request has no host to act through"
msgstr "Cette pull request n'a aucun hôte par lequel agir"
diff --git a/packages/i18n/locales/id/messages.po b/packages/i18n/locales/id/messages.po
index 687e3b9e7ae..694d82ceb52 100644
--- a/packages/i18n/locales/id/messages.po
+++ b/packages/i18n/locales/id/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Hubungkan layanan eksternal untuk menyinkronkan data."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Hubungkan GitHub di Integrasi untuk menambahkan {repositoryFullName}."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Hubungkan GitHub di Pengaturan untuk bertindak pada pull request atas nama Anda sendiri"
+
msgid "Connect GitHub…"
msgstr "Hubungkan GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "Proyek ini masih memakai config.json lama. File itu tetap berfungsi; kon
msgid "This project's host is offline"
msgstr "Host proyek ini sedang offline"
+msgid "This pull request has no GitHub access to act through."
+msgstr "Pull request ini tidak memiliki akses GitHub untuk bertindak."
+
msgid "This pull request has no host to act through"
msgstr "Pull request ini tidak memiliki host untuk bertindak"
diff --git a/packages/i18n/locales/it/messages.po b/packages/i18n/locales/it/messages.po
index daafaea2360..39879509d05 100644
--- a/packages/i18n/locales/it/messages.po
+++ b/packages/i18n/locales/it/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Collega servizi esterni per sincronizzare i dati."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Collega GitHub in Integrazioni per aggiungere {repositoryFullName}."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Collega GitHub nelle Impostazioni per agire sulle pull request a tuo nome"
+
msgid "Connect GitHub…"
msgstr "Collega GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "Questo progetto usa ancora il vecchio config.json. Continua a funzionare
msgid "This project's host is offline"
msgstr "L'host di questo progetto è offline"
+msgid "This pull request has no GitHub access to act through."
+msgstr "Nessun accesso GitHub consente di agire su questa pull request."
+
msgid "This pull request has no host to act through"
msgstr "Questa pull request non ha un host tramite cui agire"
diff --git a/packages/i18n/locales/ja/messages.po b/packages/i18n/locales/ja/messages.po
index f858d95378c..d5e7ce66737 100644
--- a/packages/i18n/locales/ja/messages.po
+++ b/packages/i18n/locales/ja/messages.po
@@ -4749,6 +4749,9 @@ msgstr "外部サービスを接続してデータを同期します。"
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "{repositoryFullName} を追加するには、連携で GitHub を接続してください。"
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "自分としてプルリクエストを操作するには、設定で GitHub を接続してください"
+
msgid "Connect GitHub…"
msgstr "GitHub を接続…"
@@ -18830,6 +18833,9 @@ msgstr "このプロジェクトはまだ以前の config.json を使ってい
msgid "This project's host is offline"
msgstr "このプロジェクトのホストはオフラインです"
+msgid "This pull request has no GitHub access to act through."
+msgstr "このプルリクエストを操作するための GitHub アクセスがありません。"
+
msgid "This pull request has no host to act through"
msgstr "このプルリクエストには操作に使うホストがありません"
diff --git a/packages/i18n/locales/ko/messages.po b/packages/i18n/locales/ko/messages.po
index b7e5c410ac1..f57f86636d5 100644
--- a/packages/i18n/locales/ko/messages.po
+++ b/packages/i18n/locales/ko/messages.po
@@ -4749,6 +4749,9 @@ msgstr "외부 서비스를 연결해 데이터를 동기화합니다."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "{repositoryFullName}을(를) 추가하려면 연동에서 GitHub를 연결하세요."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "본인 계정으로 풀 리퀘스트를 처리하려면 설정에서 GitHub를 연결하세요"
+
msgid "Connect GitHub…"
msgstr "GitHub 연결…"
@@ -18830,6 +18833,9 @@ msgstr "이 프로젝트는 아직 이전 config.json을 사용합니다. 계속
msgid "This project's host is offline"
msgstr "이 프로젝트의 호스트가 오프라인입니다"
+msgid "This pull request has no GitHub access to act through."
+msgstr "이 풀 리퀘스트를 처리할 GitHub 접근 권한이 없습니다."
+
msgid "This pull request has no host to act through"
msgstr "이 풀 리퀘스트에는 작업을 수행할 호스트가 없습니다"
diff --git a/packages/i18n/locales/nl/messages.po b/packages/i18n/locales/nl/messages.po
index d1741ed088f..46b6a78a98e 100644
--- a/packages/i18n/locales/nl/messages.po
+++ b/packages/i18n/locales/nl/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Verbind externe diensten om gegevens te synchroniseren."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Koppel GitHub in Integraties om {repositoryFullName} toe te voegen."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Koppel GitHub in Instellingen om als jezelf op pull requests te handelen"
+
msgid "Connect GitHub…"
msgstr "GitHub koppelen…"
@@ -18830,6 +18833,9 @@ msgstr "Dit project gebruikt nog de oudere config.json. Die blijft werken; zet h
msgid "This project's host is offline"
msgstr "De host van dit project is offline"
+msgid "This pull request has no GitHub access to act through."
+msgstr "Er is geen GitHub-toegang om op deze pull request te handelen."
+
msgid "This pull request has no host to act through"
msgstr "Deze pull request heeft geen host om via te handelen"
diff --git a/packages/i18n/locales/pl/messages.po b/packages/i18n/locales/pl/messages.po
index 55296f3377c..dc933f2af0c 100644
--- a/packages/i18n/locales/pl/messages.po
+++ b/packages/i18n/locales/pl/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Podłącz zewnętrzne usługi, aby synchronizować dane."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Połącz GitHub w Integracjach, aby dodać {repositoryFullName}."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Połącz GitHub w Ustawieniach, aby działać na pull requestach jako Ty"
+
msgid "Connect GitHub…"
msgstr "Połącz GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "Ten projekt nadal używa starszego config.json. Nadal działa; przekonwe
msgid "This project's host is offline"
msgstr "Host tego projektu jest offline"
+msgid "This pull request has no GitHub access to act through."
+msgstr "Brak dostępu do GitHuba, aby działać na tym pull requeście."
+
msgid "This pull request has no host to act through"
msgstr "Ten pull request nie ma hosta, przez który można działać"
diff --git a/packages/i18n/locales/pt-BR/messages.po b/packages/i18n/locales/pt-BR/messages.po
index b10a6ab86a7..52751cfd723 100644
--- a/packages/i18n/locales/pt-BR/messages.po
+++ b/packages/i18n/locales/pt-BR/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Conecte serviços externos para sincronizar dados."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Conecte o GitHub em Integrações para adicionar {repositoryFullName}."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Conecte o GitHub em Configurações para agir nos pull requests como você mesmo"
+
msgid "Connect GitHub…"
msgstr "Conectar GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "Este projeto ainda usa o antigo config.json. Ele continua funcionando; c
msgid "This project's host is offline"
msgstr "O host deste projeto está offline"
+msgid "This pull request has no GitHub access to act through."
+msgstr "Este pull request não tem acesso ao GitHub pelo qual agir."
+
msgid "This pull request has no host to act through"
msgstr "Este pull request não tem um host pelo qual agir"
diff --git a/packages/i18n/locales/ru/messages.po b/packages/i18n/locales/ru/messages.po
index fa11e945b89..b6bbd194720 100644
--- a/packages/i18n/locales/ru/messages.po
+++ b/packages/i18n/locales/ru/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Подключайте внешние сервисы для синхро
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Подключите GitHub в разделе «Интеграции», чтобы добавить {repositoryFullName}."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Подключите GitHub в настройках, чтобы работать с пул-реквестами от своего имени"
+
msgid "Connect GitHub…"
msgstr "Подключить GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "Этот проект всё ещё использует старый co
msgid "This project's host is offline"
msgstr "Хост этого проекта офлайн"
+msgid "This pull request has no GitHub access to act through."
+msgstr "Нет доступа к GitHub, чтобы выполнить действие с этим пул-реквестом."
+
msgid "This pull request has no host to act through"
msgstr "У этого пул-реквеста нет хоста, через который можно действовать"
diff --git a/packages/i18n/locales/tr/messages.po b/packages/i18n/locales/tr/messages.po
index 2eabcc376a1..ff2326d5153 100644
--- a/packages/i18n/locales/tr/messages.po
+++ b/packages/i18n/locales/tr/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Verileri eşitlemek için harici hizmetleri bağlayın."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "{repositoryFullName} eklemek için Entegrasyonlar'da GitHub'ı bağlayın."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Pull request'lerde kendi adınıza işlem yapmak için Ayarlar'dan GitHub'ı bağlayın"
+
msgid "Connect GitHub…"
msgstr "GitHub'ı bağla…"
@@ -18830,6 +18833,9 @@ msgstr "Bu proje hâlâ eski config.json dosyasını kullanıyor. Çalışmaya d
msgid "This project's host is offline"
msgstr "Bu projenin host'u çevrimdışı"
+msgid "This pull request has no GitHub access to act through."
+msgstr "Bu pull request üzerinde işlem yapmak için GitHub erişimi yok."
+
msgid "This pull request has no host to act through"
msgstr "Bu çekme isteğinin üzerinden işlem yapılacak bir ana makinesi yok"
diff --git a/packages/i18n/locales/vi/messages.po b/packages/i18n/locales/vi/messages.po
index 903bc47fb90..392e976a3c8 100644
--- a/packages/i18n/locales/vi/messages.po
+++ b/packages/i18n/locales/vi/messages.po
@@ -4749,6 +4749,9 @@ msgstr "Kết nối dịch vụ bên ngoài để đồng bộ dữ liệu."
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Kết nối GitHub trong Tích hợp để thêm {repositoryFullName}."
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "Kết nối GitHub trong Cài đặt để thao tác với pull request dưới tên của bạn"
+
msgid "Connect GitHub…"
msgstr "Kết nối GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "Dự án này vẫn dùng config.json cũ. Nó vẫn hoạt động; hã
msgid "This project's host is offline"
msgstr "Host của dự án này đang ngoại tuyến"
+msgid "This pull request has no GitHub access to act through."
+msgstr "Không có quyền truy cập GitHub để thao tác với pull request này."
+
msgid "This pull request has no host to act through"
msgstr "Pull request này không có máy chủ để thực hiện thao tác"
diff --git a/packages/i18n/locales/zh-CN/messages.po b/packages/i18n/locales/zh-CN/messages.po
index d43217b549f..6235be51556 100644
--- a/packages/i18n/locales/zh-CN/messages.po
+++ b/packages/i18n/locales/zh-CN/messages.po
@@ -4749,6 +4749,9 @@ msgstr "连接外部服务以同步数据。"
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "在集成中连接 GitHub 以添加 {repositoryFullName}。"
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "在设置中连接 GitHub,以你自己的身份处理拉取请求"
+
msgid "Connect GitHub…"
msgstr "连接 GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "此项目仍在使用旧的 config.json。它仍可正常工作;转换
msgid "This project's host is offline"
msgstr "此项目的主机已离线"
+msgid "This pull request has no GitHub access to act through."
+msgstr "没有可用于处理此拉取请求的 GitHub 访问权限。"
+
msgid "This pull request has no host to act through"
msgstr "此拉取请求没有可用于操作的主机"
diff --git a/packages/i18n/locales/zh-TW/messages.po b/packages/i18n/locales/zh-TW/messages.po
index 1c039c12fa3..31a29ac5575 100644
--- a/packages/i18n/locales/zh-TW/messages.po
+++ b/packages/i18n/locales/zh-TW/messages.po
@@ -4749,6 +4749,9 @@ msgstr "連線外部服務以同步資料。"
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "在整合中連結 GitHub 以新增 {repositoryFullName}。"
+msgid "Connect GitHub in Settings to act on pull requests as yourself"
+msgstr "在設定中連接 GitHub,以你自己的身分處理拉取請求"
+
msgid "Connect GitHub…"
msgstr "連結 GitHub…"
@@ -18830,6 +18833,9 @@ msgstr "此專案仍在使用舊的 config.json。它仍可正常運作;轉換
msgid "This project's host is offline"
msgstr "此專案的主機已離線"
+msgid "This pull request has no GitHub access to act through."
+msgstr "沒有可用於處理此拉取請求的 GitHub 存取權限。"
+
msgid "This pull request has no host to act through"
msgstr "此提取請求沒有可用於操作的主機"
diff --git a/packages/i18n/src/server-errors.ts b/packages/i18n/src/server-errors.ts
index a274926b844..7b6f8044c71 100644
--- a/packages/i18n/src/server-errors.ts
+++ b/packages/i18n/src/server-errors.ts
@@ -439,6 +439,13 @@ export const serverErrorMessages: Record<
message: "Connecting GitHub is not configured on this server",
}),
),
+ "serverError.githubUser.notConnected": () =>
+ i18n._(
+ msg({
+ message:
+ "Connect GitHub in Settings to act on pull requests as yourself",
+ }),
+ ),
"serverError.cloudWorkspace.githubRepositoryOutOfReach": () =>
i18n._(
msg({
@@ -605,6 +612,12 @@ export const serverErrorMessages: Record<
message: "Not a member of this organization",
}),
),
+ "serverError.integration.pullRequestNotFound": () =>
+ i18n._(
+ msg({
+ message: "Pull request not found",
+ }),
+ ),
"serverError.integration.onlyOwnersCanDeleteProjects": () =>
i18n._(
msg({
diff --git a/packages/shared/package.json b/packages/shared/package.json
index 1515186d436..5de8d115253 100644
--- a/packages/shared/package.json
+++ b/packages/shared/package.json
@@ -189,6 +189,14 @@
"types": "./src/pull-request.ts",
"default": "./src/pull-request.ts"
},
+ "./pull-request-checks": {
+ "types": "./src/pull-request-checks/index.ts",
+ "default": "./src/pull-request-checks/index.ts"
+ },
+ "./pull-request-threads": {
+ "types": "./src/pull-request-threads/index.ts",
+ "default": "./src/pull-request-threads/index.ts"
+ },
"./sandbox-gate": {
"types": "./src/sandbox-gate.ts",
"default": "./src/sandbox-gate.ts"
diff --git a/packages/shared/src/pull-request-checks/index.ts b/packages/shared/src/pull-request-checks/index.ts
new file mode 100644
index 00000000000..6873cc66bd0
--- /dev/null
+++ b/packages/shared/src/pull-request-checks/index.ts
@@ -0,0 +1,7 @@
+export {
+ type CheckContextNode,
+ type CheckRunNode,
+ computeChecksStatus,
+ parseCheckContexts,
+ type StatusContextNode,
+} from "./pull-request-checks";
diff --git a/packages/shared/src/pull-request-checks/pull-request-checks.ts b/packages/shared/src/pull-request-checks/pull-request-checks.ts
new file mode 100644
index 00000000000..6875fe1cf24
--- /dev/null
+++ b/packages/shared/src/pull-request-checks/pull-request-checks.ts
@@ -0,0 +1,130 @@
+import type {
+ PullRequestCheck,
+ PullRequestCheckStatus,
+ PullRequestChecksStatus,
+} from "../pull-request";
+
+/** GitHub GraphQL `StatusCheckRollupContext` nodes, as `gh pr view --json statusCheckRollup` also prints them. */
+export interface CheckRunNode {
+ __typename: "CheckRun";
+ name: string;
+ conclusion: string | null;
+ detailsUrl: string | null;
+ status: string;
+ startedAt: string | null;
+ completedAt: string | null;
+ checkSuite: {
+ workflowRun: {
+ databaseId: number | null;
+ } | null;
+ } | null;
+}
+
+export interface StatusContextNode {
+ __typename: "StatusContext";
+ context: string;
+ state: string;
+ targetUrl: string | null;
+ createdAt: string | null;
+}
+
+export type CheckContextNode = CheckRunNode | StatusContextNode;
+
+function mapCheckRunStatus(
+ status: string,
+ conclusion: string | null,
+): PullRequestCheckStatus {
+ if (status !== "COMPLETED") return "pending";
+
+ switch (conclusion) {
+ case "SUCCESS":
+ return "success";
+ case "FAILURE":
+ case "TIMED_OUT":
+ case "ACTION_REQUIRED":
+ return "failure";
+ case "CANCELLED":
+ return "cancelled";
+ case "SKIPPED":
+ case "NEUTRAL":
+ return "skipped";
+ default:
+ return "pending";
+ }
+}
+
+function mapStatusContextState(state: string): PullRequestCheckStatus {
+ switch (state) {
+ case "SUCCESS":
+ return "success";
+ case "FAILURE":
+ case "ERROR":
+ return "failure";
+ default:
+ return "pending";
+ }
+}
+
+function parseTime(timestamp: string | null): number {
+ if (!timestamp) return 0;
+ const time = Date.parse(timestamp);
+ return Number.isNaN(time) ? 0 : time;
+}
+
+function getCheckRunRecency(node: CheckRunNode): number {
+ const workflowRunId = node.checkSuite?.workflowRun?.databaseId;
+ if (typeof workflowRunId === "number") return workflowRunId;
+ return parseTime(node.completedAt ?? node.startedAt);
+}
+
+/** One row per check name; a re-run replaces the run it supersedes. */
+export function parseCheckContexts(
+ nodes: readonly (CheckContextNode | null)[],
+): PullRequestCheck[] {
+ const checks = nodes
+ .filter((node): node is CheckContextNode => node !== null)
+ .map((node) =>
+ node.__typename === "CheckRun"
+ ? {
+ name: node.name,
+ status: mapCheckRunStatus(node.status, node.conclusion),
+ url: node.detailsUrl,
+ recency: getCheckRunRecency(node),
+ }
+ : {
+ name: node.context,
+ status: mapStatusContextState(node.state),
+ url: node.targetUrl,
+ recency: parseTime(node.createdAt),
+ },
+ );
+
+ const dedupedChecks = new Map();
+ for (const check of checks) {
+ const existing = dedupedChecks.get(check.name);
+ if (!existing || check.recency > existing.recency) {
+ dedupedChecks.set(check.name, check);
+ }
+ }
+
+ return [...dedupedChecks.values()].map(
+ ({ recency: _recency, ...check }) => check,
+ );
+}
+
+export function computeChecksStatus(
+ checks: readonly PullRequestCheck[],
+): PullRequestChecksStatus {
+ if (checks.length === 0) return "none";
+ // A cancelled run never produced a real verdict — treat it as a failure
+ // rather than falling through to "success".
+ if (
+ checks.some(
+ (check) => check.status === "failure" || check.status === "cancelled",
+ )
+ ) {
+ return "failure";
+ }
+ if (checks.some((check) => check.status === "pending")) return "pending";
+ return "success";
+}
diff --git a/packages/shared/src/pull-request-threads/index.ts b/packages/shared/src/pull-request-threads/index.ts
new file mode 100644
index 00000000000..73620e1e040
--- /dev/null
+++ b/packages/shared/src/pull-request-threads/index.ts
@@ -0,0 +1,8 @@
+export {
+ type DiffSide,
+ type PullRequestReviewComment,
+ type PullRequestReviewThread,
+ parseReviewThreads,
+ REVIEW_THREADS_QUERY,
+ type ReviewThreadsQueryResult,
+} from "./pull-request-threads";
diff --git a/packages/shared/src/pull-request-threads/pull-request-threads.ts b/packages/shared/src/pull-request-threads/pull-request-threads.ts
new file mode 100644
index 00000000000..1ea82c01850
--- /dev/null
+++ b/packages/shared/src/pull-request-threads/pull-request-threads.ts
@@ -0,0 +1,104 @@
+/** GitHub GraphQL: DiffSide */
+export type DiffSide = "LEFT" | "RIGHT";
+
+export interface PullRequestReviewComment {
+ id: string;
+ databaseId: number;
+ author: { login: string; avatarUrl: string };
+ body: string;
+ createdAt: string;
+}
+
+export interface PullRequestReviewThread {
+ id: string;
+ isResolved: boolean;
+ isOutdated: boolean;
+ diffSide: DiffSide;
+ line: number | null;
+ path: string;
+ comments: PullRequestReviewComment[];
+}
+
+export const REVIEW_THREADS_QUERY = `
+ query($owner: String!, $name: String!, $prNumber: Int!) {
+ repository(owner: $owner, name: $name) {
+ pullRequest(number: $prNumber) {
+ reviewThreads(first: 100) {
+ nodes {
+ id
+ isResolved
+ diffSide
+ comments(first: 100) {
+ nodes {
+ id
+ databaseId
+ author { login avatarUrl }
+ body
+ createdAt
+ path
+ line
+ originalLine
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+`;
+
+export interface ReviewThreadsQueryResult {
+ repository: {
+ pullRequest: {
+ reviewThreads: {
+ nodes: Array<{
+ id: string;
+ isResolved: boolean;
+ diffSide: string;
+ comments: {
+ nodes: Array<{
+ id: string;
+ databaseId: number;
+ author: { login: string; avatarUrl: string } | null;
+ body: string;
+ createdAt: string;
+ path: string;
+ line: number | null;
+ originalLine: number | null;
+ }>;
+ };
+ }>;
+ };
+ };
+ };
+}
+
+export function parseReviewThreads(
+ result: ReviewThreadsQueryResult,
+): PullRequestReviewThread[] {
+ return result.repository.pullRequest.reviewThreads.nodes.map((thread) => {
+ const firstComment = thread.comments.nodes[0];
+ // GitHub clears `line` (keeping only `originalLine`) when a thread's
+ // anchor moved or was rewritten in a later commit — that's the
+ // "Outdated" signal in the Files Changed view.
+ const isOutdated =
+ firstComment?.line == null && firstComment?.originalLine != null;
+ return {
+ id: thread.id,
+ isResolved: thread.isResolved,
+ isOutdated,
+ diffSide: thread.diffSide === "LEFT" ? "LEFT" : "RIGHT",
+ line: firstComment?.line ?? firstComment?.originalLine ?? null,
+ path: firstComment?.path ?? "",
+ comments: thread.comments.nodes.map(
+ (comment): PullRequestReviewComment => ({
+ id: comment.id,
+ databaseId: comment.databaseId,
+ author: comment.author ?? { login: "ghost", avatarUrl: "" },
+ body: comment.body,
+ createdAt: comment.createdAt,
+ }),
+ ),
+ };
+ });
+}
diff --git a/packages/shared/src/pull-request.ts b/packages/shared/src/pull-request.ts
index 52910945574..04a9d3409ef 100644
--- a/packages/shared/src/pull-request.ts
+++ b/packages/shared/src/pull-request.ts
@@ -46,3 +46,58 @@ export interface PullRequestDetail {
createdAt: string;
updatedAt: string;
}
+
+export type PullRequestMergeability = "mergeable" | "conflicting" | "unknown";
+
+export interface PullRequestActor {
+ login: string;
+ name: string | null;
+}
+
+export interface PullRequestConversationComment {
+ id: string;
+ kind: "comment" | "review";
+ author: PullRequestActor | null;
+ body: string;
+ createdAt: string;
+ /** GitHub review state (APPROVED, CHANGES_REQUESTED, COMMENTED…); null for plain comments. */
+ reviewState: string | null;
+ /** The comment's own page on GitHub; reviews carry none. */
+ url: string | null;
+}
+
+export interface PullRequestCommitAuthor {
+ /** Null when GitHub maps the commit's email to no account. */
+ login: string | null;
+ name: string | null;
+}
+
+export interface PullRequestCommit {
+ oid: string;
+ messageHeadline: string;
+ committedDate: string;
+ author: PullRequestCommitAuthor | null;
+ /** The commit on the pull request's own commits page, which also serves fork commits. */
+ url: string;
+}
+
+export interface PullRequestLabel {
+ name: string;
+ color: string | null;
+}
+
+/** What a full read adds over the detail: size, mergeability, people, and the conversation so far. */
+export interface PullRequestActivity {
+ additions: number;
+ deletions: number;
+ changedFiles: number;
+ mergeability: PullRequestMergeability;
+ mergedAt: string | null;
+ closedAt: string | null;
+ reviewers: PullRequestActor[];
+ comments: PullRequestConversationComment[];
+ commits: PullRequestCommit[];
+ labels: PullRequestLabel[];
+}
+
+export type PullRequestContent = PullRequestDetail & PullRequestActivity;
diff --git a/packages/trpc/package.json b/packages/trpc/package.json
index 1b55fab83e3..45c38f509a4 100644
--- a/packages/trpc/package.json
+++ b/packages/trpc/package.json
@@ -158,6 +158,7 @@
"@modelcontextprotocol/sdk": "1.31.0",
"@notionhq/client": "5.25.2",
"@octokit/app": "16.1.2",
+ "@octokit/core": "7.0.8",
"@sentry/core": "10.68.0",
"@slack/web-api": "7.15.0",
"@superset/agent-harness": "workspace:*",
diff --git a/packages/trpc/src/router/integration/github/get-pull-request-diff.ts b/packages/trpc/src/router/integration/github/get-pull-request-diff.ts
index a71760432c4..c20484edd14 100644
--- a/packages/trpc/src/router/integration/github/get-pull-request-diff.ts
+++ b/packages/trpc/src/router/integration/github/get-pull-request-diff.ts
@@ -4,10 +4,9 @@ import {
type PullRequestDiff,
} from "@superset/shared/pull-request-diff";
import { z } from "zod";
-import { installationOctokit } from "../../../lib/sandbox/clone-token";
import { protectedProcedure } from "../../../trpc";
import { verifyOrgMembership } from "../utils";
-import { findInstalledRepository } from "./find-installed-repository";
+import { viewerOctokit } from "./viewer-octokit";
export const getPullRequestDiff = protectedProcedure
.input(
@@ -19,12 +18,12 @@ export const getPullRequestDiff = protectedProcedure
)
.query(async ({ ctx, input }): Promise => {
await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const { installation, repo } = await findInstalledRepository(
- input.organizationId,
- input.repoFullName,
- );
- const [owner, name] = repo.fullName.split("/");
- const octokit = await installationOctokit(installation.installationId);
+ const { octokit } = await viewerOctokit({
+ userId: ctx.session.user.id,
+ organizationId: input.organizationId,
+ repoFullName: input.repoFullName,
+ });
+ const [owner, name] = input.repoFullName.split("/");
const pullRequest = {
owner: owner ?? "",
repo: name ?? "",
diff --git a/packages/trpc/src/router/integration/github/github-request-error.test.ts b/packages/trpc/src/router/integration/github/github-request-error.test.ts
new file mode 100644
index 00000000000..7a514aebf90
--- /dev/null
+++ b/packages/trpc/src/router/integration/github/github-request-error.test.ts
@@ -0,0 +1,27 @@
+import { expect, test } from "bun:test";
+import { githubRequestError } from "./github-request-error";
+
+test("GitHub's status becomes the error code the desktop branches on", () => {
+ expect(
+ githubRequestError(
+ Object.assign(new Error("not mergeable"), { status: 405 }),
+ "x",
+ ).code,
+ ).toBe("CONFLICT");
+ expect(githubRequestError({ status: 404 }, "fallback")).toMatchObject({
+ code: "NOT_FOUND",
+ message: "fallback",
+ });
+ expect(
+ githubRequestError({ errors: [{ message: "already a draft" }] }, "x").code,
+ ).toBe("BAD_REQUEST");
+ expect(
+ githubRequestError(
+ { errors: [{ type: "NOT_FOUND", message: "Could not resolve" }] },
+ "x",
+ ).code,
+ ).toBe("NOT_FOUND");
+ expect(githubRequestError(new Error("boom"), "x").code).toBe(
+ "INTERNAL_SERVER_ERROR",
+ );
+});
diff --git a/packages/trpc/src/router/integration/github/github-request-error.ts b/packages/trpc/src/router/integration/github/github-request-error.ts
new file mode 100644
index 00000000000..d2c5f1888a4
--- /dev/null
+++ b/packages/trpc/src/router/integration/github/github-request-error.ts
@@ -0,0 +1,58 @@
+import { TRPCError } from "@trpc/server";
+
+/** GitHub's answer to a write, as the error code the desktop branches on. */
+export function githubRequestError(
+ error: unknown,
+ fallback: string,
+): TRPCError {
+ if (error instanceof TRPCError) return error;
+
+ const status =
+ typeof error === "object" && error !== null && "status" in error
+ ? Number((error as { status: unknown }).status)
+ : null;
+ const message =
+ error instanceof Error && error.message ? error.message : fallback;
+
+ // GraphQL rejections arrive as errors in a 200 response — no status, but
+ // still the PR's state talking (already merged, not a draft, no access).
+ if (
+ status === null &&
+ typeof error === "object" &&
+ error !== null &&
+ "errors" in error
+ ) {
+ const types = new Set(
+ (Array.isArray(error.errors) ? error.errors : []).map(
+ (entry: { type?: unknown }) => entry?.type,
+ ),
+ );
+ const code = types.has("NOT_FOUND")
+ ? "NOT_FOUND"
+ : types.has("FORBIDDEN")
+ ? "FORBIDDEN"
+ : "BAD_REQUEST";
+ return new TRPCError({ code, message, cause: error });
+ }
+
+ switch (status) {
+ // 405 not mergeable (conflicts/draft), 409 head branch moved on.
+ case 405:
+ case 409:
+ return new TRPCError({ code: "CONFLICT", message, cause: error });
+ case 401:
+ return new TRPCError({ code: "UNAUTHORIZED", message, cause: error });
+ case 403:
+ return new TRPCError({ code: "FORBIDDEN", message, cause: error });
+ case 404:
+ return new TRPCError({ code: "NOT_FOUND", message, cause: error });
+ case 422:
+ return new TRPCError({ code: "BAD_REQUEST", message, cause: error });
+ default:
+ return new TRPCError({
+ code: "INTERNAL_SERVER_ERROR",
+ message,
+ cause: error,
+ });
+ }
+}
diff --git a/packages/trpc/src/router/integration/github/github.ts b/packages/trpc/src/router/integration/github/github.ts
index 1d55af06e6d..380f3ae342d 100644
--- a/packages/trpc/src/router/integration/github/github.ts
+++ b/packages/trpc/src/router/integration/github/github.ts
@@ -19,6 +19,7 @@ import {
import { verifyOrgAdmin, verifyOrgMembership } from "../utils";
import { findInstalledRepository } from "./find-installed-repository";
import { getPullRequestDiff } from "./get-pull-request-diff";
+import { pullRequestProcedures } from "./pull-request-procedures";
import {
type PullRequestDetail,
toChecks,
@@ -31,6 +32,7 @@ import { listGithubRepositories } from "./trigger-options";
const qstash = new Client({ token: env.QSTASH_TOKEN });
export const githubRouter = {
+ ...pullRequestProcedures,
getPullRequestDiff,
getInstallation: protectedProcedure
.input(z.object({ organizationId: z.string().uuid() }))
diff --git a/packages/trpc/src/router/integration/github/pull-request-content.test.ts b/packages/trpc/src/router/integration/github/pull-request-content.test.ts
new file mode 100644
index 00000000000..ba97a58fb27
--- /dev/null
+++ b/packages/trpc/src/router/integration/github/pull-request-content.test.ts
@@ -0,0 +1,185 @@
+import { describe, expect, test } from "bun:test";
+import {
+ pullRequestContentQuerySchema,
+ toPullRequestContent,
+} from "./pull-request-content";
+
+const node = {
+ number: 12,
+ title: "Read pull requests as the viewer",
+ body: null,
+ url: "https://github.com/owner/repo/pull/12",
+ state: "OPEN",
+ isDraft: false,
+ createdAt: "2026-10-01T10:00:00Z",
+ updatedAt: "2026-10-02T10:00:00Z",
+ mergedAt: null,
+ closedAt: null,
+ mergeable: "CONFLICTING",
+ additions: 10,
+ deletions: -1,
+ changedFiles: 2,
+ reviewDecision: "CHANGES_REQUESTED",
+ headRefName: "feat/viewer",
+ baseRefName: "main",
+ isCrossRepository: true,
+ headRepository: { nameWithOwner: "fork/repo" },
+ author: { login: "satya", avatarUrl: "https://avatars/satya" },
+ labels: { nodes: [{ name: "desktop", color: "1d76db" }, null] },
+ reviewRequests: {
+ nodes: [
+ { requestedReviewer: { login: "reviewer", name: "Rev Ewer" } },
+ { requestedReviewer: null },
+ ],
+ },
+ reviews: {
+ nodes: [
+ {
+ id: "R1",
+ author: { login: "Reviewer", name: null },
+ body: "Please fix",
+ state: "CHANGES_REQUESTED",
+ submittedAt: "2026-10-02T09:00:00Z",
+ },
+ { id: "R2", author: { login: "pending" }, body: "", submittedAt: null },
+ ],
+ },
+ comments: {
+ nodes: [
+ {
+ id: "C1",
+ author: { login: "satya" },
+ body: "On it",
+ createdAt: "2026-10-02T09:30:00Z",
+ url: "https://github.com/owner/repo/pull/12#issuecomment-1",
+ },
+ ],
+ },
+ commits: {
+ nodes: [
+ {
+ commit: {
+ oid: "abc123",
+ messageHeadline: "feat: viewer reads ",
+ committedDate: "2026-10-01T09:00:00Z",
+ authors: {
+ nodes: [
+ { name: "Satya", user: null },
+ { name: null, user: null },
+ ],
+ },
+ },
+ },
+ {
+ commit: { oid: "nodate", messageHeadline: "x", committedDate: null },
+ },
+ ],
+ },
+ lastCommit: {
+ nodes: [
+ {
+ commit: {
+ statusCheckRollup: {
+ contexts: {
+ nodes: [
+ {
+ __typename: "CheckRun",
+ name: "ci",
+ status: "COMPLETED",
+ conclusion: "FAILURE",
+ detailsUrl: "https://ci/1",
+ checkSuite: { workflowRun: { databaseId: 1 } },
+ },
+ {
+ __typename: "CheckRun",
+ name: "ci",
+ status: "COMPLETED",
+ conclusion: "SUCCESS",
+ detailsUrl: "https://ci/2",
+ checkSuite: { workflowRun: { databaseId: 2 } },
+ },
+ {
+ __typename: "StatusContext",
+ context: "lint",
+ state: "PENDING",
+ targetUrl: null,
+ },
+ ],
+ },
+ },
+ },
+ },
+ ],
+ },
+};
+
+describe("toPullRequestContent", () => {
+ test("maps the GraphQL node to the shared pull request content", () => {
+ const parsed = pullRequestContentQuerySchema.parse({
+ repository: { pullRequest: node },
+ });
+ const content = toPullRequestContent(
+ parsed.repository?.pullRequest as NonNullable<
+ NonNullable["pullRequest"]
+ >,
+ "owner/repo",
+ );
+ expect(content).toMatchObject({
+ repoFullName: "owner/repo",
+ number: 12,
+ body: "",
+ state: "open",
+ author: { login: "satya", avatarUrl: "https://avatars/satya" },
+ head: { ref: "feat/viewer", repoFullName: "fork/repo" },
+ base: { ref: "main" },
+ reviewDecision: "changes_requested",
+ checksStatus: "pending",
+ additions: 10,
+ deletions: 0,
+ changedFiles: 2,
+ mergeability: "conflicting",
+ labels: [{ name: "desktop", color: "1d76db" }],
+ });
+ // The re-run replaces the failed run of the same name.
+ expect(content.checks).toEqual([
+ { name: "ci", status: "success", url: "https://ci/2" },
+ { name: "lint", status: "pending", url: null },
+ ]);
+ expect(content.reviewers).toEqual([
+ { login: "reviewer", name: "Rev Ewer" },
+ ]);
+ expect(content.comments.map((c) => [c.kind, c.id, c.reviewState])).toEqual([
+ ["comment", "C1", null],
+ ["review", "R1", "CHANGES_REQUESTED"],
+ ]);
+ expect(content.commits).toEqual([
+ {
+ oid: "abc123",
+ messageHeadline: "feat: viewer reads",
+ committedDate: "2026-10-01T09:00:00Z",
+ author: { login: null, name: "Satya" },
+ url: "https://github.com/owner/repo/pull/12/commits/abc123",
+ },
+ ]);
+ });
+
+ test("a merged pull request reads as merged even when GitHub says closed", () => {
+ const parsed = pullRequestContentQuerySchema.parse({
+ repository: {
+ pullRequest: {
+ ...node,
+ state: "CLOSED",
+ mergedAt: "2026-10-03T00:00:00Z",
+ lastCommit: null,
+ },
+ },
+ });
+ const pullRequest = parsed.repository?.pullRequest;
+ if (!pullRequest) throw new Error("expected a pull request");
+ const content = toPullRequestContent(pullRequest, "owner/repo");
+ expect(content.state).toBe("merged");
+ expect(content.mergedAt).toBe("2026-10-03T00:00:00Z");
+ expect(content.checks).toEqual([]);
+ expect(content.checksStatus).toBe("none");
+ });
+});
diff --git a/packages/trpc/src/router/integration/github/pull-request-content.ts b/packages/trpc/src/router/integration/github/pull-request-content.ts
new file mode 100644
index 00000000000..5bc1d29a5ef
--- /dev/null
+++ b/packages/trpc/src/router/integration/github/pull-request-content.ts
@@ -0,0 +1,344 @@
+import type {
+ PullRequestActor,
+ PullRequestCommit,
+ PullRequestCommitAuthor,
+ PullRequestContent,
+ PullRequestConversationComment,
+ PullRequestMergeability,
+} from "@superset/shared/pull-request";
+import {
+ computeChecksStatus,
+ parseCheckContexts,
+} from "@superset/shared/pull-request-checks";
+import { z } from "zod";
+import { toPullRequestState, toReviewDecision } from "./pull-request-shape";
+
+/** The fields `gh pr view --json` reads, asked for in one request. */
+export const PULL_REQUEST_CONTENT_QUERY = `
+ query($owner: String!, $name: String!, $number: Int!) {
+ repository(owner: $owner, name: $name) {
+ pullRequest(number: $number) {
+ number title body url state isDraft createdAt updatedAt mergedAt closedAt
+ mergeable additions deletions changedFiles reviewDecision
+ headRefName baseRefName isCrossRepository
+ headRepository { nameWithOwner }
+ author { login avatarUrl }
+ labels(first: 50) { nodes { name color } }
+ reviewRequests(first: 50) {
+ nodes {
+ requestedReviewer {
+ ... on User { login name }
+ ... on Mannequin { login }
+ ... on Team { login: slug name }
+ }
+ }
+ }
+ reviews(first: 100) {
+ nodes { id author { login ... on User { name } } body state submittedAt }
+ }
+ comments(first: 100) {
+ nodes { id author { login ... on User { name } } body createdAt url }
+ }
+ commits(last: 100) {
+ nodes {
+ commit {
+ oid messageHeadline committedDate
+ authors(first: 3) { nodes { name user { login } } }
+ }
+ }
+ }
+ lastCommit: commits(last: 1) {
+ nodes {
+ commit {
+ statusCheckRollup {
+ contexts(first: 100) {
+ nodes {
+ __typename
+ ... on CheckRun {
+ name status conclusion detailsUrl startedAt completedAt
+ checkSuite { workflowRun { databaseId } }
+ }
+ ... on StatusContext { context state targetUrl createdAt }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+`;
+
+const actorSchema = z
+ .object({
+ login: z.string().nullable().optional(),
+ name: z.string().nullable().optional(),
+ avatarUrl: z.string().nullable().optional(),
+ })
+ .nullable()
+ .optional();
+
+const nodes = (node: T) =>
+ z
+ .object({ nodes: z.array(node.nullable()).nullable().optional() })
+ .nullable()
+ .optional();
+
+const checkRunNode = z.object({
+ __typename: z.literal("CheckRun"),
+ name: z.string(),
+ status: z.string(),
+ conclusion: z.string().nullable().optional(),
+ detailsUrl: z.string().nullable().optional(),
+ startedAt: z.string().nullable().optional(),
+ completedAt: z.string().nullable().optional(),
+ checkSuite: z
+ .object({
+ workflowRun: z.object({ databaseId: z.number().nullable() }).nullable(),
+ })
+ .nullable()
+ .optional(),
+});
+const statusContextNode = z.object({
+ __typename: z.literal("StatusContext"),
+ context: z.string(),
+ state: z.string(),
+ targetUrl: z.string().nullable().optional(),
+ createdAt: z.string().nullable().optional(),
+});
+
+export const pullRequestContentNodeSchema = z.object({
+ number: z.number(),
+ title: z.string(),
+ body: z.string().nullable().optional(),
+ url: z.string(),
+ state: z.string(),
+ isDraft: z.boolean(),
+ createdAt: z.string(),
+ updatedAt: z.string(),
+ mergedAt: z.string().nullable().optional(),
+ closedAt: z.string().nullable().optional(),
+ mergeable: z.string().nullable().optional(),
+ additions: z.number().nullable().optional(),
+ deletions: z.number().nullable().optional(),
+ changedFiles: z.number().nullable().optional(),
+ reviewDecision: z.string().nullable().optional(),
+ headRefName: z.string(),
+ baseRefName: z.string(),
+ isCrossRepository: z.boolean(),
+ headRepository: z.object({ nameWithOwner: z.string() }).nullable().optional(),
+ author: actorSchema,
+ labels: nodes(
+ z.object({ name: z.string(), color: z.string().nullable().optional() }),
+ ),
+ reviewRequests: nodes(z.object({ requestedReviewer: actorSchema })),
+ reviews: nodes(
+ z.object({
+ id: z.string(),
+ author: actorSchema,
+ body: z.string().nullable().optional(),
+ state: z.string().nullable().optional(),
+ submittedAt: z.string().nullable().optional(),
+ }),
+ ),
+ comments: nodes(
+ z.object({
+ id: z.string(),
+ author: actorSchema,
+ body: z.string().nullable().optional(),
+ createdAt: z.string(),
+ url: z.string().nullable().optional(),
+ }),
+ ),
+ commits: nodes(
+ z.object({
+ commit: z.object({
+ oid: z.string(),
+ messageHeadline: z.string().nullable().optional(),
+ committedDate: z.string().nullable().optional(),
+ authors: nodes(
+ z.object({
+ name: z.string().nullable().optional(),
+ user: z.object({ login: z.string() }).nullable().optional(),
+ }),
+ ),
+ }),
+ }),
+ ),
+ lastCommit: nodes(
+ z.object({
+ commit: z.object({
+ statusCheckRollup: z
+ .object({
+ contexts: nodes(
+ z.discriminatedUnion("__typename", [
+ checkRunNode,
+ statusContextNode,
+ ]),
+ ),
+ })
+ .nullable()
+ .optional(),
+ }),
+ }),
+ ),
+});
+
+export const pullRequestContentQuerySchema = z.object({
+ repository: z
+ .object({ pullRequest: pullRequestContentNodeSchema.nullable() })
+ .nullable(),
+});
+
+export type PullRequestContentNode = z.infer<
+ typeof pullRequestContentNodeSchema
+>;
+
+function listOf(
+ connection: { nodes?: (T | null)[] | null } | null | undefined,
+): T[] {
+ return (connection?.nodes ?? []).filter((node): node is T => node !== null);
+}
+
+function toActor(actor: z.infer): PullRequestActor | null {
+ const login = actor?.login?.trim();
+ if (!login) return null;
+ return { login, name: actor?.name?.trim() || null };
+}
+
+function toMergeability(
+ mergeable: string | null | undefined,
+): PullRequestMergeability {
+ switch (mergeable?.toUpperCase()) {
+ case "MERGEABLE":
+ return "mergeable";
+ case "CONFLICTING":
+ return "conflicting";
+ default:
+ return "unknown";
+ }
+}
+
+function count(value: number | null | undefined): number {
+ return typeof value === "number" && value > 0 ? Math.floor(value) : 0;
+}
+
+export function toPullRequestContent(
+ node: PullRequestContentNode,
+ repoFullName: string,
+): PullRequestContent {
+ const contexts = listOf(
+ listOf(node.lastCommit)[0]?.commit.statusCheckRollup?.contexts,
+ ).map((context) =>
+ context.__typename === "CheckRun"
+ ? {
+ ...context,
+ conclusion: context.conclusion ?? null,
+ detailsUrl: context.detailsUrl ?? null,
+ startedAt: context.startedAt ?? null,
+ completedAt: context.completedAt ?? null,
+ checkSuite: context.checkSuite ?? null,
+ }
+ : {
+ ...context,
+ targetUrl: context.targetUrl ?? null,
+ createdAt: context.createdAt ?? null,
+ },
+ );
+ const checks = parseCheckContexts(contexts);
+ const reviews = listOf(node.reviews).filter((review) => review.submittedAt);
+
+ const reviewers = new Map();
+ for (const actor of [
+ ...listOf(node.reviewRequests).map((request) => request.requestedReviewer),
+ ...reviews.map((review) => review.author),
+ ]) {
+ const reviewer = toActor(actor);
+ if (!reviewer) continue;
+ const known = reviewers.get(reviewer.login.toLowerCase());
+ if (!known || (!known.name && reviewer.name)) {
+ reviewers.set(reviewer.login.toLowerCase(), reviewer);
+ }
+ }
+
+ const comments: PullRequestConversationComment[] = [
+ ...listOf(node.comments).map((comment) => ({
+ id: comment.id,
+ kind: "comment" as const,
+ author: toActor(comment.author),
+ body: comment.body ?? "",
+ createdAt: comment.createdAt,
+ reviewState: null,
+ url: comment.url?.trim() || null,
+ })),
+ ...reviews.map((review) => ({
+ id: review.id,
+ kind: "review" as const,
+ author: toActor(review.author),
+ body: review.body ?? "",
+ createdAt: review.submittedAt as string,
+ reviewState: review.state?.trim() || null,
+ url: null,
+ })),
+ ];
+
+ const commits: PullRequestCommit[] = listOf(node.commits).flatMap(
+ ({ commit }) => {
+ if (!commit.committedDate) return [];
+ const author = listOf(commit.authors)
+ .map(
+ (entry): PullRequestCommitAuthor => ({
+ login: entry.user?.login?.trim() || null,
+ name: entry.name?.trim() || null,
+ }),
+ )
+ .find((entry) => entry.login || entry.name);
+ return [
+ {
+ oid: commit.oid,
+ messageHeadline: commit.messageHeadline?.trim() ?? "",
+ committedDate: commit.committedDate,
+ author: author ?? null,
+ url: `${node.url}/commits/${commit.oid}`,
+ },
+ ];
+ },
+ );
+
+ return {
+ repoFullName,
+ number: node.number,
+ url: node.url,
+ title: node.title,
+ body: node.body ?? "",
+ state: toPullRequestState(node.state.toLowerCase(), node.mergedAt ?? null),
+ isDraft: node.isDraft,
+ author: node.author?.login
+ ? { login: node.author.login, avatarUrl: node.author.avatarUrl ?? null }
+ : null,
+ head: {
+ ref: node.headRefName,
+ repoFullName: node.headRepository?.nameWithOwner ?? null,
+ },
+ base: { ref: node.baseRefName },
+ reviewDecision: toReviewDecision(node.reviewDecision ?? null),
+ checksStatus: computeChecksStatus(checks),
+ checks,
+ createdAt: node.createdAt,
+ updatedAt: node.updatedAt,
+ additions: count(node.additions),
+ deletions: count(node.deletions),
+ changedFiles: count(node.changedFiles),
+ mergeability: toMergeability(node.mergeable),
+ mergedAt: node.mergedAt?.trim() || null,
+ closedAt: node.closedAt?.trim() || null,
+ reviewers: [...reviewers.values()],
+ comments,
+ commits,
+ labels: listOf(node.labels).map((label) => ({
+ name: label.name,
+ color: label.color?.trim() || null,
+ })),
+ };
+}
diff --git a/packages/trpc/src/router/integration/github/pull-request-procedures.ts b/packages/trpc/src/router/integration/github/pull-request-procedures.ts
new file mode 100644
index 00000000000..8f145fc7c27
--- /dev/null
+++ b/packages/trpc/src/router/integration/github/pull-request-procedures.ts
@@ -0,0 +1,282 @@
+import type { PullRequestContent } from "@superset/shared/pull-request";
+import {
+ parseReviewThreads,
+ REVIEW_THREADS_QUERY,
+ type ReviewThreadsQueryResult,
+} from "@superset/shared/pull-request-threads";
+import type { TRPCRouterRecord } from "@trpc/server";
+import { z } from "zod";
+import { protectedProcedure, userError } from "../../../trpc";
+import { verifyOrgMembership } from "../utils";
+import { githubRequestError } from "./github-request-error";
+import {
+ PULL_REQUEST_CONTENT_QUERY,
+ pullRequestContentQuerySchema,
+ toPullRequestContent,
+} from "./pull-request-content";
+import { viewerOctokit, viewerOnlyOctokit } from "./viewer-octokit";
+
+export const pullRequestInputSchema = z.object({
+ organizationId: z.string().uuid(),
+ repoFullName: z.string().regex(/^[\w.-]+\/[\w.-]+$/),
+ number: z.number().int().positive(),
+});
+
+function repoOf(repoFullName: string): { owner: string; repo: string } {
+ const [owner = "", repo = ""] = repoFullName.split("/");
+ return { owner, repo };
+}
+
+/**
+ * A pull request by its own identity, read and written as the person asking.
+ * Nothing here needs a project or a host: the desktop reaches these for any
+ * PR it can name, and falls back to a host's `gh` only when they are absent.
+ */
+export const pullRequestProcedures = {
+ getPullRequestContent: protectedProcedure
+ .input(pullRequestInputSchema)
+ .query(async ({ ctx, input }): Promise => {
+ await verifyOrgMembership(ctx.session.user.id, input.organizationId);
+ const { octokit } = await viewerOctokit({
+ userId: ctx.session.user.id,
+ ...input,
+ });
+ const { owner, repo } = repoOf(input.repoFullName);
+ let raw: unknown;
+ try {
+ raw = await octokit.graphql(PULL_REQUEST_CONTENT_QUERY, {
+ owner,
+ name: repo,
+ number: input.number,
+ });
+ } catch (error) {
+ throw githubRequestError(
+ error,
+ `Failed to read pull request #${input.number}`,
+ );
+ }
+ const node =
+ pullRequestContentQuerySchema.parse(raw).repository?.pullRequest;
+ if (!node) {
+ throw userError({
+ code: "NOT_FOUND",
+ message: "Pull request not found",
+ i18nKey: "serverError.integration.pullRequestNotFound",
+ });
+ }
+ return toPullRequestContent(node, input.repoFullName);
+ }),
+
+ getPullRequestThreads: protectedProcedure
+ .input(pullRequestInputSchema)
+ .query(async ({ ctx, input }) => {
+ await verifyOrgMembership(ctx.session.user.id, input.organizationId);
+ const { octokit } = await viewerOctokit({
+ userId: ctx.session.user.id,
+ ...input,
+ });
+ const { owner, repo } = repoOf(input.repoFullName);
+ try {
+ const result: ReviewThreadsQueryResult = await octokit.graphql(
+ REVIEW_THREADS_QUERY,
+ { owner, name: repo, prNumber: input.number },
+ );
+ return {
+ reviewThreads: parseReviewThreads(result),
+ fetchFailed: false,
+ };
+ } catch (error) {
+ console.warn(
+ `[github.getPullRequestThreads] review threads of ${input.repoFullName}#${input.number}:`,
+ error instanceof Error ? error.message : error,
+ );
+ // An empty list rather than an error, so the diff still shows
+ // when only its comments could not load; `fetchFailed` keeps the
+ // two apart for the caller.
+ return { reviewThreads: [], fetchFailed: true };
+ }
+ }),
+
+ addPullRequestComment: protectedProcedure
+ .input(
+ pullRequestInputSchema.extend({
+ // GitHub rejects bodies past 65536 characters.
+ body: z.string().trim().min(1).max(65536),
+ }),
+ )
+ .mutation(async ({ ctx, input }) => {
+ await verifyOrgMembership(ctx.session.user.id, input.organizationId);
+ const octokit = await viewerOnlyOctokit(ctx.session.user.id);
+ try {
+ const { data } = await octokit.request(
+ "POST /repos/{owner}/{repo}/issues/{issue_number}/comments",
+ {
+ ...repoOf(input.repoFullName),
+ issue_number: input.number,
+ body: input.body,
+ },
+ );
+ return { id: data.id, url: data.html_url };
+ } catch (error) {
+ throw githubRequestError(error, "GitHub refused the comment.");
+ }
+ }),
+
+ replyToPullRequestThread: protectedProcedure
+ .input(
+ pullRequestInputSchema.extend({
+ /** REST databaseId of any comment already in the thread. */
+ commentId: z.number().int().positive(),
+ body: z.string().trim().min(1).max(65536),
+ }),
+ )
+ .mutation(async ({ ctx, input }) => {
+ await verifyOrgMembership(ctx.session.user.id, input.organizationId);
+ const octokit = await viewerOnlyOctokit(ctx.session.user.id);
+ try {
+ const { data } = await octokit.request(
+ "POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies",
+ {
+ ...repoOf(input.repoFullName),
+ pull_number: input.number,
+ comment_id: input.commentId,
+ body: input.body,
+ },
+ );
+ return { id: data.id };
+ } catch (error) {
+ throw githubRequestError(error, "GitHub refused the reply.");
+ }
+ }),
+
+ setPullRequestThreadResolution: protectedProcedure
+ .input(
+ pullRequestInputSchema.extend({
+ threadId: z.string().min(1),
+ resolved: z.boolean(),
+ }),
+ )
+ .mutation(async ({ ctx, input }) => {
+ await verifyOrgMembership(ctx.session.user.id, input.organizationId);
+ const octokit = await viewerOnlyOctokit(ctx.session.user.id);
+ const mutation = input.resolved
+ ? `mutation($threadId: ID!) {
+ resolveReviewThread(input: {threadId: $threadId}) { thread { id isResolved } }
+ }`
+ : `mutation($threadId: ID!) {
+ unresolveReviewThread(input: {threadId: $threadId}) { thread { id isResolved } }
+ }`;
+ try {
+ await octokit.graphql(mutation, { threadId: input.threadId });
+ } catch (error) {
+ throw githubRequestError(error, "GitHub refused to update the thread.");
+ }
+ return { threadId: input.threadId, isResolved: input.resolved };
+ }),
+
+ mergePullRequest: protectedProcedure
+ .input(
+ pullRequestInputSchema.extend({
+ mergeMethod: z.enum(["merge", "squash", "rebase"]).default("merge"),
+ commitMessage: z.string().trim().min(1).optional(),
+ }),
+ )
+ .mutation(async ({ ctx, input }) => {
+ await verifyOrgMembership(ctx.session.user.id, input.organizationId);
+ const octokit = await viewerOnlyOctokit(ctx.session.user.id);
+ try {
+ const { data } = await octokit.request(
+ "PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge",
+ {
+ ...repoOf(input.repoFullName),
+ pull_number: input.number,
+ merge_method: input.mergeMethod,
+ ...(input.commitMessage
+ ? { commit_message: input.commitMessage }
+ : {}),
+ },
+ );
+ return { merged: data.merged, sha: data.sha, message: data.message };
+ } catch (error) {
+ throw githubRequestError(error, "GitHub refused the merge.");
+ }
+ }),
+
+ setPullRequestState: protectedProcedure
+ .input(
+ // Only open/closed: a merged pull request has no way back.
+ pullRequestInputSchema.extend({ state: z.enum(["open", "closed"]) }),
+ )
+ .mutation(async ({ ctx, input }) => {
+ await verifyOrgMembership(ctx.session.user.id, input.organizationId);
+ const octokit = await viewerOnlyOctokit(ctx.session.user.id);
+ try {
+ await octokit.request(
+ "PATCH /repos/{owner}/{repo}/pulls/{pull_number}",
+ {
+ ...repoOf(input.repoFullName),
+ pull_number: input.number,
+ state: input.state,
+ },
+ );
+ } catch (error) {
+ throw githubRequestError(
+ error,
+ `GitHub refused to ${input.state === "closed" ? "close" : "reopen"} the pull request.`,
+ );
+ }
+ return { ok: true as const };
+ }),
+
+ setPullRequestDraft: protectedProcedure
+ .input(pullRequestInputSchema.extend({ draft: z.boolean() }))
+ .mutation(async ({ ctx, input }) => {
+ await verifyOrgMembership(ctx.session.user.id, input.organizationId);
+ const octokit = await viewerOnlyOctokit(ctx.session.user.id);
+ const { owner, repo } = repoOf(input.repoFullName);
+ try {
+ const found = z
+ .object({
+ repository: z
+ .object({
+ pullRequest: z.object({ id: z.string() }).nullable(),
+ })
+ .nullable(),
+ })
+ .parse(
+ await octokit.graphql(
+ `query($owner: String!, $name: String!, $number: Int!) {
+ repository(owner: $owner, name: $name) { pullRequest(number: $number) { id } }
+ }`,
+ { owner, name: repo, number: input.number },
+ ),
+ );
+ const pullRequestId = found.repository?.pullRequest?.id;
+ if (!pullRequestId) {
+ throw userError({
+ code: "NOT_FOUND",
+ message: "Pull request not found",
+ i18nKey: "serverError.integration.pullRequestNotFound",
+ });
+ }
+ await octokit.graphql(
+ input.draft
+ ? `mutation($pullRequestId: ID!) {
+ convertPullRequestToDraft(input: {pullRequestId: $pullRequestId}) { pullRequest { isDraft } }
+ }`
+ : `mutation($pullRequestId: ID!) {
+ markPullRequestReadyForReview(input: {pullRequestId: $pullRequestId}) { pullRequest { isDraft } }
+ }`,
+ { pullRequestId },
+ );
+ } catch (error) {
+ throw githubRequestError(
+ error,
+ input.draft
+ ? "GitHub refused to convert the pull request to a draft."
+ : "GitHub refused to mark the pull request ready for review.",
+ );
+ }
+ return { ok: true as const };
+ }),
+} satisfies TRPCRouterRecord;
diff --git a/packages/trpc/src/router/integration/github/viewer-octokit.ts b/packages/trpc/src/router/integration/github/viewer-octokit.ts
new file mode 100644
index 00000000000..d5245231371
--- /dev/null
+++ b/packages/trpc/src/router/integration/github/viewer-octokit.ts
@@ -0,0 +1,43 @@
+import { Octokit } from "@octokit/core";
+import { githubUserTokenFor } from "../../../lib/github-user";
+import { installationOctokit } from "../../../lib/sandbox/clone-token";
+import { userError } from "../../../trpc";
+import { findInstalledRepository } from "./find-installed-repository";
+
+export const GITHUB_NOT_CONNECTED_MESSAGE =
+ "Connect GitHub in Settings to act on pull requests as yourself";
+
+/**
+ * GitHub as the person asking: their own connection when they have one, the
+ * organization's App installation otherwise. Reads may take either; a write
+ * must be theirs, or GitHub would record it under the App's name.
+ */
+export async function viewerOctokit(args: {
+ userId: string;
+ organizationId: string;
+ repoFullName: string;
+}): Promise<{ octokit: Octokit; actsAsViewer: boolean }> {
+ const token = await githubUserTokenFor(args.userId);
+ if (token)
+ return { octokit: new Octokit({ auth: token }), actsAsViewer: true };
+ const { installation } = await findInstalledRepository(
+ args.organizationId,
+ args.repoFullName,
+ );
+ return {
+ octokit: await installationOctokit(installation.installationId),
+ actsAsViewer: false,
+ };
+}
+
+export async function viewerOnlyOctokit(userId: string): Promise {
+ const token = await githubUserTokenFor(userId);
+ if (!token) {
+ throw userError({
+ code: "PRECONDITION_FAILED",
+ message: GITHUB_NOT_CONNECTED_MESSAGE,
+ i18nKey: "serverError.githubUser.notConnected",
+ });
+ }
+ return new Octokit({ auth: token });
+}
From 61a8207a2f3a6e158493d971345a70592265e281 Mon Sep 17 00:00:00 2001
From: Satya Patel <14907857+saddlepaddle@users.noreply.github.com>
Date: Thu, 22 Oct 2026 02:53:39 +0000
Subject: [PATCH 2/8] feat(mobile): read and act on pull requests as the viewer
through the API
The pull request screen, merge and the card's actions call the cloud's
integration.github procedures instead of the workspace host's gh. The
detail read moves into @superset/shared so host-service and the API run
one implementation. A missing GitHub connection offers to connect, in the
screen and in Settings; no access reads as GitHub's answer.
---
.../github-connection/githubAccess.test.ts | 19 +
.../lib/github-connection/githubAccess.ts | 23 +
apps/mobile/lib/github-connection/index.ts | 6 +
.../github-connection/useGithubConnection.ts | 46 ++
.../useGithubRefusalAlert.ts | 35 ++
.../settings/SettingsScreen.tsx | 62 ++
.../[id]/WorkspaceScreen/WorkspaceScreen.tsx | 9 +-
.../useWorkspacePullRequestDetail.ts | 74 +--
.../[pullRequestId]/PullRequestScreen.tsx | 42 +-
.../useMergePullRequest.ts | 35 +-
.../usePullRequestActions.ts | 38 +-
.../src/trpc/router/github/github.ts | 503 ++---------------
packages/i18n/locales/cs/messages.po | 51 +-
packages/i18n/locales/de/messages.po | 51 +-
packages/i18n/locales/en/messages.po | 51 +-
packages/i18n/locales/es/messages.po | 51 +-
packages/i18n/locales/fr/messages.po | 51 +-
packages/i18n/locales/id/messages.po | 51 +-
packages/i18n/locales/it/messages.po | 51 +-
packages/i18n/locales/ja/messages.po | 51 +-
packages/i18n/locales/ko/messages.po | 51 +-
packages/i18n/locales/nl/messages.po | 51 +-
packages/i18n/locales/pl/messages.po | 51 +-
packages/i18n/locales/pt-BR/messages.po | 51 +-
packages/i18n/locales/ru/messages.po | 51 +-
packages/i18n/locales/tr/messages.po | 51 +-
packages/i18n/locales/vi/messages.po | 51 +-
packages/i18n/locales/zh-CN/messages.po | 51 +-
packages/i18n/locales/zh-TW/messages.po | 51 +-
packages/shared/package.json | 4 +
.../shared/src/pull-request-detail/index.ts | 11 +
.../pull-request-detail.test.ts | 181 ++++++
.../pull-request-detail.ts | 531 ++++++++++++++++++
.../github/pull-request-procedures.ts | 92 ++-
34 files changed, 1975 insertions(+), 603 deletions(-)
create mode 100644 apps/mobile/lib/github-connection/githubAccess.test.ts
create mode 100644 apps/mobile/lib/github-connection/githubAccess.ts
create mode 100644 apps/mobile/lib/github-connection/index.ts
create mode 100644 apps/mobile/lib/github-connection/useGithubConnection.ts
create mode 100644 apps/mobile/lib/github-connection/useGithubRefusalAlert.ts
create mode 100644 packages/shared/src/pull-request-detail/index.ts
create mode 100644 packages/shared/src/pull-request-detail/pull-request-detail.test.ts
create mode 100644 packages/shared/src/pull-request-detail/pull-request-detail.ts
diff --git a/apps/mobile/lib/github-connection/githubAccess.test.ts b/apps/mobile/lib/github-connection/githubAccess.test.ts
new file mode 100644
index 00000000000..165c6ee8a21
--- /dev/null
+++ b/apps/mobile/lib/github-connection/githubAccess.test.ts
@@ -0,0 +1,19 @@
+import { expect, test } from "bun:test";
+import { TRPCClientError } from "@trpc/client";
+import { githubAccessFailure } from "./githubAccess";
+
+function serverError(code: string) {
+ return TRPCClientError.from({
+ error: { message: code, code: -32000, data: { code } },
+ });
+}
+
+test("only the API's own GitHub answers classify; transport failures do not", () => {
+ expect(githubAccessFailure(serverError("PRECONDITION_FAILED"))).toBe(
+ "not-connected",
+ );
+ expect(githubAccessFailure(serverError("NOT_FOUND"))).toBe("no-access");
+ expect(githubAccessFailure(serverError("FORBIDDEN"))).toBe("no-access");
+ expect(githubAccessFailure(serverError("CONFLICT"))).toBeNull();
+ expect(githubAccessFailure(new Error("Network request failed"))).toBeNull();
+});
diff --git a/apps/mobile/lib/github-connection/githubAccess.ts b/apps/mobile/lib/github-connection/githubAccess.ts
new file mode 100644
index 00000000000..240ce212950
--- /dev/null
+++ b/apps/mobile/lib/github-connection/githubAccess.ts
@@ -0,0 +1,23 @@
+import { TRPCClientError } from "@trpc/client";
+
+export type GithubAccessFailure = "not-connected" | "no-access";
+
+/**
+ * Why the API could not act on GitHub for this person, or null when the
+ * failure is something else. Not connected is fixable from the app; no
+ * access is GitHub's answer about their account and is not.
+ */
+export function githubAccessFailure(
+ error: unknown,
+): GithubAccessFailure | null {
+ if (!(error instanceof TRPCClientError)) return null;
+ switch (error.data?.code) {
+ case "PRECONDITION_FAILED":
+ return "not-connected";
+ case "NOT_FOUND":
+ case "FORBIDDEN":
+ return "no-access";
+ default:
+ return null;
+ }
+}
diff --git a/apps/mobile/lib/github-connection/index.ts b/apps/mobile/lib/github-connection/index.ts
new file mode 100644
index 00000000000..d9e1422887c
--- /dev/null
+++ b/apps/mobile/lib/github-connection/index.ts
@@ -0,0 +1,6 @@
+export { type GithubAccessFailure, githubAccessFailure } from "./githubAccess";
+export {
+ GITHUB_CONNECTION_QUERY_KEY,
+ useGithubConnection,
+} from "./useGithubConnection";
+export { useGithubRefusalAlert } from "./useGithubRefusalAlert";
diff --git a/apps/mobile/lib/github-connection/useGithubConnection.ts b/apps/mobile/lib/github-connection/useGithubConnection.ts
new file mode 100644
index 00000000000..cd7190b69da
--- /dev/null
+++ b/apps/mobile/lib/github-connection/useGithubConnection.ts
@@ -0,0 +1,46 @@
+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
+import * as WebBrowser from "expo-web-browser";
+import { apiClient } from "@/lib/trpc/client";
+
+export const GITHUB_CONNECTION_QUERY_KEY = [
+ "cloud",
+ "githubUser",
+ "get",
+] as const;
+
+/**
+ * The person's own GitHub connection: what it is, and how to start or end
+ * one. Authorizing happens on GitHub in an in-app browser; the API's callback
+ * page tells them to come back, and closing it is when the answer is re-read.
+ */
+export function useGithubConnection() {
+ const queryClient = useQueryClient();
+ const status = useQuery({
+ queryKey: GITHUB_CONNECTION_QUERY_KEY,
+ queryFn: () => apiClient.githubUser.get.query(),
+ staleTime: 60_000,
+ });
+ const refresh = () =>
+ queryClient.invalidateQueries({ queryKey: GITHUB_CONNECTION_QUERY_KEY });
+
+ const connect = useMutation({
+ mutationFn: async () => {
+ const { url } = await apiClient.githubUser.connect.mutate();
+ await WebBrowser.openBrowserAsync(url);
+ },
+ onSettled: refresh,
+ });
+ const disconnect = useMutation({
+ mutationFn: () => apiClient.githubUser.disconnect.mutate(),
+ onSettled: refresh,
+ });
+
+ return {
+ /** Null while unknown; the server says whether connecting is even offered. */
+ available: status.data?.available ?? null,
+ connection: status.data?.connection ?? null,
+ isLoading: status.isPending,
+ connect,
+ disconnect,
+ };
+}
diff --git a/apps/mobile/lib/github-connection/useGithubRefusalAlert.ts b/apps/mobile/lib/github-connection/useGithubRefusalAlert.ts
new file mode 100644
index 00000000000..c6c58758d47
--- /dev/null
+++ b/apps/mobile/lib/github-connection/useGithubRefusalAlert.ts
@@ -0,0 +1,35 @@
+import { useLingui } from "@lingui/react/macro";
+import { Alert } from "react-native";
+import { errorCopy } from "@/lib/errors";
+import { githubAccessFailure } from "./githubAccess";
+import { useGithubConnection } from "./useGithubConnection";
+
+/**
+ * What to say when GitHub refused an action. A missing connection gets the
+ * way to fix it; anything else keeps GitHub's own wording, the only text that
+ * says which rule refused.
+ */
+export function useGithubRefusalAlert() {
+ const { t } = useLingui();
+ const { connect } = useGithubConnection();
+ return (title: string, error: unknown) => {
+ if (githubAccessFailure(error) === "not-connected") {
+ Alert.alert(
+ t({ message: "Connect GitHub to continue" }),
+ t({
+ message:
+ "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests.",
+ }),
+ [
+ { text: t({ message: "Not now" }), style: "cancel" },
+ {
+ text: t({ message: "Connect GitHub" }),
+ onPress: () => connect.mutate(),
+ },
+ ],
+ );
+ return;
+ }
+ Alert.alert(title, errorCopy(error));
+ };
+}
diff --git a/apps/mobile/screens/(authenticated)/settings/SettingsScreen.tsx b/apps/mobile/screens/(authenticated)/settings/SettingsScreen.tsx
index b3b5b48b45f..c054624b6ed 100644
--- a/apps/mobile/screens/(authenticated)/settings/SettingsScreen.tsx
+++ b/apps/mobile/screens/(authenticated)/settings/SettingsScreen.tsx
@@ -16,6 +16,7 @@ import { useReadableInset } from "@/hooks/useReadableInset";
import { useSignOut } from "@/hooks/useSignOut";
import { useTheme } from "@/hooks/useTheme";
import { useSession } from "@/lib/auth/client";
+import { useGithubConnection } from "@/lib/github-connection";
import { openUrl } from "@/lib/open-url";
import { billingSettingsUrl } from "@/lib/web-links";
import { ListRow } from "@/screens/(authenticated)/components/ListRow";
@@ -48,6 +49,7 @@ export function SettingsScreen() {
const { activeOrganization, activeOrganizationId } = useOrganizations();
const { signOut, isSigningOut } = useSignOut();
const { deleteAccount, isDeleting } = useDeleteAccount();
+ const github = useGithubConnection();
const user = session?.user;
const plan = session?.session.plan;
@@ -125,6 +127,28 @@ export function SettingsScreen() {
);
};
+ const handleGithub = () => {
+ if (github.connection) {
+ Alert.alert(
+ t({ message: "Disconnect GitHub?" }),
+ t({
+ message:
+ "Pull requests, comments and pushes from Superset will no longer be made as you.",
+ }),
+ [
+ { style: "cancel", text: t({ message: "Cancel" }) },
+ {
+ style: "destructive",
+ text: t({ message: "Disconnect" }),
+ onPress: () => github.disconnect.mutate(),
+ },
+ ],
+ );
+ return;
+ }
+ github.connect.mutate();
+ };
+
// 24pt (px-6) on a phone; a centered column on iPad.
const readableInset = useReadableInset(24);
return (
@@ -235,6 +259,44 @@ export function SettingsScreen() {
/>
+ {github.available !== false ? (
+
+
+ }
+ label="GitHub"
+ subtitle={
+ github.connection
+ ? t({
+ message:
+ "Pull requests, comments and pushes from Superset are made as you.",
+ })
+ : t({
+ message:
+ "Connect to act on pull requests as yourself instead of as the workspace.",
+ })
+ }
+ trailing={
+
+ }
+ onPress={github.isLoading ? undefined : handleGithub}
+ isLast
+ />
+
+ ) : null}
+
{
- if (!hostUrl || !owner || !repo || pullNumber === null) {
- throw new Error("Host is not resolved");
+ if (!organizationId || !owner || !repo || pullNumber === null) {
+ throw new Error("Pull request is not resolved");
}
- const raw = await getHostServiceClientByUrl(
- hostUrl,
- ).github.getPullRequestDetail.query({ owner, repo, pullNumber });
+ const raw = await apiClient.integration.github.getPullRequestDetail.query(
+ {
+ organizationId,
+ repoFullName: `${owner}/${repo}`,
+ number: pullNumber,
+ },
+ );
return toDetail(raw);
},
});
+ const resolvingRepo =
+ (owner === null || repo === null) &&
+ (isResolving || sandboxWaking) &&
+ !sandboxUnreachable;
return {
detail: query.data ?? null,
- // An idle query is not an empty one: while the box is still waking the
- // pull request is unknown, not gone.
+ // An idle query is not an empty one: while the session or the repository
+ // is still unknown the pull request is unknown, not gone.
isLoading: ready
? query.isPending
- : (isResolving || sandboxWaking) && !sandboxUnreachable,
+ : organizationId === null || resolvingRepo,
isRefetching: query.isRefetching,
error: query.error,
refetch: query.refetch,
};
}
-type RawDetail = Awaited<
- ReturnType<
- ReturnType<
- typeof getHostServiceClientByUrl
- >["github"]["getPullRequestDetail"]["query"]
- >
->;
-
function at(value: string | null): Date | null {
return value ? new Date(value) : null;
}
-function toDetail(raw: RawDetail): PullRequestDetail {
+function toDetail(raw: PullRequestDetailRead): PullRequestDetail {
return {
pullRequest: {
...raw.pullRequest,
- state: raw.pullRequest.state as "open" | "closed" | "merged",
mergedAt: at(raw.pullRequest.mergedAt),
},
checks: raw.checks.map(
diff --git a/apps/mobile/screens/(authenticated)/workspace/[id]/pull-request/[pullRequestId]/PullRequestScreen.tsx b/apps/mobile/screens/(authenticated)/workspace/[id]/pull-request/[pullRequestId]/PullRequestScreen.tsx
index 7a0ab233f41..7392baf051b 100644
--- a/apps/mobile/screens/(authenticated)/workspace/[id]/pull-request/[pullRequestId]/PullRequestScreen.tsx
+++ b/apps/mobile/screens/(authenticated)/workspace/[id]/pull-request/[pullRequestId]/PullRequestScreen.tsx
@@ -16,6 +16,10 @@ import {
import { Icon } from "@/components/ui/icon";
import { Text } from "@/components/ui/text";
import { useReadableInset } from "@/hooks/useReadableInset";
+import {
+ githubAccessFailure,
+ useGithubConnection,
+} from "@/lib/github-connection";
import { posthog } from "@/lib/posthog";
import { HeaderNotice } from "@/screens/(authenticated)/components/HeaderNotice";
import {
@@ -62,7 +66,6 @@ export function PullRequestScreen() {
}, [workspaceId, pullNumber]);
const merge = useMergePullRequest({
- workspaceId,
owner,
repo,
pullNumber,
@@ -75,13 +78,13 @@ export function PullRequestScreen() {
},
});
const actions = usePullRequestActions({
- workspaceId,
owner,
repo,
pullNumber,
onDone: () => void refetch(),
});
const askAgent = useAskAgent({ workspaceId });
+ const github = useGithubConnection();
const [notice, setNotice] = useState(null);
const hideNotice = useCallback(() => setNotice(null), []);
@@ -111,17 +114,42 @@ export function PullRequestScreen() {
}
if (error || !detail) {
+ const failure = githubAccessFailure(error);
return (
- {error
+ {failure === "not-connected"
? t({
- message: "Could not reach the host to load this pull request.",
+ message:
+ "Connect your GitHub account to load this pull request as you.",
})
- : t({
- message: "This pull request is no longer available.",
- })}
+ : failure === "no-access"
+ ? t({
+ message:
+ "You don't have access to this pull request on GitHub, or it no longer exists.",
+ })
+ : error
+ ? t({ message: "Could not load this pull request." })
+ : t({
+ message: "This pull request is no longer available.",
+ })}
+ {failure === "not-connected" ? (
+
+ github.connect.mutate(undefined, {
+ onSuccess: () => void refetch(),
+ })
+ }
+ >
+
+ {t({ message: "Connect GitHub" })}
+
+
+ ) : null}
= {
* which rule stopped the merge.
*/
export function useMergePullRequest({
- workspaceId,
owner,
repo,
pullNumber,
onMerged,
}: {
- workspaceId: string | null;
owner: string | null;
repo: string | null;
pullNumber: number | null;
onMerged: () => void;
}) {
const { i18n, t } = useLingui();
- const { host } = useWorkspaceHost(workspaceId);
- const hostUrl =
- host?.isOnline === true
- ? hostServiceUrl(host.organizationId, host.machineId)
- : null;
+ const { data: session } = useSession();
+ const organizationId = session?.session?.activeOrganizationId ?? null;
+ const alertRefusal = useGithubRefusalAlert();
const mutation = useMutation({
networkMode: "always" as const,
mutationFn: (mergeMethod: MergeMethod) => {
- if (!hostUrl || !owner || !repo || pullNumber === null) {
- throw new Error("Host is not resolved");
+ if (!organizationId || !owner || !repo || pullNumber === null) {
+ throw new Error("Pull request is not resolved");
}
- return getHostServiceClientByUrl(hostUrl).github.mergePR.mutate({
- owner,
- repo,
- pullNumber,
+ return apiClient.integration.github.mergePullRequest.mutate({
+ organizationId,
+ repoFullName: `${owner}/${repo}`,
+ number: pullNumber,
mergeMethod,
});
},
onSuccess: onMerged,
onError: (error: Error) => {
- Alert.alert(
+ alertRefusal(
t({
message: "GitHub refused the merge",
}),
- errorCopy(error),
+ error,
);
},
});
diff --git a/apps/mobile/screens/(authenticated)/workspace/[id]/pull-request/[pullRequestId]/hooks/usePullRequestActions/usePullRequestActions.ts b/apps/mobile/screens/(authenticated)/workspace/[id]/pull-request/[pullRequestId]/hooks/usePullRequestActions/usePullRequestActions.ts
index f39f6e6e80b..745753e30f0 100644
--- a/apps/mobile/screens/(authenticated)/workspace/[id]/pull-request/[pullRequestId]/hooks/usePullRequestActions/usePullRequestActions.ts
+++ b/apps/mobile/screens/(authenticated)/workspace/[id]/pull-request/[pullRequestId]/hooks/usePullRequestActions/usePullRequestActions.ts
@@ -3,13 +3,9 @@ import { msg } from "@lingui/core/macro";
import { i18n } from "@superset/i18n";
import { useMutation } from "@tanstack/react-query";
import { useRef } from "react";
-import { Alert } from "react-native";
-import { useWorkspaceHost } from "@/hooks/useWorkspaceHost";
-import { errorCopy } from "@/lib/errors";
-import {
- getHostServiceClientByUrl,
- hostServiceUrl,
-} from "@/lib/host-service/client";
+import { useSession } from "@/lib/auth/client";
+import { useGithubRefusalAlert } from "@/lib/github-connection";
+import { apiClient } from "@/lib/trpc/client";
import type { PlainActionId } from "../../utils/pullRequestState";
const REFUSED_TITLE: Record = {
@@ -34,46 +30,46 @@ const REFUSED_TITLE: Record = {
* rule refused it.
*/
export function usePullRequestActions({
- workspaceId,
owner,
repo,
pullNumber,
onDone,
}: {
- workspaceId: string | null;
owner: string | null;
repo: string | null;
pullNumber: number | null;
onDone: () => void;
}) {
- const { host } = useWorkspaceHost(workspaceId);
- const hostUrl =
- host?.isOnline === true
- ? hostServiceUrl(host.organizationId, host.machineId)
- : null;
+ const { data: session } = useSession();
+ const organizationId = session?.session?.activeOrganizationId ?? null;
+ const alertRefusal = useGithubRefusalAlert();
const mutation = useMutation({
networkMode: "always" as const,
mutationFn: async (action: PlainActionId) => {
- if (!hostUrl || !owner || !repo || pullNumber === null) {
- throw new Error("Host is not resolved");
+ if (!organizationId || !owner || !repo || pullNumber === null) {
+ throw new Error("Pull request is not resolved");
}
- const github = getHostServiceClientByUrl(hostUrl).github;
- const input = { owner, repo, pullNumber };
+ const github = apiClient.integration.github;
+ const input = {
+ organizationId,
+ repoFullName: `${owner}/${repo}`,
+ number: pullNumber,
+ };
switch (action) {
case "mark-ready":
- return github.markPullRequestReady.mutate(input);
+ return github.setPullRequestDraft.mutate({ ...input, draft: false });
case "update-branch":
return github.updatePullRequestBranch.mutate(input);
case "reopen":
- return github.reopenPullRequest.mutate(input);
+ return github.setPullRequestState.mutate({ ...input, state: "open" });
case "dequeue":
return github.dequeuePullRequest.mutate(input);
}
},
onSuccess: onDone,
onError: (error: Error, action) => {
- Alert.alert(i18n._(REFUSED_TITLE[action]), errorCopy(error));
+ alertRefusal(i18n._(REFUSED_TITLE[action]), error);
},
});
diff --git a/packages/host-service/src/trpc/router/github/github.ts b/packages/host-service/src/trpc/router/github/github.ts
index 160090ff4f9..cb3e3d6f748 100644
--- a/packages/host-service/src/trpc/router/github/github.ts
+++ b/packages/host-service/src/trpc/router/github/github.ts
@@ -1,3 +1,8 @@
+import {
+ PullRequestReadError,
+ readPullRequestDetail,
+ pullRequestNodeId as sharedPullRequestNodeId,
+} from "@superset/shared/pull-request-detail";
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { protectedProcedure, router } from "../../index";
@@ -165,181 +170,24 @@ export const githubRouter = router({
)
.query(async ({ ctx, input }) => {
const octokit = await ctx.github();
- const data = await octokit.graphql(
- PULL_REQUEST_DETAIL_QUERY,
- { owner: input.owner, name: input.repo, number: input.pullNumber },
- );
- const pr = data.repository?.pullRequest;
- if (!pr) {
- throw new TRPCError({
- code: "NOT_FOUND",
- message: `Pull request #${input.pullNumber} not found.`,
- });
- }
-
- // Both connections page at 100; anything past the first page must be
- // fetched before grading, or a failing check or open thread there is
- // silently invisible. Review requests come from REST because every
- // GraphQL Team field needs the read:org scope, which tokens minted by
- // editors and GitHub Desktop lack.
- const [restThreads, restContexts, requested] = await Promise.all([
- drainReviewThreads(octokit, input, pr.reviewThreads?.pageInfo),
- drainCheckContexts(
- octokit,
- input,
- pr.statusCheckRollup?.contexts?.pageInfo,
- ),
- octokit.pulls.listRequestedReviewers({
- owner: input.owner,
- repo: input.repo,
- pull_number: input.pullNumber,
- }),
- ]);
-
- const reviewers = new Map<
- string,
- {
- login: string;
- avatarUrl: string | null;
- isTeam: boolean;
- state: string;
- }
- >();
- // Requested first, so an actual review overwrites the placeholder.
- for (const user of requested.data.users) {
- reviewers.set(user.login, {
- login: user.login,
- avatarUrl: user.avatar_url,
- isTeam: false,
- state: "REQUESTED",
- });
- }
- for (const team of requested.data.teams) {
- reviewers.set(team.name, {
- login: team.name,
- avatarUrl: null,
- isTeam: true,
- state: "REQUESTED",
- });
- }
- for (const node of pr.latestOpinionatedReviews?.nodes ?? []) {
- const who = node?.author;
- if (!node || !who?.login) continue;
- reviewers.set(who.login, {
- login: who.login,
- avatarUrl: who.avatarUrl ?? null,
- isTeam: false,
- state: node.state,
- });
- }
- const contextNodes = (pr.statusCheckRollup?.contexts?.nodes ?? []).concat(
- restContexts,
- );
-
- const checks = contextNodes.flatMap((node) => {
- if (!node) return [];
- if (node.__typename === "CheckRun") {
- return [
- {
- name: node.name ?? "Check",
- status: node.status ?? "COMPLETED",
- conclusion: node.conclusion ?? null,
- isRequired: node.isRequired ?? false,
- startedAt: node.startedAt ?? null,
- completedAt: node.completedAt ?? null,
- detailsUrl: node.detailsUrl ?? null,
- },
- ];
- }
- // A commit status has no runtime of its own, only a verdict.
- return [
+ try {
+ return await readPullRequestDetail(
{
- name: node.context ?? "Status",
- status: "COMPLETED",
- conclusion:
- node.state === "SUCCESS"
- ? "SUCCESS"
- : node.state === "PENDING"
- ? null
- : "FAILURE",
- isRequired: node.isRequired ?? false,
- startedAt: null,
- completedAt: node.createdAt ?? null,
- detailsUrl: node.targetUrl ?? null,
+ graphql: (query, variables) => octokit.graphql(query, variables),
+ requestedReviewers: async ({ owner, repo, pullNumber }) =>
+ (
+ await octokit.pulls.listRequestedReviewers({
+ owner,
+ repo,
+ pull_number: pullNumber,
+ })
+ ).data,
},
- ];
- });
-
- const threads = (pr.reviewThreads?.nodes ?? []).concat(restThreads);
- const allowed: string[] = [];
- if (data.repository?.squashMergeAllowed) allowed.push("squash");
- if (data.repository?.mergeCommitAllowed) allowed.push("merge");
- if (data.repository?.rebaseMergeAllowed) allowed.push("rebase");
-
- return {
- pullRequest: {
- id: pr.id,
- number: pr.number,
- title: pr.title,
- body: pr.body,
- url: pr.url,
- baseBranch: pr.baseRefName,
- state: pr.merged
- ? "merged"
- : pr.state === "CLOSED"
- ? "closed"
- : "open",
- isDraft: pr.isDraft,
- additions: pr.additions,
- deletions: pr.deletions,
- changedFiles: pr.changedFiles,
- mergedAt: pr.mergedAt,
- mergedBy: pr.mergedBy
- ? {
- login: pr.mergedBy.login,
- avatarUrl: pr.mergedBy.avatarUrl ?? null,
- }
- : null,
- },
- checks,
- reviewers: [...reviewers.values()],
- mergeability: {
- mergeable: pr.mergeable,
- mergeStateStatus: pr.mergeStateStatus,
- approvals: (pr.latestOpinionatedReviews?.nodes ?? []).filter(
- (node) => node?.state === "APPROVED",
- ).length,
- requiredApprovals:
- pr.baseRef?.branchProtectionRule?.requiredApprovingReviewCount ?? 0,
- // GitHub's own verdict, and the only one that sees rulesets — a
- // repository that requires review through a ruleset has no
- // branchProtectionRule at all, so the count above reads 0.
- reviewDecision: pr.reviewDecision,
- unresolvedThreads: threads.filter(
- (node) => node && !node.isResolved && !node.isOutdated,
- ).length,
- requiresThreadResolution:
- pr.baseRef?.branchProtectionRule?.requiresConversationResolution ??
- false,
- queue: pr.mergeQueueEntry
- ? {
- position: pr.mergeQueueEntry.position ?? null,
- state: pr.mergeQueueEntry.state,
- }
- : null,
- allowedMergeMethods: allowed,
- },
- capabilities: {
- // Permission only. Whether GitHub would accept the merge right now
- // is mergeStateStatus's job — gating the button on mergeability
- // makes it vanish while GitHub is still computing it.
- merge: pr.viewerCanMergeAsAdmin || pr.viewerCanUpdate,
- markReady: pr.isDraft && pr.viewerCanUpdate,
- updateBranch: pr.mergeStateStatus === "BEHIND" && pr.viewerCanUpdate,
- reopen: pr.state === "CLOSED" && !pr.merged && pr.viewerCanUpdate,
- dequeue: pr.mergeQueueEntry !== null && pr.viewerCanUpdate,
- },
- };
+ input,
+ );
+ } catch (error) {
+ throw readError(error);
+ }
}),
mergePR: protectedProcedure
@@ -472,7 +320,12 @@ export const githubRouter = router({
}),
});
-/** The GraphQL mutations address the pull request by node id, not number. */
+function readError(error: unknown): unknown {
+ return error instanceof PullRequestReadError
+ ? new TRPCError({ code: error.code, message: error.message })
+ : error;
+}
+
async function pullRequestNodeId(
octokit: {
graphql: (
@@ -482,302 +335,14 @@ async function pullRequestNodeId(
},
input: { owner: string; repo: string; pullNumber: number },
): Promise {
- const data = await octokit.graphql<{
- repository: { pullRequest: { id: string } | null } | null;
- }>(
- `query($owner: String!, $name: String!, $number: Int!) {
- repository(owner: $owner, name: $name) { pullRequest(number: $number) { id } }
- }`,
- { owner: input.owner, name: input.repo, number: input.pullNumber },
- );
- const id = data.repository?.pullRequest?.id;
- if (!id) {
- throw new TRPCError({
- code: "NOT_FOUND",
- message: `Pull request #${input.pullNumber} not found.`,
- });
- }
- return id;
-}
-
-/**
- * `isRequired` is asked per pull request because a check is only required
- * relative to the branch rules it runs under.
- */
-const PULL_REQUEST_DETAIL_QUERY = `
-query($owner: String!, $name: String!, $number: Int!) {
- repository(owner: $owner, name: $name) {
- squashMergeAllowed
- mergeCommitAllowed
- rebaseMergeAllowed
- pullRequest(number: $number) {
- id number title body url baseRefName state isDraft merged mergedAt
- additions deletions changedFiles
- mergeable mergeStateStatus reviewDecision
- viewerCanUpdate viewerCanMergeAsAdmin
- mergedBy { login avatarUrl }
- mergeQueueEntry { position state }
- baseRef {
- branchProtectionRule {
- requiredApprovingReviewCount
- requiresConversationResolution
- }
- }
- latestOpinionatedReviews(first: 20) {
- nodes { state author { login avatarUrl } }
- }
- reviewThreads(first: 100) {
- pageInfo { hasNextPage endCursor }
- nodes { isResolved isOutdated }
- }
- statusCheckRollup {
- contexts(first: 100) {
- pageInfo { hasNextPage endCursor }
- nodes {
- __typename
- ... on CheckRun {
- name status conclusion detailsUrl startedAt completedAt
- isRequired(pullRequestNumber: $number)
- }
- ... on StatusContext {
- context state targetUrl createdAt
- isRequired(pullRequestNumber: $number)
- }
- }
- }
- }
- }
- }
-}`;
-
-const REVIEW_THREADS_PAGE_QUERY = `
-query($owner: String!, $name: String!, $number: Int!, $cursor: String!) {
- repository(owner: $owner, name: $name) {
- pullRequest(number: $number) {
- reviewThreads(first: 100, after: $cursor) {
- pageInfo { hasNextPage endCursor }
- nodes { isResolved isOutdated }
- }
- }
- }
-}`;
-
-const CHECK_CONTEXTS_PAGE_QUERY = `
-query($owner: String!, $name: String!, $number: Int!, $cursor: String!) {
- repository(owner: $owner, name: $name) {
- pullRequest(number: $number) {
- statusCheckRollup {
- contexts(first: 100, after: $cursor) {
- pageInfo { hasNextPage endCursor }
- nodes {
- __typename
- ... on CheckRun {
- name status conclusion detailsUrl startedAt completedAt
- isRequired(pullRequestNumber: $number)
- }
- ... on StatusContext {
- context state targetUrl createdAt
- isRequired(pullRequestNumber: $number)
- }
- }
- }
- }
- }
- }
-}`;
-
-interface PullRequestDetailQuery {
- repository: {
- squashMergeAllowed: boolean;
- mergeCommitAllowed: boolean;
- rebaseMergeAllowed: boolean;
- pullRequest: {
- id: string;
- number: number;
- title: string;
- body: string;
- url: string;
- baseRefName: string;
- state: string;
- isDraft: boolean;
- merged: boolean;
- mergedAt: string | null;
- additions: number;
- deletions: number;
- changedFiles: number;
- mergeable: string;
- mergeStateStatus: string;
- reviewDecision: string | null;
- viewerCanUpdate: boolean;
- viewerCanMergeAsAdmin: boolean;
- mergedBy: { login: string; avatarUrl: string | null } | null;
- mergeQueueEntry: { position: number | null; state: string } | null;
- baseRef: {
- branchProtectionRule: {
- requiredApprovingReviewCount: number | null;
- requiresConversationResolution: boolean | null;
- } | null;
- } | null;
- latestOpinionatedReviews: {
- nodes: ({
- state: string;
- author: { login: string; avatarUrl: string | null } | null;
- } | null)[];
- } | null;
- reviewThreads: ReviewThreadsConnection | null;
- statusCheckRollup: {
- contexts: CheckContextsConnection | null;
- } | null;
- } | null;
- } | null;
-}
-
-interface ConnectionPageInfo {
- hasNextPage: boolean;
- endCursor: string | null;
-}
-
-interface ReviewThreadNode {
- isResolved: boolean;
- isOutdated: boolean;
-}
-
-interface ReviewThreadsConnection {
- pageInfo: ConnectionPageInfo;
- nodes: (ReviewThreadNode | null)[];
-}
-
-interface CheckContextNode {
- __typename: string;
- name?: string;
- status?: string;
- conclusion?: string | null;
- detailsUrl?: string | null;
- startedAt?: string | null;
- completedAt?: string | null;
- context?: string;
- state?: string;
- targetUrl?: string | null;
- createdAt?: string | null;
- isRequired?: boolean;
-}
-
-interface CheckContextsConnection {
- pageInfo: ConnectionPageInfo;
- nodes: (CheckContextNode | null)[];
-}
-
-interface GithubGraphqlClient {
- graphql: (query: string, variables: Record) => Promise;
-}
-
-/**
- * 100 nodes is GitHub's page cap, not a promise of completeness — a failing
- * required check or an open thread past the first page would otherwise never
- * be seen, and the card would grade a partial pull request as ready. Drains
- * the connection; a handful of round trips at most.
- */
-// GitHub's own flags are trusted but not absolutely: a stuck cursor from a
-// GitHub-side pagination bug must not turn one detail query into an infinite
-// loop that pins the host and burns the token's rate limit. 20 pages is
-// 2,000 nodes — far past any real pull request.
-const MAX_DRAIN_PAGES = 20;
-
-async function drainReviewThreads(
- octokit: GithubGraphqlClient,
- input: { owner: string; repo: string; pullNumber: number },
- pageInfo: ConnectionPageInfo | undefined,
-): Promise<(ReviewThreadNode | null)[]> {
- const nodes: (ReviewThreadNode | null)[] = [];
- let page = pageInfo ?? null;
- let pages = 0;
- while (page?.hasNextPage) {
- // hasNextPage with no cursor would end the loop on a partial set —
- // the silent truncation this drain exists to remove.
- if (!page.endCursor) {
- throw new TRPCError({
- code: "CONFLICT",
- message: `GitHub reported more review threads but no cursor for pull request #${input.pullNumber}.`,
- });
- }
- if (++pages > MAX_DRAIN_PAGES) {
- throw new TRPCError({
- code: "CONFLICT",
- message: `Pull request #${input.pullNumber} did not finish paginating review threads after ${MAX_DRAIN_PAGES} pages.`,
- });
- }
- const data = await octokit.graphql<{
- repository: {
- pullRequest: { reviewThreads: ReviewThreadsConnection | null } | null;
- } | null;
- }>(REVIEW_THREADS_PAGE_QUERY, {
- owner: input.owner,
- name: input.repo,
- number: input.pullNumber,
- cursor: page.endCursor,
- });
- const connection = data.repository?.pullRequest?.reviewThreads;
- // A missing page mid-drain would silently re-create the truncation this
- // drain exists to remove — fail the query instead of grading on less.
- if (!connection) {
- throw new TRPCError({
- code: "CONFLICT",
- message: `GitHub returned no reviewThreads page for pull request #${input.pullNumber} while paginating.`,
- });
- }
- nodes.push(...connection.nodes);
- page = connection.pageInfo;
- }
- return nodes;
-}
-
-async function drainCheckContexts(
- octokit: GithubGraphqlClient,
- input: { owner: string; repo: string; pullNumber: number },
- pageInfo: ConnectionPageInfo | undefined,
-): Promise<(CheckContextNode | null)[]> {
- const nodes: (CheckContextNode | null)[] = [];
- let page = pageInfo ?? null;
- let pages = 0;
- while (page?.hasNextPage) {
- if (!page.endCursor) {
- throw new TRPCError({
- code: "CONFLICT",
- message: `GitHub reported more checks but no cursor for pull request #${input.pullNumber}.`,
- });
- }
- if (++pages > MAX_DRAIN_PAGES) {
- throw new TRPCError({
- code: "CONFLICT",
- message: `Pull request #${input.pullNumber} did not finish paginating checks after ${MAX_DRAIN_PAGES} pages.`,
- });
- }
- const data = await octokit.graphql<{
- repository: {
- pullRequest: {
- statusCheckRollup: {
- contexts: CheckContextsConnection | null;
- } | null;
- } | null;
- } | null;
- }>(CHECK_CONTEXTS_PAGE_QUERY, {
- owner: input.owner,
- name: input.repo,
- number: input.pullNumber,
- cursor: page.endCursor,
- });
- const connection =
- data.repository?.pullRequest?.statusCheckRollup?.contexts;
- if (!connection) {
- throw new TRPCError({
- code: "CONFLICT",
- message: `GitHub returned no check contexts page for pull request #${input.pullNumber} while paginating.`,
- });
- }
- nodes.push(...connection.nodes);
- page = connection.pageInfo;
+ try {
+ return await sharedPullRequestNodeId(
+ { graphql: (query, variables) => octokit.graphql(query, variables) },
+ input,
+ );
+ } catch (error) {
+ throw readError(error);
}
- return nodes;
}
/**
diff --git a/packages/i18n/locales/cs/messages.po b/packages/i18n/locales/cs/messages.po
index b8829b81c6e..3204920fd89 100644
--- a/packages/i18n/locales/cs/messages.po
+++ b/packages/i18n/locales/cs/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Připojte externí služby a synchronizujte data se svou organizací."
msgid "Connect external services to sync data."
msgstr "Připojte externí služby a synchronizujte data."
+msgid "Connect GitHub"
+msgstr "Připojit GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Připojte GitHub v Integracích a přidejte {repositoryFullName}."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Připojte GitHub v Nastavení, abyste s pull requesty pracovali sami za sebe"
+msgid "Connect GitHub to continue"
+msgstr "Pro pokračování připojte GitHub"
+
msgid "Connect GitHub…"
msgstr "Připojit GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "Připojte Slack a spravujte úkoly přímo z konverzací. Zmiňte bota v
msgid "Connect this computer"
msgstr "Připojte tento počítač"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Připojte se, abyste s pull requesty pracovali sami za sebe, ne jako pracovní prostor."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Připojte svůj účet {pluginLabel} a pak tuto stránku znovu načtěte."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Připojte svůj účet GitHub, aby se tento pull request načetl pod vaším jménem."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Připojte své GitHub repozitáře a synchronizujte pull requesty. Sledujte stav CI a revize napříč týmem."
@@ -5334,6 +5346,9 @@ msgstr "Tento rozdíl se nepodařilo načíst"
msgid "Could not load this file."
msgstr "Tento soubor se nepodařilo načíst."
+msgid "Could not load this pull request."
+msgstr "Tento pull request se nepodařilo načíst."
+
msgid "Could not load your machines"
msgstr "Nepodařilo se načíst vaše počítače"
@@ -5367,9 +5382,6 @@ msgstr "Nepodařilo se připojit k mobilnímu simulátoru."
msgid "Could not reach the desktop."
msgstr "K ploše se nepodařilo připojit."
-msgid "Could not reach the host to load this pull request."
-msgstr "Nepodařilo se spojit s hostem a načíst tento pull request."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Nepodařilo se spojit s hostitelem a zahájit aktualizaci. Zkontrolujte, že je online, a zkuste to znovu."
@@ -14341,6 +14353,12 @@ msgstr "Pull requesty"
msgid "Pull Requests"
msgstr "Pull requesty"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Pull requesty, komentáře a pushe ze Supersetu se provádějí pod vaším jménem."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Pull requesty, komentáře a pushe ze Supersetu už nebudou prováděny pod vaším jménem."
+
msgid "Purple"
msgstr "Fialová"
@@ -17673,6 +17691,30 @@ msgstr "nahrazeno"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26) je IDE s dostupným zdrojovým kódem pro éru AI agentů, ve kterém inženýři paralelně spouštějí stovky programovacích agentů, jako jsou Claude Code a Codex."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset jedná na GitHubu za vás. Připojte svůj účet GitHub, abyste mohli slučovat, komentovat a aktualizovat pull requesty."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "Aplikace Superset"
+
+msgid "Superset App"
+msgstr "Aplikace Superset"
+
+msgid "Superset Automations"
+msgstr "Automatizace Superset"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp vypíše endpoint jen pro daný panel. Namiřte na něj Playwright nebo browser-use."
@@ -20822,6 +20864,9 @@ msgstr "Žádost o autorizaci pro {plugin} jste odmítli."
msgid "You don't have access to this host"
msgstr "K tomuto hostu nemáte přístup"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "K tomuto pull requestu nemáte na GitHubu přístup, nebo už neexistuje."
+
msgid "You don't have access to this terminal."
msgstr "K tomuto terminálu nemáte přístup."
diff --git a/packages/i18n/locales/de/messages.po b/packages/i18n/locales/de/messages.po
index 303f0d1d003..22516d77545 100644
--- a/packages/i18n/locales/de/messages.po
+++ b/packages/i18n/locales/de/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Verbinde externe Dienste, um Daten mit deiner Organisation zu synchronis
msgid "Connect external services to sync data."
msgstr "Verbinde externe Dienste, um Daten zu synchronisieren."
+msgid "Connect GitHub"
+msgstr "GitHub verbinden"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Verbinde GitHub unter Integrationen, um {repositoryFullName} hinzuzufügen."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Verbinde GitHub in den Einstellungen, um Pull Requests als du selbst zu bearbeiten"
+msgid "Connect GitHub to continue"
+msgstr "Verbinde GitHub, um fortzufahren"
+
msgid "Connect GitHub…"
msgstr "GitHub verbinden…"
@@ -4785,9 +4791,15 @@ msgstr "Verbinde Slack, um Aufgaben aus Unterhaltungen zu verwalten. Erwähne de
msgid "Connect this computer"
msgstr "Diesen Computer verbinden"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Verbinde dich, um Pull Requests als du selbst statt als Workspace zu bearbeiten."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Verbinde dein {pluginLabel}-Konto und lade diese Seite dann neu."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Verbinde dein GitHub-Konto, um diesen Pull Request als du selbst zu laden."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Verbinde deine GitHub-Repositories und synchronisiere Pull Requests. Verfolge CI-Status und Reviews im ganzen Team."
@@ -5334,6 +5346,9 @@ msgstr "Dieser Diff konnte nicht geladen werden"
msgid "Could not load this file."
msgstr "Diese Datei konnte nicht geladen werden."
+msgid "Could not load this pull request."
+msgstr "Dieser Pull Request konnte nicht geladen werden."
+
msgid "Could not load your machines"
msgstr "Deine Rechner konnten nicht geladen werden"
@@ -5367,9 +5382,6 @@ msgstr "Der mobile Simulator konnte nicht erreicht werden."
msgid "Could not reach the desktop."
msgstr "Der Desktop konnte nicht erreicht werden."
-msgid "Could not reach the host to load this pull request."
-msgstr "Der Host war nicht erreichbar, um diesen Pull Request zu laden."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Der Host konnte nicht erreicht werden, um das Update zu starten. Prüfe, ob er online ist, und versuche es erneut."
@@ -14341,6 +14353,12 @@ msgstr "Pull Requests"
msgid "Pull Requests"
msgstr "Pull Requests"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Pull Requests, Kommentare und Pushes aus Superset werden in deinem Namen gemacht."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Pull Requests, Kommentare und Pushes aus Superset werden nicht mehr in deinem Namen gemacht."
+
msgid "Purple"
msgstr "Lila"
@@ -17673,6 +17691,30 @@ msgstr "ersetzt"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26) ist die Source-Available-IDE für die Ära der KI-Agents, in der Entwickler Hunderte Coding-Agents wie Claude Code und Codex parallel ausführen."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset handelt auf GitHub in deinem Namen. Verbinde dein GitHub-Konto, um Pull Requests zu mergen, zu kommentieren und zu aktualisieren."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "Superset-App"
+
+msgid "Superset App"
+msgstr "Superset App"
+
+msgid "Superset Automations"
+msgstr "Superset-Automatisierungen"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp gibt nur für diesen Bereich einen Endpunkt aus. Richte Playwright oder browser-use darauf."
@@ -20822,6 +20864,9 @@ msgstr "Sie haben die Autorisierungsanfrage für {plugin} abgelehnt."
msgid "You don't have access to this host"
msgstr "Du hast keinen Zugriff auf diesen Host"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "Du hast auf GitHub keinen Zugriff auf diesen Pull Request, oder er existiert nicht mehr."
+
msgid "You don't have access to this terminal."
msgstr "Du hast keinen Zugriff auf dieses Terminal."
diff --git a/packages/i18n/locales/en/messages.po b/packages/i18n/locales/en/messages.po
index 07349a2b200..12650a692c5 100644
--- a/packages/i18n/locales/en/messages.po
+++ b/packages/i18n/locales/en/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Connect external services to sync data with your organization."
msgid "Connect external services to sync data."
msgstr "Connect external services to sync data."
+msgid "Connect GitHub"
+msgstr "Connect GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Connect GitHub in Integrations to add {repositoryFullName}."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Connect GitHub in Settings to act on pull requests as yourself"
+msgid "Connect GitHub to continue"
+msgstr "Connect GitHub to continue"
+
msgid "Connect GitHub…"
msgstr "Connect GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "Connect Slack to manage tasks from conversations. Mention the bot in any
msgid "Connect this computer"
msgstr "Connect this computer"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Connect to act on pull requests as yourself instead of as the workspace."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Connect your {pluginLabel} account, then reload this page."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Connect your GitHub account to load this pull request as you."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
@@ -5334,6 +5346,9 @@ msgstr "Could not load this diff"
msgid "Could not load this file."
msgstr "Could not load this file."
+msgid "Could not load this pull request."
+msgstr "Could not load this pull request."
+
msgid "Could not load your machines"
msgstr "Could not load your machines"
@@ -5367,9 +5382,6 @@ msgstr "Could not reach a mobile simulator."
msgid "Could not reach the desktop."
msgstr "Could not reach the desktop."
-msgid "Could not reach the host to load this pull request."
-msgstr "Could not reach the host to load this pull request."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Could not reach the host to start the update. Check that it is online and try again."
@@ -14341,6 +14353,12 @@ msgstr "Pull requests"
msgid "Pull Requests"
msgstr "Pull Requests"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Pull requests, comments and pushes from Superset are made as you."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Pull requests, comments and pushes from Superset will no longer be made as you."
+
msgid "Purple"
msgstr "Purple"
@@ -17673,6 +17691,30 @@ msgstr "superseded"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "Superset app"
+
+msgid "Superset App"
+msgstr "Superset App"
+
+msgid "Superset Automations"
+msgstr "Superset Automations"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
@@ -20822,6 +20864,9 @@ msgstr "You declined the {plugin} authorization request."
msgid "You don't have access to this host"
msgstr "You don't have access to this host"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "You don't have access to this pull request on GitHub, or it no longer exists."
+
msgid "You don't have access to this terminal."
msgstr "You don't have access to this terminal."
diff --git a/packages/i18n/locales/es/messages.po b/packages/i18n/locales/es/messages.po
index 49e08d74866..65f4488ef76 100644
--- a/packages/i18n/locales/es/messages.po
+++ b/packages/i18n/locales/es/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Conecta servicios externos para sincronizar datos con tu organización."
msgid "Connect external services to sync data."
msgstr "Conecta servicios externos para sincronizar datos."
+msgid "Connect GitHub"
+msgstr "Conectar GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Conecta GitHub en Integraciones para añadir {repositoryFullName}."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Conecta GitHub en Configuración para actuar en las pull requests como tú mismo"
+msgid "Connect GitHub to continue"
+msgstr "Conecta GitHub para continuar"
+
msgid "Connect GitHub…"
msgstr "Conectar GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "Conecta Slack para gestionar tareas desde las conversaciones. Menciona a
msgid "Connect this computer"
msgstr "Conectar este ordenador"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Conéctate para actuar en las pull requests como tú mismo en lugar de como el workspace."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Conecta tu cuenta de {pluginLabel} y vuelve a cargar esta página."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Conecta tu cuenta de GitHub para cargar esta pull request como tú."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Conecta tus repositorios de GitHub y sincroniza las pull requests. Sigue el estado de CI y las revisiones de todo tu equipo."
@@ -5334,6 +5346,9 @@ msgstr "No se pudo cargar este diff"
msgid "Could not load this file."
msgstr "No se pudo cargar este archivo."
+msgid "Could not load this pull request."
+msgstr "No se pudo cargar esta pull request."
+
msgid "Could not load your machines"
msgstr "No se pudieron cargar tus máquinas"
@@ -5367,9 +5382,6 @@ msgstr "No se pudo acceder a un simulador móvil."
msgid "Could not reach the desktop."
msgstr "No se pudo acceder al escritorio."
-msgid "Could not reach the host to load this pull request."
-msgstr "No se pudo contactar con el host para cargar esta pull request."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "No se pudo contactar con el host para iniciar la actualización. Comprueba que está en línea y vuelve a intentarlo."
@@ -14341,6 +14353,12 @@ msgstr "Pull requests"
msgid "Pull Requests"
msgstr "Pull requests"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Las pull requests, comentarios y pushes desde Superset se hacen en tu nombre."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Las pull requests, comentarios y pushes desde Superset dejarán de hacerse en tu nombre."
+
msgid "Purple"
msgstr "Morado"
@@ -17673,6 +17691,30 @@ msgstr "reemplazada"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26) es el IDE con código fuente disponible para la era de los agentes de IA, donde los ingenieros ejecutan en paralelo cientos de agentes de programación como Claude Code y Codex."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset actúa en GitHub en tu nombre. Conecta tu cuenta de GitHub para fusionar, comentar y actualizar pull requests."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "App de Superset"
+
+msgid "Superset App"
+msgstr "App de Superset"
+
+msgid "Superset Automations"
+msgstr "Automatizaciones de Superset"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp imprime un endpoint solo para ese panel. Apunta Playwright o browser-use hacia él."
@@ -20822,6 +20864,9 @@ msgstr "Has rechazado la solicitud de autorización de {plugin}."
msgid "You don't have access to this host"
msgstr "No tienes acceso a este host"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "No tienes acceso a esta pull request en GitHub, o ya no existe."
+
msgid "You don't have access to this terminal."
msgstr "No tienes acceso a este terminal."
diff --git a/packages/i18n/locales/fr/messages.po b/packages/i18n/locales/fr/messages.po
index 65b14be8072..4162558f04c 100644
--- a/packages/i18n/locales/fr/messages.po
+++ b/packages/i18n/locales/fr/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Connectez des services externes pour synchroniser des données avec votr
msgid "Connect external services to sync data."
msgstr "Connectez des services externes pour synchroniser vos données."
+msgid "Connect GitHub"
+msgstr "Connecter GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Connectez GitHub dans Intégrations pour ajouter {repositoryFullName}."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Connectez GitHub dans les Paramètres pour agir sur les pull requests en votre nom"
+msgid "Connect GitHub to continue"
+msgstr "Connectez GitHub pour continuer"
+
msgid "Connect GitHub…"
msgstr "Connecter GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "Connectez Slack pour gérer les tâches depuis vos conversations. Mentio
msgid "Connect this computer"
msgstr "Connecter cet ordinateur"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Connectez-vous pour agir sur les pull requests en votre nom plutôt qu'au nom du workspace."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Connectez votre compte {pluginLabel}, puis rechargez cette page."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Connectez votre compte GitHub pour charger cette pull request en votre nom."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Connectez vos dépôts GitHub et synchronisez les pull requests. Suivez l'état de la CI et les revues au sein de votre équipe."
@@ -5334,6 +5346,9 @@ msgstr "Impossible de charger ce diff"
msgid "Could not load this file."
msgstr "Impossible de charger ce fichier."
+msgid "Could not load this pull request."
+msgstr "Impossible de charger cette pull request."
+
msgid "Could not load your machines"
msgstr "Impossible de charger vos machines"
@@ -5367,9 +5382,6 @@ msgstr "Impossible de joindre un simulateur mobile."
msgid "Could not reach the desktop."
msgstr "Impossible de joindre le bureau."
-msgid "Could not reach the host to load this pull request."
-msgstr "Impossible de joindre l'hôte pour charger cette pull request."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Impossible de joindre l'hôte pour lancer la mise à jour. Vérifiez qu'il est en ligne et réessayez."
@@ -14341,6 +14353,12 @@ msgstr "Pull requests"
msgid "Pull Requests"
msgstr "Pull requests"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Les pull requests, commentaires et pushes depuis Superset sont faits en votre nom."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Les pull requests, commentaires et pushes depuis Superset ne seront plus faits en votre nom."
+
msgid "Purple"
msgstr "Violet"
@@ -17673,6 +17691,30 @@ msgstr "remplacée"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26) est l’IDE au code source disponible de l’ère des agents IA, où les ingénieurs exécutent en parallèle des centaines d’agents de code comme Claude Code et Codex."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset agit sur GitHub en votre nom. Connectez votre compte GitHub pour fusionner, commenter et mettre à jour des pull requests."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "Application Superset"
+
+msgid "Superset App"
+msgstr "Application Superset"
+
+msgid "Superset Automations"
+msgstr "Automatisations Superset"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp affiche un point de terminaison pour ce volet uniquement. Pointez Playwright ou browser-use dessus."
@@ -20822,6 +20864,9 @@ msgstr "Vous avez refusé la demande d'autorisation de {plugin}."
msgid "You don't have access to this host"
msgstr "Vous n'avez pas accès à cet hôte"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "Vous n'avez pas accès à cette pull request sur GitHub, ou elle n'existe plus."
+
msgid "You don't have access to this terminal."
msgstr "Vous n'avez pas accès à ce terminal."
diff --git a/packages/i18n/locales/id/messages.po b/packages/i18n/locales/id/messages.po
index 694d82ceb52..79dce5fc169 100644
--- a/packages/i18n/locales/id/messages.po
+++ b/packages/i18n/locales/id/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Hubungkan layanan eksternal untuk menyinkronkan data dengan organisasi A
msgid "Connect external services to sync data."
msgstr "Hubungkan layanan eksternal untuk menyinkronkan data."
+msgid "Connect GitHub"
+msgstr "Hubungkan GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Hubungkan GitHub di Integrasi untuk menambahkan {repositoryFullName}."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Hubungkan GitHub di Pengaturan untuk bertindak pada pull request atas nama Anda sendiri"
+msgid "Connect GitHub to continue"
+msgstr "Hubungkan GitHub untuk melanjutkan"
+
msgid "Connect GitHub…"
msgstr "Hubungkan GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "Hubungkan Slack untuk mengelola tugas dari percakapan. Sebut bot-nya di
msgid "Connect this computer"
msgstr "Hubungkan komputer ini"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Hubungkan untuk bertindak pada pull request sebagai diri Anda, bukan sebagai workspace."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Hubungkan akun {pluginLabel} Anda, lalu muat ulang halaman ini."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Hubungkan akun GitHub Anda untuk memuat pull request ini sebagai diri Anda."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Hubungkan repositori GitHub Anda dan sinkronkan pull request. Lacak status CI dan review di seluruh tim Anda."
@@ -5334,6 +5346,9 @@ msgstr "Tidak bisa memuat diff ini"
msgid "Could not load this file."
msgstr "Tidak bisa memuat file ini."
+msgid "Could not load this pull request."
+msgstr "Tidak bisa memuat pull request ini."
+
msgid "Could not load your machines"
msgstr "Tidak bisa memuat mesin Anda"
@@ -5367,9 +5382,6 @@ msgstr "Tidak dapat menjangkau simulator seluler."
msgid "Could not reach the desktop."
msgstr "Tidak dapat menjangkau desktop."
-msgid "Could not reach the host to load this pull request."
-msgstr "Tidak bisa menjangkau host untuk memuat pull request ini."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Tidak dapat menjangkau host untuk memulai pembaruan. Pastikan host online lalu coba lagi."
@@ -14341,6 +14353,12 @@ msgstr "Pull request"
msgid "Pull Requests"
msgstr "Pull Request"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Pull request, komentar, dan push dari Superset dibuat atas nama Anda."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Pull request, komentar, dan push dari Superset tidak lagi dibuat atas nama Anda."
+
msgid "Purple"
msgstr "Ungu"
@@ -17673,6 +17691,30 @@ msgstr "digantikan"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26) adalah IDE source-available untuk era agen AI, tempat para engineer menjalankan ratusan agen coding seperti Claude Code dan Codex secara paralel."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset bertindak di GitHub atas nama Anda. Hubungkan akun GitHub Anda untuk menggabungkan, mengomentari, dan memperbarui pull request."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "Aplikasi Superset"
+
+msgid "Superset App"
+msgstr "Aplikasi Superset"
+
+msgid "Superset Automations"
+msgstr "Otomatisasi Superset"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp mencetak endpoint hanya untuk panel itu. Arahkan Playwright atau browser-use ke sana."
@@ -20822,6 +20864,9 @@ msgstr "Anda menolak permintaan otorisasi {plugin}."
msgid "You don't have access to this host"
msgstr "Anda tidak punya akses ke host ini"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "Anda tidak memiliki akses ke pull request ini di GitHub, atau pull request ini sudah tidak ada."
+
msgid "You don't have access to this terminal."
msgstr "Anda tidak punya akses ke terminal ini."
diff --git a/packages/i18n/locales/it/messages.po b/packages/i18n/locales/it/messages.po
index 39879509d05..41e1e7b76d2 100644
--- a/packages/i18n/locales/it/messages.po
+++ b/packages/i18n/locales/it/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Collega servizi esterni per sincronizzare i dati con la tua organizzazio
msgid "Connect external services to sync data."
msgstr "Collega servizi esterni per sincronizzare i dati."
+msgid "Connect GitHub"
+msgstr "Collega GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Collega GitHub in Integrazioni per aggiungere {repositoryFullName}."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Collega GitHub nelle Impostazioni per agire sulle pull request a tuo nome"
+msgid "Connect GitHub to continue"
+msgstr "Collega GitHub per continuare"
+
msgid "Connect GitHub…"
msgstr "Collega GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "Collega Slack per gestire i task dalle conversazioni. Menziona il bot in
msgid "Connect this computer"
msgstr "Collega questo computer"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Collegati per agire sulle pull request a tuo nome invece che come workspace."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Collega il tuo account {pluginLabel}, poi ricarica questa pagina."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Collega il tuo account GitHub per caricare questa pull request a tuo nome."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Collega i tuoi repository GitHub e sincronizza le pull request. Tieni traccia dello stato della CI e delle revisioni in tutto il team."
@@ -5334,6 +5346,9 @@ msgstr "Impossibile caricare questo diff"
msgid "Could not load this file."
msgstr "Impossibile caricare questo file."
+msgid "Could not load this pull request."
+msgstr "Impossibile caricare questa pull request."
+
msgid "Could not load your machines"
msgstr "Impossibile caricare le tue macchine"
@@ -5367,9 +5382,6 @@ msgstr "Impossibile raggiungere un simulatore mobile."
msgid "Could not reach the desktop."
msgstr "Impossibile raggiungere il desktop."
-msgid "Could not reach the host to load this pull request."
-msgstr "Impossibile raggiungere l'host per caricare questa pull request."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Impossibile raggiungere l'host per avviare l'aggiornamento. Verifica che sia online e riprova."
@@ -14341,6 +14353,12 @@ msgstr "Pull request"
msgid "Pull Requests"
msgstr "Pull request"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Le pull request, i commenti e i push da Superset sono fatti a tuo nome."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Le pull request, i commenti e i push da Superset non saranno più fatti a tuo nome."
+
msgid "Purple"
msgstr "Viola"
@@ -17673,6 +17691,30 @@ msgstr "sostituita"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26) è l’IDE source-available per l’era degli agenti IA, in cui gli ingegneri eseguono in parallelo centinaia di agenti di programmazione come Claude Code e Codex."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset agisce su GitHub a tuo nome. Collega il tuo account GitHub per unire, commentare e aggiornare le pull request."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "App Superset"
+
+msgid "Superset App"
+msgstr "App Superset"
+
+msgid "Superset Automations"
+msgstr "Superset Automazioni"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp stampa un endpoint solo per quel riquadro. Punta Playwright o browser-use su di esso."
@@ -20822,6 +20864,9 @@ msgstr "Hai rifiutato la richiesta di autorizzazione di {plugin}."
msgid "You don't have access to this host"
msgstr "Non hai accesso a questo host"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "Non hai accesso a questa pull request su GitHub, oppure non esiste più."
+
msgid "You don't have access to this terminal."
msgstr "Non hai accesso a questo terminale."
diff --git a/packages/i18n/locales/ja/messages.po b/packages/i18n/locales/ja/messages.po
index d5e7ce66737..b58044d8eb8 100644
--- a/packages/i18n/locales/ja/messages.po
+++ b/packages/i18n/locales/ja/messages.po
@@ -4746,12 +4746,18 @@ msgstr "外部サービスを接続して組織とデータを同期します。
msgid "Connect external services to sync data."
msgstr "外部サービスを接続してデータを同期します。"
+msgid "Connect GitHub"
+msgstr "GitHub を接続"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "{repositoryFullName} を追加するには、連携で GitHub を接続してください。"
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "自分としてプルリクエストを操作するには、設定で GitHub を接続してください"
+msgid "Connect GitHub to continue"
+msgstr "続行するには GitHub を接続してください"
+
msgid "Connect GitHub…"
msgstr "GitHub を接続…"
@@ -4785,9 +4791,15 @@ msgstr "Slackを接続して会話からタスクを管理します。任意の
msgid "Connect this computer"
msgstr "このコンピューターに接続"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "接続すると、ワークスペースではなく自分としてプルリクエストを操作できます。"
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "{pluginLabel} アカウントを接続してから、このページを再読み込みしてください。"
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "このプルリクエストを自分として読み込むには、GitHub アカウントを接続してください。"
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "GitHubリポジトリを接続してプルリクエストを同期します。チーム全体のCIステータスとレビューを追跡できます。"
@@ -5334,6 +5346,9 @@ msgstr "この差分を読み込めませんでした"
msgid "Could not load this file."
msgstr "このファイルを読み込めませんでした。"
+msgid "Could not load this pull request."
+msgstr "このプルリクエストを読み込めませんでした。"
+
msgid "Could not load your machines"
msgstr "マシンを読み込めませんでした"
@@ -5367,9 +5382,6 @@ msgstr "モバイルシミュレーターに接続できませんでした。"
msgid "Could not reach the desktop."
msgstr "デスクトップに接続できませんでした。"
-msgid "Could not reach the host to load this pull request."
-msgstr "このプルリクエストを読み込むためのホストに接続できませんでした。"
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "更新を開始するためにホストに接続できませんでした。オンラインであることを確認して、もう一度お試しください。"
@@ -14341,6 +14353,12 @@ msgstr "プルリクエスト"
msgid "Pull Requests"
msgstr "プルリクエスト"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Superset からのプルリクエスト、コメント、プッシュはあなたとして行われます。"
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Superset からのプルリクエスト、コメント、プッシュは、あなたとして行われなくなります。"
+
msgid "Purple"
msgstr "紫"
@@ -17673,6 +17691,30 @@ msgstr "置き換え済み"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset(YC P26)は、AI エージェント時代のためのソースコード公開型 IDE です。エンジニアは Claude Code や Codex などのコーディングエージェントを数百単位で並行して実行できます。"
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset はあなたとして GitHub を操作します。プルリクエストのマージ、コメント、更新を行うには GitHub アカウントを接続してください。"
+
+msgid "Superset Agent"
+msgstr "Supersetエージェント"
+
+msgid "Superset app"
+msgstr "Supersetアプリ"
+
+msgid "Superset App"
+msgstr "Supersetアプリ"
+
+msgid "Superset Automations"
+msgstr "Superset オートメーション"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp は、そのペイン専用のエンドポイントを出力します。Playwrightやbrowser-useをそこに向けてください。"
@@ -20822,6 +20864,9 @@ msgstr "{plugin} の認可リクエストを拒否しました。"
msgid "You don't have access to this host"
msgstr "このホストへのアクセス権がありません"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "GitHub でこのプルリクエストにアクセスできないか、プルリクエストがもう存在しません。"
+
msgid "You don't have access to this terminal."
msgstr "このターミナルへのアクセス権がありません。"
diff --git a/packages/i18n/locales/ko/messages.po b/packages/i18n/locales/ko/messages.po
index f57f86636d5..c905dc935da 100644
--- a/packages/i18n/locales/ko/messages.po
+++ b/packages/i18n/locales/ko/messages.po
@@ -4746,12 +4746,18 @@ msgstr "외부 서비스를 연결해 조직과 데이터를 동기화합니다.
msgid "Connect external services to sync data."
msgstr "외부 서비스를 연결해 데이터를 동기화합니다."
+msgid "Connect GitHub"
+msgstr "GitHub 연결"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "{repositoryFullName}을(를) 추가하려면 연동에서 GitHub를 연결하세요."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "본인 계정으로 풀 리퀘스트를 처리하려면 설정에서 GitHub를 연결하세요"
+msgid "Connect GitHub to continue"
+msgstr "계속하려면 GitHub를 연결하세요"
+
msgid "Connect GitHub…"
msgstr "GitHub 연결…"
@@ -4785,9 +4791,15 @@ msgstr "Slack을 연결해 대화에서 바로 작업을 관리하세요. 아무
msgid "Connect this computer"
msgstr "이 컴퓨터에 연결"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "연결하면 워크스페이스가 아닌 본인 계정으로 풀 리퀘스트를 처리할 수 있습니다."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "{pluginLabel} 계정을 연결한 다음 이 페이지를 새로 고치세요."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "이 풀 리퀘스트를 본인 계정으로 불러오려면 GitHub 계정을 연결하세요."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "GitHub 리포지토리를 연결하고 풀 리퀘스트를 동기화하세요. 팀 전체의 CI 상태와 리뷰를 추적할 수 있습니다."
@@ -5334,6 +5346,9 @@ msgstr "이 차이를 불러올 수 없습니다"
msgid "Could not load this file."
msgstr "이 파일을 불러올 수 없습니다."
+msgid "Could not load this pull request."
+msgstr "이 풀 리퀘스트를 불러오지 못했습니다."
+
msgid "Could not load your machines"
msgstr "머신을 불러오지 못했습니다"
@@ -5367,9 +5382,6 @@ msgstr "모바일 시뮬레이터에 연결할 수 없습니다."
msgid "Could not reach the desktop."
msgstr "데스크톱에 연결할 수 없습니다."
-msgid "Could not reach the host to load this pull request."
-msgstr "호스트에 연결할 수 없어 이 풀 리퀘스트를 불러오지 못했습니다."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "업데이트를 시작하기 위해 호스트에 연결할 수 없습니다. 온라인 상태인지 확인한 후 다시 시도하세요."
@@ -14341,6 +14353,12 @@ msgstr "풀 리퀘스트"
msgid "Pull Requests"
msgstr "풀 리퀘스트"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Superset에서의 풀 리퀘스트, 댓글, 푸시는 본인 계정으로 처리됩니다."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Superset에서의 풀 리퀘스트, 댓글, 푸시가 더 이상 본인 계정으로 처리되지 않습니다."
+
msgid "Purple"
msgstr "보라"
@@ -17673,6 +17691,30 @@ msgstr "대체됨"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset(YC P26)은 AI 에이전트 시대를 위한 소스 공개형 IDE로, 엔지니어가 Claude Code와 Codex 같은 코딩 에이전트 수백 개를 병렬로 실행할 수 있습니다."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset은 본인 계정으로 GitHub에서 작업합니다. 풀 리퀘스트를 병합, 댓글 작성, 업데이트하려면 GitHub 계정을 연결하세요."
+
+msgid "Superset Agent"
+msgstr "Superset 에이전트"
+
+msgid "Superset app"
+msgstr "Superset 앱"
+
+msgid "Superset App"
+msgstr "Superset 앱"
+
+msgid "Superset Automations"
+msgstr "Superset 자동화"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp는 해당 패널 전용 엔드포인트만 출력합니다. Playwright나 browser-use를 여기에 연결하세요."
@@ -20822,6 +20864,9 @@ msgstr "{plugin} 인증 요청을 거부했습니다."
msgid "You don't have access to this host"
msgstr "이 호스트에 접근할 권한이 없습니다"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "GitHub에서 이 풀 리퀘스트에 접근할 수 없거나, 더 이상 존재하지 않습니다."
+
msgid "You don't have access to this terminal."
msgstr "이 터미널에 접근할 권한이 없습니다."
diff --git a/packages/i18n/locales/nl/messages.po b/packages/i18n/locales/nl/messages.po
index 46b6a78a98e..813ed95a352 100644
--- a/packages/i18n/locales/nl/messages.po
+++ b/packages/i18n/locales/nl/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Verbind externe diensten om gegevens met je organisatie te synchronisere
msgid "Connect external services to sync data."
msgstr "Verbind externe diensten om gegevens te synchroniseren."
+msgid "Connect GitHub"
+msgstr "GitHub koppelen"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Koppel GitHub in Integraties om {repositoryFullName} toe te voegen."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Koppel GitHub in Instellingen om als jezelf op pull requests te handelen"
+msgid "Connect GitHub to continue"
+msgstr "Koppel GitHub om verder te gaan"
+
msgid "Connect GitHub…"
msgstr "GitHub koppelen…"
@@ -4785,9 +4791,15 @@ msgstr "Verbind Slack om taken vanuit gesprekken te beheren. Vermeld de bot in e
msgid "Connect this computer"
msgstr "Verbind deze computer"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Koppel om als jezelf op pull requests te handelen in plaats van als de workspace."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Verbind je {pluginLabel}-account en laad deze pagina daarna opnieuw."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Koppel je GitHub-account om deze pull request als jezelf te laden."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Koppel je GitHub-repository's en synchroniseer pull requests. Volg CI-status en reviews in je hele team."
@@ -5334,6 +5346,9 @@ msgstr "Kan deze diff niet laden"
msgid "Could not load this file."
msgstr "Kan dit bestand niet laden."
+msgid "Could not load this pull request."
+msgstr "Kan deze pull request niet laden."
+
msgid "Could not load your machines"
msgstr "Kan je machines niet laden"
@@ -5367,9 +5382,6 @@ msgstr "Kan geen mobiele simulator bereiken."
msgid "Could not reach the desktop."
msgstr "Kan het bureaublad niet bereiken."
-msgid "Could not reach the host to load this pull request."
-msgstr "Kan de host niet bereiken om deze pull request te laden."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Kon de host niet bereiken om de update te starten. Controleer of hij online is en probeer het opnieuw."
@@ -14341,6 +14353,12 @@ msgstr "Pull requests"
msgid "Pull Requests"
msgstr "Pull requests"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Pull requests, reacties en pushes vanuit Superset worden namens jou gedaan."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Pull requests, reacties en pushes vanuit Superset worden niet langer namens jou gedaan."
+
msgid "Purple"
msgstr "Paars"
@@ -17673,6 +17691,30 @@ msgstr "vervangen"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26) is de source-available IDE voor het tijdperk van AI-agents, waarin engineers honderden codeeragents zoals Claude Code en Codex parallel draaien."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset handelt op GitHub namens jou. Koppel je GitHub-account om pull requests te mergen, erop te reageren en bij te werken."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "Superset-app"
+
+msgid "Superset App"
+msgstr "Superset-app"
+
+msgid "Superset Automations"
+msgstr "Superset Automatiseringen"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp toont een endpoint voor alleen dat paneel. Richt Playwright of browser-use erop."
@@ -20822,6 +20864,9 @@ msgstr "Je hebt het autorisatieverzoek van {plugin} geweigerd."
msgid "You don't have access to this host"
msgstr "Je hebt geen toegang tot deze host"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "Je hebt op GitHub geen toegang tot deze pull request, of hij bestaat niet meer."
+
msgid "You don't have access to this terminal."
msgstr "Je hebt geen toegang tot deze terminal."
diff --git a/packages/i18n/locales/pl/messages.po b/packages/i18n/locales/pl/messages.po
index dc933f2af0c..f1201ea875d 100644
--- a/packages/i18n/locales/pl/messages.po
+++ b/packages/i18n/locales/pl/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Podłącz zewnętrzne usługi, aby synchronizować dane z organizacją."
msgid "Connect external services to sync data."
msgstr "Podłącz zewnętrzne usługi, aby synchronizować dane."
+msgid "Connect GitHub"
+msgstr "Połącz GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Połącz GitHub w Integracjach, aby dodać {repositoryFullName}."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Połącz GitHub w Ustawieniach, aby działać na pull requestach jako Ty"
+msgid "Connect GitHub to continue"
+msgstr "Połącz GitHub, aby kontynuować"
+
msgid "Connect GitHub…"
msgstr "Połącz GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "Podłącz Slack, aby zarządzać zadaniami z rozmów. Wspomnij bota na d
msgid "Connect this computer"
msgstr "Połącz ten komputer"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Połącz, aby działać na pull requestach jako Ty, a nie jako obszar roboczy."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Połącz swoje konto {pluginLabel}, a następnie odśwież tę stronę."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Połącz swoje konto GitHub, aby wczytać ten pull request jako Ty."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Podłącz swoje repozytoria GitHub i synchronizuj pull requesty. Śledź status CI i przeglądy w całym zespole."
@@ -5334,6 +5346,9 @@ msgstr "Nie udało się wczytać tych różnic"
msgid "Could not load this file."
msgstr "Nie udało się wczytać tego pliku."
+msgid "Could not load this pull request."
+msgstr "Nie udało się wczytać tego pull requesta."
+
msgid "Could not load your machines"
msgstr "Nie udało się wczytać Twoich maszyn"
@@ -5367,9 +5382,6 @@ msgstr "Nie można połączyć się z symulatorem mobilnym."
msgid "Could not reach the desktop."
msgstr "Nie można połączyć się z pulpitem."
-msgid "Could not reach the host to load this pull request."
-msgstr "Nie udało się połączyć z hostem, aby wczytać ten pull request."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Nie udało się połączyć z hostem, aby rozpocząć aktualizację. Sprawdź, czy jest online, i spróbuj ponownie."
@@ -14341,6 +14353,12 @@ msgstr "Pull requesty"
msgid "Pull Requests"
msgstr "Pull requesty"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Pull requesty, komentarze i pushe z Superset są wykonywane w Twoim imieniu."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Pull requesty, komentarze i pushe z Superset nie będą już wykonywane w Twoim imieniu."
+
msgid "Purple"
msgstr "Fioletowy"
@@ -17673,6 +17691,30 @@ msgstr "zastąpione"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26) to IDE z publicznie dostępnym kodem źródłowym na erę agentów AI, w którym inżynierowie uruchamiają równolegle setki agentów programistycznych, takich jak Claude Code i Codex."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset działa na GitHubie w Twoim imieniu. Połącz swoje konto GitHub, aby scalać, komentować i aktualizować pull requesty."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "Aplikacja Superset"
+
+msgid "Superset App"
+msgstr "Aplikacja Superset"
+
+msgid "Superset Automations"
+msgstr "Superset Automatyzacje"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp wypisuje endpoint tylko dla tego panelu. Skieruj na niego Playwright lub browser-use."
@@ -20822,6 +20864,9 @@ msgstr "Odrzucono żądanie autoryzacji {plugin}."
msgid "You don't have access to this host"
msgstr "Nie masz dostępu do tego hosta"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "Nie masz dostępu do tego pull requesta na GitHubie albo już nie istnieje."
+
msgid "You don't have access to this terminal."
msgstr "Nie masz dostępu do tego terminala."
diff --git a/packages/i18n/locales/pt-BR/messages.po b/packages/i18n/locales/pt-BR/messages.po
index 52751cfd723..b52d9a2c095 100644
--- a/packages/i18n/locales/pt-BR/messages.po
+++ b/packages/i18n/locales/pt-BR/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Conecte serviços externos para sincronizar dados com a sua organizaçã
msgid "Connect external services to sync data."
msgstr "Conecte serviços externos para sincronizar dados."
+msgid "Connect GitHub"
+msgstr "Conectar GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Conecte o GitHub em Integrações para adicionar {repositoryFullName}."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Conecte o GitHub em Configurações para agir nos pull requests como você mesmo"
+msgid "Connect GitHub to continue"
+msgstr "Conecte o GitHub para continuar"
+
msgid "Connect GitHub…"
msgstr "Conectar GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "Conecte o Slack para gerenciar tarefas a partir das conversas. Mencione
msgid "Connect this computer"
msgstr "Conectar este computador"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Conecte-se para agir nos pull requests como você mesmo, e não como o workspace."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Conecte sua conta do {pluginLabel} e recarregue esta página."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Conecte sua conta do GitHub para carregar este pull request como você."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Conecte seus repositórios do GitHub e sincronize pull requests. Acompanhe o status de CI e as revisões do time."
@@ -5334,6 +5346,9 @@ msgstr "Não foi possível carregar este diff"
msgid "Could not load this file."
msgstr "Não foi possível carregar este arquivo."
+msgid "Could not load this pull request."
+msgstr "Não foi possível carregar este pull request."
+
msgid "Could not load your machines"
msgstr "Não foi possível carregar suas máquinas"
@@ -5367,9 +5382,6 @@ msgstr "Não foi possível acessar um simulador móvel."
msgid "Could not reach the desktop."
msgstr "Não foi possível acessar a área de trabalho."
-msgid "Could not reach the host to load this pull request."
-msgstr "Não foi possível acessar o host para carregar este pull request."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Não foi possível alcançar o host para iniciar a atualização. Verifique se ele está online e tente novamente."
@@ -14341,6 +14353,12 @@ msgstr "Pull requests"
msgid "Pull Requests"
msgstr "Pull requests"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Pull requests, comentários e pushes feitos pelo Superset são feitos em seu nome."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Pull requests, comentários e pushes feitos pelo Superset deixarão de ser feitos em seu nome."
+
msgid "Purple"
msgstr "Roxo"
@@ -17673,6 +17691,30 @@ msgstr "substituída"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "O Superset (YC P26) é o IDE com código-fonte disponível para a era dos agentes de IA, em que engenheiros executam centenas de agentes de programação como Claude Code e Codex em paralelo."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "O Superset age no GitHub em seu nome. Conecte sua conta do GitHub para fazer merge, comentar e atualizar pull requests."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "App Superset"
+
+msgid "Superset App"
+msgstr "App Superset"
+
+msgid "Superset Automations"
+msgstr "Automações do Superset"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp imprime um endpoint apenas para esse painel. Aponte o Playwright ou o browser-use para ele."
@@ -20822,6 +20864,9 @@ msgstr "Você recusou a solicitação de autorização do {plugin}."
msgid "You don't have access to this host"
msgstr "Você não tem acesso a este host"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "Você não tem acesso a este pull request no GitHub, ou ele não existe mais."
+
msgid "You don't have access to this terminal."
msgstr "Você não tem acesso a este terminal."
diff --git a/packages/i18n/locales/ru/messages.po b/packages/i18n/locales/ru/messages.po
index b6bbd194720..c367985ec07 100644
--- a/packages/i18n/locales/ru/messages.po
+++ b/packages/i18n/locales/ru/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Подключайте внешние сервисы для синхро
msgid "Connect external services to sync data."
msgstr "Подключайте внешние сервисы для синхронизации данных."
+msgid "Connect GitHub"
+msgstr "Подключить GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Подключите GitHub в разделе «Интеграции», чтобы добавить {repositoryFullName}."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Подключите GitHub в настройках, чтобы работать с пул-реквестами от своего имени"
+msgid "Connect GitHub to continue"
+msgstr "Подключите GitHub, чтобы продолжить"
+
msgid "Connect GitHub…"
msgstr "Подключить GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "Подключите Slack, чтобы управлять задачам
msgid "Connect this computer"
msgstr "Подключите этот компьютер"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Подключитесь, чтобы работать с пул-реквестами от своего имени, а не от имени рабочей области."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Подключите аккаунт {pluginLabel}, затем перезагрузите эту страницу."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Подключите свой аккаунт GitHub, чтобы загрузить этот пул-реквест от своего имени."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Подключите репозитории GitHub и синхронизируйте пул-реквесты. Отслеживайте статус CI и ревью по всей команде."
@@ -5334,6 +5346,9 @@ msgstr "Не удалось загрузить этот diff"
msgid "Could not load this file."
msgstr "Не удалось загрузить этот файл."
+msgid "Could not load this pull request."
+msgstr "Не удалось загрузить этот пул-реквест."
+
msgid "Could not load your machines"
msgstr "Не удалось загрузить ваши машины"
@@ -5367,9 +5382,6 @@ msgstr "Не удалось подключиться к мобильному с
msgid "Could not reach the desktop."
msgstr "Не удалось подключиться к рабочему столу."
-msgid "Could not reach the host to load this pull request."
-msgstr "Не удалось связаться с хостом, чтобы загрузить этот пул-реквест."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Не удалось связаться с хостом, чтобы начать обновление. Убедитесь, что он в сети, и попробуйте снова."
@@ -14341,6 +14353,12 @@ msgstr "Пул-реквесты"
msgid "Pull Requests"
msgstr "Пул-реквесты"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Пул-реквесты, комментарии и пуши из Superset выполняются от вашего имени."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Пул-реквесты, комментарии и пуши из Superset больше не будут выполняться от вашего имени."
+
msgid "Purple"
msgstr "Фиолетовый"
@@ -17673,6 +17691,30 @@ msgstr "заменён"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26) — это IDE с доступным исходным кодом для эпохи ИИ-агентов, в которой инженеры параллельно запускают сотни агентов для программирования, таких как Claude Code и Codex."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset действует на GitHub от вашего имени. Подключите свой аккаунт GitHub, чтобы объединять, комментировать и обновлять пул-реквесты."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "Приложение Superset"
+
+msgid "Superset App"
+msgstr "Приложение Superset"
+
+msgid "Superset Automations"
+msgstr "Superset Автоматизации"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp выводит эндпоинт только для этой панели. Направьте на него Playwright или browser-use."
@@ -20822,6 +20864,9 @@ msgstr "Вы отклонили запрос на авторизацию {plugin
msgid "You don't have access to this host"
msgstr "У вас нет доступа к этому хосту"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "У вас нет доступа к этому пул-реквесту на GitHub, или он больше не существует."
+
msgid "You don't have access to this terminal."
msgstr "У вас нет доступа к этому терминалу."
diff --git a/packages/i18n/locales/tr/messages.po b/packages/i18n/locales/tr/messages.po
index ff2326d5153..ba00d065c41 100644
--- a/packages/i18n/locales/tr/messages.po
+++ b/packages/i18n/locales/tr/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Kuruluşunuzla veri eşitlemek için harici hizmetleri bağlayın."
msgid "Connect external services to sync data."
msgstr "Verileri eşitlemek için harici hizmetleri bağlayın."
+msgid "Connect GitHub"
+msgstr "GitHub'ı bağla"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "{repositoryFullName} eklemek için Entegrasyonlar'da GitHub'ı bağlayın."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Pull request'lerde kendi adınıza işlem yapmak için Ayarlar'dan GitHub'ı bağlayın"
+msgid "Connect GitHub to continue"
+msgstr "Devam etmek için GitHub'ı bağlayın"
+
msgid "Connect GitHub…"
msgstr "GitHub'ı bağla…"
@@ -4785,9 +4791,15 @@ msgstr "Görevleri konuşmalardan yönetmek için Slack'i bağlayın. Görev olu
msgid "Connect this computer"
msgstr "Bu bilgisayarı bağlayın"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Pull request'lerde çalışma alanı yerine kendi adınıza işlem yapmak için bağlanın."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "{pluginLabel} hesabınızı bağlayın, ardından bu sayfayı yeniden yükleyin."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Bu pull request'i kendi adınıza yüklemek için GitHub hesabınızı bağlayın."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "GitHub depolarınızı bağlayın ve pull request'leri eşitleyin. CI durumunu ve incelemeleri takımınız genelinde izleyin."
@@ -5334,6 +5346,9 @@ msgstr "Bu fark yüklenemedi"
msgid "Could not load this file."
msgstr "Bu dosya yüklenemedi."
+msgid "Could not load this pull request."
+msgstr "Bu pull request yüklenemedi."
+
msgid "Could not load your machines"
msgstr "Makineleriniz yüklenemedi"
@@ -5367,9 +5382,6 @@ msgstr "Bir mobil simülatöre ulaşılamadı."
msgid "Could not reach the desktop."
msgstr "Masaüstüne ulaşılamadı."
-msgid "Could not reach the host to load this pull request."
-msgstr "Bu pull request'i yüklemek için host'a erişilemedi."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Güncellemeyi başlatmak için ana makineye ulaşılamadı. Çevrimiçi olduğundan emin olup tekrar deneyin."
@@ -14341,6 +14353,12 @@ msgstr "Pull request'ler"
msgid "Pull Requests"
msgstr "Pull request'ler"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Superset'ten yapılan pull request'ler, yorumlar ve push'lar sizin adınıza yapılır."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Superset'ten yapılan pull request'ler, yorumlar ve push'lar artık sizin adınıza yapılmayacak."
+
msgid "Purple"
msgstr "Mor"
@@ -17673,6 +17691,30 @@ msgstr "geçersiz kılındı"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26), mühendislerin Claude Code ve Codex gibi yüzlerce kodlama ajanını paralel olarak çalıştırdığı, yapay zekâ ajanları çağı için kaynak kodu erişilebilir IDE'dir."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset, GitHub'da sizin adınıza işlem yapar. Pull request'leri birleştirmek, yorumlamak ve güncellemek için GitHub hesabınızı bağlayın."
+
+msgid "Superset Agent"
+msgstr "Superset Ajanı"
+
+msgid "Superset app"
+msgstr "Superset uygulaması"
+
+msgid "Superset App"
+msgstr "Superset uygulaması"
+
+msgid "Superset Automations"
+msgstr "Superset Otomasyonlar"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp yalnızca o bölme için bir uç nokta yazdırır. Playwright'ı veya browser-use'u ona yönlendirin."
@@ -20822,6 +20864,9 @@ msgstr "{plugin} yetkilendirme isteğini reddettiniz."
msgid "You don't have access to this host"
msgstr "Bu host'a erişiminiz yok"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "GitHub'da bu pull request'e erişiminiz yok veya artık mevcut değil."
+
msgid "You don't have access to this terminal."
msgstr "Bu terminale erişiminiz yok."
diff --git a/packages/i18n/locales/vi/messages.po b/packages/i18n/locales/vi/messages.po
index 392e976a3c8..2d83b67c863 100644
--- a/packages/i18n/locales/vi/messages.po
+++ b/packages/i18n/locales/vi/messages.po
@@ -4746,12 +4746,18 @@ msgstr "Kết nối dịch vụ bên ngoài để đồng bộ dữ liệu với
msgid "Connect external services to sync data."
msgstr "Kết nối dịch vụ bên ngoài để đồng bộ dữ liệu."
+msgid "Connect GitHub"
+msgstr "Kết nối GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "Kết nối GitHub trong Tích hợp để thêm {repositoryFullName}."
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "Kết nối GitHub trong Cài đặt để thao tác với pull request dưới tên của bạn"
+msgid "Connect GitHub to continue"
+msgstr "Kết nối GitHub để tiếp tục"
+
msgid "Connect GitHub…"
msgstr "Kết nối GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "Kết nối Slack để quản lý tác vụ ngay trong hội thoại. N
msgid "Connect this computer"
msgstr "Kết nối máy tính này"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "Kết nối để thao tác với pull request dưới tên của bạn thay vì dưới tên workspace."
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "Kết nối tài khoản {pluginLabel} của bạn, sau đó tải lại trang này."
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "Kết nối tài khoản GitHub của bạn để tải pull request này dưới tên của bạn."
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "Kết nối các repository GitHub của bạn và đồng bộ pull request. Theo dõi trạng thái CI và review trong cả nhóm."
@@ -5334,6 +5346,9 @@ msgstr "Không thể tải diff này"
msgid "Could not load this file."
msgstr "Không thể tải tệp này."
+msgid "Could not load this pull request."
+msgstr "Không thể tải pull request này."
+
msgid "Could not load your machines"
msgstr "Không thể tải danh sách máy của bạn"
@@ -5367,9 +5382,6 @@ msgstr "Không thể kết nối tới trình giả lập di động."
msgid "Could not reach the desktop."
msgstr "Không thể kết nối tới màn hình nền."
-msgid "Could not reach the host to load this pull request."
-msgstr "Không kết nối được tới host để tải pull request này."
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "Không thể kết nối tới máy chủ để bắt đầu cập nhật. Hãy kiểm tra máy chủ đang trực tuyến rồi thử lại."
@@ -14341,6 +14353,12 @@ msgstr "Pull request"
msgid "Pull Requests"
msgstr "Pull request"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "Các pull request, bình luận và push từ Superset được thực hiện dưới tên của bạn."
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "Các pull request, bình luận và push từ Superset sẽ không còn được thực hiện dưới tên của bạn."
+
msgid "Purple"
msgstr "Tím"
@@ -17673,6 +17691,30 @@ msgstr "bị thay thế"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset (YC P26) là IDE công khai mã nguồn cho kỷ nguyên agent AI, nơi các kỹ sư chạy song song hàng trăm agent lập trình như Claude Code và Codex."
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset thao tác trên GitHub dưới tên của bạn. Kết nối tài khoản GitHub để hợp nhất, bình luận và cập nhật pull request."
+
+msgid "Superset Agent"
+msgstr "Superset Agent"
+
+msgid "Superset app"
+msgstr "Ứng dụng Superset"
+
+msgid "Superset App"
+msgstr "Ứng dụng Superset"
+
+msgid "Superset Automations"
+msgstr "Tự động hóa Superset"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp in ra endpoint chỉ cho ngăn đó. Trỏ Playwright hoặc browser-use vào đó."
@@ -20822,6 +20864,9 @@ msgstr "Bạn đã từ chối yêu cầu ủy quyền của {plugin}."
msgid "You don't have access to this host"
msgstr "Bạn không có quyền truy cập host này"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "Bạn không có quyền truy cập pull request này trên GitHub, hoặc nó không còn tồn tại."
+
msgid "You don't have access to this terminal."
msgstr "Bạn không có quyền truy cập terminal này."
diff --git a/packages/i18n/locales/zh-CN/messages.po b/packages/i18n/locales/zh-CN/messages.po
index 6235be51556..2545852b2de 100644
--- a/packages/i18n/locales/zh-CN/messages.po
+++ b/packages/i18n/locales/zh-CN/messages.po
@@ -4746,12 +4746,18 @@ msgstr "连接外部服务,与你的组织同步数据。"
msgid "Connect external services to sync data."
msgstr "连接外部服务以同步数据。"
+msgid "Connect GitHub"
+msgstr "连接 GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "在集成中连接 GitHub 以添加 {repositoryFullName}。"
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "在设置中连接 GitHub,以你自己的身份处理拉取请求"
+msgid "Connect GitHub to continue"
+msgstr "连接 GitHub 以继续"
+
msgid "Connect GitHub…"
msgstr "连接 GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "连接Slack,直接在对话中管理任务。在任意频道提及机
msgid "Connect this computer"
msgstr "连接这台电脑"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "连接后,将以你自己的身份而非工作区的身份处理拉取请求。"
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "连接你的 {pluginLabel} 账户,然后重新加载此页面。"
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "连接你的 GitHub 账户,以你自己的身份加载此拉取请求。"
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "连接你的GitHub仓库并同步拉取请求。跟踪整个团队的CI状态和代码审查。"
@@ -5334,6 +5346,9 @@ msgstr "无法加载这个差异"
msgid "Could not load this file."
msgstr "无法加载这个文件。"
+msgid "Could not load this pull request."
+msgstr "无法加载此拉取请求。"
+
msgid "Could not load your machines"
msgstr "无法加载你的机器"
@@ -5367,9 +5382,6 @@ msgstr "无法连接到移动模拟器。"
msgid "Could not reach the desktop."
msgstr "无法连接到桌面。"
-msgid "Could not reach the host to load this pull request."
-msgstr "无法连接到主机以加载此拉取请求。"
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "无法连接主机以开始更新。请确认主机在线后重试。"
@@ -14341,6 +14353,12 @@ msgstr "拉取请求"
msgid "Pull Requests"
msgstr "拉取请求"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "来自 Superset 的拉取请求、评论和推送以你的身份进行。"
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "来自 Superset 的拉取请求、评论和推送将不再以你的身份进行。"
+
msgid "Purple"
msgstr "紫色"
@@ -17673,6 +17691,30 @@ msgstr "已被取代"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset(YC P26)是面向 AI 智能体时代的源码可用 IDE,工程师可以在其中并行运行数百个 Claude Code、Codex 等编程智能体。"
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset 以你的身份在 GitHub 上操作。连接你的 GitHub 账户以合并、评论和更新拉取请求。"
+
+msgid "Superset Agent"
+msgstr "Superset智能体"
+
+msgid "Superset app"
+msgstr "Superset应用"
+
+msgid "Superset App"
+msgstr "Superset应用"
+
+msgid "Superset Automations"
+msgstr "Superset 自动化"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp 只会输出该窗格专属的端点。让 Playwright 或 browser-use 连接它即可。"
@@ -20822,6 +20864,9 @@ msgstr "你拒绝了 {plugin} 的授权请求。"
msgid "You don't have access to this host"
msgstr "你没有此主机的访问权限"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "你在 GitHub 上没有此拉取请求的访问权限,或者它已不存在。"
+
msgid "You don't have access to this terminal."
msgstr "你没有此终端的访问权限。"
diff --git a/packages/i18n/locales/zh-TW/messages.po b/packages/i18n/locales/zh-TW/messages.po
index 31a29ac5575..bb0b5ff9ac5 100644
--- a/packages/i18n/locales/zh-TW/messages.po
+++ b/packages/i18n/locales/zh-TW/messages.po
@@ -4746,12 +4746,18 @@ msgstr "連線外部服務,與你的組織同步資料。"
msgid "Connect external services to sync data."
msgstr "連線外部服務以同步資料。"
+msgid "Connect GitHub"
+msgstr "連接 GitHub"
+
msgid "Connect GitHub in Integrations to add {repositoryFullName}."
msgstr "在整合中連結 GitHub 以新增 {repositoryFullName}。"
msgid "Connect GitHub in Settings to act on pull requests as yourself"
msgstr "在設定中連接 GitHub,以你自己的身分處理拉取請求"
+msgid "Connect GitHub to continue"
+msgstr "連接 GitHub 以繼續"
+
msgid "Connect GitHub…"
msgstr "連結 GitHub…"
@@ -4785,9 +4791,15 @@ msgstr "連線Slack,直接在對話中管理任務。在任意頻道提及機
msgid "Connect this computer"
msgstr "連線至這台電腦"
+msgid "Connect to act on pull requests as yourself instead of as the workspace."
+msgstr "連接後,將以你自己的身分而非工作區的身分處理拉取請求。"
+
msgid "Connect your {pluginLabel} account, then reload this page."
msgstr "連線你的 {pluginLabel} 帳戶,然後重新載入此頁面。"
+msgid "Connect your GitHub account to load this pull request as you."
+msgstr "連接你的 GitHub 帳戶,以你自己的身分載入此拉取請求。"
+
msgid "Connect your GitHub repositories and sync pull requests. Track CI status and reviews across your team."
msgstr "連線你的GitHub儲存庫並同步拉取請求。追蹤整個團隊的CI狀態和程式碼審查。"
@@ -5334,6 +5346,9 @@ msgstr "無法載入這個差異"
msgid "Could not load this file."
msgstr "無法載入這個檔案。"
+msgid "Could not load this pull request."
+msgstr "無法載入此拉取請求。"
+
msgid "Could not load your machines"
msgstr "無法載入你的機器"
@@ -5367,9 +5382,6 @@ msgstr "無法連線至行動模擬器。"
msgid "Could not reach the desktop."
msgstr "無法連線至桌面。"
-msgid "Could not reach the host to load this pull request."
-msgstr "無法連線到主機以載入此拉取請求。"
-
msgid "Could not reach the host to start the update. Check that it is online and try again."
msgstr "無法連線主機以開始更新。請確認主機在線上後重試。"
@@ -14341,6 +14353,12 @@ msgstr "拉取請求"
msgid "Pull Requests"
msgstr "拉取請求"
+msgid "Pull requests, comments and pushes from Superset are made as you."
+msgstr "來自 Superset 的拉取請求、留言和推送以你的身分進行。"
+
+msgid "Pull requests, comments and pushes from Superset will no longer be made as you."
+msgstr "來自 Superset 的拉取請求、留言和推送將不再以你的身分進行。"
+
msgid "Purple"
msgstr "紫色"
@@ -17673,6 +17691,30 @@ msgstr "已被取代"
msgid "superset"
msgstr "superset"
+msgid "Superset"
+msgstr "Superset"
+
+msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
+msgstr "Superset(YC P26)是為 AI agent 時代打造的原始碼公開 IDE,工程師可以在其中平行執行數百個 Claude Code、Codex 等程式設計 agent。"
+
+msgid "Superset {version}"
+msgstr "Superset {version}"
+
+msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
+msgstr "Superset 以你的身分在 GitHub 上操作。連接你的 GitHub 帳戶以合併、留言和更新拉取請求。"
+
+msgid "Superset Agent"
+msgstr "Superset代理程式"
+
+msgid "Superset app"
+msgstr "Superset應用程式"
+
+msgid "Superset App"
+msgstr "Superset應用程式"
+
+msgid "Superset Automations"
+msgstr "Superset 自動化"
+
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp 只會輸出該窗格專屬的端點。讓 Playwright 或 browser-use 連接它即可。"
@@ -20822,6 +20864,9 @@ msgstr "你拒絕了 {plugin} 的授權請求。"
msgid "You don't have access to this host"
msgstr "你沒有此主機的存取權限"
+msgid "You don't have access to this pull request on GitHub, or it no longer exists."
+msgstr "你在 GitHub 上沒有此拉取請求的存取權限,或者它已不存在。"
+
msgid "You don't have access to this terminal."
msgstr "你沒有此終端的存取權限。"
diff --git a/packages/shared/package.json b/packages/shared/package.json
index 5de8d115253..2515c402668 100644
--- a/packages/shared/package.json
+++ b/packages/shared/package.json
@@ -189,6 +189,10 @@
"types": "./src/pull-request.ts",
"default": "./src/pull-request.ts"
},
+ "./pull-request-detail": {
+ "types": "./src/pull-request-detail/index.ts",
+ "default": "./src/pull-request-detail/index.ts"
+ },
"./pull-request-checks": {
"types": "./src/pull-request-checks/index.ts",
"default": "./src/pull-request-checks/index.ts"
diff --git a/packages/shared/src/pull-request-detail/index.ts b/packages/shared/src/pull-request-detail/index.ts
new file mode 100644
index 00000000000..bf10a85adcc
--- /dev/null
+++ b/packages/shared/src/pull-request-detail/index.ts
@@ -0,0 +1,11 @@
+export {
+ type PullRequestDetailCheck,
+ type PullRequestDetailClient,
+ type PullRequestDetailInput,
+ type PullRequestDetailQuery,
+ type PullRequestDetailRead,
+ type PullRequestDetailReviewer,
+ PullRequestReadError,
+ pullRequestNodeId,
+ readPullRequestDetail,
+} from "./pull-request-detail";
diff --git a/packages/shared/src/pull-request-detail/pull-request-detail.test.ts b/packages/shared/src/pull-request-detail/pull-request-detail.test.ts
new file mode 100644
index 00000000000..c110146d2b8
--- /dev/null
+++ b/packages/shared/src/pull-request-detail/pull-request-detail.test.ts
@@ -0,0 +1,181 @@
+import { describe, expect, test } from "bun:test";
+import {
+ type PullRequestDetailQuery,
+ PullRequestReadError,
+ readPullRequestDetail,
+} from "./pull-request-detail";
+
+const input = { owner: "acme", repo: "widgets", pullNumber: 7 };
+
+function pullRequest(
+ overrides: Partial<
+ NonNullable<
+ NonNullable["pullRequest"]
+ >
+ > = {},
+): PullRequestDetailQuery {
+ return {
+ repository: {
+ squashMergeAllowed: true,
+ mergeCommitAllowed: false,
+ rebaseMergeAllowed: true,
+ pullRequest: {
+ id: "PR_1",
+ number: 7,
+ title: "Widgets",
+ body: "",
+ url: "https://github.com/acme/widgets/pull/7",
+ baseRefName: "main",
+ state: "OPEN",
+ isDraft: false,
+ merged: false,
+ mergedAt: null,
+ additions: 3,
+ deletions: 1,
+ changedFiles: 2,
+ mergeable: "MERGEABLE",
+ mergeStateStatus: "BEHIND",
+ reviewDecision: "REVIEW_REQUIRED",
+ viewerCanUpdate: true,
+ viewerCanMergeAsAdmin: false,
+ mergedBy: null,
+ mergeQueueEntry: null,
+ baseRef: {
+ branchProtectionRule: {
+ requiredApprovingReviewCount: 2,
+ requiresConversationResolution: true,
+ },
+ },
+ latestOpinionatedReviews: {
+ nodes: [
+ { state: "APPROVED", author: { login: "maya", avatarUrl: "m" } },
+ {
+ state: "CHANGES_REQUESTED",
+ author: { login: "lee", avatarUrl: null },
+ },
+ ],
+ },
+ reviewThreads: {
+ pageInfo: { hasNextPage: true, endCursor: "c1" },
+ nodes: [{ isResolved: false, isOutdated: false }],
+ },
+ statusCheckRollup: {
+ contexts: {
+ pageInfo: { hasNextPage: false, endCursor: null },
+ nodes: [
+ {
+ __typename: "CheckRun",
+ name: "CI / Typecheck",
+ status: "COMPLETED",
+ conclusion: "FAILURE",
+ isRequired: true,
+ },
+ {
+ __typename: "StatusContext",
+ context: "lint",
+ state: "PENDING",
+ },
+ ],
+ },
+ },
+ ...overrides,
+ },
+ },
+ };
+}
+
+describe("readPullRequestDetail", () => {
+ test("drains every page before grading, and a review outranks a request", async () => {
+ const queries: string[] = [];
+ const detail = await readPullRequestDetail(
+ {
+ graphql: async (
+ query: string,
+ variables: Record,
+ ) => {
+ queries.push(String(variables.cursor ?? "first"));
+ if (variables.cursor === "c1") {
+ return {
+ repository: {
+ pullRequest: {
+ reviewThreads: {
+ pageInfo: { hasNextPage: false, endCursor: null },
+ nodes: [{ isResolved: false, isOutdated: true }, null],
+ },
+ },
+ },
+ } as T;
+ }
+ return pullRequest() as T;
+ },
+ requestedReviewers: async () => ({
+ users: [{ login: "maya", avatar_url: "m" }, { login: "sam" }],
+ teams: [{ name: "platform" }],
+ }),
+ },
+ input,
+ );
+ expect(queries).toEqual(["first", "c1"]);
+ expect(detail.reviewers).toEqual([
+ { login: "maya", avatarUrl: "m", isTeam: false, state: "APPROVED" },
+ { login: "sam", avatarUrl: null, isTeam: false, state: "REQUESTED" },
+ { login: "platform", avatarUrl: null, isTeam: true, state: "REQUESTED" },
+ {
+ login: "lee",
+ avatarUrl: null,
+ isTeam: false,
+ state: "CHANGES_REQUESTED",
+ },
+ ]);
+ expect(detail.mergeability).toMatchObject({
+ approvals: 1,
+ requiredApprovals: 2,
+ unresolvedThreads: 1,
+ requiresThreadResolution: true,
+ allowedMergeMethods: ["squash", "rebase"],
+ });
+ expect(
+ detail.checks.map((check) => [check.name, check.conclusion]),
+ ).toEqual([
+ ["CI / Typecheck", "FAILURE"],
+ ["lint", null],
+ ]);
+ expect(detail.capabilities).toEqual({
+ merge: true,
+ markReady: false,
+ updateBranch: true,
+ reopen: false,
+ dequeue: false,
+ });
+ });
+
+ test("a page without a cursor fails the read rather than grading a partial set", async () => {
+ await expect(
+ readPullRequestDetail(
+ {
+ graphql: async () =>
+ pullRequest({
+ reviewThreads: {
+ pageInfo: { hasNextPage: true, endCursor: null },
+ nodes: [],
+ },
+ }) as T,
+ requestedReviewers: async () => ({ users: [], teams: [] }),
+ },
+ input,
+ ),
+ ).rejects.toMatchObject({ code: "CONFLICT" });
+ });
+
+ test("a missing pull request is NOT_FOUND", async () => {
+ const error = await readPullRequestDetail(
+ {
+ graphql: async () => ({ repository: { pullRequest: null } }) as T,
+ requestedReviewers: async () => ({ users: [], teams: [] }),
+ },
+ input,
+ ).catch((e) => e);
+ expect(error).toBeInstanceOf(PullRequestReadError);
+ expect(error.code).toBe("NOT_FOUND");
+ });
+});
diff --git a/packages/shared/src/pull-request-detail/pull-request-detail.ts b/packages/shared/src/pull-request-detail/pull-request-detail.ts
new file mode 100644
index 00000000000..bc69ae8b3ea
--- /dev/null
+++ b/packages/shared/src/pull-request-detail/pull-request-detail.ts
@@ -0,0 +1,531 @@
+/**
+ * Everything one pull request view needs, read live from GitHub.
+ *
+ * Deliberately GraphQL and deliberately live: mergeability, per-viewer
+ * capabilities, reviewer states and whether a check is required exist
+ * nowhere in the synced rows, and a button offered on stale data is a
+ * button that fails when pressed.
+ */
+
+export interface PullRequestDetailInput {
+ owner: string;
+ repo: string;
+ pullNumber: number;
+}
+
+export interface PullRequestDetailClient {
+ graphql: (query: string, variables: Record) => Promise;
+ /**
+ * `GET /repos/{owner}/{repo}/pulls/{n}/requested_reviewers`. REST because
+ * every GraphQL Team field needs the read:org scope, which tokens minted by
+ * editors and GitHub Desktop lack.
+ */
+ requestedReviewers: (input: PullRequestDetailInput) => Promise<{
+ users: { login: string; avatar_url?: string | null }[];
+ teams: { name: string }[];
+ }>;
+}
+
+/** GitHub answered, but not with a pull request: the caller maps the code onto its own error type. */
+export class PullRequestReadError extends Error {
+ constructor(
+ readonly code: "NOT_FOUND" | "CONFLICT",
+ message: string,
+ ) {
+ super(message);
+ this.name = "PullRequestReadError";
+ }
+}
+
+export interface PullRequestDetailCheck {
+ name: string;
+ status: string;
+ conclusion: string | null;
+ isRequired: boolean;
+ startedAt: string | null;
+ completedAt: string | null;
+ detailsUrl: string | null;
+}
+
+export interface PullRequestDetailReviewer {
+ login: string;
+ avatarUrl: string | null;
+ isTeam: boolean;
+ state: string;
+}
+
+export interface PullRequestDetailRead {
+ pullRequest: {
+ id: string;
+ number: number;
+ title: string;
+ body: string;
+ url: string;
+ baseBranch: string;
+ state: "open" | "closed" | "merged";
+ isDraft: boolean;
+ additions: number;
+ deletions: number;
+ changedFiles: number;
+ mergedAt: string | null;
+ mergedBy: { login: string; avatarUrl: string | null } | null;
+ };
+ checks: PullRequestDetailCheck[];
+ reviewers: PullRequestDetailReviewer[];
+ mergeability: {
+ mergeable: string;
+ mergeStateStatus: string;
+ approvals: number;
+ requiredApprovals: number;
+ reviewDecision: string | null;
+ unresolvedThreads: number;
+ requiresThreadResolution: boolean;
+ queue: { position: number | null; state: string } | null;
+ allowedMergeMethods: string[];
+ };
+ capabilities: {
+ merge: boolean;
+ markReady: boolean;
+ updateBranch: boolean;
+ reopen: boolean;
+ dequeue: boolean;
+ };
+}
+
+/**
+ * `isRequired` is asked per pull request because a check is only required
+ * relative to the branch rules it runs under.
+ */
+const PULL_REQUEST_DETAIL_QUERY = `
+query($owner: String!, $name: String!, $number: Int!) {
+ repository(owner: $owner, name: $name) {
+ squashMergeAllowed
+ mergeCommitAllowed
+ rebaseMergeAllowed
+ pullRequest(number: $number) {
+ id number title body url baseRefName state isDraft merged mergedAt
+ additions deletions changedFiles
+ mergeable mergeStateStatus reviewDecision
+ viewerCanUpdate viewerCanMergeAsAdmin
+ mergedBy { login avatarUrl }
+ mergeQueueEntry { position state }
+ baseRef {
+ branchProtectionRule {
+ requiredApprovingReviewCount
+ requiresConversationResolution
+ }
+ }
+ latestOpinionatedReviews(first: 20) {
+ nodes { state author { login avatarUrl } }
+ }
+ reviewThreads(first: 100) {
+ pageInfo { hasNextPage endCursor }
+ nodes { isResolved isOutdated }
+ }
+ statusCheckRollup {
+ contexts(first: 100) {
+ pageInfo { hasNextPage endCursor }
+ nodes {
+ __typename
+ ... on CheckRun {
+ name status conclusion detailsUrl startedAt completedAt
+ isRequired(pullRequestNumber: $number)
+ }
+ ... on StatusContext {
+ context state targetUrl createdAt
+ isRequired(pullRequestNumber: $number)
+ }
+ }
+ }
+ }
+ }
+ }
+}`;
+
+const REVIEW_THREADS_PAGE_QUERY = `
+query($owner: String!, $name: String!, $number: Int!, $cursor: String!) {
+ repository(owner: $owner, name: $name) {
+ pullRequest(number: $number) {
+ reviewThreads(first: 100, after: $cursor) {
+ pageInfo { hasNextPage endCursor }
+ nodes { isResolved isOutdated }
+ }
+ }
+ }
+}`;
+
+const CHECK_CONTEXTS_PAGE_QUERY = `
+query($owner: String!, $name: String!, $number: Int!, $cursor: String!) {
+ repository(owner: $owner, name: $name) {
+ pullRequest(number: $number) {
+ statusCheckRollup {
+ contexts(first: 100, after: $cursor) {
+ pageInfo { hasNextPage endCursor }
+ nodes {
+ __typename
+ ... on CheckRun {
+ name status conclusion detailsUrl startedAt completedAt
+ isRequired(pullRequestNumber: $number)
+ }
+ ... on StatusContext {
+ context state targetUrl createdAt
+ isRequired(pullRequestNumber: $number)
+ }
+ }
+ }
+ }
+ }
+ }
+}`;
+
+interface ConnectionPageInfo {
+ hasNextPage: boolean;
+ endCursor: string | null;
+}
+
+interface ReviewThreadNode {
+ isResolved: boolean;
+ isOutdated: boolean;
+}
+
+interface ReviewThreadsConnection {
+ pageInfo: ConnectionPageInfo;
+ nodes: (ReviewThreadNode | null)[];
+}
+
+interface CheckContextNode {
+ __typename: string;
+ name?: string;
+ status?: string;
+ conclusion?: string | null;
+ detailsUrl?: string | null;
+ startedAt?: string | null;
+ completedAt?: string | null;
+ context?: string;
+ state?: string;
+ targetUrl?: string | null;
+ createdAt?: string | null;
+ isRequired?: boolean;
+}
+
+interface CheckContextsConnection {
+ pageInfo: ConnectionPageInfo;
+ nodes: (CheckContextNode | null)[];
+}
+
+export interface PullRequestDetailQuery {
+ repository: {
+ squashMergeAllowed: boolean;
+ mergeCommitAllowed: boolean;
+ rebaseMergeAllowed: boolean;
+ pullRequest: {
+ id: string;
+ number: number;
+ title: string;
+ body: string;
+ url: string;
+ baseRefName: string;
+ state: string;
+ isDraft: boolean;
+ merged: boolean;
+ mergedAt: string | null;
+ additions: number;
+ deletions: number;
+ changedFiles: number;
+ mergeable: string;
+ mergeStateStatus: string;
+ reviewDecision: string | null;
+ viewerCanUpdate: boolean;
+ viewerCanMergeAsAdmin: boolean;
+ mergedBy: { login: string; avatarUrl: string | null } | null;
+ mergeQueueEntry: { position: number | null; state: string } | null;
+ baseRef: {
+ branchProtectionRule: {
+ requiredApprovingReviewCount: number | null;
+ requiresConversationResolution: boolean | null;
+ } | null;
+ } | null;
+ latestOpinionatedReviews: {
+ nodes: ({
+ state: string;
+ author: { login: string; avatarUrl: string | null } | null;
+ } | null)[];
+ } | null;
+ reviewThreads: ReviewThreadsConnection | null;
+ statusCheckRollup: {
+ contexts: CheckContextsConnection | null;
+ } | null;
+ } | null;
+ } | null;
+}
+
+/**
+ * 100 nodes is GitHub's page cap, not a promise of completeness — a failing
+ * required check or an open thread past the first page would otherwise never
+ * be seen, and the card would grade a partial pull request as ready. Drains
+ * the connection; a handful of round trips at most.
+ *
+ * GitHub's own flags are trusted but not absolutely: a stuck cursor from a
+ * GitHub-side pagination bug must not turn one detail query into an infinite
+ * loop that pins the server and burns the token's rate limit. 20 pages is
+ * 2,000 nodes — far past any real pull request.
+ */
+const MAX_DRAIN_PAGES = 20;
+
+async function drain(
+ what: string,
+ input: PullRequestDetailInput,
+ pageInfo: ConnectionPageInfo | undefined,
+ fetchPage: (
+ cursor: string,
+ ) => Promise<
+ { pageInfo: ConnectionPageInfo; nodes: Node[] } | null | undefined
+ >,
+): Promise {
+ const nodes: Node[] = [];
+ let page = pageInfo ?? null;
+ let pages = 0;
+ while (page?.hasNextPage) {
+ // hasNextPage with no cursor would end the loop on a partial set —
+ // the silent truncation this drain exists to remove.
+ if (!page.endCursor) {
+ throw new PullRequestReadError(
+ "CONFLICT",
+ `GitHub reported more ${what} but no cursor for pull request #${input.pullNumber}.`,
+ );
+ }
+ if (++pages > MAX_DRAIN_PAGES) {
+ throw new PullRequestReadError(
+ "CONFLICT",
+ `Pull request #${input.pullNumber} did not finish paginating ${what} after ${MAX_DRAIN_PAGES} pages.`,
+ );
+ }
+ const connection = await fetchPage(page.endCursor);
+ if (!connection) {
+ throw new PullRequestReadError(
+ "CONFLICT",
+ `GitHub returned no ${what} page for pull request #${input.pullNumber} while paginating.`,
+ );
+ }
+ nodes.push(...connection.nodes);
+ page = connection.pageInfo;
+ }
+ return nodes;
+}
+
+function variables(input: PullRequestDetailInput, cursor?: string) {
+ return {
+ owner: input.owner,
+ name: input.repo,
+ number: input.pullNumber,
+ ...(cursor === undefined ? {} : { cursor }),
+ };
+}
+
+export async function readPullRequestDetail(
+ client: PullRequestDetailClient,
+ input: PullRequestDetailInput,
+): Promise {
+ const data = await client.graphql(
+ PULL_REQUEST_DETAIL_QUERY,
+ variables(input),
+ );
+ const pr = data.repository?.pullRequest;
+ if (!pr) {
+ throw new PullRequestReadError(
+ "NOT_FOUND",
+ `Pull request #${input.pullNumber} not found.`,
+ );
+ }
+
+ // Both connections page at 100; anything past the first page must be
+ // fetched before grading, or a failing check or open thread there is
+ // silently invisible.
+ const [restThreads, restContexts, requested] = await Promise.all([
+ drain(
+ "review threads",
+ input,
+ pr.reviewThreads?.pageInfo,
+ async (cursor) =>
+ (
+ await client.graphql<{
+ repository: {
+ pullRequest: {
+ reviewThreads: ReviewThreadsConnection | null;
+ } | null;
+ } | null;
+ }>(REVIEW_THREADS_PAGE_QUERY, variables(input, cursor))
+ ).repository?.pullRequest?.reviewThreads,
+ ),
+ drain(
+ "checks",
+ input,
+ pr.statusCheckRollup?.contexts?.pageInfo,
+ async (cursor) =>
+ (
+ await client.graphql<{
+ repository: {
+ pullRequest: {
+ statusCheckRollup: {
+ contexts: CheckContextsConnection | null;
+ } | null;
+ } | null;
+ } | null;
+ }>(CHECK_CONTEXTS_PAGE_QUERY, variables(input, cursor))
+ ).repository?.pullRequest?.statusCheckRollup?.contexts,
+ ),
+ client.requestedReviewers(input),
+ ]);
+
+ const reviewers = new Map();
+ // Requested first, so an actual review overwrites the placeholder.
+ for (const user of requested.users) {
+ reviewers.set(user.login, {
+ login: user.login,
+ avatarUrl: user.avatar_url ?? null,
+ isTeam: false,
+ state: "REQUESTED",
+ });
+ }
+ for (const team of requested.teams) {
+ reviewers.set(team.name, {
+ login: team.name,
+ avatarUrl: null,
+ isTeam: true,
+ state: "REQUESTED",
+ });
+ }
+ for (const node of pr.latestOpinionatedReviews?.nodes ?? []) {
+ const who = node?.author;
+ if (!node || !who?.login) continue;
+ reviewers.set(who.login, {
+ login: who.login,
+ avatarUrl: who.avatarUrl ?? null,
+ isTeam: false,
+ state: node.state,
+ });
+ }
+
+ const checks = (pr.statusCheckRollup?.contexts?.nodes ?? [])
+ .concat(restContexts)
+ .flatMap((node): PullRequestDetailCheck[] => {
+ if (!node) return [];
+ if (node.__typename === "CheckRun") {
+ return [
+ {
+ name: node.name ?? "Check",
+ status: node.status ?? "COMPLETED",
+ conclusion: node.conclusion ?? null,
+ isRequired: node.isRequired ?? false,
+ startedAt: node.startedAt ?? null,
+ completedAt: node.completedAt ?? null,
+ detailsUrl: node.detailsUrl ?? null,
+ },
+ ];
+ }
+ // A commit status has no runtime of its own, only a verdict.
+ return [
+ {
+ name: node.context ?? "Status",
+ status: "COMPLETED",
+ conclusion:
+ node.state === "SUCCESS"
+ ? "SUCCESS"
+ : node.state === "PENDING"
+ ? null
+ : "FAILURE",
+ isRequired: node.isRequired ?? false,
+ startedAt: null,
+ completedAt: node.createdAt ?? null,
+ detailsUrl: node.targetUrl ?? null,
+ },
+ ];
+ });
+
+ const threads = (pr.reviewThreads?.nodes ?? []).concat(restThreads);
+ const allowed: string[] = [];
+ if (data.repository?.squashMergeAllowed) allowed.push("squash");
+ if (data.repository?.mergeCommitAllowed) allowed.push("merge");
+ if (data.repository?.rebaseMergeAllowed) allowed.push("rebase");
+
+ return {
+ pullRequest: {
+ id: pr.id,
+ number: pr.number,
+ title: pr.title,
+ body: pr.body,
+ url: pr.url,
+ baseBranch: pr.baseRefName,
+ state: pr.merged ? "merged" : pr.state === "CLOSED" ? "closed" : "open",
+ isDraft: pr.isDraft,
+ additions: pr.additions,
+ deletions: pr.deletions,
+ changedFiles: pr.changedFiles,
+ mergedAt: pr.mergedAt,
+ mergedBy: pr.mergedBy
+ ? { login: pr.mergedBy.login, avatarUrl: pr.mergedBy.avatarUrl ?? null }
+ : null,
+ },
+ checks,
+ reviewers: [...reviewers.values()],
+ mergeability: {
+ mergeable: pr.mergeable,
+ mergeStateStatus: pr.mergeStateStatus,
+ approvals: (pr.latestOpinionatedReviews?.nodes ?? []).filter(
+ (node) => node?.state === "APPROVED",
+ ).length,
+ requiredApprovals:
+ pr.baseRef?.branchProtectionRule?.requiredApprovingReviewCount ?? 0,
+ // GitHub's own verdict, and the only one that sees rulesets — a
+ // repository that requires review through a ruleset has no
+ // branchProtectionRule at all, so the count above reads 0.
+ reviewDecision: pr.reviewDecision,
+ unresolvedThreads: threads.filter(
+ (node) => node && !node.isResolved && !node.isOutdated,
+ ).length,
+ requiresThreadResolution:
+ pr.baseRef?.branchProtectionRule?.requiresConversationResolution ??
+ false,
+ queue: pr.mergeQueueEntry
+ ? {
+ position: pr.mergeQueueEntry.position ?? null,
+ state: pr.mergeQueueEntry.state,
+ }
+ : null,
+ allowedMergeMethods: allowed,
+ },
+ capabilities: {
+ // Permission only. Whether GitHub would accept the merge right now
+ // is mergeStateStatus's job — gating the button on mergeability
+ // makes it vanish while GitHub is still computing it.
+ merge: pr.viewerCanMergeAsAdmin || pr.viewerCanUpdate,
+ markReady: pr.isDraft && pr.viewerCanUpdate,
+ updateBranch: pr.mergeStateStatus === "BEHIND" && pr.viewerCanUpdate,
+ reopen: pr.state === "CLOSED" && !pr.merged && pr.viewerCanUpdate,
+ dequeue: pr.mergeQueueEntry !== null && pr.viewerCanUpdate,
+ },
+ };
+}
+
+/** The GraphQL mutations address the pull request by node id, not number. */
+export async function pullRequestNodeId(
+ client: Pick,
+ input: PullRequestDetailInput,
+): Promise {
+ const data = await client.graphql<{
+ repository: { pullRequest: { id: string } | null } | null;
+ }>(
+ `query($owner: String!, $name: String!, $number: Int!) {
+ repository(owner: $owner, name: $name) { pullRequest(number: $number) { id } }
+ }`,
+ variables(input),
+ );
+ const id = data.repository?.pullRequest?.id;
+ if (!id) {
+ throw new PullRequestReadError(
+ "NOT_FOUND",
+ `Pull request #${input.pullNumber} not found.`,
+ );
+ }
+ return id;
+}
diff --git a/packages/trpc/src/router/integration/github/pull-request-procedures.ts b/packages/trpc/src/router/integration/github/pull-request-procedures.ts
index 8f145fc7c27..f8c1d0080f3 100644
--- a/packages/trpc/src/router/integration/github/pull-request-procedures.ts
+++ b/packages/trpc/src/router/integration/github/pull-request-procedures.ts
@@ -1,10 +1,16 @@
import type { PullRequestContent } from "@superset/shared/pull-request";
+import {
+ type PullRequestDetailRead,
+ PullRequestReadError,
+ pullRequestNodeId,
+ readPullRequestDetail,
+} from "@superset/shared/pull-request-detail";
import {
parseReviewThreads,
REVIEW_THREADS_QUERY,
type ReviewThreadsQueryResult,
} from "@superset/shared/pull-request-threads";
-import type { TRPCRouterRecord } from "@trpc/server";
+import { TRPCError, type TRPCRouterRecord } from "@trpc/server";
import { z } from "zod";
import { protectedProcedure, userError } from "../../../trpc";
import { verifyOrgMembership } from "../utils";
@@ -27,6 +33,19 @@ function repoOf(repoFullName: string): { owner: string; repo: string } {
return { owner, repo };
}
+function readError(error: unknown, fallback: string) {
+ if (error instanceof PullRequestReadError) {
+ return error.code === "NOT_FOUND"
+ ? userError({
+ code: "NOT_FOUND",
+ message: "Pull request not found",
+ i18nKey: "serverError.integration.pullRequestNotFound",
+ })
+ : new TRPCError({ code: error.code, message: error.message });
+ }
+ return githubRequestError(error, fallback);
+}
+
/**
* A pull request by its own identity, read and written as the person asking.
* Nothing here needs a project or a host: the desktop reaches these for any
@@ -67,6 +86,77 @@ export const pullRequestProcedures = {
return toPullRequestContent(node, input.repoFullName);
}),
+ /** What the mobile pull request view grades and acts from: mergeability, checks, reviewers, and the viewer's own capabilities. */
+ getPullRequestDetail: protectedProcedure
+ .input(pullRequestInputSchema)
+ .query(async ({ ctx, input }): Promise => {
+ await verifyOrgMembership(ctx.session.user.id, input.organizationId);
+ const { octokit } = await viewerOctokit({
+ userId: ctx.session.user.id,
+ ...input,
+ });
+ const { owner, repo } = repoOf(input.repoFullName);
+ try {
+ return await readPullRequestDetail(
+ {
+ graphql: (query, variables) => octokit.graphql(query, variables),
+ requestedReviewers: async () =>
+ (
+ await octokit.request(
+ "GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers",
+ { owner, repo, pull_number: input.number },
+ )
+ ).data,
+ },
+ { owner, repo, pullNumber: input.number },
+ );
+ } catch (error) {
+ throw readError(error, `Failed to read pull request #${input.number}`);
+ }
+ }),
+
+ updatePullRequestBranch: protectedProcedure
+ .input(pullRequestInputSchema)
+ .mutation(async ({ ctx, input }) => {
+ await verifyOrgMembership(ctx.session.user.id, input.organizationId);
+ const octokit = await viewerOnlyOctokit(ctx.session.user.id);
+ try {
+ await octokit.request(
+ "PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch",
+ { ...repoOf(input.repoFullName), pull_number: input.number },
+ );
+ } catch (error) {
+ throw githubRequestError(error, "GitHub refused to update the branch.");
+ }
+ return { ok: true as const };
+ }),
+
+ dequeuePullRequest: protectedProcedure
+ .input(pullRequestInputSchema)
+ .mutation(async ({ ctx, input }) => {
+ await verifyOrgMembership(ctx.session.user.id, input.organizationId);
+ const octokit = await viewerOnlyOctokit(ctx.session.user.id);
+ const { owner, repo } = repoOf(input.repoFullName);
+ try {
+ const id = await pullRequestNodeId(
+ { graphql: (query, variables) => octokit.graphql(query, variables) },
+ { owner, repo, pullNumber: input.number },
+ );
+ await octokit.graphql(
+ `mutation($id: ID!) {
+ dequeuePullRequest(input: { id: $id }) { mergeQueueEntry { position } }
+ }`,
+ { id },
+ );
+ } catch (error) {
+ throw readError(
+ error,
+ "GitHub refused to remove the pull request from the queue.",
+ );
+ }
+ return { ok: true as const };
+ }),
+
getPullRequestThreads: protectedProcedure
.input(pullRequestInputSchema)
.query(async ({ ctx, input }) => {
From 37b28b69a39fd339c1128a7484843922d860d92c Mon Sep 17 00:00:00 2001
From: Satya Patel <14907857+saddlepaddle@users.noreply.github.com>
Date: Thu, 22 Oct 2026 04:32:37 +0000
Subject: [PATCH 3/8] chore(pull-requests): deprecate host PR procedures the
API now serves as the viewer
---
packages/host-service/src/trpc/router/git/git.ts | 4 ++++
.../host-service/src/trpc/router/github/github.ts | 8 ++++++++
.../src/trpc/router/pull-requests/pull-requests.ts | 11 +++++++++++
packages/trpc/src/router/integration/github/github.ts | 2 ++
4 files changed, 25 insertions(+)
diff --git a/packages/host-service/src/trpc/router/git/git.ts b/packages/host-service/src/trpc/router/git/git.ts
index 9ad76d90fe1..645a1079472 100644
--- a/packages/host-service/src/trpc/router/git/git.ts
+++ b/packages/host-service/src/trpc/router/git/git.ts
@@ -1094,6 +1094,7 @@ export const gitRouter = router({
return { logs: typeof data === "string" ? data : String(data) };
}),
+ /** @deprecated Use the API's `integration.github.getPullRequestThreads`, which acts as the viewer. Kept for released clients. */
getPullRequestThreads: queryProcedure
.meta({ timeoutMs: 30_000 })
.input(z.object({ workspaceId: z.string() }))
@@ -1197,6 +1198,7 @@ export const gitRouter = router({
return { reviewThreads, conversationComments };
}),
+ /** @deprecated Use the API's `integration.github.setPullRequestThreadResolution`, which acts as the viewer. Kept for released clients. */
setReviewThreadResolution: protectedProcedure
.input(
z.object({
@@ -1244,6 +1246,8 @@ export const gitRouter = router({
* Replies into a review thread on the workspace's linked PR. Threads onto
* `commentId` — a REST databaseId from getPullRequestThreads — which
* GitHub accepts for any comment already in the thread.
+ *
+ * @deprecated Use the API's `integration.github.replyToPullRequestThread`, which acts as the viewer. Kept for released clients.
*/
replyToReviewThread: protectedProcedure
.input(
diff --git a/packages/host-service/src/trpc/router/github/github.ts b/packages/host-service/src/trpc/router/github/github.ts
index cb3e3d6f748..7dae36680b2 100644
--- a/packages/host-service/src/trpc/router/github/github.ts
+++ b/packages/host-service/src/trpc/router/github/github.ts
@@ -42,6 +42,7 @@ export const githubRouter = router({
return data[0] ?? null;
}),
+ /** @deprecated Use the API's `integration.github.getPullRequestContent`, which acts as the viewer. Kept for released clients. */
getPR: protectedProcedure
.input(
z.object({
@@ -159,6 +160,8 @@ export const githubRouter = router({
* capabilities, reviewer states and whether a check is required exist
* nowhere in the synced rows, and a button offered on stale data is a
* button that fails when pressed.
+ *
+ * @deprecated Use the API's `integration.github.getPullRequestDetail`, which acts as the viewer. Kept for released clients.
*/
getPullRequestDetail: protectedProcedure
.input(
@@ -190,6 +193,7 @@ export const githubRouter = router({
}
}),
+ /** @deprecated Use the API's `integration.github.mergePullRequest`, which acts as the viewer. Kept for released clients. */
mergePR: protectedProcedure
.input(
z.object({
@@ -214,6 +218,7 @@ export const githubRouter = router({
}
}),
+ /** @deprecated Use the API's `integration.github.setPullRequestDraft` with `draft: false`, which acts as the viewer. Kept for released clients. */
markPullRequestReady: protectedProcedure
.input(
z.object({
@@ -242,6 +247,7 @@ export const githubRouter = router({
}
}),
+ /** @deprecated Use the API's `integration.github.updatePullRequestBranch`, which acts as the viewer. Kept for released clients. */
updatePullRequestBranch: protectedProcedure
.input(
z.object({
@@ -266,6 +272,7 @@ export const githubRouter = router({
}
}),
+ /** @deprecated Use the API's `integration.github.setPullRequestState` with `state: "open"`, which acts as the viewer. Kept for released clients. */
reopenPullRequest: protectedProcedure
.input(
z.object({
@@ -291,6 +298,7 @@ export const githubRouter = router({
}
}),
+ /** @deprecated Use the API's `integration.github.dequeuePullRequest`, which acts as the viewer. Kept for released clients. */
dequeuePullRequest: protectedProcedure
.input(
z.object({
diff --git a/packages/host-service/src/trpc/router/pull-requests/pull-requests.ts b/packages/host-service/src/trpc/router/pull-requests/pull-requests.ts
index 6056ad53250..d8b8e56d847 100644
--- a/packages/host-service/src/trpc/router/pull-requests/pull-requests.ts
+++ b/packages/host-service/src/trpc/router/pull-requests/pull-requests.ts
@@ -74,17 +74,28 @@ export const pullRequestsRouter = router({
);
return { ok: true };
}),
+ /** @deprecated Use the API's `integration.github.addPullRequestComment`, which acts as the viewer. Kept for released clients. */
addComment,
createForWorkspace,
+ /** @deprecated Use the API's `integration.github.getPullRequestContent`, which acts as the viewer. Kept for released clients. */
getContent,
+ /** @deprecated Use the API's `integration.github.getPullRequestContent`, which acts as the viewer. Kept for released clients. */
getContentByRepo,
+ /** @deprecated Use the API's `integration.github.getPullRequestDiff`, which acts as the viewer. Kept for released clients. */
getDiff,
+ /** @deprecated Use the API's `integration.github.getPullRequestDiff`, which acts as the viewer. Kept for released clients. */
getDiffByRepo,
getLinkedWorkspace,
+ /** @deprecated Use the API's `integration.github.getPullRequestThreads`, which acts as the viewer. Kept for released clients. */
getThreads,
+ /** @deprecated Use the API's `integration.github.setPullRequestDraft`, which acts as the viewer. Kept for released clients. */
setDraft,
+ /** @deprecated Use the API's `integration.github.setPullRequestState`, which acts as the viewer. Kept for released clients. */
setState,
+ /** @deprecated Use the API's `integration.github.setPullRequestThreadResolution`, which acts as the viewer. Kept for released clients. */
setThreadResolution,
+ /** @deprecated Use the API's `integration.github.replyToPullRequestThread`, which acts as the viewer. Kept for released clients. */
replyToThread,
+ /** @deprecated Use the API's `integration.github.mergePullRequest`, which acts as the viewer. Kept for released clients. */
mergePR,
});
diff --git a/packages/trpc/src/router/integration/github/github.ts b/packages/trpc/src/router/integration/github/github.ts
index 380f3ae342d..87d6c5b7917 100644
--- a/packages/trpc/src/router/integration/github/github.ts
+++ b/packages/trpc/src/router/integration/github/github.ts
@@ -340,6 +340,8 @@ export const githubRouter = {
* detail pane that has no host in the loop: the webhook row supplies
* everything but the description, which comes from GitHub with the
* installation's token.
+ *
+ * @deprecated Use the API's `integration.github.getPullRequestContent`, which acts as the viewer. Kept for released clients.
*/
getPullRequest: protectedProcedure
.input(
From 8b58c78ffc0e4d071f01bc01408ea5972e46ad34 Mon Sep 17 00:00:00 2001
From: Satya Patel <14907857+saddlepaddle@users.noreply.github.com>
Date: Thu, 22 Oct 2026 21:59:19 +0000
Subject: [PATCH 4/8] refactor(pull-requests): one viewer read for desktop and
mobile
getPullRequestDetail serves both, with an opt-in activity section for the
desktop's conversation and commits; getPullRequestContent and its
GraphQL normalizer go. The write procedures share one viewer helper and
one error mapper, and the check mapper returns to host-service unchanged.
---
.../utils/fromCloudPullRequest/fixtures.ts | 45 ++
.../fromCloudPullRequest.test.ts | 71 +++
.../fromCloudPullRequest.ts | 117 +++++
.../utils/fromCloudPullRequest/index.ts | 1 +
.../pullRequestClient.test.ts | 20 +-
.../pullRequestClient/pullRequestClient.ts | 9 +-
.../fixtures/checks.tsx | 20 +-
.../pull-request-mappers.ts | 139 +++++-
.../src/trpc/router/github/github.ts | 2 +-
.../router/pull-requests/pull-requests.ts | 4 +-
packages/shared/package.json | 4 -
.../shared/src/pull-request-checks/index.ts | 7 -
.../pull-request-checks.ts | 130 ------
.../shared/src/pull-request-detail/index.ts | 1 +
.../pull-request-detail.test.ts | 93 ++++
.../pull-request-detail.ts | 241 ++++++++--
packages/shared/src/pull-request.ts | 2 -
.../github/get-pull-request-diff.ts | 21 +-
.../github/github-request-error.ts | 13 +-
.../src/router/integration/github/github.ts | 2 +-
.../github/pull-request-content.test.ts | 185 --------
.../github/pull-request-content.ts | 344 ---------------
.../github/pull-request-procedures.ts | 413 +++++++-----------
.../integration/github/viewer-octokit.ts | 64 ++-
24 files changed, 905 insertions(+), 1043 deletions(-)
create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fixtures.ts
create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fromCloudPullRequest.test.ts
create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fromCloudPullRequest.ts
create mode 100644 apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/index.ts
delete mode 100644 packages/shared/src/pull-request-checks/index.ts
delete mode 100644 packages/shared/src/pull-request-checks/pull-request-checks.ts
delete mode 100644 packages/trpc/src/router/integration/github/pull-request-content.test.ts
delete mode 100644 packages/trpc/src/router/integration/github/pull-request-content.ts
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fixtures.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fixtures.ts
new file mode 100644
index 00000000000..bb8e5016273
--- /dev/null
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fixtures.ts
@@ -0,0 +1,45 @@
+import type { PullRequestDetailRead } from "@superset/shared/pull-request-detail";
+
+export function cloudPullRequestRead(
+ overrides: Partial = {},
+): PullRequestDetailRead {
+ return {
+ pullRequest: {
+ id: "PR_1",
+ number: 12,
+ title: "cloud title",
+ body: "",
+ url: "https://github.com/owner/repo/pull/12",
+ baseBranch: "main",
+ state: "open",
+ isDraft: false,
+ additions: 3,
+ deletions: 1,
+ changedFiles: 2,
+ mergedAt: null,
+ mergedBy: null,
+ ...overrides,
+ },
+ checks: [],
+ reviewers: [],
+ mergeability: {
+ mergeable: "MERGEABLE",
+ mergeStateStatus: "CLEAN",
+ approvals: 0,
+ requiredApprovals: 0,
+ reviewDecision: null,
+ unresolvedThreads: 0,
+ requiresThreadResolution: false,
+ queue: null,
+ allowedMergeMethods: ["squash"],
+ },
+ capabilities: {
+ merge: true,
+ markReady: false,
+ updateBranch: false,
+ reopen: false,
+ dequeue: false,
+ },
+ activity: null,
+ };
+}
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fromCloudPullRequest.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fromCloudPullRequest.test.ts
new file mode 100644
index 00000000000..2a491fc3e20
--- /dev/null
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fromCloudPullRequest.test.ts
@@ -0,0 +1,71 @@
+import { expect, test } from "bun:test";
+import { cloudPullRequestRead } from "./fixtures";
+import { fromCloudPullRequest } from "./fromCloudPullRequest";
+
+test("maps GitHub's vocabulary, keeping the latest run of each check", () => {
+ const read = {
+ ...cloudPullRequestRead(),
+ checks: [
+ {
+ name: "ci",
+ status: "COMPLETED",
+ conclusion: "FAILURE",
+ isRequired: true,
+ startedAt: "2026-10-01T10:00:00Z",
+ completedAt: "2026-10-01T10:05:00Z",
+ detailsUrl: "https://ci/1",
+ },
+ {
+ name: "ci",
+ status: "COMPLETED",
+ conclusion: "SUCCESS",
+ isRequired: true,
+ startedAt: "2026-10-01T11:00:00Z",
+ completedAt: "2026-10-01T11:05:00Z",
+ detailsUrl: "https://ci/2",
+ },
+ {
+ name: "lint",
+ status: "IN_PROGRESS",
+ conclusion: null,
+ isRequired: false,
+ startedAt: null,
+ completedAt: null,
+ detailsUrl: null,
+ },
+ ],
+ reviewers: [
+ { login: "maya", avatarUrl: null, isTeam: false, state: "APPROVED" },
+ ],
+ mergeability: {
+ ...cloudPullRequestRead().mergeability,
+ mergeable: "CONFLICTING",
+ reviewDecision: "CHANGES_REQUESTED",
+ },
+ activity: {
+ author: { login: "satya", avatarUrl: "a" },
+ headBranch: "feat/x",
+ headRepoFullName: "fork/repo",
+ createdAt: "2026-10-01T09:00:00Z",
+ updatedAt: "2026-10-02T09:00:00Z",
+ closedAt: null,
+ labels: [{ name: "desktop", color: "1d76db" }],
+ comments: [],
+ commits: [],
+ },
+ };
+ expect(fromCloudPullRequest(read, "owner/repo")).toMatchObject({
+ repoFullName: "owner/repo",
+ head: { ref: "feat/x", repoFullName: "fork/repo" },
+ author: { login: "satya", avatarUrl: "a" },
+ checks: [
+ { name: "ci", status: "success", url: "https://ci/2" },
+ { name: "lint", status: "pending", url: null },
+ ],
+ checksStatus: "pending",
+ reviewDecision: "changes_requested",
+ mergeability: "conflicting",
+ reviewers: [{ login: "maya", name: null }],
+ labels: [{ name: "desktop", color: "1d76db" }],
+ });
+});
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fromCloudPullRequest.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fromCloudPullRequest.ts
new file mode 100644
index 00000000000..ad8f6d9f04b
--- /dev/null
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fromCloudPullRequest.ts
@@ -0,0 +1,117 @@
+import type {
+ PullRequestCheck,
+ PullRequestCheckStatus,
+ PullRequestChecksStatus,
+ PullRequestMergeability,
+ PullRequestReviewDecision,
+} from "@superset/shared/pull-request";
+import type {
+ PullRequestDetailCheck,
+ PullRequestDetailRead,
+} from "@superset/shared/pull-request-detail";
+import type { PullRequestDetail } from "../../hooks/usePullRequestDetail";
+
+function checkStatus(check: PullRequestDetailCheck): PullRequestCheckStatus {
+ if (check.status !== "COMPLETED") return "pending";
+ switch (check.conclusion) {
+ case "SUCCESS":
+ return "success";
+ case "SKIPPED":
+ case "NEUTRAL":
+ return "skipped";
+ case "CANCELLED":
+ return "cancelled";
+ case "FAILURE":
+ case "TIMED_OUT":
+ case "ACTION_REQUIRED":
+ case "STARTUP_FAILURE":
+ return "failure";
+ default:
+ return "pending";
+ }
+}
+
+/** One row per check name; a re-run replaces the run it supersedes. */
+function toChecks(checks: PullRequestDetailCheck[]): PullRequestCheck[] {
+ const latest = new Map();
+ const at = (check: PullRequestDetailCheck) =>
+ Date.parse(check.completedAt ?? check.startedAt ?? "") || 0;
+ for (const check of checks) {
+ const seen = latest.get(check.name);
+ if (!seen || at(check) >= at(seen)) latest.set(check.name, check);
+ }
+ return [...latest.values()].map((check) => ({
+ name: check.name,
+ status: checkStatus(check),
+ url: check.detailsUrl,
+ }));
+}
+
+function checksStatus(checks: PullRequestCheck[]): PullRequestChecksStatus {
+ if (checks.length === 0) return "none";
+ if (checks.some((c) => c.status === "failure" || c.status === "cancelled"))
+ return "failure";
+ if (checks.some((c) => c.status === "pending")) return "pending";
+ return "success";
+}
+
+function reviewDecision(value: string | null): PullRequestReviewDecision {
+ switch (value) {
+ case "APPROVED":
+ return "approved";
+ case "CHANGES_REQUESTED":
+ return "changes_requested";
+ case "REVIEW_REQUIRED":
+ return "pending";
+ default:
+ return null;
+ }
+}
+
+function mergeability(value: string): PullRequestMergeability {
+ if (value === "MERGEABLE") return "mergeable";
+ if (value === "CONFLICTING") return "conflicting";
+ return "unknown";
+}
+
+/** The API's detail read, asked for with `activity: true`, in the shape the desktop renders. */
+export function fromCloudPullRequest(
+ read: PullRequestDetailRead,
+ repoFullName: string,
+): PullRequestDetail {
+ const { pullRequest: pr, activity } = read;
+ const checks = toChecks(read.checks);
+ return {
+ repoFullName,
+ number: pr.number,
+ url: pr.url,
+ title: pr.title,
+ body: pr.body,
+ state: pr.state,
+ isDraft: pr.isDraft,
+ author: activity?.author ?? null,
+ head: {
+ ref: activity?.headBranch ?? "",
+ repoFullName: activity?.headRepoFullName ?? null,
+ },
+ base: { ref: pr.baseBranch },
+ reviewDecision: reviewDecision(read.mergeability.reviewDecision),
+ checksStatus: checksStatus(checks),
+ checks,
+ createdAt: activity?.createdAt ?? "",
+ updatedAt: activity?.updatedAt ?? "",
+ additions: pr.additions,
+ deletions: pr.deletions,
+ changedFiles: pr.changedFiles,
+ mergeability: mergeability(read.mergeability.mergeable),
+ mergedAt: pr.mergedAt,
+ closedAt: activity?.closedAt ?? null,
+ reviewers: read.reviewers.map((reviewer) => ({
+ login: reviewer.login,
+ name: null,
+ })),
+ comments: activity?.comments ?? [],
+ commits: activity?.commits ?? [],
+ labels: activity?.labels ?? [],
+ };
+}
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/index.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/index.ts
new file mode 100644
index 00000000000..f01aff3cc6f
--- /dev/null
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/index.ts
@@ -0,0 +1 @@
+export { fromCloudPullRequest } from "./fromCloudPullRequest";
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts
index bcba443d362..f9bbb6aaf51 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts
@@ -1,4 +1,5 @@
import { beforeEach, describe, expect, mock, test } from "bun:test";
+import { cloudPullRequestRead } from "../fromCloudPullRequest/fixtures";
import {
addPullRequestComment,
canActOnPullRequest,
@@ -19,9 +20,7 @@ const hostContent = {
checks: [],
};
const cloud = {
- getPullRequestContent: {
- query: mock(async () => ({ title: "cloud title" })),
- },
+ getPullRequestDetail: { query: mock(async () => cloudPullRequestRead()) },
getPullRequestThreads: {
query: mock(async () => ({ reviewThreads: [], fetchFailed: false })),
},
@@ -80,16 +79,17 @@ describe("reads", () => {
expect(await readPullRequestContent(target, deps)).toMatchObject({
title: "cloud title",
});
- expect(cloud.getPullRequestContent.query).toHaveBeenCalledWith({
+ expect(cloud.getPullRequestDetail.query).toHaveBeenCalledWith({
organizationId: "org",
repoFullName: "owner/repo",
number: 12,
+ activity: true,
});
expect(hostFor).not.toHaveBeenCalled();
});
test("a cloud that cannot act yields to the project's host, then the repository", async () => {
- cloud.getPullRequestContent.query.mockRejectedValueOnce(cannotAct);
+ cloud.getPullRequestDetail.query.mockRejectedValueOnce(cannotAct);
expect(await readPullRequestContent(target, deps)).toMatchObject({
title: "host title",
});
@@ -98,9 +98,9 @@ describe("reads", () => {
prNumber: 12,
});
- cloud.getPullRequestContent.query.mockRejectedValueOnce(
+ cloud.getPullRequestDetail.query.mockRejectedValueOnce(
new Error(
- 'No procedure found on path "integration.github.getPullRequestContent"',
+ 'No procedure found on path "integration.github.getPullRequestDetail"',
),
);
expect(
@@ -119,18 +119,18 @@ describe("reads", () => {
expect(
await readPullRequestContent({ ...target, organizationId: null }, deps),
).toMatchObject({ title: "host title" });
- expect(cloud.getPullRequestContent.query).not.toHaveBeenCalled();
+ expect(cloud.getPullRequestDetail.query).not.toHaveBeenCalled();
});
test("a quiet cloud miss is dropped from the error; two real failures are both reported", async () => {
- cloud.getPullRequestContent.query.mockRejectedValueOnce(cannotAct);
+ cloud.getPullRequestDetail.query.mockRejectedValueOnce(cannotAct);
host.getContent.query.mockRejectedValueOnce(new Error("gh offline"));
host.getContentByRepo.query.mockRejectedValueOnce(new Error("gh offline"));
await expect(readPullRequestContent(target, deps)).rejects.toThrow(
"gh offline",
);
- cloud.getPullRequestContent.query.mockRejectedValueOnce(
+ cloud.getPullRequestDetail.query.mockRejectedValueOnce(
new Error("Access denied"),
);
host.getContent.query.mockRejectedValueOnce(new Error("gh offline"));
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
index 6a6e849be01..f631e115aa2 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
@@ -5,6 +5,7 @@ import { cloudTrpcClient } from "renderer/lib/cloud-trpc";
import { getHostServiceClientByUrl } from "renderer/lib/host-service-client";
import type { PullRequestDetail } from "../../hooks/usePullRequestDetail";
import { combinePullRequestErrors } from "../combinePullRequestReadErrors";
+import { fromCloudPullRequest } from "../fromCloudPullRequest";
import { fromHostPullRequestContent } from "../fromHostPullRequestContent";
/** A host with the repository checked out, for `gh` when the cloud cannot act. */
@@ -119,7 +120,13 @@ export function readPullRequestContent(
return firstAnswer(
[
reachesCloud(target) &&
- (() => deps.cloud().getPullRequestContent.query(cloudInput(target))),
+ (() => {
+ const input = cloudInput(target);
+ return deps
+ .cloud()
+ .getPullRequestDetail.query({ ...input, activity: true })
+ .then((read) => fromCloudPullRequest(read, input.repoFullName));
+ }),
host &&
projectId &&
(() =>
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/hooks/usePullRequestPaneDetail/fixtures/checks.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/hooks/usePullRequestPaneDetail/fixtures/checks.tsx
index 285420dc22b..f82a98ca869 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/hooks/usePullRequestPaneDetail/fixtures/checks.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/PullRequestPane/hooks/usePullRequestPaneDetail/fixtures/checks.tsx
@@ -1,5 +1,6 @@
import { afterEach, beforeEach, expect, mock, test } from "bun:test";
import { GlobalRegistrator } from "@happy-dom/global-registrator";
+import { cloudPullRequestRead } from "renderer/routes/_authenticated/_dashboard/pull-requests/utils/fromCloudPullRequest/fixtures";
import type { PullRequestProject } from "renderer/routes/_authenticated/_dashboard/pull-requests/utils/resolvePullRequestTarget";
if (!GlobalRegistrator.isRegistered) GlobalRegistrator.register();
@@ -28,11 +29,9 @@ const getContentByRepo = mock(async (_input: unknown) => ({
const cannotAct = Object.assign(new Error("Connect GitHub"), {
data: { code: "PRECONDITION_FAILED" },
});
-const getPullRequestContent = mock(
- async (_input: unknown): Promise => {
- throw cannotAct;
- },
-);
+const getPullRequestDetail = mock(async (_input: unknown): Promise => {
+ throw cannotAct;
+});
const root = "renderer/routes/_authenticated/_dashboard";
mock.module("@superset/workspace-client", () => ({
workspaceTrpc: {
@@ -62,7 +61,7 @@ mock.module("renderer/lib/host-service-client", () => ({
mock.module("renderer/lib/cloud-trpc", () => ({
cloudTrpcClient: {
integration: {
- github: { getPullRequestContent: { query: getPullRequestContent } },
+ github: { getPullRequestDetail: { query: getPullRequestDetail } },
},
},
}));
@@ -95,7 +94,7 @@ beforeEach(() => {
workspaceProjectQuery.mockClear();
getContent.mockClear();
getContentByRepo.mockClear();
- getPullRequestContent.mockClear();
+ getPullRequestDetail.mockClear();
});
function mountDetail(
@@ -113,15 +112,18 @@ function mountDetail(
}
test("the cloud reads the pull request as the viewer before any host path", async () => {
- getPullRequestContent.mockResolvedValueOnce({ title: "viewer title" });
+ getPullRequestDetail.mockResolvedValueOnce(
+ cloudPullRequestRead({ title: "viewer title" }),
+ );
const view = mountDetail();
await waitFor(() =>
expect(view.result.current.data?.title).toBe("viewer title"),
);
- expect(getPullRequestContent).toHaveBeenCalledWith({
+ expect(getPullRequestDetail).toHaveBeenCalledWith({
organizationId: "org",
repoFullName: "owner/repo",
number: 12,
+ activity: true,
});
expect(getContent).not.toHaveBeenCalled();
expect(getContentByRepo).not.toHaveBeenCalled();
diff --git a/packages/host-service/src/runtime/pull-requests/utils/pull-request-mappers/pull-request-mappers.ts b/packages/host-service/src/runtime/pull-requests/utils/pull-request-mappers/pull-request-mappers.ts
index dede41e771f..77a2c86fc30 100644
--- a/packages/host-service/src/runtime/pull-requests/utils/pull-request-mappers/pull-request-mappers.ts
+++ b/packages/host-service/src/runtime/pull-requests/utils/pull-request-mappers/pull-request-mappers.ts
@@ -1,15 +1,9 @@
-import type { PullRequestCheck } from "@superset/shared/pull-request";
import type {
+ GitHubCheckContextNode,
GitHubPullRequestNode,
GitHubPullRequestReviewDecision,
} from "../github-query";
-export {
- computeChecksStatus,
- parseCheckContexts,
-} from "@superset/shared/pull-request-checks";
-export type { PullRequestCheck };
-
export type PullRequestState =
| "open"
| "draft"
@@ -22,6 +16,13 @@ export type ReviewDecision =
| "pending"
| null;
export type ChecksStatus = "success" | "failure" | "pending" | "none";
+type CheckStatus = "success" | "failure" | "pending" | "skipped" | "cancelled";
+
+export interface PullRequestCheck {
+ name: string;
+ status: CheckStatus;
+ url: string | null;
+}
export function mapPullRequestState(
state: GitHubPullRequestNode["state"],
@@ -44,6 +45,64 @@ export function mapReviewDecision(
return null;
}
+export function parseCheckContexts(
+ nodes: GitHubCheckContextNode[],
+): PullRequestCheck[] {
+ const checks = nodes
+ .filter(
+ (node): node is NonNullable => node !== null,
+ )
+ .map((node) => {
+ if (node.__typename === "CheckRun") {
+ return {
+ name: node.name,
+ status: mapCheckRunStatus(node.status, node.conclusion),
+ url: node.detailsUrl,
+ recency: getCheckRunRecency(node),
+ };
+ }
+
+ return {
+ name: node.context,
+ status: mapStatusContextState(node.state),
+ url: node.targetUrl,
+ recency: getStatusContextRecency(node),
+ };
+ });
+
+ const dedupedChecks = new Map<
+ string,
+ PullRequestCheck & {
+ recency: number;
+ }
+ >();
+ for (const check of checks) {
+ const existing = dedupedChecks.get(check.name);
+ if (!existing || check.recency > existing.recency) {
+ dedupedChecks.set(check.name, check);
+ }
+ }
+
+ return [...dedupedChecks.values()].map(
+ ({ recency: _recency, ...check }) => check,
+ );
+}
+
+export function computeChecksStatus(checks: PullRequestCheck[]): ChecksStatus {
+ if (checks.length === 0) return "none";
+ // A cancelled run never produced a real verdict — treat it as a failure
+ // rather than falling through to "success".
+ if (
+ checks.some(
+ (check) => check.status === "failure" || check.status === "cancelled",
+ )
+ ) {
+ return "failure";
+ }
+ if (checks.some((check) => check.status === "pending")) return "pending";
+ return "success";
+}
+
export function coercePullRequestState(value: string | null): PullRequestState {
if (
value === "merged" ||
@@ -93,3 +152,69 @@ export function parseChecksJson(value: string | null): PullRequestCheck[] {
return [];
}
}
+
+function mapCheckRunStatus(
+ status: string,
+ conclusion: string | null,
+): CheckStatus {
+ if (status !== "COMPLETED") return "pending";
+
+ switch (conclusion) {
+ case "SUCCESS":
+ return "success";
+ case "FAILURE":
+ case "TIMED_OUT":
+ case "ACTION_REQUIRED":
+ return "failure";
+ case "CANCELLED":
+ return "cancelled";
+ case "SKIPPED":
+ case "NEUTRAL":
+ return "skipped";
+ default:
+ return "pending";
+ }
+}
+
+function mapStatusContextState(state: string): CheckStatus {
+ switch (state) {
+ case "SUCCESS":
+ return "success";
+ case "FAILURE":
+ case "ERROR":
+ return "failure";
+ case "EXPECTED":
+ case "PENDING":
+ return "pending";
+ default:
+ return "pending";
+ }
+}
+
+function getCheckRunRecency(
+ node: Extract,
+): number {
+ const workflowRunId = node.checkSuite?.workflowRun?.databaseId;
+ if (typeof workflowRunId === "number") {
+ return workflowRunId;
+ }
+
+ const timestamp = node.completedAt ?? node.startedAt;
+ if (!timestamp) {
+ return 0;
+ }
+
+ const time = Date.parse(timestamp);
+ return Number.isNaN(time) ? 0 : time;
+}
+
+function getStatusContextRecency(
+ node: Extract,
+): number {
+ if (!node.createdAt) {
+ return 0;
+ }
+
+ const time = Date.parse(node.createdAt);
+ return Number.isNaN(time) ? 0 : time;
+}
diff --git a/packages/host-service/src/trpc/router/github/github.ts b/packages/host-service/src/trpc/router/github/github.ts
index 7dae36680b2..a2442c50ad9 100644
--- a/packages/host-service/src/trpc/router/github/github.ts
+++ b/packages/host-service/src/trpc/router/github/github.ts
@@ -42,7 +42,7 @@ export const githubRouter = router({
return data[0] ?? null;
}),
- /** @deprecated Use the API's `integration.github.getPullRequestContent`, which acts as the viewer. Kept for released clients. */
+ /** @deprecated Use the API's `integration.github.getPullRequestDetail` with `activity: true`, which acts as the viewer. Kept for released clients. */
getPR: protectedProcedure
.input(
z.object({
diff --git a/packages/host-service/src/trpc/router/pull-requests/pull-requests.ts b/packages/host-service/src/trpc/router/pull-requests/pull-requests.ts
index d8b8e56d847..f1f492356a1 100644
--- a/packages/host-service/src/trpc/router/pull-requests/pull-requests.ts
+++ b/packages/host-service/src/trpc/router/pull-requests/pull-requests.ts
@@ -77,9 +77,9 @@ export const pullRequestsRouter = router({
/** @deprecated Use the API's `integration.github.addPullRequestComment`, which acts as the viewer. Kept for released clients. */
addComment,
createForWorkspace,
- /** @deprecated Use the API's `integration.github.getPullRequestContent`, which acts as the viewer. Kept for released clients. */
+ /** @deprecated Use the API's `integration.github.getPullRequestDetail` with `activity: true`, which acts as the viewer. Kept for released clients. */
getContent,
- /** @deprecated Use the API's `integration.github.getPullRequestContent`, which acts as the viewer. Kept for released clients. */
+ /** @deprecated Use the API's `integration.github.getPullRequestDetail` with `activity: true`, which acts as the viewer. Kept for released clients. */
getContentByRepo,
/** @deprecated Use the API's `integration.github.getPullRequestDiff`, which acts as the viewer. Kept for released clients. */
getDiff,
diff --git a/packages/shared/package.json b/packages/shared/package.json
index 2515c402668..eb01b04026c 100644
--- a/packages/shared/package.json
+++ b/packages/shared/package.json
@@ -193,10 +193,6 @@
"types": "./src/pull-request-detail/index.ts",
"default": "./src/pull-request-detail/index.ts"
},
- "./pull-request-checks": {
- "types": "./src/pull-request-checks/index.ts",
- "default": "./src/pull-request-checks/index.ts"
- },
"./pull-request-threads": {
"types": "./src/pull-request-threads/index.ts",
"default": "./src/pull-request-threads/index.ts"
diff --git a/packages/shared/src/pull-request-checks/index.ts b/packages/shared/src/pull-request-checks/index.ts
deleted file mode 100644
index 6873cc66bd0..00000000000
--- a/packages/shared/src/pull-request-checks/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export {
- type CheckContextNode,
- type CheckRunNode,
- computeChecksStatus,
- parseCheckContexts,
- type StatusContextNode,
-} from "./pull-request-checks";
diff --git a/packages/shared/src/pull-request-checks/pull-request-checks.ts b/packages/shared/src/pull-request-checks/pull-request-checks.ts
deleted file mode 100644
index 6875fe1cf24..00000000000
--- a/packages/shared/src/pull-request-checks/pull-request-checks.ts
+++ /dev/null
@@ -1,130 +0,0 @@
-import type {
- PullRequestCheck,
- PullRequestCheckStatus,
- PullRequestChecksStatus,
-} from "../pull-request";
-
-/** GitHub GraphQL `StatusCheckRollupContext` nodes, as `gh pr view --json statusCheckRollup` also prints them. */
-export interface CheckRunNode {
- __typename: "CheckRun";
- name: string;
- conclusion: string | null;
- detailsUrl: string | null;
- status: string;
- startedAt: string | null;
- completedAt: string | null;
- checkSuite: {
- workflowRun: {
- databaseId: number | null;
- } | null;
- } | null;
-}
-
-export interface StatusContextNode {
- __typename: "StatusContext";
- context: string;
- state: string;
- targetUrl: string | null;
- createdAt: string | null;
-}
-
-export type CheckContextNode = CheckRunNode | StatusContextNode;
-
-function mapCheckRunStatus(
- status: string,
- conclusion: string | null,
-): PullRequestCheckStatus {
- if (status !== "COMPLETED") return "pending";
-
- switch (conclusion) {
- case "SUCCESS":
- return "success";
- case "FAILURE":
- case "TIMED_OUT":
- case "ACTION_REQUIRED":
- return "failure";
- case "CANCELLED":
- return "cancelled";
- case "SKIPPED":
- case "NEUTRAL":
- return "skipped";
- default:
- return "pending";
- }
-}
-
-function mapStatusContextState(state: string): PullRequestCheckStatus {
- switch (state) {
- case "SUCCESS":
- return "success";
- case "FAILURE":
- case "ERROR":
- return "failure";
- default:
- return "pending";
- }
-}
-
-function parseTime(timestamp: string | null): number {
- if (!timestamp) return 0;
- const time = Date.parse(timestamp);
- return Number.isNaN(time) ? 0 : time;
-}
-
-function getCheckRunRecency(node: CheckRunNode): number {
- const workflowRunId = node.checkSuite?.workflowRun?.databaseId;
- if (typeof workflowRunId === "number") return workflowRunId;
- return parseTime(node.completedAt ?? node.startedAt);
-}
-
-/** One row per check name; a re-run replaces the run it supersedes. */
-export function parseCheckContexts(
- nodes: readonly (CheckContextNode | null)[],
-): PullRequestCheck[] {
- const checks = nodes
- .filter((node): node is CheckContextNode => node !== null)
- .map((node) =>
- node.__typename === "CheckRun"
- ? {
- name: node.name,
- status: mapCheckRunStatus(node.status, node.conclusion),
- url: node.detailsUrl,
- recency: getCheckRunRecency(node),
- }
- : {
- name: node.context,
- status: mapStatusContextState(node.state),
- url: node.targetUrl,
- recency: parseTime(node.createdAt),
- },
- );
-
- const dedupedChecks = new Map();
- for (const check of checks) {
- const existing = dedupedChecks.get(check.name);
- if (!existing || check.recency > existing.recency) {
- dedupedChecks.set(check.name, check);
- }
- }
-
- return [...dedupedChecks.values()].map(
- ({ recency: _recency, ...check }) => check,
- );
-}
-
-export function computeChecksStatus(
- checks: readonly PullRequestCheck[],
-): PullRequestChecksStatus {
- if (checks.length === 0) return "none";
- // A cancelled run never produced a real verdict — treat it as a failure
- // rather than falling through to "success".
- if (
- checks.some(
- (check) => check.status === "failure" || check.status === "cancelled",
- )
- ) {
- return "failure";
- }
- if (checks.some((check) => check.status === "pending")) return "pending";
- return "success";
-}
diff --git a/packages/shared/src/pull-request-detail/index.ts b/packages/shared/src/pull-request-detail/index.ts
index bf10a85adcc..8d7b1c7d60c 100644
--- a/packages/shared/src/pull-request-detail/index.ts
+++ b/packages/shared/src/pull-request-detail/index.ts
@@ -1,4 +1,5 @@
export {
+ type PullRequestDetailActivity,
type PullRequestDetailCheck,
type PullRequestDetailClient,
type PullRequestDetailInput,
diff --git a/packages/shared/src/pull-request-detail/pull-request-detail.test.ts b/packages/shared/src/pull-request-detail/pull-request-detail.test.ts
index c110146d2b8..57c5d2930a4 100644
--- a/packages/shared/src/pull-request-detail/pull-request-detail.test.ts
+++ b/packages/shared/src/pull-request-detail/pull-request-detail.test.ts
@@ -178,4 +178,97 @@ describe("readPullRequestDetail", () => {
expect(error).toBeInstanceOf(PullRequestReadError);
expect(error.code).toBe("NOT_FOUND");
});
+
+ test("activity is read only when asked for, with reviews folded into the conversation", async () => {
+ const asked: unknown[] = [];
+ const client = {
+ graphql: async (
+ _query: string,
+ variables: Record,
+ ) => {
+ asked.push(variables.activity);
+ return pullRequest({
+ reviewThreads: {
+ pageInfo: { hasNextPage: false, endCursor: null },
+ nodes: [],
+ },
+ author: { login: "satya", avatarUrl: null },
+ headRefName: "feat/x",
+ headRepository: { nameWithOwner: "fork/widgets" },
+ createdAt: "2026-10-01T09:00:00Z",
+ updatedAt: "2026-10-02T09:00:00Z",
+ closedAt: null,
+ labels: { nodes: [{ name: "desktop", color: "1d76db" }, null] },
+ comments: {
+ nodes: [
+ {
+ id: "C1",
+ body: "On it",
+ createdAt: "2026-10-02T09:30:00Z",
+ url: "https://github.com/acme/widgets/pull/7#issuecomment-1",
+ author: { login: "satya", name: "Satya" },
+ },
+ ],
+ },
+ reviews: {
+ nodes: [
+ {
+ id: "R1",
+ body: "Fix it",
+ state: "CHANGES_REQUESTED",
+ submittedAt: "2026-10-02T10:00:00Z",
+ author: { login: "lee" },
+ },
+ {
+ id: "R2",
+ body: "",
+ state: "PENDING",
+ submittedAt: null,
+ author: null,
+ },
+ ],
+ },
+ commits: {
+ nodes: [
+ {
+ commit: {
+ oid: "abc",
+ messageHeadline: "feat: x ",
+ committedDate: "2026-10-01T08:00:00Z",
+ authors: { nodes: [{ name: "Satya", user: null }] },
+ },
+ },
+ ],
+ },
+ }) as T;
+ },
+ requestedReviewers: async () => ({ users: [], teams: [] }),
+ };
+
+ expect((await readPullRequestDetail(client, input)).activity).toBeNull();
+ const { activity } = await readPullRequestDetail(client, input, {
+ activity: true,
+ });
+ expect(asked).toEqual([false, true]);
+ expect(activity).toMatchObject({
+ author: { login: "satya", avatarUrl: null },
+ headBranch: "feat/x",
+ headRepoFullName: "fork/widgets",
+ labels: [{ name: "desktop", color: "1d76db" }],
+ commits: [
+ {
+ oid: "abc",
+ messageHeadline: "feat: x",
+ author: { login: null, name: "Satya" },
+ url: "https://github.com/acme/widgets/pull/7/commits/abc",
+ },
+ ],
+ });
+ expect(
+ activity?.comments.map((c) => [c.kind, c.id, c.reviewState]),
+ ).toEqual([
+ ["comment", "C1", null],
+ ["review", "R1", "CHANGES_REQUESTED"],
+ ]);
+ });
});
diff --git a/packages/shared/src/pull-request-detail/pull-request-detail.ts b/packages/shared/src/pull-request-detail/pull-request-detail.ts
index bc69ae8b3ea..51236eb2a99 100644
--- a/packages/shared/src/pull-request-detail/pull-request-detail.ts
+++ b/packages/shared/src/pull-request-detail/pull-request-detail.ts
@@ -1,3 +1,9 @@
+import type {
+ PullRequestCommit,
+ PullRequestConversationComment,
+ PullRequestLabel,
+} from "../pull-request";
+
/**
* Everything one pull request view needs, read live from GitHub.
*
@@ -54,6 +60,20 @@ export interface PullRequestDetailReviewer {
state: string;
}
+/** The conversation and identity a full page shows; a status card asks without it. */
+export interface PullRequestDetailActivity {
+ author: { login: string; avatarUrl: string | null } | null;
+ headBranch: string;
+ /** Null when the head repository is gone (a deleted fork). */
+ headRepoFullName: string | null;
+ createdAt: string;
+ updatedAt: string;
+ closedAt: string | null;
+ labels: PullRequestLabel[];
+ comments: PullRequestConversationComment[];
+ commits: PullRequestCommit[];
+}
+
export interface PullRequestDetailRead {
pullRequest: {
id: string;
@@ -90,6 +110,8 @@ export interface PullRequestDetailRead {
reopen: boolean;
dequeue: boolean;
};
+ /** Present only when asked for with `activity: true`. */
+ activity: PullRequestDetailActivity | null;
}
/**
@@ -97,7 +119,7 @@ export interface PullRequestDetailRead {
* relative to the branch rules it runs under.
*/
const PULL_REQUEST_DETAIL_QUERY = `
-query($owner: String!, $name: String!, $number: Int!) {
+query($owner: String!, $name: String!, $number: Int!, $activity: Boolean = false) {
repository(owner: $owner, name: $name) {
squashMergeAllowed
mergeCommitAllowed
@@ -122,6 +144,26 @@ query($owner: String!, $name: String!, $number: Int!) {
pageInfo { hasNextPage endCursor }
nodes { isResolved isOutdated }
}
+ ... on PullRequest @include(if: $activity) {
+ author { login avatarUrl }
+ headRefName createdAt updatedAt closedAt
+ headRepository { nameWithOwner }
+ labels(first: 50) { nodes { name color } }
+ comments(first: 100) {
+ nodes { id body createdAt url author { login ... on User { name } } }
+ }
+ reviews(first: 100) {
+ nodes { id body state submittedAt author { login ... on User { name } } }
+ }
+ commits(last: 100) {
+ nodes {
+ commit {
+ oid messageHeadline committedDate
+ authors(first: 3) { nodes { name user { login } } }
+ }
+ }
+ }
+ }
statusCheckRollup {
contexts(first: 100) {
pageInfo { hasNextPage endCursor }
@@ -213,49 +255,90 @@ interface CheckContextsConnection {
nodes: (CheckContextNode | null)[];
}
+type Nodes = { nodes: (T | null)[] | null } | null;
+
+interface ActivityActor {
+ login: string;
+ name?: string | null;
+}
+
+interface ActivityFields {
+ author?: { login: string; avatarUrl: string | null } | null;
+ headRefName?: string;
+ headRepository?: { nameWithOwner: string } | null;
+ createdAt?: string;
+ updatedAt?: string;
+ closedAt?: string | null;
+ labels?: Nodes<{ name: string; color: string | null }>;
+ comments?: Nodes<{
+ id: string;
+ body: string | null;
+ createdAt: string;
+ url: string | null;
+ author: ActivityActor | null;
+ }>;
+ reviews?: Nodes<{
+ id: string;
+ body: string | null;
+ state: string | null;
+ submittedAt: string | null;
+ author: ActivityActor | null;
+ }>;
+ commits?: Nodes<{
+ commit: {
+ oid: string;
+ messageHeadline: string | null;
+ committedDate: string | null;
+ authors: Nodes<{ name: string | null; user: { login: string } | null }>;
+ };
+ }>;
+}
+
export interface PullRequestDetailQuery {
repository: {
squashMergeAllowed: boolean;
mergeCommitAllowed: boolean;
rebaseMergeAllowed: boolean;
- pullRequest: {
- id: string;
- number: number;
- title: string;
- body: string;
- url: string;
- baseRefName: string;
- state: string;
- isDraft: boolean;
- merged: boolean;
- mergedAt: string | null;
- additions: number;
- deletions: number;
- changedFiles: number;
- mergeable: string;
- mergeStateStatus: string;
- reviewDecision: string | null;
- viewerCanUpdate: boolean;
- viewerCanMergeAsAdmin: boolean;
- mergedBy: { login: string; avatarUrl: string | null } | null;
- mergeQueueEntry: { position: number | null; state: string } | null;
- baseRef: {
- branchProtectionRule: {
- requiredApprovingReviewCount: number | null;
- requiresConversationResolution: boolean | null;
- } | null;
- } | null;
- latestOpinionatedReviews: {
- nodes: ({
+ pullRequest:
+ | ({
+ id: string;
+ number: number;
+ title: string;
+ body: string;
+ url: string;
+ baseRefName: string;
state: string;
- author: { login: string; avatarUrl: string | null } | null;
- } | null)[];
- } | null;
- reviewThreads: ReviewThreadsConnection | null;
- statusCheckRollup: {
- contexts: CheckContextsConnection | null;
- } | null;
- } | null;
+ isDraft: boolean;
+ merged: boolean;
+ mergedAt: string | null;
+ additions: number;
+ deletions: number;
+ changedFiles: number;
+ mergeable: string;
+ mergeStateStatus: string;
+ reviewDecision: string | null;
+ viewerCanUpdate: boolean;
+ viewerCanMergeAsAdmin: boolean;
+ mergedBy: { login: string; avatarUrl: string | null } | null;
+ mergeQueueEntry: { position: number | null; state: string } | null;
+ baseRef: {
+ branchProtectionRule: {
+ requiredApprovingReviewCount: number | null;
+ requiresConversationResolution: boolean | null;
+ } | null;
+ } | null;
+ latestOpinionatedReviews: {
+ nodes: ({
+ state: string;
+ author: { login: string; avatarUrl: string | null } | null;
+ } | null)[];
+ } | null;
+ reviewThreads: ReviewThreadsConnection | null;
+ statusCheckRollup: {
+ contexts: CheckContextsConnection | null;
+ } | null;
+ } & ActivityFields)
+ | null;
} | null;
}
@@ -313,6 +396,83 @@ async function drain(
return nodes;
}
+function listOf(connection: Nodes | undefined): T[] {
+ return (connection?.nodes ?? []).filter((node): node is T => node !== null);
+}
+
+function actorOf(author: ActivityActor | null) {
+ const login = author?.login?.trim();
+ return login ? { login, name: author?.name?.trim() || null } : null;
+}
+
+function toActivity(
+ pr: ActivityFields,
+ url: string,
+): PullRequestDetailActivity {
+ const comments: PullRequestConversationComment[] = [
+ ...listOf(pr.comments).map((comment) => ({
+ id: comment.id,
+ kind: "comment" as const,
+ author: actorOf(comment.author),
+ body: comment.body ?? "",
+ createdAt: comment.createdAt,
+ reviewState: null,
+ url: comment.url?.trim() || null,
+ })),
+ ...listOf(pr.reviews).flatMap((review) =>
+ review.submittedAt
+ ? [
+ {
+ id: review.id,
+ kind: "review" as const,
+ author: actorOf(review.author),
+ body: review.body ?? "",
+ createdAt: review.submittedAt,
+ reviewState: review.state?.trim() || null,
+ url: null,
+ },
+ ]
+ : [],
+ ),
+ ];
+ const commits = listOf(pr.commits).flatMap(
+ ({ commit }): PullRequestCommit[] => {
+ if (!commit.committedDate) return [];
+ const author = listOf(commit.authors)
+ .map((entry) => ({
+ login: entry.user?.login?.trim() || null,
+ name: entry.name?.trim() || null,
+ }))
+ .find((entry) => entry.login || entry.name);
+ return [
+ {
+ oid: commit.oid,
+ messageHeadline: commit.messageHeadline?.trim() ?? "",
+ committedDate: commit.committedDate,
+ author: author ?? null,
+ url: `${url}/commits/${commit.oid}`,
+ },
+ ];
+ },
+ );
+ return {
+ author: pr.author?.login
+ ? { login: pr.author.login, avatarUrl: pr.author.avatarUrl ?? null }
+ : null,
+ headBranch: pr.headRefName ?? "",
+ headRepoFullName: pr.headRepository?.nameWithOwner ?? null,
+ createdAt: pr.createdAt ?? "",
+ updatedAt: pr.updatedAt ?? "",
+ closedAt: pr.closedAt?.trim() || null,
+ labels: listOf(pr.labels).map((label) => ({
+ name: label.name,
+ color: label.color?.trim() || null,
+ })),
+ comments,
+ commits,
+ };
+}
+
function variables(input: PullRequestDetailInput, cursor?: string) {
return {
owner: input.owner,
@@ -325,10 +485,12 @@ function variables(input: PullRequestDetailInput, cursor?: string) {
export async function readPullRequestDetail(
client: PullRequestDetailClient,
input: PullRequestDetailInput,
+ options: { activity?: boolean } = {},
): Promise {
+ const activity = options.activity ?? false;
const data = await client.graphql(
PULL_REQUEST_DETAIL_QUERY,
- variables(input),
+ { ...variables(input), activity },
);
const pr = data.repository?.pullRequest;
if (!pr) {
@@ -504,6 +666,7 @@ export async function readPullRequestDetail(
reopen: pr.state === "CLOSED" && !pr.merged && pr.viewerCanUpdate,
dequeue: pr.mergeQueueEntry !== null && pr.viewerCanUpdate,
},
+ activity: activity ? toActivity(pr, pr.url) : null,
};
}
diff --git a/packages/shared/src/pull-request.ts b/packages/shared/src/pull-request.ts
index 04a9d3409ef..99792a499a0 100644
--- a/packages/shared/src/pull-request.ts
+++ b/packages/shared/src/pull-request.ts
@@ -99,5 +99,3 @@ export interface PullRequestActivity {
commits: PullRequestCommit[];
labels: PullRequestLabel[];
}
-
-export type PullRequestContent = PullRequestDetail & PullRequestActivity;
diff --git a/packages/trpc/src/router/integration/github/get-pull-request-diff.ts b/packages/trpc/src/router/integration/github/get-pull-request-diff.ts
index c20484edd14..9348814ada1 100644
--- a/packages/trpc/src/router/integration/github/get-pull-request-diff.ts
+++ b/packages/trpc/src/router/integration/github/get-pull-request-diff.ts
@@ -5,8 +5,7 @@ import {
} from "@superset/shared/pull-request-diff";
import { z } from "zod";
import { protectedProcedure } from "../../../trpc";
-import { verifyOrgMembership } from "../utils";
-import { viewerOctokit } from "./viewer-octokit";
+import { asViewer } from "./viewer-octokit";
export const getPullRequestDiff = protectedProcedure
.input(
@@ -17,18 +16,12 @@ export const getPullRequestDiff = protectedProcedure
}),
)
.query(async ({ ctx, input }): Promise => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const { octokit } = await viewerOctokit({
- userId: ctx.session.user.id,
- organizationId: input.organizationId,
- repoFullName: input.repoFullName,
- });
- const [owner, name] = input.repoFullName.split("/");
- const pullRequest = {
- owner: owner ?? "",
- repo: name ?? "",
- pull_number: input.number,
- };
+ const { octokit, owner, repo } = await asViewer(
+ ctx.session.user.id,
+ input,
+ "read",
+ );
+ const pullRequest = { owner, repo, pull_number: input.number };
let data: unknown;
try {
const response = await octokit.request(
diff --git a/packages/trpc/src/router/integration/github/github-request-error.ts b/packages/trpc/src/router/integration/github/github-request-error.ts
index d2c5f1888a4..81e5ffec0c2 100644
--- a/packages/trpc/src/router/integration/github/github-request-error.ts
+++ b/packages/trpc/src/router/integration/github/github-request-error.ts
@@ -1,11 +1,22 @@
+import { PullRequestReadError } from "@superset/shared/pull-request-detail";
import { TRPCError } from "@trpc/server";
+import { userError } from "../../../trpc";
-/** GitHub's answer to a write, as the error code the desktop branches on. */
+/** GitHub's answer, as the error code clients branch on. */
export function githubRequestError(
error: unknown,
fallback: string,
): TRPCError {
if (error instanceof TRPCError) return error;
+ if (error instanceof PullRequestReadError) {
+ return error.code === "NOT_FOUND"
+ ? userError({
+ code: "NOT_FOUND",
+ message: "Pull request not found",
+ i18nKey: "serverError.integration.pullRequestNotFound",
+ })
+ : new TRPCError({ code: error.code, message: error.message });
+ }
const status =
typeof error === "object" && error !== null && "status" in error
diff --git a/packages/trpc/src/router/integration/github/github.ts b/packages/trpc/src/router/integration/github/github.ts
index 87d6c5b7917..80675086a24 100644
--- a/packages/trpc/src/router/integration/github/github.ts
+++ b/packages/trpc/src/router/integration/github/github.ts
@@ -341,7 +341,7 @@ export const githubRouter = {
* everything but the description, which comes from GitHub with the
* installation's token.
*
- * @deprecated Use the API's `integration.github.getPullRequestContent`, which acts as the viewer. Kept for released clients.
+ * @deprecated Use the API's `integration.github.getPullRequestDetail`, which acts as the viewer. Kept for released clients.
*/
getPullRequest: protectedProcedure
.input(
diff --git a/packages/trpc/src/router/integration/github/pull-request-content.test.ts b/packages/trpc/src/router/integration/github/pull-request-content.test.ts
deleted file mode 100644
index ba97a58fb27..00000000000
--- a/packages/trpc/src/router/integration/github/pull-request-content.test.ts
+++ /dev/null
@@ -1,185 +0,0 @@
-import { describe, expect, test } from "bun:test";
-import {
- pullRequestContentQuerySchema,
- toPullRequestContent,
-} from "./pull-request-content";
-
-const node = {
- number: 12,
- title: "Read pull requests as the viewer",
- body: null,
- url: "https://github.com/owner/repo/pull/12",
- state: "OPEN",
- isDraft: false,
- createdAt: "2026-10-01T10:00:00Z",
- updatedAt: "2026-10-02T10:00:00Z",
- mergedAt: null,
- closedAt: null,
- mergeable: "CONFLICTING",
- additions: 10,
- deletions: -1,
- changedFiles: 2,
- reviewDecision: "CHANGES_REQUESTED",
- headRefName: "feat/viewer",
- baseRefName: "main",
- isCrossRepository: true,
- headRepository: { nameWithOwner: "fork/repo" },
- author: { login: "satya", avatarUrl: "https://avatars/satya" },
- labels: { nodes: [{ name: "desktop", color: "1d76db" }, null] },
- reviewRequests: {
- nodes: [
- { requestedReviewer: { login: "reviewer", name: "Rev Ewer" } },
- { requestedReviewer: null },
- ],
- },
- reviews: {
- nodes: [
- {
- id: "R1",
- author: { login: "Reviewer", name: null },
- body: "Please fix",
- state: "CHANGES_REQUESTED",
- submittedAt: "2026-10-02T09:00:00Z",
- },
- { id: "R2", author: { login: "pending" }, body: "", submittedAt: null },
- ],
- },
- comments: {
- nodes: [
- {
- id: "C1",
- author: { login: "satya" },
- body: "On it",
- createdAt: "2026-10-02T09:30:00Z",
- url: "https://github.com/owner/repo/pull/12#issuecomment-1",
- },
- ],
- },
- commits: {
- nodes: [
- {
- commit: {
- oid: "abc123",
- messageHeadline: "feat: viewer reads ",
- committedDate: "2026-10-01T09:00:00Z",
- authors: {
- nodes: [
- { name: "Satya", user: null },
- { name: null, user: null },
- ],
- },
- },
- },
- {
- commit: { oid: "nodate", messageHeadline: "x", committedDate: null },
- },
- ],
- },
- lastCommit: {
- nodes: [
- {
- commit: {
- statusCheckRollup: {
- contexts: {
- nodes: [
- {
- __typename: "CheckRun",
- name: "ci",
- status: "COMPLETED",
- conclusion: "FAILURE",
- detailsUrl: "https://ci/1",
- checkSuite: { workflowRun: { databaseId: 1 } },
- },
- {
- __typename: "CheckRun",
- name: "ci",
- status: "COMPLETED",
- conclusion: "SUCCESS",
- detailsUrl: "https://ci/2",
- checkSuite: { workflowRun: { databaseId: 2 } },
- },
- {
- __typename: "StatusContext",
- context: "lint",
- state: "PENDING",
- targetUrl: null,
- },
- ],
- },
- },
- },
- },
- ],
- },
-};
-
-describe("toPullRequestContent", () => {
- test("maps the GraphQL node to the shared pull request content", () => {
- const parsed = pullRequestContentQuerySchema.parse({
- repository: { pullRequest: node },
- });
- const content = toPullRequestContent(
- parsed.repository?.pullRequest as NonNullable<
- NonNullable["pullRequest"]
- >,
- "owner/repo",
- );
- expect(content).toMatchObject({
- repoFullName: "owner/repo",
- number: 12,
- body: "",
- state: "open",
- author: { login: "satya", avatarUrl: "https://avatars/satya" },
- head: { ref: "feat/viewer", repoFullName: "fork/repo" },
- base: { ref: "main" },
- reviewDecision: "changes_requested",
- checksStatus: "pending",
- additions: 10,
- deletions: 0,
- changedFiles: 2,
- mergeability: "conflicting",
- labels: [{ name: "desktop", color: "1d76db" }],
- });
- // The re-run replaces the failed run of the same name.
- expect(content.checks).toEqual([
- { name: "ci", status: "success", url: "https://ci/2" },
- { name: "lint", status: "pending", url: null },
- ]);
- expect(content.reviewers).toEqual([
- { login: "reviewer", name: "Rev Ewer" },
- ]);
- expect(content.comments.map((c) => [c.kind, c.id, c.reviewState])).toEqual([
- ["comment", "C1", null],
- ["review", "R1", "CHANGES_REQUESTED"],
- ]);
- expect(content.commits).toEqual([
- {
- oid: "abc123",
- messageHeadline: "feat: viewer reads",
- committedDate: "2026-10-01T09:00:00Z",
- author: { login: null, name: "Satya" },
- url: "https://github.com/owner/repo/pull/12/commits/abc123",
- },
- ]);
- });
-
- test("a merged pull request reads as merged even when GitHub says closed", () => {
- const parsed = pullRequestContentQuerySchema.parse({
- repository: {
- pullRequest: {
- ...node,
- state: "CLOSED",
- mergedAt: "2026-10-03T00:00:00Z",
- lastCommit: null,
- },
- },
- });
- const pullRequest = parsed.repository?.pullRequest;
- if (!pullRequest) throw new Error("expected a pull request");
- const content = toPullRequestContent(pullRequest, "owner/repo");
- expect(content.state).toBe("merged");
- expect(content.mergedAt).toBe("2026-10-03T00:00:00Z");
- expect(content.checks).toEqual([]);
- expect(content.checksStatus).toBe("none");
- });
-});
diff --git a/packages/trpc/src/router/integration/github/pull-request-content.ts b/packages/trpc/src/router/integration/github/pull-request-content.ts
deleted file mode 100644
index 5bc1d29a5ef..00000000000
--- a/packages/trpc/src/router/integration/github/pull-request-content.ts
+++ /dev/null
@@ -1,344 +0,0 @@
-import type {
- PullRequestActor,
- PullRequestCommit,
- PullRequestCommitAuthor,
- PullRequestContent,
- PullRequestConversationComment,
- PullRequestMergeability,
-} from "@superset/shared/pull-request";
-import {
- computeChecksStatus,
- parseCheckContexts,
-} from "@superset/shared/pull-request-checks";
-import { z } from "zod";
-import { toPullRequestState, toReviewDecision } from "./pull-request-shape";
-
-/** The fields `gh pr view --json` reads, asked for in one request. */
-export const PULL_REQUEST_CONTENT_QUERY = `
- query($owner: String!, $name: String!, $number: Int!) {
- repository(owner: $owner, name: $name) {
- pullRequest(number: $number) {
- number title body url state isDraft createdAt updatedAt mergedAt closedAt
- mergeable additions deletions changedFiles reviewDecision
- headRefName baseRefName isCrossRepository
- headRepository { nameWithOwner }
- author { login avatarUrl }
- labels(first: 50) { nodes { name color } }
- reviewRequests(first: 50) {
- nodes {
- requestedReviewer {
- ... on User { login name }
- ... on Mannequin { login }
- ... on Team { login: slug name }
- }
- }
- }
- reviews(first: 100) {
- nodes { id author { login ... on User { name } } body state submittedAt }
- }
- comments(first: 100) {
- nodes { id author { login ... on User { name } } body createdAt url }
- }
- commits(last: 100) {
- nodes {
- commit {
- oid messageHeadline committedDate
- authors(first: 3) { nodes { name user { login } } }
- }
- }
- }
- lastCommit: commits(last: 1) {
- nodes {
- commit {
- statusCheckRollup {
- contexts(first: 100) {
- nodes {
- __typename
- ... on CheckRun {
- name status conclusion detailsUrl startedAt completedAt
- checkSuite { workflowRun { databaseId } }
- }
- ... on StatusContext { context state targetUrl createdAt }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-`;
-
-const actorSchema = z
- .object({
- login: z.string().nullable().optional(),
- name: z.string().nullable().optional(),
- avatarUrl: z.string().nullable().optional(),
- })
- .nullable()
- .optional();
-
-const nodes = (node: T) =>
- z
- .object({ nodes: z.array(node.nullable()).nullable().optional() })
- .nullable()
- .optional();
-
-const checkRunNode = z.object({
- __typename: z.literal("CheckRun"),
- name: z.string(),
- status: z.string(),
- conclusion: z.string().nullable().optional(),
- detailsUrl: z.string().nullable().optional(),
- startedAt: z.string().nullable().optional(),
- completedAt: z.string().nullable().optional(),
- checkSuite: z
- .object({
- workflowRun: z.object({ databaseId: z.number().nullable() }).nullable(),
- })
- .nullable()
- .optional(),
-});
-const statusContextNode = z.object({
- __typename: z.literal("StatusContext"),
- context: z.string(),
- state: z.string(),
- targetUrl: z.string().nullable().optional(),
- createdAt: z.string().nullable().optional(),
-});
-
-export const pullRequestContentNodeSchema = z.object({
- number: z.number(),
- title: z.string(),
- body: z.string().nullable().optional(),
- url: z.string(),
- state: z.string(),
- isDraft: z.boolean(),
- createdAt: z.string(),
- updatedAt: z.string(),
- mergedAt: z.string().nullable().optional(),
- closedAt: z.string().nullable().optional(),
- mergeable: z.string().nullable().optional(),
- additions: z.number().nullable().optional(),
- deletions: z.number().nullable().optional(),
- changedFiles: z.number().nullable().optional(),
- reviewDecision: z.string().nullable().optional(),
- headRefName: z.string(),
- baseRefName: z.string(),
- isCrossRepository: z.boolean(),
- headRepository: z.object({ nameWithOwner: z.string() }).nullable().optional(),
- author: actorSchema,
- labels: nodes(
- z.object({ name: z.string(), color: z.string().nullable().optional() }),
- ),
- reviewRequests: nodes(z.object({ requestedReviewer: actorSchema })),
- reviews: nodes(
- z.object({
- id: z.string(),
- author: actorSchema,
- body: z.string().nullable().optional(),
- state: z.string().nullable().optional(),
- submittedAt: z.string().nullable().optional(),
- }),
- ),
- comments: nodes(
- z.object({
- id: z.string(),
- author: actorSchema,
- body: z.string().nullable().optional(),
- createdAt: z.string(),
- url: z.string().nullable().optional(),
- }),
- ),
- commits: nodes(
- z.object({
- commit: z.object({
- oid: z.string(),
- messageHeadline: z.string().nullable().optional(),
- committedDate: z.string().nullable().optional(),
- authors: nodes(
- z.object({
- name: z.string().nullable().optional(),
- user: z.object({ login: z.string() }).nullable().optional(),
- }),
- ),
- }),
- }),
- ),
- lastCommit: nodes(
- z.object({
- commit: z.object({
- statusCheckRollup: z
- .object({
- contexts: nodes(
- z.discriminatedUnion("__typename", [
- checkRunNode,
- statusContextNode,
- ]),
- ),
- })
- .nullable()
- .optional(),
- }),
- }),
- ),
-});
-
-export const pullRequestContentQuerySchema = z.object({
- repository: z
- .object({ pullRequest: pullRequestContentNodeSchema.nullable() })
- .nullable(),
-});
-
-export type PullRequestContentNode = z.infer<
- typeof pullRequestContentNodeSchema
->;
-
-function listOf(
- connection: { nodes?: (T | null)[] | null } | null | undefined,
-): T[] {
- return (connection?.nodes ?? []).filter((node): node is T => node !== null);
-}
-
-function toActor(actor: z.infer): PullRequestActor | null {
- const login = actor?.login?.trim();
- if (!login) return null;
- return { login, name: actor?.name?.trim() || null };
-}
-
-function toMergeability(
- mergeable: string | null | undefined,
-): PullRequestMergeability {
- switch (mergeable?.toUpperCase()) {
- case "MERGEABLE":
- return "mergeable";
- case "CONFLICTING":
- return "conflicting";
- default:
- return "unknown";
- }
-}
-
-function count(value: number | null | undefined): number {
- return typeof value === "number" && value > 0 ? Math.floor(value) : 0;
-}
-
-export function toPullRequestContent(
- node: PullRequestContentNode,
- repoFullName: string,
-): PullRequestContent {
- const contexts = listOf(
- listOf(node.lastCommit)[0]?.commit.statusCheckRollup?.contexts,
- ).map((context) =>
- context.__typename === "CheckRun"
- ? {
- ...context,
- conclusion: context.conclusion ?? null,
- detailsUrl: context.detailsUrl ?? null,
- startedAt: context.startedAt ?? null,
- completedAt: context.completedAt ?? null,
- checkSuite: context.checkSuite ?? null,
- }
- : {
- ...context,
- targetUrl: context.targetUrl ?? null,
- createdAt: context.createdAt ?? null,
- },
- );
- const checks = parseCheckContexts(contexts);
- const reviews = listOf(node.reviews).filter((review) => review.submittedAt);
-
- const reviewers = new Map();
- for (const actor of [
- ...listOf(node.reviewRequests).map((request) => request.requestedReviewer),
- ...reviews.map((review) => review.author),
- ]) {
- const reviewer = toActor(actor);
- if (!reviewer) continue;
- const known = reviewers.get(reviewer.login.toLowerCase());
- if (!known || (!known.name && reviewer.name)) {
- reviewers.set(reviewer.login.toLowerCase(), reviewer);
- }
- }
-
- const comments: PullRequestConversationComment[] = [
- ...listOf(node.comments).map((comment) => ({
- id: comment.id,
- kind: "comment" as const,
- author: toActor(comment.author),
- body: comment.body ?? "",
- createdAt: comment.createdAt,
- reviewState: null,
- url: comment.url?.trim() || null,
- })),
- ...reviews.map((review) => ({
- id: review.id,
- kind: "review" as const,
- author: toActor(review.author),
- body: review.body ?? "",
- createdAt: review.submittedAt as string,
- reviewState: review.state?.trim() || null,
- url: null,
- })),
- ];
-
- const commits: PullRequestCommit[] = listOf(node.commits).flatMap(
- ({ commit }) => {
- if (!commit.committedDate) return [];
- const author = listOf(commit.authors)
- .map(
- (entry): PullRequestCommitAuthor => ({
- login: entry.user?.login?.trim() || null,
- name: entry.name?.trim() || null,
- }),
- )
- .find((entry) => entry.login || entry.name);
- return [
- {
- oid: commit.oid,
- messageHeadline: commit.messageHeadline?.trim() ?? "",
- committedDate: commit.committedDate,
- author: author ?? null,
- url: `${node.url}/commits/${commit.oid}`,
- },
- ];
- },
- );
-
- return {
- repoFullName,
- number: node.number,
- url: node.url,
- title: node.title,
- body: node.body ?? "",
- state: toPullRequestState(node.state.toLowerCase(), node.mergedAt ?? null),
- isDraft: node.isDraft,
- author: node.author?.login
- ? { login: node.author.login, avatarUrl: node.author.avatarUrl ?? null }
- : null,
- head: {
- ref: node.headRefName,
- repoFullName: node.headRepository?.nameWithOwner ?? null,
- },
- base: { ref: node.baseRefName },
- reviewDecision: toReviewDecision(node.reviewDecision ?? null),
- checksStatus: computeChecksStatus(checks),
- checks,
- createdAt: node.createdAt,
- updatedAt: node.updatedAt,
- additions: count(node.additions),
- deletions: count(node.deletions),
- changedFiles: count(node.changedFiles),
- mergeability: toMergeability(node.mergeable),
- mergedAt: node.mergedAt?.trim() || null,
- closedAt: node.closedAt?.trim() || null,
- reviewers: [...reviewers.values()],
- comments,
- commits,
- labels: listOf(node.labels).map((label) => ({
- name: label.name,
- color: label.color?.trim() || null,
- })),
- };
-}
diff --git a/packages/trpc/src/router/integration/github/pull-request-procedures.ts b/packages/trpc/src/router/integration/github/pull-request-procedures.ts
index f8c1d0080f3..a0042103fc0 100644
--- a/packages/trpc/src/router/integration/github/pull-request-procedures.ts
+++ b/packages/trpc/src/router/integration/github/pull-request-procedures.ts
@@ -1,7 +1,5 @@
-import type { PullRequestContent } from "@superset/shared/pull-request";
import {
type PullRequestDetailRead,
- PullRequestReadError,
pullRequestNodeId,
readPullRequestDetail,
} from "@superset/shared/pull-request-detail";
@@ -10,166 +8,73 @@ import {
REVIEW_THREADS_QUERY,
type ReviewThreadsQueryResult,
} from "@superset/shared/pull-request-threads";
-import { TRPCError, type TRPCRouterRecord } from "@trpc/server";
+import type { TRPCRouterRecord } from "@trpc/server";
import { z } from "zod";
-import { protectedProcedure, userError } from "../../../trpc";
-import { verifyOrgMembership } from "../utils";
+import { protectedProcedure } from "../../../trpc";
import { githubRequestError } from "./github-request-error";
-import {
- PULL_REQUEST_CONTENT_QUERY,
- pullRequestContentQuerySchema,
- toPullRequestContent,
-} from "./pull-request-content";
-import { viewerOctokit, viewerOnlyOctokit } from "./viewer-octokit";
+import { asViewer, type ViewerPullRequest } from "./viewer-octokit";
-export const pullRequestInputSchema = z.object({
+const pullRequestInput = z.object({
organizationId: z.string().uuid(),
repoFullName: z.string().regex(/^[\w.-]+\/[\w.-]+$/),
number: z.number().int().positive(),
});
+// GitHub rejects bodies past 65536 characters.
+const body = z.string().trim().min(1).max(65536);
-function repoOf(repoFullName: string): { owner: string; repo: string } {
- const [owner = "", repo = ""] = repoFullName.split("/");
- return { owner, repo };
-}
-
-function readError(error: unknown, fallback: string) {
- if (error instanceof PullRequestReadError) {
- return error.code === "NOT_FOUND"
- ? userError({
- code: "NOT_FOUND",
- message: "Pull request not found",
- i18nKey: "serverError.integration.pullRequestNotFound",
- })
- : new TRPCError({ code: error.code, message: error.message });
+async function onGithub(
+ fallback: string,
+ run: () => Promise,
+): Promise {
+ try {
+ return await run();
+ } catch (error) {
+ throw githubRequestError(error, fallback);
}
- return githubRequestError(error, fallback);
}
+const graphqlOf = ({ octokit }: ViewerPullRequest) => ({
+ graphql: (query: string, variables: Record) =>
+ octokit.graphql(query, variables),
+});
+
/**
* A pull request by its own identity, read and written as the person asking.
- * Nothing here needs a project or a host: the desktop reaches these for any
- * PR it can name, and falls back to a host's `gh` only when they are absent.
+ * Nothing here needs a project or a host: clients reach these for any PR
+ * they can name.
*/
export const pullRequestProcedures = {
- getPullRequestContent: protectedProcedure
- .input(pullRequestInputSchema)
- .query(async ({ ctx, input }): Promise => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const { octokit } = await viewerOctokit({
- userId: ctx.session.user.id,
- ...input,
- });
- const { owner, repo } = repoOf(input.repoFullName);
- let raw: unknown;
- try {
- raw = await octokit.graphql(PULL_REQUEST_CONTENT_QUERY, {
- owner,
- name: repo,
- number: input.number,
- });
- } catch (error) {
- throw githubRequestError(
- error,
- `Failed to read pull request #${input.number}`,
- );
- }
- const node =
- pullRequestContentQuerySchema.parse(raw).repository?.pullRequest;
- if (!node) {
- throw userError({
- code: "NOT_FOUND",
- message: "Pull request not found",
- i18nKey: "serverError.integration.pullRequestNotFound",
- });
- }
- return toPullRequestContent(node, input.repoFullName);
- }),
-
- /** What the mobile pull request view grades and acts from: mergeability, checks, reviewers, and the viewer's own capabilities. */
+ /** Mergeability, checks, reviewers and the viewer's own capabilities; with `activity`, the conversation and commits too. */
getPullRequestDetail: protectedProcedure
- .input(pullRequestInputSchema)
+ .input(pullRequestInput.extend({ activity: z.boolean().optional() }))
.query(async ({ ctx, input }): Promise => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const { octokit } = await viewerOctokit({
- userId: ctx.session.user.id,
- ...input,
- });
- const { owner, repo } = repoOf(input.repoFullName);
- try {
- return await readPullRequestDetail(
+ const pr = await asViewer(ctx.session.user.id, input, "read");
+ return onGithub(`Failed to read pull request #${pr.number}`, () =>
+ readPullRequestDetail(
{
- graphql: (query, variables) => octokit.graphql(query, variables),
+ ...graphqlOf(pr),
requestedReviewers: async () =>
(
- await octokit.request(
+ await pr.octokit.request(
"GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers",
- { owner, repo, pull_number: input.number },
+ { owner: pr.owner, repo: pr.repo, pull_number: pr.number },
)
).data,
},
- { owner, repo, pullNumber: input.number },
- );
- } catch (error) {
- throw readError(error, `Failed to read pull request #${input.number}`);
- }
- }),
-
- updatePullRequestBranch: protectedProcedure
- .input(pullRequestInputSchema)
- .mutation(async ({ ctx, input }) => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const octokit = await viewerOnlyOctokit(ctx.session.user.id);
- try {
- await octokit.request(
- "PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch",
- { ...repoOf(input.repoFullName), pull_number: input.number },
- );
- } catch (error) {
- throw githubRequestError(error, "GitHub refused to update the branch.");
- }
- return { ok: true as const };
- }),
-
- dequeuePullRequest: protectedProcedure
- .input(pullRequestInputSchema)
- .mutation(async ({ ctx, input }) => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const octokit = await viewerOnlyOctokit(ctx.session.user.id);
- const { owner, repo } = repoOf(input.repoFullName);
- try {
- const id = await pullRequestNodeId(
- { graphql: (query, variables) => octokit.graphql(query, variables) },
- { owner, repo, pullNumber: input.number },
- );
- await octokit.graphql(
- `mutation($id: ID!) {
- dequeuePullRequest(input: { id: $id }) { mergeQueueEntry { position } }
- }`,
- { id },
- );
- } catch (error) {
- throw readError(
- error,
- "GitHub refused to remove the pull request from the queue.",
- );
- }
- return { ok: true as const };
+ { owner: pr.owner, repo: pr.repo, pullNumber: pr.number },
+ { activity: input.activity },
+ ),
+ );
}),
getPullRequestThreads: protectedProcedure
- .input(pullRequestInputSchema)
+ .input(pullRequestInput)
.query(async ({ ctx, input }) => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const { octokit } = await viewerOctokit({
- userId: ctx.session.user.id,
- ...input,
- });
- const { owner, repo } = repoOf(input.repoFullName);
+ const pr = await asViewer(ctx.session.user.id, input, "read");
try {
- const result: ReviewThreadsQueryResult = await octokit.graphql(
+ const result = await pr.octokit.graphql(
REVIEW_THREADS_QUERY,
- { owner, name: repo, prNumber: input.number },
+ { owner: pr.owner, name: pr.repo, prNumber: pr.number },
);
return {
reviewThreads: parseReviewThreads(result),
@@ -177,196 +82,180 @@ export const pullRequestProcedures = {
};
} catch (error) {
console.warn(
- `[github.getPullRequestThreads] review threads of ${input.repoFullName}#${input.number}:`,
+ `[github.getPullRequestThreads] ${input.repoFullName}#${pr.number}:`,
error instanceof Error ? error.message : error,
);
- // An empty list rather than an error, so the diff still shows
- // when only its comments could not load; `fetchFailed` keeps the
- // two apart for the caller.
+ // Empty rather than an error, so the diff still shows when only its
+ // comments failed; `fetchFailed` keeps the two apart.
return { reviewThreads: [], fetchFailed: true };
}
}),
addPullRequestComment: protectedProcedure
- .input(
- pullRequestInputSchema.extend({
- // GitHub rejects bodies past 65536 characters.
- body: z.string().trim().min(1).max(65536),
- }),
- )
+ .input(pullRequestInput.extend({ body }))
.mutation(async ({ ctx, input }) => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const octokit = await viewerOnlyOctokit(ctx.session.user.id);
- try {
- const { data } = await octokit.request(
+ const pr = await asViewer(ctx.session.user.id, input, "write");
+ const { data } = await onGithub("GitHub refused the comment.", () =>
+ pr.octokit.request(
"POST /repos/{owner}/{repo}/issues/{issue_number}/comments",
{
- ...repoOf(input.repoFullName),
- issue_number: input.number,
+ owner: pr.owner,
+ repo: pr.repo,
+ issue_number: pr.number,
body: input.body,
},
- );
- return { id: data.id, url: data.html_url };
- } catch (error) {
- throw githubRequestError(error, "GitHub refused the comment.");
- }
+ ),
+ );
+ return { id: data.id, url: data.html_url };
}),
replyToPullRequestThread: protectedProcedure
.input(
- pullRequestInputSchema.extend({
- /** REST databaseId of any comment already in the thread. */
- commentId: z.number().int().positive(),
- body: z.string().trim().min(1).max(65536),
- }),
+ /** `commentId`: REST databaseId of any comment already in the thread. */
+ pullRequestInput.extend({ commentId: z.number().int().positive(), body }),
)
.mutation(async ({ ctx, input }) => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const octokit = await viewerOnlyOctokit(ctx.session.user.id);
- try {
- const { data } = await octokit.request(
+ const pr = await asViewer(ctx.session.user.id, input, "write");
+ const { data } = await onGithub("GitHub refused the reply.", () =>
+ pr.octokit.request(
"POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies",
{
- ...repoOf(input.repoFullName),
- pull_number: input.number,
+ owner: pr.owner,
+ repo: pr.repo,
+ pull_number: pr.number,
comment_id: input.commentId,
body: input.body,
},
- );
- return { id: data.id };
- } catch (error) {
- throw githubRequestError(error, "GitHub refused the reply.");
- }
+ ),
+ );
+ return { id: data.id };
}),
setPullRequestThreadResolution: protectedProcedure
.input(
- pullRequestInputSchema.extend({
+ pullRequestInput.extend({
threadId: z.string().min(1),
resolved: z.boolean(),
}),
)
.mutation(async ({ ctx, input }) => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const octokit = await viewerOnlyOctokit(ctx.session.user.id);
- const mutation = input.resolved
- ? `mutation($threadId: ID!) {
- resolveReviewThread(input: {threadId: $threadId}) { thread { id isResolved } }
- }`
- : `mutation($threadId: ID!) {
- unresolveReviewThread(input: {threadId: $threadId}) { thread { id isResolved } }
- }`;
- try {
- await octokit.graphql(mutation, { threadId: input.threadId });
- } catch (error) {
- throw githubRequestError(error, "GitHub refused to update the thread.");
- }
+ const pr = await asViewer(ctx.session.user.id, input, "write");
+ const verb = input.resolved
+ ? "resolveReviewThread"
+ : "unresolveReviewThread";
+ await onGithub("GitHub refused to update the thread.", () =>
+ pr.octokit.graphql(
+ `mutation($threadId: ID!) { ${verb}(input: {threadId: $threadId}) { thread { id } } }`,
+ { threadId: input.threadId },
+ ),
+ );
return { threadId: input.threadId, isResolved: input.resolved };
}),
mergePullRequest: protectedProcedure
.input(
- pullRequestInputSchema.extend({
+ pullRequestInput.extend({
mergeMethod: z.enum(["merge", "squash", "rebase"]).default("merge"),
commitMessage: z.string().trim().min(1).optional(),
}),
)
.mutation(async ({ ctx, input }) => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const octokit = await viewerOnlyOctokit(ctx.session.user.id);
- try {
- const { data } = await octokit.request(
+ const pr = await asViewer(ctx.session.user.id, input, "write");
+ const { data } = await onGithub("GitHub refused the merge.", () =>
+ pr.octokit.request(
"PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge",
{
- ...repoOf(input.repoFullName),
- pull_number: input.number,
+ owner: pr.owner,
+ repo: pr.repo,
+ pull_number: pr.number,
merge_method: input.mergeMethod,
...(input.commitMessage
? { commit_message: input.commitMessage }
: {}),
},
- );
- return { merged: data.merged, sha: data.sha, message: data.message };
- } catch (error) {
- throw githubRequestError(error, "GitHub refused the merge.");
- }
+ ),
+ );
+ return { merged: data.merged, sha: data.sha, message: data.message };
}),
setPullRequestState: protectedProcedure
- .input(
- // Only open/closed: a merged pull request has no way back.
- pullRequestInputSchema.extend({ state: z.enum(["open", "closed"]) }),
- )
+ // Only open/closed: a merged pull request has no way back.
+ .input(pullRequestInput.extend({ state: z.enum(["open", "closed"]) }))
.mutation(async ({ ctx, input }) => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const octokit = await viewerOnlyOctokit(ctx.session.user.id);
- try {
- await octokit.request(
- "PATCH /repos/{owner}/{repo}/pulls/{pull_number}",
- {
- ...repoOf(input.repoFullName),
- pull_number: input.number,
- state: input.state,
- },
- );
- } catch (error) {
- throw githubRequestError(
- error,
- `GitHub refused to ${input.state === "closed" ? "close" : "reopen"} the pull request.`,
- );
- }
+ const pr = await asViewer(ctx.session.user.id, input, "write");
+ await onGithub(
+ `GitHub refused to ${input.state === "closed" ? "close" : "reopen"} the pull request.`,
+ () =>
+ pr.octokit.request(
+ "PATCH /repos/{owner}/{repo}/pulls/{pull_number}",
+ {
+ owner: pr.owner,
+ repo: pr.repo,
+ pull_number: pr.number,
+ state: input.state,
+ },
+ ),
+ );
return { ok: true as const };
}),
setPullRequestDraft: protectedProcedure
- .input(pullRequestInputSchema.extend({ draft: z.boolean() }))
+ .input(pullRequestInput.extend({ draft: z.boolean() }))
.mutation(async ({ ctx, input }) => {
- await verifyOrgMembership(ctx.session.user.id, input.organizationId);
- const octokit = await viewerOnlyOctokit(ctx.session.user.id);
- const { owner, repo } = repoOf(input.repoFullName);
- try {
- const found = z
- .object({
- repository: z
- .object({
- pullRequest: z.object({ id: z.string() }).nullable(),
- })
- .nullable(),
- })
- .parse(
- await octokit.graphql(
- `query($owner: String!, $name: String!, $number: Int!) {
- repository(owner: $owner, name: $name) { pullRequest(number: $number) { id } }
- }`,
- { owner, name: repo, number: input.number },
- ),
+ const pr = await asViewer(ctx.session.user.id, input, "write");
+ const mutation = input.draft
+ ? "convertPullRequestToDraft"
+ : "markPullRequestReadyForReview";
+ await onGithub(
+ input.draft
+ ? "GitHub refused to convert the pull request to a draft."
+ : "GitHub refused to mark the pull request ready for review.",
+ async () => {
+ const id = await pullRequestNodeId(graphqlOf(pr), {
+ owner: pr.owner,
+ repo: pr.repo,
+ pullNumber: pr.number,
+ });
+ await pr.octokit.graphql(
+ `mutation($id: ID!) { ${mutation}(input: {pullRequestId: $id}) { pullRequest { isDraft } } }`,
+ { id },
);
- const pullRequestId = found.repository?.pullRequest?.id;
- if (!pullRequestId) {
- throw userError({
- code: "NOT_FOUND",
- message: "Pull request not found",
- i18nKey: "serverError.integration.pullRequestNotFound",
+ },
+ );
+ return { ok: true as const };
+ }),
+
+ updatePullRequestBranch: protectedProcedure
+ .input(pullRequestInput)
+ .mutation(async ({ ctx, input }) => {
+ const pr = await asViewer(ctx.session.user.id, input, "write");
+ await onGithub("GitHub refused to update the branch.", () =>
+ pr.octokit.request(
+ "PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch",
+ { owner: pr.owner, repo: pr.repo, pull_number: pr.number },
+ ),
+ );
+ return { ok: true as const };
+ }),
+
+ dequeuePullRequest: protectedProcedure
+ .input(pullRequestInput)
+ .mutation(async ({ ctx, input }) => {
+ const pr = await asViewer(ctx.session.user.id, input, "write");
+ await onGithub(
+ "GitHub refused to remove the pull request from the queue.",
+ async () => {
+ const id = await pullRequestNodeId(graphqlOf(pr), {
+ owner: pr.owner,
+ repo: pr.repo,
+ pullNumber: pr.number,
});
- }
- await octokit.graphql(
- input.draft
- ? `mutation($pullRequestId: ID!) {
- convertPullRequestToDraft(input: {pullRequestId: $pullRequestId}) { pullRequest { isDraft } }
- }`
- : `mutation($pullRequestId: ID!) {
- markPullRequestReadyForReview(input: {pullRequestId: $pullRequestId}) { pullRequest { isDraft } }
- }`,
- { pullRequestId },
- );
- } catch (error) {
- throw githubRequestError(
- error,
- input.draft
- ? "GitHub refused to convert the pull request to a draft."
- : "GitHub refused to mark the pull request ready for review.",
- );
- }
+ await pr.octokit.graphql(
+ "mutation($id: ID!) { dequeuePullRequest(input: { id: $id }) { mergeQueueEntry { position } } }",
+ { id },
+ );
+ },
+ );
return { ok: true as const };
}),
} satisfies TRPCRouterRecord;
diff --git a/packages/trpc/src/router/integration/github/viewer-octokit.ts b/packages/trpc/src/router/integration/github/viewer-octokit.ts
index d5245231371..1a00ebe3870 100644
--- a/packages/trpc/src/router/integration/github/viewer-octokit.ts
+++ b/packages/trpc/src/router/integration/github/viewer-octokit.ts
@@ -2,42 +2,58 @@ import { Octokit } from "@octokit/core";
import { githubUserTokenFor } from "../../../lib/github-user";
import { installationOctokit } from "../../../lib/sandbox/clone-token";
import { userError } from "../../../trpc";
+import { verifyOrgMembership } from "../utils";
import { findInstalledRepository } from "./find-installed-repository";
-export const GITHUB_NOT_CONNECTED_MESSAGE =
- "Connect GitHub in Settings to act on pull requests as yourself";
+export interface PullRequestInput {
+ organizationId: string;
+ repoFullName: string;
+ number: number;
+}
+
+export interface ViewerPullRequest {
+ octokit: Octokit;
+ owner: string;
+ repo: string;
+ number: number;
+}
/**
* GitHub as the person asking: their own connection when they have one, the
* organization's App installation otherwise. Reads may take either; a write
* must be theirs, or GitHub would record it under the App's name.
*/
-export async function viewerOctokit(args: {
- userId: string;
- organizationId: string;
- repoFullName: string;
-}): Promise<{ octokit: Octokit; actsAsViewer: boolean }> {
- const token = await githubUserTokenFor(args.userId);
- if (token)
- return { octokit: new Octokit({ auth: token }), actsAsViewer: true };
- const { installation } = await findInstalledRepository(
- args.organizationId,
- args.repoFullName,
- );
- return {
- octokit: await installationOctokit(installation.installationId),
- actsAsViewer: false,
- };
-}
-
-export async function viewerOnlyOctokit(userId: string): Promise {
+export async function asViewer(
+ userId: string,
+ input: PullRequestInput,
+ access: "read" | "write",
+): Promise {
+ await verifyOrgMembership(userId, input.organizationId);
+ const [owner = "", repo = ""] = input.repoFullName.split("/");
const token = await githubUserTokenFor(userId);
- if (!token) {
+ if (token) {
+ return {
+ octokit: new Octokit({ auth: token }),
+ owner,
+ repo,
+ number: input.number,
+ };
+ }
+ if (access === "write") {
throw userError({
code: "PRECONDITION_FAILED",
- message: GITHUB_NOT_CONNECTED_MESSAGE,
+ message: "Connect GitHub in Settings to act on pull requests as yourself",
i18nKey: "serverError.githubUser.notConnected",
});
}
- return new Octokit({ auth: token });
+ const { installation } = await findInstalledRepository(
+ input.organizationId,
+ input.repoFullName,
+ );
+ return {
+ octokit: await installationOctokit(installation.installationId),
+ owner,
+ repo,
+ number: input.number,
+ };
}
From ec2ed7cc4d4493948fc0dd42beda58440ce73969 Mon Sep 17 00:00:00 2001
From: Satya Patel <14907857+saddlepaddle@users.noreply.github.com>
Date: Tue, 27 Oct 2026 22:19:10 +0000
Subject: [PATCH 5/8] chore(i18n): regenerate catalogs after rebasing onto main
---
packages/i18n/locales/cs/messages.po | 24 ------------------------
packages/i18n/locales/de/messages.po | 24 ------------------------
packages/i18n/locales/en/messages.po | 24 ------------------------
packages/i18n/locales/es/messages.po | 24 ------------------------
packages/i18n/locales/fr/messages.po | 24 ------------------------
packages/i18n/locales/id/messages.po | 24 ------------------------
packages/i18n/locales/it/messages.po | 24 ------------------------
packages/i18n/locales/ja/messages.po | 24 ------------------------
packages/i18n/locales/ko/messages.po | 24 ------------------------
packages/i18n/locales/nl/messages.po | 24 ------------------------
packages/i18n/locales/pl/messages.po | 24 ------------------------
packages/i18n/locales/pt-BR/messages.po | 24 ------------------------
packages/i18n/locales/ru/messages.po | 24 ------------------------
packages/i18n/locales/tr/messages.po | 24 ------------------------
packages/i18n/locales/vi/messages.po | 24 ------------------------
packages/i18n/locales/zh-CN/messages.po | 24 ------------------------
packages/i18n/locales/zh-TW/messages.po | 24 ------------------------
17 files changed, 408 deletions(-)
diff --git a/packages/i18n/locales/cs/messages.po b/packages/i18n/locales/cs/messages.po
index 3204920fd89..8593f8ddd84 100644
--- a/packages/i18n/locales/cs/messages.po
+++ b/packages/i18n/locales/cs/messages.po
@@ -17691,30 +17691,9 @@ msgstr "nahrazeno"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26) je IDE s dostupným zdrojovým kódem pro éru AI agentů, ve kterém inženýři paralelně spouštějí stovky programovacích agentů, jako jsou Claude Code a Codex."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset jedná na GitHubu za vás. Připojte svůj účet GitHub, abyste mohli slučovat, komentovat a aktualizovat pull requesty."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "Aplikace Superset"
-
-msgid "Superset App"
-msgstr "Aplikace Superset"
-
-msgid "Superset Automations"
-msgstr "Automatizace Superset"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp vypíše endpoint jen pro daný panel. Namiřte na něj Playwright nebo browser-use."
@@ -18866,9 +18845,6 @@ msgstr "Tento profil je právě přetížený"
msgid "This project is no longer available on your devices."
msgstr "Tento projekt už na vašich zařízeních není dostupný."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Tento projekt není propojen s repozitářem GitHub."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Tento projekt stále používá starší config.json. Dál funguje; převeďte ho na config.toml, abyste mohli používat nové sekce."
diff --git a/packages/i18n/locales/de/messages.po b/packages/i18n/locales/de/messages.po
index 22516d77545..b1cebbc5368 100644
--- a/packages/i18n/locales/de/messages.po
+++ b/packages/i18n/locales/de/messages.po
@@ -17691,30 +17691,9 @@ msgstr "ersetzt"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26) ist die Source-Available-IDE für die Ära der KI-Agents, in der Entwickler Hunderte Coding-Agents wie Claude Code und Codex parallel ausführen."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset handelt auf GitHub in deinem Namen. Verbinde dein GitHub-Konto, um Pull Requests zu mergen, zu kommentieren und zu aktualisieren."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "Superset-App"
-
-msgid "Superset App"
-msgstr "Superset App"
-
-msgid "Superset Automations"
-msgstr "Superset-Automatisierungen"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp gibt nur für diesen Bereich einen Endpunkt aus. Richte Playwright oder browser-use darauf."
@@ -18866,9 +18845,6 @@ msgstr "Dieses Profil ist gerade stark ausgelastet"
msgid "This project is no longer available on your devices."
msgstr "Dieses Projekt ist auf deinen Geräten nicht mehr verfügbar."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Dieses Projekt ist mit keinem GitHub-Repository verknüpft."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Dieses Projekt verwendet noch die ältere config.json. Sie funktioniert weiterhin; wandle sie in config.toml um, um die neuen Abschnitte zu nutzen."
diff --git a/packages/i18n/locales/en/messages.po b/packages/i18n/locales/en/messages.po
index 12650a692c5..a5b19ab3db8 100644
--- a/packages/i18n/locales/en/messages.po
+++ b/packages/i18n/locales/en/messages.po
@@ -17691,30 +17691,9 @@ msgstr "superseded"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "Superset app"
-
-msgid "Superset App"
-msgstr "Superset App"
-
-msgid "Superset Automations"
-msgstr "Superset Automations"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
@@ -18866,9 +18845,6 @@ msgstr "This profile is busy right now"
msgid "This project is no longer available on your devices."
msgstr "This project is no longer available on your devices."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "This project isn't linked to a GitHub repository."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
diff --git a/packages/i18n/locales/es/messages.po b/packages/i18n/locales/es/messages.po
index 65f4488ef76..4a83d63913a 100644
--- a/packages/i18n/locales/es/messages.po
+++ b/packages/i18n/locales/es/messages.po
@@ -17691,30 +17691,9 @@ msgstr "reemplazada"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26) es el IDE con código fuente disponible para la era de los agentes de IA, donde los ingenieros ejecutan en paralelo cientos de agentes de programación como Claude Code y Codex."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset actúa en GitHub en tu nombre. Conecta tu cuenta de GitHub para fusionar, comentar y actualizar pull requests."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "App de Superset"
-
-msgid "Superset App"
-msgstr "App de Superset"
-
-msgid "Superset Automations"
-msgstr "Automatizaciones de Superset"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp imprime un endpoint solo para ese panel. Apunta Playwright o browser-use hacia él."
@@ -18866,9 +18845,6 @@ msgstr "Este perfil está saturado ahora mismo"
msgid "This project is no longer available on your devices."
msgstr "Este proyecto ya no está disponible en tus dispositivos."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Este proyecto no está vinculado a un repositorio de GitHub."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Este proyecto aún usa el antiguo config.json. Sigue funcionando; conviértelo a config.toml para usar las nuevas secciones."
diff --git a/packages/i18n/locales/fr/messages.po b/packages/i18n/locales/fr/messages.po
index 4162558f04c..7eff1a8c8a3 100644
--- a/packages/i18n/locales/fr/messages.po
+++ b/packages/i18n/locales/fr/messages.po
@@ -17691,30 +17691,9 @@ msgstr "remplacée"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26) est l’IDE au code source disponible de l’ère des agents IA, où les ingénieurs exécutent en parallèle des centaines d’agents de code comme Claude Code et Codex."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset agit sur GitHub en votre nom. Connectez votre compte GitHub pour fusionner, commenter et mettre à jour des pull requests."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "Application Superset"
-
-msgid "Superset App"
-msgstr "Application Superset"
-
-msgid "Superset Automations"
-msgstr "Automatisations Superset"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp affiche un point de terminaison pour ce volet uniquement. Pointez Playwright ou browser-use dessus."
@@ -18866,9 +18845,6 @@ msgstr "Ce profil est très sollicité en ce moment"
msgid "This project is no longer available on your devices."
msgstr "Ce projet n'est plus disponible sur vos appareils."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Ce projet n'est lié à aucun dépôt GitHub."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Ce projet utilise encore l'ancien config.json. Il fonctionne toujours ; convertissez-le en config.toml pour utiliser les nouvelles sections."
diff --git a/packages/i18n/locales/id/messages.po b/packages/i18n/locales/id/messages.po
index 79dce5fc169..4b0e5e5bb5e 100644
--- a/packages/i18n/locales/id/messages.po
+++ b/packages/i18n/locales/id/messages.po
@@ -17691,30 +17691,9 @@ msgstr "digantikan"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26) adalah IDE source-available untuk era agen AI, tempat para engineer menjalankan ratusan agen coding seperti Claude Code dan Codex secara paralel."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset bertindak di GitHub atas nama Anda. Hubungkan akun GitHub Anda untuk menggabungkan, mengomentari, dan memperbarui pull request."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "Aplikasi Superset"
-
-msgid "Superset App"
-msgstr "Aplikasi Superset"
-
-msgid "Superset Automations"
-msgstr "Otomatisasi Superset"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp mencetak endpoint hanya untuk panel itu. Arahkan Playwright atau browser-use ke sana."
@@ -18866,9 +18845,6 @@ msgstr "Profil ini sedang sibuk"
msgid "This project is no longer available on your devices."
msgstr "Proyek ini sudah tidak tersedia di perangkat Anda."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Proyek ini tidak tertaut ke repositori GitHub."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Proyek ini masih memakai config.json lama. File itu tetap berfungsi; konversikan ke config.toml untuk memakai bagian-bagian baru."
diff --git a/packages/i18n/locales/it/messages.po b/packages/i18n/locales/it/messages.po
index 41e1e7b76d2..575c963c965 100644
--- a/packages/i18n/locales/it/messages.po
+++ b/packages/i18n/locales/it/messages.po
@@ -17691,30 +17691,9 @@ msgstr "sostituita"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26) è l’IDE source-available per l’era degli agenti IA, in cui gli ingegneri eseguono in parallelo centinaia di agenti di programmazione come Claude Code e Codex."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset agisce su GitHub a tuo nome. Collega il tuo account GitHub per unire, commentare e aggiornare le pull request."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "App Superset"
-
-msgid "Superset App"
-msgstr "App Superset"
-
-msgid "Superset Automations"
-msgstr "Superset Automazioni"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp stampa un endpoint solo per quel riquadro. Punta Playwright o browser-use su di esso."
@@ -18866,9 +18845,6 @@ msgstr "Questo profilo è molto richiesto in questo momento"
msgid "This project is no longer available on your devices."
msgstr "Questo progetto non è più disponibile sui tuoi dispositivi."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Questo progetto non è collegato a un repository GitHub."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Questo progetto usa ancora il vecchio config.json. Continua a funzionare; convertilo in config.toml per usare le nuove sezioni."
diff --git a/packages/i18n/locales/ja/messages.po b/packages/i18n/locales/ja/messages.po
index b58044d8eb8..f4417032773 100644
--- a/packages/i18n/locales/ja/messages.po
+++ b/packages/i18n/locales/ja/messages.po
@@ -17691,30 +17691,9 @@ msgstr "置き換え済み"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset(YC P26)は、AI エージェント時代のためのソースコード公開型 IDE です。エンジニアは Claude Code や Codex などのコーディングエージェントを数百単位で並行して実行できます。"
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset はあなたとして GitHub を操作します。プルリクエストのマージ、コメント、更新を行うには GitHub アカウントを接続してください。"
-msgid "Superset Agent"
-msgstr "Supersetエージェント"
-
-msgid "Superset app"
-msgstr "Supersetアプリ"
-
-msgid "Superset App"
-msgstr "Supersetアプリ"
-
-msgid "Superset Automations"
-msgstr "Superset オートメーション"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp は、そのペイン専用のエンドポイントを出力します。Playwrightやbrowser-useをそこに向けてください。"
@@ -18866,9 +18845,6 @@ msgstr "このプロフィールは現在混み合っています"
msgid "This project is no longer available on your devices."
msgstr "このプロジェクトはお使いのデバイスでは利用できなくなりました。"
-msgid "This project isn't linked to a GitHub repository."
-msgstr "このプロジェクトは GitHub リポジトリにリンクされていません。"
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "このプロジェクトはまだ以前の config.json を使っています。引き続き動作しますが、新しいセクションを使うには config.toml に変換してください。"
diff --git a/packages/i18n/locales/ko/messages.po b/packages/i18n/locales/ko/messages.po
index c905dc935da..7accfdd58dd 100644
--- a/packages/i18n/locales/ko/messages.po
+++ b/packages/i18n/locales/ko/messages.po
@@ -17691,30 +17691,9 @@ msgstr "대체됨"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset(YC P26)은 AI 에이전트 시대를 위한 소스 공개형 IDE로, 엔지니어가 Claude Code와 Codex 같은 코딩 에이전트 수백 개를 병렬로 실행할 수 있습니다."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset은 본인 계정으로 GitHub에서 작업합니다. 풀 리퀘스트를 병합, 댓글 작성, 업데이트하려면 GitHub 계정을 연결하세요."
-msgid "Superset Agent"
-msgstr "Superset 에이전트"
-
-msgid "Superset app"
-msgstr "Superset 앱"
-
-msgid "Superset App"
-msgstr "Superset 앱"
-
-msgid "Superset Automations"
-msgstr "Superset 자동화"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp는 해당 패널 전용 엔드포인트만 출력합니다. Playwright나 browser-use를 여기에 연결하세요."
@@ -18866,9 +18845,6 @@ msgstr "이 프로필은 지금 이용자가 많습니다"
msgid "This project is no longer available on your devices."
msgstr "이 프로젝트는 더 이상 내 기기에서 사용할 수 없습니다."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "이 프로젝트는 GitHub 저장소에 연결되어 있지 않습니다."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "이 프로젝트는 아직 이전 config.json을 사용합니다. 계속 작동하지만, 새 섹션을 사용하려면 config.toml로 변환하세요."
diff --git a/packages/i18n/locales/nl/messages.po b/packages/i18n/locales/nl/messages.po
index 813ed95a352..3ea71070f01 100644
--- a/packages/i18n/locales/nl/messages.po
+++ b/packages/i18n/locales/nl/messages.po
@@ -17691,30 +17691,9 @@ msgstr "vervangen"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26) is de source-available IDE voor het tijdperk van AI-agents, waarin engineers honderden codeeragents zoals Claude Code en Codex parallel draaien."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset handelt op GitHub namens jou. Koppel je GitHub-account om pull requests te mergen, erop te reageren en bij te werken."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "Superset-app"
-
-msgid "Superset App"
-msgstr "Superset-app"
-
-msgid "Superset Automations"
-msgstr "Superset Automatiseringen"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp toont een endpoint voor alleen dat paneel. Richt Playwright of browser-use erop."
@@ -18866,9 +18845,6 @@ msgstr "Dit profiel is momenteel druk bezet"
msgid "This project is no longer available on your devices."
msgstr "Dit project is niet meer beschikbaar op je apparaten."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Dit project is niet gekoppeld aan een GitHub-repository."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Dit project gebruikt nog de oudere config.json. Die blijft werken; zet hem om naar config.toml om de nieuwe secties te gebruiken."
diff --git a/packages/i18n/locales/pl/messages.po b/packages/i18n/locales/pl/messages.po
index f1201ea875d..28a251ae6cf 100644
--- a/packages/i18n/locales/pl/messages.po
+++ b/packages/i18n/locales/pl/messages.po
@@ -17691,30 +17691,9 @@ msgstr "zastąpione"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26) to IDE z publicznie dostępnym kodem źródłowym na erę agentów AI, w którym inżynierowie uruchamiają równolegle setki agentów programistycznych, takich jak Claude Code i Codex."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset działa na GitHubie w Twoim imieniu. Połącz swoje konto GitHub, aby scalać, komentować i aktualizować pull requesty."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "Aplikacja Superset"
-
-msgid "Superset App"
-msgstr "Aplikacja Superset"
-
-msgid "Superset Automations"
-msgstr "Superset Automatyzacje"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp wypisuje endpoint tylko dla tego panelu. Skieruj na niego Playwright lub browser-use."
@@ -18866,9 +18845,6 @@ msgstr "Ten profil jest teraz przeciążony"
msgid "This project is no longer available on your devices."
msgstr "Ten projekt nie jest już dostępny na Twoich urządzeniach."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Ten projekt nie jest powiązany z repozytorium GitHub."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Ten projekt nadal używa starszego config.json. Nadal działa; przekonwertuj go na config.toml, aby korzystać z nowych sekcji."
diff --git a/packages/i18n/locales/pt-BR/messages.po b/packages/i18n/locales/pt-BR/messages.po
index b52d9a2c095..1e15e045411 100644
--- a/packages/i18n/locales/pt-BR/messages.po
+++ b/packages/i18n/locales/pt-BR/messages.po
@@ -17691,30 +17691,9 @@ msgstr "substituída"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "O Superset (YC P26) é o IDE com código-fonte disponível para a era dos agentes de IA, em que engenheiros executam centenas de agentes de programação como Claude Code e Codex em paralelo."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "O Superset age no GitHub em seu nome. Conecte sua conta do GitHub para fazer merge, comentar e atualizar pull requests."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "App Superset"
-
-msgid "Superset App"
-msgstr "App Superset"
-
-msgid "Superset Automations"
-msgstr "Automações do Superset"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp imprime um endpoint apenas para esse painel. Aponte o Playwright ou o browser-use para ele."
@@ -18866,9 +18845,6 @@ msgstr "Este perfil está sobrecarregado agora"
msgid "This project is no longer available on your devices."
msgstr "Este projeto não está mais disponível nos seus dispositivos."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Este projeto não está vinculado a um repositório do GitHub."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Este projeto ainda usa o antigo config.json. Ele continua funcionando; converta-o para config.toml para usar as novas seções."
diff --git a/packages/i18n/locales/ru/messages.po b/packages/i18n/locales/ru/messages.po
index c367985ec07..e0f9b22b05a 100644
--- a/packages/i18n/locales/ru/messages.po
+++ b/packages/i18n/locales/ru/messages.po
@@ -17691,30 +17691,9 @@ msgstr "заменён"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26) — это IDE с доступным исходным кодом для эпохи ИИ-агентов, в которой инженеры параллельно запускают сотни агентов для программирования, таких как Claude Code и Codex."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset действует на GitHub от вашего имени. Подключите свой аккаунт GitHub, чтобы объединять, комментировать и обновлять пул-реквесты."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "Приложение Superset"
-
-msgid "Superset App"
-msgstr "Приложение Superset"
-
-msgid "Superset Automations"
-msgstr "Superset Автоматизации"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp выводит эндпоинт только для этой панели. Направьте на него Playwright или browser-use."
@@ -18866,9 +18845,6 @@ msgstr "Этот профиль сейчас перегружен"
msgid "This project is no longer available on your devices."
msgstr "Этот проект больше недоступен на ваших устройствах."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Этот проект не связан с репозиторием GitHub."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Этот проект всё ещё использует старый config.json. Он продолжает работать; преобразуйте его в config.toml, чтобы использовать новые разделы."
diff --git a/packages/i18n/locales/tr/messages.po b/packages/i18n/locales/tr/messages.po
index ba00d065c41..060ccd59401 100644
--- a/packages/i18n/locales/tr/messages.po
+++ b/packages/i18n/locales/tr/messages.po
@@ -17691,30 +17691,9 @@ msgstr "geçersiz kılındı"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26), mühendislerin Claude Code ve Codex gibi yüzlerce kodlama ajanını paralel olarak çalıştırdığı, yapay zekâ ajanları çağı için kaynak kodu erişilebilir IDE'dir."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset, GitHub'da sizin adınıza işlem yapar. Pull request'leri birleştirmek, yorumlamak ve güncellemek için GitHub hesabınızı bağlayın."
-msgid "Superset Agent"
-msgstr "Superset Ajanı"
-
-msgid "Superset app"
-msgstr "Superset uygulaması"
-
-msgid "Superset App"
-msgstr "Superset uygulaması"
-
-msgid "Superset Automations"
-msgstr "Superset Otomasyonlar"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp yalnızca o bölme için bir uç nokta yazdırır. Playwright'ı veya browser-use'u ona yönlendirin."
@@ -18866,9 +18845,6 @@ msgstr "Bu profil şu anda yoğun"
msgid "This project is no longer available on your devices."
msgstr "Bu proje artık cihazlarınızda kullanılamıyor."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Bu proje bir GitHub deposuna bağlı değil."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Bu proje hâlâ eski config.json dosyasını kullanıyor. Çalışmaya devam eder; yeni bölümleri kullanmak için config.toml'a dönüştürün."
diff --git a/packages/i18n/locales/vi/messages.po b/packages/i18n/locales/vi/messages.po
index 2d83b67c863..6a78b7b5720 100644
--- a/packages/i18n/locales/vi/messages.po
+++ b/packages/i18n/locales/vi/messages.po
@@ -17691,30 +17691,9 @@ msgstr "bị thay thế"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset (YC P26) là IDE công khai mã nguồn cho kỷ nguyên agent AI, nơi các kỹ sư chạy song song hàng trăm agent lập trình như Claude Code và Codex."
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset thao tác trên GitHub dưới tên của bạn. Kết nối tài khoản GitHub để hợp nhất, bình luận và cập nhật pull request."
-msgid "Superset Agent"
-msgstr "Superset Agent"
-
-msgid "Superset app"
-msgstr "Ứng dụng Superset"
-
-msgid "Superset App"
-msgstr "Ứng dụng Superset"
-
-msgid "Superset Automations"
-msgstr "Tự động hóa Superset"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp in ra endpoint chỉ cho ngăn đó. Trỏ Playwright hoặc browser-use vào đó."
@@ -18866,9 +18845,6 @@ msgstr "Hồ sơ này hiện đang quá tải"
msgid "This project is no longer available on your devices."
msgstr "Dự án này không còn khả dụng trên các thiết bị của bạn."
-msgid "This project isn't linked to a GitHub repository."
-msgstr "Dự án này chưa được liên kết với kho lưu trữ GitHub."
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "Dự án này vẫn dùng config.json cũ. Nó vẫn hoạt động; hãy chuyển sang config.toml để dùng các phần mới."
diff --git a/packages/i18n/locales/zh-CN/messages.po b/packages/i18n/locales/zh-CN/messages.po
index 2545852b2de..2588e294e2a 100644
--- a/packages/i18n/locales/zh-CN/messages.po
+++ b/packages/i18n/locales/zh-CN/messages.po
@@ -17691,30 +17691,9 @@ msgstr "已被取代"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset(YC P26)是面向 AI 智能体时代的源码可用 IDE,工程师可以在其中并行运行数百个 Claude Code、Codex 等编程智能体。"
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset 以你的身份在 GitHub 上操作。连接你的 GitHub 账户以合并、评论和更新拉取请求。"
-msgid "Superset Agent"
-msgstr "Superset智能体"
-
-msgid "Superset app"
-msgstr "Superset应用"
-
-msgid "Superset App"
-msgstr "Superset应用"
-
-msgid "Superset Automations"
-msgstr "Superset 自动化"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp 只会输出该窗格专属的端点。让 Playwright 或 browser-use 连接它即可。"
@@ -18866,9 +18845,6 @@ msgstr "此个人主页当前繁忙"
msgid "This project is no longer available on your devices."
msgstr "这个项目在你的设备上已不可用。"
-msgid "This project isn't linked to a GitHub repository."
-msgstr "此项目未关联 GitHub 仓库。"
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "此项目仍在使用旧的 config.json。它仍可正常工作;转换为 config.toml 即可使用新的配置节。"
diff --git a/packages/i18n/locales/zh-TW/messages.po b/packages/i18n/locales/zh-TW/messages.po
index bb0b5ff9ac5..ef5bfb88165 100644
--- a/packages/i18n/locales/zh-TW/messages.po
+++ b/packages/i18n/locales/zh-TW/messages.po
@@ -17691,30 +17691,9 @@ msgstr "已被取代"
msgid "superset"
msgstr "superset"
-msgid "Superset"
-msgstr "Superset"
-
-msgid "Superset (YC P26) is the source-available IDE for the AI agents era, where engineers run hundreds of coding agents like Claude Code and Codex in parallel."
-msgstr "Superset(YC P26)是為 AI agent 時代打造的原始碼公開 IDE,工程師可以在其中平行執行數百個 Claude Code、Codex 等程式設計 agent。"
-
-msgid "Superset {version}"
-msgstr "Superset {version}"
-
msgid "Superset acts on GitHub as you. Connect your GitHub account to merge, comment on and update pull requests."
msgstr "Superset 以你的身分在 GitHub 上操作。連接你的 GitHub 帳戶以合併、留言和更新拉取請求。"
-msgid "Superset Agent"
-msgstr "Superset代理程式"
-
-msgid "Superset app"
-msgstr "Superset應用程式"
-
-msgid "Superset App"
-msgstr "Superset應用程式"
-
-msgid "Superset Automations"
-msgstr "Superset 自動化"
-
msgid "superset browser cdp prints an endpoint for that pane only. Point Playwright or browser-use at it."
msgstr "superset browser cdp 只會輸出該窗格專屬的端點。讓 Playwright 或 browser-use 連接它即可。"
@@ -18866,9 +18845,6 @@ msgstr "此個人檔案目前繁忙"
msgid "This project is no longer available on your devices."
msgstr "這個專案在你的裝置上已不可用。"
-msgid "This project isn't linked to a GitHub repository."
-msgstr "此專案未連結 GitHub 儲存庫。"
-
msgid "This project still uses the older config.json. It keeps working; convert it to config.toml to use the new sections."
msgstr "此專案仍在使用舊的 config.json。它仍可正常運作;轉換為 config.toml 即可使用新的區段。"
From 43aa788b1edeabf246718f9e9e62465e615ddd2b Mon Sep 17 00:00:00 2001
From: Satya Patel <14907857+saddlepaddle@users.noreply.github.com>
Date: Wed, 28 Oct 2026 01:03:17 +0000
Subject: [PATCH 6/8] fix(pull-requests): pass lint and the i18n ratchet
---
apps/mobile/screens/(authenticated)/settings/SettingsScreen.tsx | 2 +-
.../shared/src/pull-request-detail/pull-request-detail.test.ts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/mobile/screens/(authenticated)/settings/SettingsScreen.tsx b/apps/mobile/screens/(authenticated)/settings/SettingsScreen.tsx
index c054624b6ed..86eebb93b66 100644
--- a/apps/mobile/screens/(authenticated)/settings/SettingsScreen.tsx
+++ b/apps/mobile/screens/(authenticated)/settings/SettingsScreen.tsx
@@ -269,7 +269,7 @@ export function SettingsScreen() {
color={theme.mutedForeground}
/>
}
- label="GitHub"
+ label={t({ message: "GitHub" })}
subtitle={
github.connection
? t({
diff --git a/packages/shared/src/pull-request-detail/pull-request-detail.test.ts b/packages/shared/src/pull-request-detail/pull-request-detail.test.ts
index 57c5d2930a4..5b4b2f7e937 100644
--- a/packages/shared/src/pull-request-detail/pull-request-detail.test.ts
+++ b/packages/shared/src/pull-request-detail/pull-request-detail.test.ts
@@ -90,7 +90,7 @@ describe("readPullRequestDetail", () => {
const detail = await readPullRequestDetail(
{
graphql: async (
- query: string,
+ _query: string,
variables: Record,
) => {
queries.push(String(variables.cursor ?? "first"));
From 7281728ef08f6b3b9c8d1d5dcc3dbb74b9a18542 Mon Sep 17 00:00:00 2001
From: Satya Patel <14907857+saddlepaddle@users.noreply.github.com>
Date: Wed, 28 Oct 2026 02:35:44 +0000
Subject: [PATCH 7/8] fix(pull-requests): never read through the host's gh
after GitHub refused the viewer
A cloud read that GitHub refused fell back to the host's own gh session,
which could show a pull request the viewer has no access to. Reads now
fall back only when the API could not act at all, as writes already did.
---
.../pullRequestClient.test.ts | 22 +++++++++++--------
.../pullRequestClient/pullRequestClient.ts | 22 ++++++++++++++++---
2 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts
index f9bbb6aaf51..68ae1bdd6a4 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.test.ts
@@ -122,22 +122,26 @@ describe("reads", () => {
expect(cloud.getPullRequestDetail.query).not.toHaveBeenCalled();
});
- test("a quiet cloud miss is dropped from the error; two real failures are both reported", async () => {
+ test("a quiet cloud miss is dropped from the error when the host fails too", async () => {
cloud.getPullRequestDetail.query.mockRejectedValueOnce(cannotAct);
host.getContent.query.mockRejectedValueOnce(new Error("gh offline"));
host.getContentByRepo.query.mockRejectedValueOnce(new Error("gh offline"));
await expect(readPullRequestContent(target, deps)).rejects.toThrow(
"gh offline",
);
+ });
- cloud.getPullRequestDetail.query.mockRejectedValueOnce(
- new Error("Access denied"),
- );
- host.getContent.query.mockRejectedValueOnce(new Error("gh offline"));
- host.getContentByRepo.query.mockRejectedValueOnce(new Error("gh offline"));
- const error = await readPullRequestContent(target, deps).catch((e) => e);
- expect(error).toBeInstanceOf(AggregateError);
- expect(error.message).toBe("Access denied\ngh offline\ngh offline");
+ test("GitHub refusing the viewer is final: the host's gh is not asked to read it", async () => {
+ const forbidden = Object.assign(new Error("Resource not accessible"), {
+ data: { code: "FORBIDDEN" },
+ });
+ cloud.getPullRequestDetail.query.mockRejectedValueOnce(forbidden);
+ cloud.getPullRequestThreads.query.mockRejectedValueOnce(forbidden);
+ cloud.getPullRequestDiff.query.mockRejectedValueOnce(forbidden);
+ await expect(readPullRequestContent(target, deps)).rejects.toBe(forbidden);
+ await expect(readPullRequestThreads(target, deps)).rejects.toBe(forbidden);
+ await expect(readPullRequestDiff(target, deps)).rejects.toBe(forbidden);
+ expect(hostFor).not.toHaveBeenCalled();
});
test("nothing to read from is an error, not empty content", async () => {
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
index f631e115aa2..39d7e32e503 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
@@ -94,6 +94,21 @@ function cloudInput(target: PullRequestTarget) {
type Attempt = (() => Promise) | null | false | undefined | "";
+class Refused {
+ constructor(readonly error: unknown) {}
+}
+
+/** GitHub's answer to the viewer is final; only an API that could not act at all lets the host try. */
+function asViewer(read: () => Promise): () => Promise {
+ return async () => {
+ try {
+ return await read();
+ } catch (error) {
+ throw cloudCannotAct(error) ? error : new Refused(error);
+ }
+ };
+}
+
async function firstAnswer(
attempts: Attempt[],
none: string,
@@ -104,6 +119,7 @@ async function firstAnswer(
try {
return await attempt();
} catch (error) {
+ if (error instanceof Refused) throw error.error;
errors.push(error);
}
}
@@ -120,7 +136,7 @@ export function readPullRequestContent(
return firstAnswer(
[
reachesCloud(target) &&
- (() => {
+ asViewer(() => {
const input = cloudInput(target);
return deps
.cloud()
@@ -155,7 +171,7 @@ export function readPullRequestThreads(
return firstAnswer(
[
reachesCloud(target) &&
- (() => deps.cloud().getPullRequestThreads.query(cloudInput(target))),
+ asViewer(() => deps.cloud().getPullRequestThreads.query(cloudInput(target))),
host &&
projectId &&
(() =>
@@ -174,7 +190,7 @@ export function readPullRequestDiff(
return firstAnswer(
[
reachesCloud(target) &&
- (() => deps.cloud().getPullRequestDiff.query(cloudInput(target))),
+ asViewer(() => deps.cloud().getPullRequestDiff.query(cloudInput(target))),
host &&
projectId &&
(() => deps.host(host.hostUrl).getDiff.query({ projectId, prNumber })),
From a3defece652502766dced0cb8ebcfd5a8d9bc5e0 Mon Sep 17 00:00:00 2001
From: Satya Patel <14907857+saddlepaddle@users.noreply.github.com>
Date: Wed, 28 Oct 2026 02:56:22 +0000
Subject: [PATCH 8/8] style(pull-requests): format the pull request client
---
.../utils/pullRequestClient/pullRequestClient.ts | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
index 39d7e32e503..b74d5908496 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/pull-requests/utils/pullRequestClient/pullRequestClient.ts
@@ -171,7 +171,9 @@ export function readPullRequestThreads(
return firstAnswer(
[
reachesCloud(target) &&
- asViewer(() => deps.cloud().getPullRequestThreads.query(cloudInput(target))),
+ asViewer(() =>
+ deps.cloud().getPullRequestThreads.query(cloudInput(target)),
+ ),
host &&
projectId &&
(() =>
@@ -190,7 +192,9 @@ export function readPullRequestDiff(
return firstAnswer(
[
reachesCloud(target) &&
- asViewer(() => deps.cloud().getPullRequestDiff.query(cloudInput(target))),
+ asViewer(() =>
+ deps.cloud().getPullRequestDiff.query(cloudInput(target)),
+ ),
host &&
projectId &&
(() => deps.host(host.hostUrl).getDiff.query({ projectId, prNumber })),