Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(desktop): show live pull request status in sessions (#85313)

Adam Leith94eff31e2cb0
diff --git a/products/desktop/packages/core/src/git/router-schemas.ts b/products/desktop/packages/core/src/git/router-schemas.ts
index 1f5513a6612c..4ebf087929f2 100644
--- a/products/desktop/packages/core/src/git/router-schemas.ts
+++ b/products/desktop/packages/core/src/git/router-schemas.ts
@@ -386,6 +386,7 @@ export const getPrDetailsByUrlOutput = z.object({
draft: z.boolean(),
headRefName: z.string().nullable(),
title: z.string().nullable(),
+ author: z.string().nullable(),
});
export type PrDetailsByUrlOutput = z.infer<typeof getPrDetailsByUrlOutput>;
diff --git a/products/desktop/packages/host-router/src/routers/git.router.ts b/products/desktop/packages/host-router/src/routers/git.router.ts
index cb85eceff2a7..eb292f07cee6 100644
--- a/products/desktop/packages/host-router/src/routers/git.router.ts
+++ b/products/desktop/packages/host-router/src/routers/git.router.ts
@@ -530,6 +530,7 @@ export const gitRouter = router({
draft: false,
headRefName: null,
title: null,
+ author: null,
}
);
}),
diff --git a/products/desktop/packages/ui/src/features/editor/components/GithubPrRefChip.test.tsx b/products/desktop/packages/ui/src/features/editor/components/GithubPrRefChip.test.tsx
new file mode 100644
index 000000000000..e07fc464c595
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/editor/components/GithubPrRefChip.test.tsx
@@ -0,0 +1,64 @@
+import { render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { describe, expect, it, vi } from "vitest";
+
+const usePrDetailsMock = vi.hoisted(() => vi.fn());
+const usePrChecksMock = vi.hoisted(() => vi.fn());
+
+vi.mock("@posthog/ui/features/git-interaction/usePrDetails", () => ({
+ usePrDetails: usePrDetailsMock,
+}));
+
+vi.mock("@posthog/ui/features/pr-review/usePrChecks", () => ({
+ usePrChecks: usePrChecksMock,
+}));
+
+import { GithubPrRefChip } from "./GithubPrRefChip";
+
+describe("GithubPrRefChip", () => {
+ it("refreshes lifecycle state and loads CI when its tooltip opens", async () => {
+ const href = "https://github.com/PostHog/posthog/pull/23985";
+ usePrDetailsMock.mockReturnValue({
+ meta: {
+ state: "open",
+ merged: false,
+ draft: true,
+ headRefName: "posthog/status-chip",
+ title: "Show pull request status in sessions",
+ author: "octocat",
+ isLoading: false,
+ },
+ commentThreads: new Map(),
+ commentsLoading: false,
+ });
+ usePrChecksMock.mockReturnValue({
+ data: [
+ {
+ name: "Desktop CI",
+ bucket: "pass",
+ link: null,
+ workflow: null,
+ description: null,
+ },
+ ],
+ isLoading: false,
+ });
+
+ render(
+ <GithubPrRefChip href={href}>PostHog/posthog#23985</GithubPrRefChip>,
+ );
+
+ expect(screen.getByRole("img", { name: "Draft" })).toBeInTheDocument();
+ expect(usePrDetailsMock).toHaveBeenCalledWith(href, {
+ refetchInterval: 30_000,
+ });
+ expect(usePrChecksMock).toHaveBeenCalledWith(null);
+
+ const link = screen.getByText("PostHog/posthog#23985").closest("a");
+ expect(link).not.toBeNull();
+ await userEvent.hover(link as HTMLAnchorElement);
+
+ expect(await screen.findByText("CI passed")).toBeInTheDocument();
+ expect(usePrChecksMock).toHaveBeenCalledWith(href);
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/editor/components/GithubPrRefChip.tsx b/products/desktop/packages/ui/src/features/editor/components/GithubPrRefChip.tsx
new file mode 100644
index 000000000000..857aee5c8cd6
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/editor/components/GithubPrRefChip.tsx
@@ -0,0 +1,54 @@
+import type { PrCheck } from "@posthog/core/git/router-schemas";
+import {
+ type PrCiStatus,
+ PrRefChip,
+} from "@posthog/ui/features/editor/components/PrRefChip";
+import { usePrDetails } from "@posthog/ui/features/git-interaction/usePrDetails";
+import { usePrChecks } from "@posthog/ui/features/pr-review/usePrChecks";
+import { type ReactElement, type ReactNode, useState } from "react";
+
+function summarizeCiStatus(
+ checks: PrCheck[] | null | undefined,
+): PrCiStatus | null {
+ if (!checks || checks.length === 0) return null;
+ if (
+ checks.some((check) => check.bucket === "fail" || check.bucket === "cancel")
+ ) {
+ return "failure";
+ }
+ if (checks.some((check) => check.bucket === "pending")) return "pending";
+ return checks.some((check) => check.bucket === "pass") ? "success" : null;
+}
+
+/** A pull request chip wired to live lifecycle and CI state. */
+export function GithubPrRefChip({
+ href,
+ children,
+}: {
+ href: string;
+ children: ReactNode;
+}): ReactElement {
+ const [tooltipOpen, setTooltipOpen] = useState(false);
+ const { meta } = usePrDetails(href, { refetchInterval: 30_000 });
+ // CI is the expensive half, so it loads only once someone asks to see it.
+ const checksQuery = usePrChecks(tooltipOpen ? href : null);
+
+ return (
+ <PrRefChip
+ href={href}
+ onTooltipOpenChange={setTooltipOpen}
+ details={{
+ state: meta.state,
+ merged: meta.merged,
+ draft: meta.draft,
+ title: meta.title,
+ author: meta.author,
+ isLoading: meta.isLoading,
+ ciStatus: tooltipOpen ? summarizeCiStatus(checksQuery.data) : null,
+ isCiLoading: tooltipOpen && checksQuery.isLoading,
+ }}
+ >
+ {children}
+ </PrRefChip>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.stories.tsx b/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.stories.tsx
new file mode 100644
index 000000000000..2883b99a5ec4
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.stories.tsx
@@ -0,0 +1,121 @@
+import { GithubRefChip } from "@posthog/ui/features/editor/components/GithubRefChip";
+import {
+ PrRefChip,
+ type PrRefDetails,
+} from "@posthog/ui/features/editor/components/PrRefChip";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+
+const meta = {
+ title: "Editor/GithubRefChip",
+ component: GithubRefChip,
+ parameters: { layout: "padded" },
+} satisfies Meta<typeof GithubRefChip>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+export const WithoutLiveDetails: Story = {
+ render: () => (
+ <div className="text-[13px]">
+ <GithubRefChip
+ href="https://github.com/example-org/example-repo/pull/101"
+ kind="pr"
+ >
+ example-org/example-repo#101
+ </GithubRefChip>
+ </div>
+ ),
+};
+
+const LIFECYCLE_CASES: { number: number; details: PrRefDetails }[] = [
+ {
+ number: 101,
+ details: {
+ state: "open",
+ merged: false,
+ draft: false,
+ title: "Add account settings",
+ author: "octocat",
+ isLoading: false,
+ ciStatus: "success",
+ isCiLoading: false,
+ },
+ },
+ {
+ number: 102,
+ details: {
+ state: "open",
+ merged: false,
+ draft: true,
+ title: "Improve search filters",
+ author: "hubot",
+ isLoading: false,
+ ciStatus: "pending",
+ isCiLoading: false,
+ },
+ },
+ {
+ number: 103,
+ details: {
+ state: "closed",
+ merged: false,
+ draft: false,
+ title: "Update billing copy",
+ author: "monalisa",
+ isLoading: false,
+ ciStatus: "failure",
+ isCiLoading: false,
+ },
+ },
+ {
+ number: 104,
+ details: {
+ state: "closed",
+ merged: true,
+ draft: false,
+ title: "Fix the sign-up redirect",
+ author: "octocat",
+ isLoading: false,
+ ciStatus: "success",
+ isCiLoading: false,
+ },
+ },
+];
+
+export const LifecycleStates: Story = {
+ render: () => (
+ <div className="flex flex-wrap items-center gap-3 text-[13px]">
+ {LIFECYCLE_CASES.map(({ number, details }) => (
+ <PrRefChip
+ key={number}
+ href={`https://github.com/example-org/example-repo/pull/${number}`}
+ details={details}
+ >
+ {`example-org/example-repo#${number}`}
+ </PrRefChip>
+ ))}
+ </div>
+ ),
+};
+
+export const LoadingDetails: Story = {
+ render: () => (
+ <div className="text-[13px]">
+ <PrRefChip
+ href="https://github.com/example-org/example-repo/pull/105"
+ details={{
+ state: null,
+ merged: false,
+ draft: false,
+ title: null,
+ author: null,
+ isLoading: true,
+ ciStatus: null,
+ isCiLoading: true,
+ }}
+ >
+ example-org/example-repo#105
+ </PrRefChip>
+ </div>
+ ),
+};
diff --git a/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.tsx b/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.tsx
index a8a712f0959d..5f74b8c62ed0 100644
--- a/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.tsx
+++ b/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.tsx
@@ -1,6 +1,8 @@
+import type { Icon } from "@phosphor-icons/react";
import { GithubLogoIcon, GitPullRequestIcon } from "@phosphor-icons/react";
-import { Chip } from "@posthog/quill";
-import type { ReactNode } from "react";
+import { Button, cn } from "@posthog/quill";
+import type { ComponentProps, ReactElement, ReactNode } from "react";
+import { forwardRef } from "react";
/**
* DOM attribute carrying the chip's GitHub URL. The conversation context menu
@@ -9,6 +11,72 @@ import type { ReactNode } from "react";
*/
export const GITHUB_REF_URL_ATTR = "data-github-ref-url";
+interface GithubRefChipLinkProps
+ extends Omit<ComponentProps<typeof Button>, "children"> {
+ href: string;
+ icon: Icon;
+ /** Names the icon for screen readers. Omit when the icon says nothing extra. */
+ iconLabel?: string;
+ toneClass?: string;
+ children: ReactNode;
+}
+
+/**
+ * The chip every GitHub reference renders as: a quill button whose element is
+ * the link itself, so the chip is one thing to click and one thing to tab to.
+ *
+ * Forwards button props and its ref, so a tooltip or menu can drive it through
+ * `render`.
+ */
+export const GithubRefChipLink = forwardRef<
+ HTMLButtonElement,
+ GithubRefChipLinkProps
+>(function GithubRefChipLink(
+ { href, icon: RefIcon, iconLabel, toneClass, children, ...buttonProps },
+ ref,
+) {
+ return (
+ <Button
+ ref={ref}
+ variant="outline"
+ size="sm"
+ // The chip is a link, so it keeps link semantics and Base UI must not
+ // expect a native <button>.
+ nativeButton={false}
+ render={
+ <a
+ {...{ [GITHUB_REF_URL_ATTR]: href }}
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ />
+ }
+ {...buttonProps}
+ className={cn(
+ "cli-file-mention focus-visible:-outline-offset-1 mx-0.5 max-w-full cursor-pointer! whitespace-nowrap pl-1.5 align-baseline no-underline",
+ buttonProps.className,
+ )}
+ >
+ <RefIcon
+ size={12}
+ weight="bold"
+ className={cn("shrink-0", toneClass)}
+ aria-label={iconLabel}
+ aria-hidden={iconLabel ? undefined : true}
+ role={iconLabel ? "img" : undefined}
+ />
+ <span className={cn("min-w-0 max-w-64 truncate", toneClass)}>
+ {children}
+ </span>
+ </Button>
+ );
+});
+
+/**
+ * A GitHub reference with no live status behind it: issue links, and stored
+ * mentions that render from saved text rather than from a fetch. `PrRefChip`
+ * is the one that reports a pull request's lifecycle.
+ */
export function GithubRefChip({
href,
kind,
@@ -17,17 +85,13 @@ export function GithubRefChip({
href: string;
kind: "issue" | "pr";
children: ReactNode;
-}) {
- const Icon = kind === "pr" ? GitPullRequestIcon : GithubLogoIcon;
+}): ReactElement {
return (
- <Chip
- {...{ [GITHUB_REF_URL_ATTR]: href }}
- size="xs"
- onClick={() => window.open(href, "_blank")}
- className="cli-file-mention mx-0.5 max-w-full cursor-pointer! whitespace-nowrap pl-1 align-middle active:translate-y-0"
+ <GithubRefChipLink
+ href={href}
+ icon={kind === "pr" ? GitPullRequestIcon : GithubLogoIcon}
>
- <Icon size={10} />
- <span className="min-w-0 truncate">{children}</span>
- </Chip>
+ {children}
+ </GithubRefChipLink>
);
}
diff --git a/products/desktop/packages/ui/src/features/editor/components/MarkdownRenderer.tsx b/products/desktop/packages/ui/src/features/editor/components/MarkdownRenderer.tsx
index 980fc96bb5ac..b3434a78b53f 100644
--- a/products/desktop/packages/ui/src/features/editor/components/MarkdownRenderer.tsx
+++ b/products/desktop/packages/ui/src/features/editor/components/MarkdownRenderer.tsx
@@ -1,9 +1,8 @@
import { isPostHogCodeDeeplink } from "@posthog/shared";
import { ArtifactRefChip } from "@posthog/ui/features/editor/components/ArtifactRefChip";
import { EvidenceRefChip } from "@posthog/ui/features/editor/components/EvidenceRefChip";
-import { GithubRefChip } from "@posthog/ui/features/editor/components/GithubRefChip";
+import { githubRefChipFor } from "@posthog/ui/features/editor/components/githubRefChipFor";
import { MessageChartCard } from "@posthog/ui/features/editor/components/MessageChartCard";
-import { parseGithubIssueUrl } from "@posthog/ui/features/message-editor/githubIssueUrl";
import { CodeBlock } from "@posthog/ui/primitives/CodeBlock";
import { Divider } from "@posthog/ui/primitives/Divider";
import { HighlightedCode } from "@posthog/ui/primitives/HighlightedCode";
@@ -177,18 +176,8 @@ export const baseComponents: Components = {
</ArtifactRefChip>
);
}
- const githubRef = href ? parseGithubIssueUrl(href) : null;
- if (githubRef) {
- const isAutoLink = typeof children === "string" && children === href;
- const label = isAutoLink
- ? `${githubRef.owner}/${githubRef.repo}#${githubRef.number}`
- : children;
- return (
- <GithubRefChip href={githubRef.normalizedUrl} kind={githubRef.kind}>
- {label}
- </GithubRefChip>
- );
- }
+ const githubChip = githubRefChipFor(href, children);
+ if (githubChip) return githubChip;
return <ExternalMarkdownLink href={href}>{children}</ExternalMarkdownLink>;
},
kbd: ({ children }) => <Kbd>{children}</Kbd>,
diff --git a/products/desktop/packages/ui/src/features/editor/components/PrRefChip.test.tsx b/products/desktop/packages/ui/src/features/editor/components/PrRefChip.test.tsx
new file mode 100644
index 000000000000..76e0ce6f5025
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/editor/components/PrRefChip.test.tsx
@@ -0,0 +1,71 @@
+import { render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { describe, expect, it } from "vitest";
+import { PrRefChip, type PrRefDetails } from "./PrRefChip";
+
+const LOADED: PrRefDetails = {
+ state: "closed",
+ merged: true,
+ draft: false,
+ title: "Show pull request status in sessions",
+ author: "octocat",
+ isLoading: false,
+ ciStatus: "success",
+ isCiLoading: false,
+};
+
+describe("PrRefChip", () => {
+ const href = "https://github.com/PostHog/posthog/pull/23985";
+
+ async function hoverChip(): Promise<void> {
+ const link = screen.getByText("PostHog/posthog#23985").closest("a");
+ expect(link).not.toBeNull();
+ await userEvent.hover(link as HTMLAnchorElement);
+ }
+
+ it("shows lifecycle, creator, and CI details for a pull request", async () => {
+ render(
+ <PrRefChip href={href} details={LOADED}>
+ PostHog/posthog#23985
+ </PrRefChip>,
+ );
+
+ expect(screen.getByRole("img", { name: "Merged" })).toBeInTheDocument();
+
+ await hoverChip();
+
+ expect(
+ await screen.findByText("Show pull request status in sessions"),
+ ).toBeInTheDocument();
+ expect(screen.getByText("Created by @octocat")).toBeInTheDocument();
+ expect(screen.getByText("CI passed")).toBeInTheDocument();
+ });
+
+ it("names the loading state while details are on the way", async () => {
+ render(
+ <PrRefChip
+ href={href}
+ details={{
+ state: null,
+ merged: false,
+ draft: false,
+ title: null,
+ author: null,
+ isLoading: true,
+ ciStatus: null,
+ isCiLoading: true,
+ }}
+ >
+ PostHog/posthog#23985
+ </PrRefChip>,
+ );
+
+ expect(
+ screen.getByRole("img", { name: "Loading pull request status" }),
+ ).toBeInTheDocument();
+
+ await hoverChip();
+
+ expect(screen.queryByText("CI passed")).not.toBeInTheDocument();
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/editor/components/PrRefChip.tsx b/products/desktop/packages/ui/src/features/editor/components/PrRefChip.tsx
new file mode 100644
index 000000000000..17a464a9df1c
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/editor/components/PrRefChip.tsx
@@ -0,0 +1,128 @@
+import { GitPullRequestIcon } from "@phosphor-icons/react";
+import { getPrVisualConfig } from "@posthog/core/git-interaction/prStatus";
+import {
+ cn,
+ Skeleton,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@posthog/quill";
+import { GithubRefChipLink } from "@posthog/ui/features/editor/components/GithubRefChip";
+import { getPrVisualIcon } from "@posthog/ui/features/git-interaction/prIcon";
+import { PR_TONE_TEXT } from "@posthog/ui/features/git-interaction/prTone";
+import type { ReactElement, ReactNode } from "react";
+
+const CI_STATUS_LABELS = {
+ success: "CI passed",
+ failure: "CI needs attention",
+ pending: "CI running",
+} as const;
+
+export type PrCiStatus = keyof typeof CI_STATUS_LABELS;
+
+export interface PrRefDetails {
+ state: string | null;
+ merged: boolean;
+ draft: boolean;
+ title: string | null;
+ author: string | null;
+ isLoading: boolean;
+ ciStatus: PrCiStatus | null;
+ isCiLoading: boolean;
+}
+
+/*
+ * Skeletons sit on the tooltip's inverted surface, where quill's --muted fill
+ * reads as a solid block. Tinting the inherited text color keeps them faint in
+ * both themes.
+ */
+const SKELETON_LINE = "h-3 w-24 rounded-xs bg-current/25";
+
+/**
+ * A pull request chip that reports the PR's lifecycle: a tinted icon on the
+ * chip, and title, creator, and CI status in the hover card. Presentational —
+ * `GithubPrRefChip` supplies the details.
+ */
+export function PrRefChip({
+ href,
+ details,
+ onTooltipOpenChange,
+ children,
+}: {
+ href: string;
+ details: PrRefDetails;
+ onTooltipOpenChange?: (open: boolean) => void;
+ children: ReactNode;
+}): ReactElement {
+ const config =
+ details.state && details.state !== "unknown"
+ ? getPrVisualConfig(details.state, details.merged, details.draft)
+ : null;
+ const isLoading = !config && details.isLoading;
+ const statusLabel = config?.label ?? "Status unavailable. Open in GitHub.";
+ // The chip shows the state as an icon only, so the screen reader label has to
+ // carry the loading state the tooltip renders as a skeleton.
+ const iconLabel = isLoading ? "Loading pull request status" : statusLabel;
+ const StatusIcon = config ? getPrVisualIcon(config.icon) : GitPullRequestIcon;
+ const toneClass = config ? PR_TONE_TEXT[config.color] : undefined;
+
+ return (
+ <Tooltip onOpenChange={onTooltipOpenChange}>
+ <TooltipTrigger
+ render={
+ <GithubRefChipLink
+ href={href}
+ icon={StatusIcon}
+ iconLabel={iconLabel}
+ toneClass={toneClass}
+ >
+ {children}
+ </GithubRefChipLink>
+ }
+ />
+ <TooltipContent side="top" className="max-w-80 py-2">
+ {/* The tooltip surface is inverted, so its contents inherit that color
+ rather than the page foreground/muted tokens. */}
+ <div className="flex min-w-0 flex-col gap-1.5 text-start">
+ <div className="flex items-center gap-1.5 font-medium">
+ <StatusIcon
+ size={12}
+ weight="bold"
+ className="shrink-0"
+ aria-hidden="true"
+ />
+ {isLoading ? (
+ <Skeleton className={SKELETON_LINE} />
+ ) : (
+ <span>{statusLabel}</span>
+ )}
+ </div>
+ {details.title ? (
+ <span className="line-clamp-2 font-medium">{details.title}</span>
+ ) : (
+ isLoading && <Skeleton className={cn(SKELETON_LINE, "w-56")} />
+ )}
+ {(isLoading ||
+ details.author ||
+ details.ciStatus ||
+ details.isCiLoading) && (
+ <span className="flex flex-wrap items-center gap-x-2 gap-y-1 text-current/70">
+ {isLoading ? (
+ <Skeleton className={cn(SKELETON_LINE, "w-28")} />
+ ) : (
+ details.author && <span>Created by @{details.author}</span>
+ )}
+ {details.isCiLoading ? (
+ <Skeleton className={cn(SKELETON_LINE, "w-16")} />
+ ) : (
+ details.ciStatus && (
+ <span>{CI_STATUS_LABELS[details.ciStatus]}</span>
+ )
+ )}
+ </span>
+ )}
+ </div>
+ </TooltipContent>
+ </Tooltip>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/editor/components/githubRefChipFor.tsx b/products/desktop/packages/ui/src/features/editor/components/githubRefChipFor.tsx
new file mode 100644
index 000000000000..d0cf81c9b828
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/editor/components/githubRefChipFor.tsx
@@ -0,0 +1,34 @@
+import { GithubPrRefChip } from "@posthog/ui/features/editor/components/GithubPrRefChip";
+import { GithubRefChip } from "@posthog/ui/features/editor/components/GithubRefChip";
+import { parseGithubIssueUrl } from "@posthog/ui/features/message-editor/githubIssueUrl";
+import type { ReactElement, ReactNode } from "react";
+
+/**
+ * The chip a markdown link to GitHub renders as, or null when the link points
+ * somewhere else. Shared so both markdown renderers route references the same
+ * way.
+ */
+export function githubRefChipFor(
+ href: string | undefined,
+ children: ReactNode,
+): ReactElement | null {
+ const githubRef = href ? parseGithubIssueUrl(href) : null;
+ if (!githubRef) return null;
+
+ // A bare URL reads as noise in a sentence, so it becomes owner/repo#number.
+ const isAutoLink = typeof children === "string" && children === href;
+ const label = isAutoLink
+ ? `${githubRef.owner}/${githubRef.repo}#${githubRef.number}`
+ : children;
+
+ if (githubRef.kind === "pr") {
+ return (
+ <GithubPrRefChip href={githubRef.normalizedUrl}>{label}</GithubPrRefChip>
+ );
+ }
+ return (
+ <GithubRefChip href={githubRef.normalizedUrl} kind="issue">
+ {label}
+ </GithubRefChip>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/git-interaction/components/PRBadgeLink.tsx b/products/desktop/packages/ui/src/features/git-interaction/components/PRBadgeLink.tsx
index 3c67a59934f2..72574d512e1d 100644
--- a/products/desktop/packages/ui/src/features/git-interaction/components/PRBadgeLink.tsx
+++ b/products/desktop/packages/ui/src/features/git-interaction/components/PRBadgeLink.tsx
@@ -1,10 +1,14 @@
import {
getPrVisualConfig,
- type PrVisualConfig,
parsePrNumber,
} from "@posthog/core/git-interaction/prStatus";
import { Button, cn, Spinner } from "@posthog/quill";
import { getPrVisualIcon } from "../prIcon";
+import {
+ PR_TONE_BORDER,
+ PR_TONE_FILL_COMPACT,
+ prBadgeToneProps,
+} from "../prTone";
interface PRBadgeLinkProps {
prUrl: string;
@@ -25,51 +29,6 @@ interface PRBadgeLinkProps {
otherCount?: number;
}
-const COMPACT_COLOR_CLASSES: Record<PrVisualConfig["color"], string> = {
- gray: "bg-(--gray-3) text-(--gray-11) hover:bg-(--gray-4)",
- green: "bg-(--green-3) text-(--green-11) hover:bg-(--green-4)",
- red: "bg-(--red-3) text-(--red-11) hover:bg-(--red-4)",
- purple: "bg-(--purple-3) text-(--purple-11) hover:bg-(--purple-4)",
-};
-
-/**
- * The PR's lifecycle colour, as classes for a quill button. quill's variants
- * are one neutral palette by design, and this badge's whole job is to say
- * merged from closed from open at a glance — so the tint comes from the Radix
- * token layer, which is what the app's colour scales live in anyway.
- */
-const PR_BADGE_TONE_CLASSES: Record<PrVisualConfig["color"], string> = {
- gray: "bg-(--gray-3) text-(--gray-11) not-disabled:hover:bg-(--gray-4) not-disabled:hover:text-(--gray-12)",
- green:
- "bg-(--green-3) text-(--green-11) not-disabled:hover:bg-(--green-4) not-disabled:hover:text-(--green-12)",
- red: "bg-(--red-3) text-(--red-11) not-disabled:hover:bg-(--red-4) not-disabled:hover:text-(--red-12)",
- purple:
- "bg-(--purple-3) text-(--purple-11) not-disabled:hover:bg-(--purple-4) not-disabled:hover:text-(--purple-12)",
-};
-
-/**
- * How a badge wears its lifecycle state, as props for a quill button. A solid
- * state takes quill's own primary; the rest take their tint.
- *
- * Exported because the dropdown trigger that sits beside the badge in a
- * `ButtonGroup` has to wear the same thing, or the group reads as two controls.
- */
-export function prBadgeToneProps(config: PrVisualConfig): {
- variant?: "primary";
- className?: string;
-} {
- if (config.solid) return { variant: "primary" };
- return { className: PR_BADGE_TONE_CLASSES[config.color] };
-}
-
-// Divider ahead of the PR-count segment, tinted to the badge's own color.
-const COUNT_DIVIDER_CLASSES: Record<PrVisualConfig["color"], string> = {
- gray: "border-(--gray-a6)",
- green: "border-(--green-a6)",
- red: "border-(--red-a6)",
- purple: "border-(--purple-a6)",
-};
-
/**
* The colored "open this PR on GitHub" badge — styled by the PR's lifecycle
* state (open / draft / closed / merged) and rendered as an external anchor.
@@ -102,7 +61,7 @@ export function PRBadgeLink({
rel="noopener noreferrer"
onClick={(e) => e.stopPropagation()}
title={stackTitle}
- className={`inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] no-underline ${COMPACT_COLOR_CLASSES[config.color]}`}
+ className={`inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] no-underline ${PR_TONE_FILL_COMPACT[config.color]}`}
>
{isPrPending ? (
<Spinner className="size-2.5" />
@@ -147,9 +106,7 @@ export function PRBadgeLink({
{prNumber && ` #${prNumber}`}
</span>
{otherCount > 0 && (
- <span
- className={`border-l pl-2 ${COUNT_DIVIDER_CLASSES[config.color]}`}
- >
+ <span className={`border-l pl-2 ${PR_TONE_BORDER[config.color]}`}>
{totalCount}
</span>
)}
diff --git a/products/desktop/packages/ui/src/features/git-interaction/components/TaskActionsMenu.tsx b/products/desktop/packages/ui/src/features/git-interaction/components/TaskActionsMenu.tsx
index 2e15ecb314cd..1cbfd1839943 100644
--- a/products/desktop/packages/ui/src/features/git-interaction/components/TaskActionsMenu.tsx
+++ b/products/desktop/packages/ui/src/features/git-interaction/components/TaskActionsMenu.tsx
@@ -34,6 +34,7 @@ import type { ReactNode } from "react";
import { toast } from "../../../primitives/toast";
import { useLocalRepoPath } from "../../workspace/useLocalRepoPath";
import { getPrActionIcon, getPrVisualIcon } from "../prIcon";
+import { prBadgeToneProps } from "../prTone";
import { useCloudPrSummaries, useCloudPrUrls } from "../useCloudPrUrl";
import {
type GitMenuAction,
@@ -55,7 +56,7 @@ import {
GitCommitDialog,
GitPushDialog,
} from "./GitInteractionDialogs";
-import { PRBadgeLink, prBadgeToneProps } from "./PRBadgeLink";
+import { PRBadgeLink } from "./PRBadgeLink";
interface TaskActionsMenuProps {
taskId: string;
diff --git a/products/desktop/packages/ui/src/features/git-interaction/prTone.ts b/products/desktop/packages/ui/src/features/git-interaction/prTone.ts
new file mode 100644
index 000000000000..298ec566b616
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/git-interaction/prTone.ts
@@ -0,0 +1,62 @@
+import type { PrVisualConfig } from "@posthog/core/git-interaction/prStatus";
+
+/**
+ * A pull request's lifecycle color, as classes for the surfaces that wear it.
+ * quill's variants are one neutral palette by design, and these surfaces exist
+ * to say merged from closed from open at a glance, so the tint comes from the
+ * Radix token layer that the app's color scales already live in.
+ *
+ * Tailwind only sees class names it can read in the source, so each map spells
+ * its classes out. Keeping the maps together means a new lifecycle color is one
+ * file to edit rather than five.
+ */
+type PrToneColor = PrVisualConfig["color"];
+
+/** Icon or label tint on an untinted surface. */
+export const PR_TONE_TEXT: Record<PrToneColor, string> = {
+ gray: "text-(--gray-11)",
+ green: "text-(--green-11)",
+ red: "text-(--red-11)",
+ purple: "text-(--purple-11)",
+};
+
+/** Filled badge, for a control that can be disabled. */
+export const PR_TONE_FILL: Record<PrToneColor, string> = {
+ gray: "bg-(--gray-3) text-(--gray-11) not-disabled:hover:bg-(--gray-4) not-disabled:hover:text-(--gray-12)",
+ green:
+ "bg-(--green-3) text-(--green-11) not-disabled:hover:bg-(--green-4) not-disabled:hover:text-(--green-12)",
+ red: "bg-(--red-3) text-(--red-11) not-disabled:hover:bg-(--red-4) not-disabled:hover:text-(--red-12)",
+ purple:
+ "bg-(--purple-3) text-(--purple-11) not-disabled:hover:bg-(--purple-4) not-disabled:hover:text-(--purple-12)",
+};
+
+/** Filled pill for the compact command-center badge, which is a plain anchor. */
+export const PR_TONE_FILL_COMPACT: Record<PrToneColor, string> = {
+ gray: "bg-(--gray-3) text-(--gray-11) hover:bg-(--gray-4)",
+ green: "bg-(--green-3) text-(--green-11) hover:bg-(--green-4)",
+ red: "bg-(--red-3) text-(--red-11) hover:bg-(--red-4)",
+ purple: "bg-(--purple-3) text-(--purple-11) hover:bg-(--purple-4)",
+};
+
+/** Divider inside a filled badge, tinted to the badge's own color. */
+export const PR_TONE_BORDER: Record<PrToneColor, string> = {
+ gray: "border-(--gray-a6)",
+ green: "border-(--green-a6)",
+ red: "border-(--red-a6)",
+ purple: "border-(--purple-a6)",
+};
+
+/**
+ * How a badge wears its lifecycle state, as props for a quill button. A solid
+ * state takes quill's own primary; the rest take their tint.
+ *
+ * Exported because the dropdown trigger that sits beside the badge in a
+ * `ButtonGroup` has to wear the same thing, or the group reads as two controls.
+ */
+export function prBadgeToneProps(config: PrVisualConfig): {
+ variant?: "primary";
+ className?: string;
+} {
+ if (config.solid) return { variant: "primary" };
+ return { className: PR_TONE_FILL[config.color] };
+}
diff --git a/products/desktop/packages/ui/src/features/git-interaction/usePrActions.ts b/products/desktop/packages/ui/src/features/git-interaction/usePrActions.ts
index dcc16e9acd23..f7c06fbb7667 100644
--- a/products/desktop/packages/ui/src/features/git-interaction/usePrActions.ts
+++ b/products/desktop/packages/ui/src/features/git-interaction/usePrActions.ts
@@ -25,6 +25,7 @@ export function usePrActions(prUrl: string | null) {
...getOptimisticPrState(variables.action),
headRefName: prev?.headRefName ?? null,
title: prev?.title ?? null,
+ author: prev?.author ?? null,
}),
);
// The inbox Pulls list reads PR status from the batched
diff --git a/products/desktop/packages/ui/src/features/git-interaction/usePrDetails.ts b/products/desktop/packages/ui/src/features/git-interaction/usePrDetails.ts
index c049bb5c8f2e..b784eb868ee1 100644
--- a/products/desktop/packages/ui/src/features/git-interaction/usePrDetails.ts
+++ b/products/desktop/packages/ui/src/features/git-interaction/usePrDetails.ts
@@ -6,6 +6,7 @@ import type { PrCommentThread } from "../code-review/prCommentAnnotations";
interface UsePrDetailsOptions {
includeComments?: boolean;
+ refetchInterval?: number | false;
}
function mapPrCommentThreads(
@@ -69,13 +70,14 @@ export function usePrDetails(
prUrl: string | null,
options?: UsePrDetailsOptions,
) {
- const { includeComments = false } = options ?? {};
+ const { includeComments = false, refetchInterval = false } = options ?? {};
const trpc = useHostTRPC();
const metaQuery = useQuery({
...trpc.git.getPrDetailsByUrl.queryOptions({ prUrl: prUrl as string }),
enabled: !!prUrl,
staleTime: 60_000,
+ refetchInterval,
placeholderData: (prev) => prev,
retry: 1,
});
@@ -100,6 +102,8 @@ export function usePrDetails(
merged: metaQuery.data?.merged ?? false,
draft: metaQuery.data?.draft ?? false,
headRefName: metaQuery.data?.headRefName ?? null,
+ title: metaQuery.data?.title ?? null,
+ author: metaQuery.data?.author ?? null,
isLoading: metaQuery.isLoading,
},
commentThreads,
diff --git a/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.stories.tsx b/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.stories.tsx
index 960830d7c579..407e4d781725 100644
--- a/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.stories.tsx
+++ b/products/desktop/packages/ui/src/features/message-editor/components/PromptInput.stories.tsx
@@ -341,6 +341,11 @@ export const AllChipTypes: Story = {
id: "https://github.com/org/repo/issues/123",
label: "#123 Fix the bug",
},
+ {
+ type: "github_pr",
+ id: "https://github.com/org/repo/pull/456",
+ label: "org/repo#456",
+ },
{ type: "error", id: "error-1", label: "TypeError: undefined" },
{ type: "experiment", id: "exp-1", label: "new-checkout-flow" },
{ type: "insight", id: "insight-1", label: "Weekly active users" },
diff --git a/products/desktop/packages/ui/src/features/message-editor/tiptap/MentionChipView.tsx b/products/desktop/packages/ui/src/features/message-editor/tiptap/MentionChipView.tsx
index ccc3d6b508ee..220ca09d41dd 100644
--- a/products/desktop/packages/ui/src/features/message-editor/tiptap/MentionChipView.tsx
+++ b/products/desktop/packages/ui/src/features/message-editor/tiptap/MentionChipView.tsx
@@ -16,7 +16,7 @@ import { type NodeViewProps, NodeViewWrapper } from "@tiptap/react";
import { usePasteUndoStore } from "../pasteUndoStore";
import type { ChipType, MentionChipAttrs } from "./MentionChipNode";
-const chipBase = "group/chip relative top-px active:translate-y-0 pl-1";
+const chipBase = "group/chip relative top-px active:translate-y-0";
const selectedRing = "border-ring/50 ring-[1px] ring-ring/50";
@@ -34,9 +34,11 @@ const typeIconMap: Record<ChipType, React.ComponentType<{ size: number }>> = {
function IconCloseButton({
type,
+ iconSize,
onRemove,
}: {
type: ChipType;
+ iconSize: number;
onRemove: () => void;
}) {
const Icon = typeIconMap[type] || FileTextIcon;
@@ -45,17 +47,20 @@ function IconCloseButton({
<button
type="button"
tabIndex={-1}
- className="relative inline-flex size-3.5 shrink-0 cursor-pointer items-center justify-center border-none bg-transparent p-0"
+ className={cn(
+ "relative inline-flex shrink-0 cursor-pointer items-center justify-center border-none bg-transparent p-0",
+ iconSize > 10 ? "size-4" : "size-3.5",
+ )}
onClick={(e) => {
e.stopPropagation();
onRemove();
}}
>
<span className="ease pointer-events-none absolute inset-0 flex items-center justify-center opacity-50 transition-opacity duration-150 group-hover/chip:opacity-0 motion-reduce:transition-none">
- <Icon size={10} />
+ <Icon size={iconSize} />
</span>
<span className="ease pointer-events-none absolute inset-0 flex items-center justify-center opacity-0 transition-opacity duration-150 group-hover/chip:opacity-100 motion-reduce:transition-none">
- <XIcon size={10} />
+ <XIcon size={iconSize} />
</span>
</button>
);
@@ -86,6 +91,7 @@ function DefaultChip({
const isFile = type === "file";
const isFolder = type === "folder";
const isGithubRef = type === "github_issue" || type === "github_pr";
+ const isPr = type === "github_pr";
const canOpenUrl = isGithubRef && /^https:\/\//.test(id);
// A skill reads as part of the sentence being written, not as an object
@@ -112,12 +118,16 @@ function DefaultChip({
const chipContent = (
<Chip
- size="xs"
+ size={isPr ? "sm" : "xs"}
contentEditable={false}
onClick={canOpenUrl ? () => window.open(id, "_blank") : undefined}
- className={`${chipBase} max-w-full whitespace-nowrap ${isGithubRef ? "cursor-pointer!" : "cursor-default! active:translate-y-0!"} ${isCommand ? "cli-slash-command" : "cli-file-mention"} ${selected ? selectedRing : ""}`}
+ className={`${chipBase} ${isPr ? "pl-1.5" : "pl-1"} max-w-full whitespace-nowrap ${isGithubRef ? "cursor-pointer!" : "cursor-default! active:translate-y-0!"} ${isCommand ? "cli-slash-command" : "cli-file-mention"} ${selected ? selectedRing : ""}`}
>
- <IconCloseButton type={type as ChipType} onRemove={onRemove} />
+ <IconCloseButton
+ type={type as ChipType}
+ iconSize={isPr ? 12 : 10}
+ onRemove={onRemove}
+ />
{isGithubRef ? (
<span className="min-w-0 truncate">{label}</span>
) : (
diff --git a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.test.tsx b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.test.tsx
index cf3956680910..1d5b022b2223 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.test.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.test.tsx
@@ -12,6 +12,26 @@ vi.mock("../../../../hooks/useAuthenticatedQuery", () => ({
}),
}));
+vi.mock("@posthog/ui/features/git-interaction/usePrDetails", () => ({
+ usePrDetails: () => ({
+ meta: {
+ state: "open",
+ merged: false,
+ draft: false,
+ headRefName: "posthog/status-chip",
+ title: "Show pull request status in sessions",
+ author: "octocat",
+ isLoading: false,
+ },
+ commentThreads: new Map(),
+ commentsLoading: false,
+ }),
+}));
+
+vi.mock("@posthog/ui/features/pr-review/usePrChecks", () => ({
+ usePrChecks: () => ({ data: [], isLoading: false }),
+}));
+
import { ChatMarkdown, ChatStreamingMarkdown } from "./ChatMarkdown";
describe("ChatMarkdown", () => {
@@ -41,6 +61,18 @@ Verdict: valid.
expect(html).not.toContain("<img");
expect(html).not.toContain("http://127.0.0.1/action");
});
+
+ it("renders a GitHub pull request with its live status chip", () => {
+ const html = renderToStaticMarkup(
+ <ChatMarkdown content="Review https://github.com/PostHog/posthog/pull/23985" />,
+ );
+
+ expect(html).toContain("PostHog/posthog#23985");
+ expect(html).toContain('aria-label="Open"');
+ expect(html).toContain(
+ 'data-github-ref-url="https://github.com/PostHog/posthog/pull/23985"',
+ );
+ });
});
describe("ChatMarkdown object tags", () => {
diff --git a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.tsx b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.tsx
index 1c76f02feda1..26a66b7599f2 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.tsx
@@ -12,6 +12,7 @@ import {
} from "@posthog/quill";
import { ArtifactRefChip } from "@posthog/ui/features/editor/components/ArtifactRefChip";
import { EvidenceRefChip } from "@posthog/ui/features/editor/components/EvidenceRefChip";
+import { githubRefChipFor } from "@posthog/ui/features/editor/components/githubRefChipFor";
import { MessageChartCard } from "@posthog/ui/features/editor/components/MessageChartCard";
import {
markOpenLinkDestination,
@@ -100,6 +101,8 @@ const components: Components = {
<EvidenceRefChip target={evidenceTarget}>{children}</EvidenceRefChip>
);
}
+ const githubChip = githubRefChipFor(href, children);
+ if (githubChip) return githubChip;
const link = (
<a
href={href}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/session-update/fileLinkChips.tsx b/products/desktop/packages/ui/src/features/sessions/components/session-update/fileLinkChips.tsx
index 5cea104e563d..f390ab61286d 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/session-update/fileLinkChips.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/session-update/fileLinkChips.tsx
@@ -71,7 +71,7 @@ export function InlineFileLink({
type="button"
onClick={taskId ? handleClick : undefined}
disabled={!taskId}
- className={`m-0 inline border-0 bg-transparent p-0 font-[inherit] text-(--accent-11) text-[length:inherit] ${taskId ? "cursor-pointer underline decoration-(--accent-a8) underline-offset-2 hover:decoration-(--accent-11)" : ""}`}
+ className={`m-0 inline border-0 bg-transparent p-0 font-[inherit] text-[length:inherit] text-foreground ${taskId ? "cursor-pointer underline underline-offset-2" : ""}`}
>
{filename}
{lineSuffix ? `:${lineSuffix}` : ""}
diff --git a/products/desktop/packages/ui/src/primitives/ArtifactChip.tsx b/products/desktop/packages/ui/src/primitives/ArtifactChip.tsx
index 1c21410461d3..6637cdec4d2d 100644
--- a/products/desktop/packages/ui/src/primitives/ArtifactChip.tsx
+++ b/products/desktop/packages/ui/src/primitives/ArtifactChip.tsx
@@ -53,6 +53,7 @@ export function ArtifactChip({
// the download half out of reach.
className="min-w-0 shrink"
variant="outline"
+ size="sm"
>
{typeof name === "string" && <FileIcon filename={name} size={12} />}
<span className="min-w-0 truncate">{label}</span>
@@ -61,7 +62,7 @@ export function ArtifactChip({
{onDownload && (
<Tooltip content={downloading ? "Downloading…" : "Download"}>
<Button
- size="icon"
+ size="icon-sm"
variant="outline"
onClick={onDownload}
disabled={downloading}
diff --git a/products/desktop/packages/workspace-server/src/services/git/schemas.ts b/products/desktop/packages/workspace-server/src/services/git/schemas.ts
index 29eddac6c8da..b974dd014820 100644
--- a/products/desktop/packages/workspace-server/src/services/git/schemas.ts
+++ b/products/desktop/packages/workspace-server/src/services/git/schemas.ts
@@ -315,6 +315,7 @@ export const getPrDetailsByUrlOutput = z.object({
draft: z.boolean(),
headRefName: z.string().nullable(),
title: z.string().nullable(),
+ author: z.string().nullable(),
});
export type PrDetailsByUrlOutput = z.infer<typeof getPrDetailsByUrlOutput>;
diff --git a/products/desktop/packages/workspace-server/src/services/git/service.test.ts b/products/desktop/packages/workspace-server/src/services/git/service.test.ts
index 47fbe0579e22..7140000e17e6 100644
--- a/products/desktop/packages/workspace-server/src/services/git/service.test.ts
+++ b/products/desktop/packages/workspace-server/src/services/git/service.test.ts
@@ -21,6 +21,26 @@ describe("GitService", () => {
execGhMock.mockReset();
});
+ it("returns lifecycle and creator details for a pull request", async () => {
+ const details = {
+ state: "open",
+ merged: false,
+ draft: false,
+ headRefName: "posthog/status-chip",
+ title: "Show pull request status in sessions",
+ author: "octocat",
+ };
+ execGhMock.mockResolvedValueOnce(
+ ghResult({ stdout: JSON.stringify(details) }),
+ );
+
+ await expect(
+ new GitService().getPrDetailsByUrl(
+ "https://github.com/PostHog/posthog/pull/23985",
+ ),
+ ).resolves.toEqual(details);
+ });
+
it("returns no changed files when the remote branch does not exist yet", async () => {
execGhMock
.mockResolvedValueOnce(ghResult({ stdout: "main\n" }))
diff --git a/products/desktop/packages/workspace-server/src/services/git/service.ts b/products/desktop/packages/workspace-server/src/services/git/service.ts
index ad66721e619c..36b3eb964fc7 100644
--- a/products/desktop/packages/workspace-server/src/services/git/service.ts
+++ b/products/desktop/packages/workspace-server/src/services/git/service.ts
@@ -91,7 +91,11 @@ import type {
SyncOutput,
UpdatePrByUrlOutput,
} from "./schemas";
-import { getPrInfoByUrlOutput, prConversationCommentSchema } from "./schemas";
+import {
+ getPrDetailsByUrlOutput,
+ getPrInfoByUrlOutput,
+ prConversationCommentSchema,
+} from "./schemas";
const FETCH_THROTTLE_MS = 30_000;
/** Max PRs per GraphQL request – stays well under GitHub's complexity ceiling. */
@@ -1032,22 +1036,16 @@ export class GitService extends TypedEventEmitter<GitCloneEvents> {
"api",
`repos/${pr.owner}/${pr.repo}/pulls/${pr.number}`,
"--jq",
- "{state,merged,draft,headRefName: .head.ref,title}",
+ "{state,merged,draft,headRefName: .head.ref,title,author: (.user.login // null)}",
]);
if (result.exitCode !== 0) {
return null;
}
- const data = JSON.parse(result.stdout) as {
- state: string;
- merged: boolean;
- draft: boolean;
- headRefName: string | null;
- title: string | null;
- };
-
- return data;
+ // The jq expression above and this schema describe one shape, so parse
+ // rather than cast: a GitHub field that moves fails here, not downstream.
+ return getPrDetailsByUrlOutput.parse(JSON.parse(result.stdout));
} catch {
return null;
}