: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(desktop): render http(s) step details as external links (#89978)
Alessandro Pogliaghif29f26880671
diff --git a/products/desktop/packages/ui/src/primitives/StepList.test.tsx b/products/desktop/packages/ui/src/primitives/StepList.test.tsxnew file mode 100644index 000000000000..f42b0de3c401--- /dev/null+++ b/products/desktop/packages/ui/src/primitives/StepList.test.tsx@@ -0,0 +1,63 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { beforeEach, describe, expect, it, vi } from "vitest";+import { StepList } from "./StepList";++const openExternalUrl = vi.fn();++vi.mock("@posthog/ui/shell/openExternal", () => ({+ openExternalUrl: (url: string) => openExternalUrl(url),+}));++describe("StepList", () => {+ beforeEach(() => {+ openExternalUrl.mockClear();+ });++ it("opens a URL detail in the system browser", async () => {+ render(+ <StepList+ steps={[+ {+ key: "pr",+ label: "Opened pull request",+ status: "completed",+ detail: "https://github.com/PostHog/posthog/pull/123",+ },+ ]}+ />,+ );++ const link = screen.getByRole("button", {+ name: "Open github.com/PostHog/posthog/pull/123",+ });+ expect(link).toHaveTextContent("github.com/PostHog/posthog/pull/123");++ await userEvent.click(link);++ expect(openExternalUrl).toHaveBeenCalledWith(+ "https://github.com/PostHog/posthog/pull/123",+ );+ });++ it.each([+ ["plain text", "Cloned PostHog/posthog"],+ ["a non-web scheme", "file:///tmp/report.txt"],+ ])("renders %s as inert text", (_case, detail) => {+ render(+ <StepList+ steps={[+ {+ key: "repo",+ label: "Repository ready",+ detail,+ status: "completed",+ },+ ]}+ />,+ );++ expect(screen.getByText(detail)).toBeInTheDocument();+ expect(screen.queryByRole("button")).toBeNull();+ });+});diff --git a/products/desktop/packages/ui/src/primitives/StepList.tsx b/products/desktop/packages/ui/src/primitives/StepList.tsxindex 6db503073b28..9ce7e8998a12 100644--- a/products/desktop/packages/ui/src/primitives/StepList.tsx+++ b/products/desktop/packages/ui/src/primitives/StepList.tsx@@ -1,10 +1,12 @@import {+ ArrowSquareOut,CheckCircle,Circle,CircleNotch,XCircle,} from "@phosphor-icons/react";-import { Box, Flex, Text } from "@radix-ui/themes";+import { Button, Text } from "@posthog/quill";+import { openExternalUrl } from "@posthog/ui/shell/openExternal";export type StepStatus = "pending" | "in_progress" | "completed" | "failed";@@ -33,6 +35,47 @@ export function StepIcon({ status, size = 14 }: StepIconProps) {}}+function parseWebUrl(detail: string): URL | null {+ let parsed: URL;+ try {+ parsed = new URL(detail);+ } catch {+ return null;+ }+ return parsed.protocol === "https:" || parsed.protocol === "http:"+ ? parsed+ : null;+}++function formatWebUrl(url: URL): string {+ const path = url.pathname === "/" ? "" : url.pathname.replace(/\/$/, "");+ return `${url.host}${path}${url.search}`;+}++function StepDetail({ detail }: { detail: string }) {+ const url = parseWebUrl(detail);++ if (!url) {+ return <Text className="text-[13px] text-gray-10">{detail}</Text>;+ }++ const label = formatWebUrl(url);+ return (+ <Button+ variant="link"+ size="sm"+ className="h-auto gap-1 p-0 text-[13px]"+ onClick={() => openExternalUrl(url.href)}+ title={url.href}+ aria-label={`Open ${label}`}+ data-attr="step-detail-link"+ >+ <span className="max-w-xs truncate">{label}</span>+ <ArrowSquareOut size={12} className="shrink-0" />+ </Button>+ );+}+interface StepRowProps {step: Step;size?: "1" | "2";@@ -41,20 +84,26 @@ interface StepRowProps {function StepRow({ step, size = "2" }: StepRowProps) {const sizeClass = size === "1" ? "text-[13px]" : "text-sm";return (- <Flex direction="column" gap="0">- <Flex align="center" gap="2">+ <div className="flex flex-col">+ <div className="flex items-center gap-2"><StepIcon status={step.status} /><Text className={`${sizeClass} text-gray-12`}>{step.label}</Text>- </Flex>+ </div>{step.detail && (- <Box pl="5">- <Text className="text-[13px] text-gray-10">{step.detail}</Text>- </Box>+ <div className="pl-6">+ <StepDetail detail={step.detail} />+ </div>)}- </Flex>+ </div>);}+const GAP_CLASSES: Record<"1" | "2" | "3", string> = {+ "1": "gap-1",+ "2": "gap-2",+ "3": "gap-3",+};+interface StepListProps {steps: Step[];/** Text size for step labels. Default "2". */@@ -65,10 +114,10 @@ interface StepListProps {export function StepList({ steps, size = "2", gap = "1" }: StepListProps) {return (- <Flex direction="column" gap={gap}>+ <div className={`flex flex-col ${GAP_CLASSES[gap]}`}>{steps.map((step) => (<StepRow key={step.key} step={step} size={size} />))}- </Flex>+ </div>);}