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): simplify the desktop onboarding flow (#88035)

Adam Bowker42b3539b408a
diff --git a/products/desktop/apps/web/tests/e2e/tests/happy-path.spec.ts b/products/desktop/apps/web/tests/e2e/tests/happy-path.spec.ts
index b0a1aa7bad41..99e498eb3e8e 100644
--- a/products/desktop/apps/web/tests/e2e/tests/happy-path.spec.ts
+++ b/products/desktop/apps/web/tests/e2e/tests/happy-path.spec.ts
@@ -25,7 +25,7 @@ test.describe("web host happy path", () => {
.catch(() => {});
await expect(
- page.getByText("Sign in / sign up with PostHog").first(),
+ page.getByRole("button", { name: "Sign in with PostHog" }),
).toBeVisible({ timeout: 30_000 });
await expect(page.getByRole("button", { name: "Back" })).toHaveCount(0);
diff --git a/products/desktop/packages/core/src/integrations/repositories.ts b/products/desktop/packages/core/src/integrations/repositories.ts
index c7815e337830..7357ecd3d433 100644
--- a/products/desktop/packages/core/src/integrations/repositories.ts
+++ b/products/desktop/packages/core/src/integrations/repositories.ts
@@ -192,7 +192,10 @@ export function combineUserGithubRepositories(
results.forEach((result, index) => {
if (result.isPending) pending = true;
- if (result.isError) {
+ // A refetch in flight is not a broken installation. Returning from the
+ // browser after connecting refetches on focus, and the new installation's
+ // first repo fetch can beat the backend finishing the link.
+ if (result.isError && !result.isRefetching) {
const installationId = installationIds[index] ?? null;
if (installationId) failedInstallationIds.push(installationId);
}
diff --git a/products/desktop/packages/core/src/onboarding/githubConnectPanel.test.ts b/products/desktop/packages/core/src/onboarding/githubConnectPanel.test.ts
index d250cfde2a1a..09313a6ee056 100644
--- a/products/desktop/packages/core/src/onboarding/githubConnectPanel.test.ts
+++ b/products/desktop/packages/core/src/onboarding/githubConnectPanel.test.ts
@@ -25,7 +25,7 @@ describe("getGithubPanelMessage", () => {
).toBe("boom");
});
- it("falls through timeout, connecting, then default", () => {
+ it("reports a timeout, and nothing while connecting or idle", () => {
const base = {
hasConnectError: false,
connectErrorMessage: "",
@@ -35,10 +35,10 @@ describe("getGithubPanelMessage", () => {
).toBe(GITHUB_CONNECT_TIMEOUT_MESSAGE);
expect(
getGithubPanelMessage({ ...base, timedOut: false, isConnecting: true }),
- ).toBe("Waiting for GitHub...");
+ ).toBeNull();
expect(
getGithubPanelMessage({ ...base, timedOut: false, isConnecting: false }),
- ).toMatch(/Unlocks cloud runs/);
+ ).toBeNull();
});
});
@@ -205,7 +205,11 @@ describe("deriveConnectButtonState", () => {
hasConnectError: false,
timedOut: false,
}),
- ).toEqual({ isRetry: false, shouldReset: false, label: "Connect GitHub" });
+ ).toEqual({
+ isRetry: false,
+ shouldReset: false,
+ label: "Sign in with GitHub",
+ });
});
it("labels a retry on error and asks to reset", () => {
diff --git a/products/desktop/packages/core/src/onboarding/githubConnectPanel.ts b/products/desktop/packages/core/src/onboarding/githubConnectPanel.ts
index 147af9b28d03..d0508f0e49f6 100644
--- a/products/desktop/packages/core/src/onboarding/githubConnectPanel.ts
+++ b/products/desktop/packages/core/src/onboarding/githubConnectPanel.ts
@@ -15,16 +15,16 @@ export interface GithubPanelMessageOptions {
isPending?: boolean;
}
+/** Null when the connect flow has nothing to report, so the line stays out. */
export function getGithubPanelMessage(
options: GithubPanelMessageOptions,
-): string {
+): string | null {
if (options.hasConnectError) return options.connectErrorMessage;
if (options.isPending) return GITHUB_INSTALL_PENDING_MESSAGE;
if (options.timedOut) {
return GITHUB_CONNECT_TIMEOUT_MESSAGE;
}
- if (options.isConnecting) return "Waiting for GitHub...";
- return "Unlocks cloud runs, branch pushes, and PR review on this account.";
+ return null;
}
export function resolveSelectedProjectId(
@@ -141,7 +141,7 @@ export function deriveConnectButtonState(inputs: {
? "Retry connection"
: isRetry
? "Try again"
- : "Connect GitHub";
+ : "Sign in with GitHub";
return { isRetry, shouldReset: inputs.hasConnectError, label };
}
diff --git a/products/desktop/packages/core/src/onboarding/steps.test.ts b/products/desktop/packages/core/src/onboarding/steps.test.ts
index a2469ec30eb5..0ba33928258d 100644
--- a/products/desktop/packages/core/src/onboarding/steps.test.ts
+++ b/products/desktop/packages/core/src/onboarding/steps.test.ts
@@ -11,8 +11,11 @@ import {
stepDirection,
} from "./steps";
-const allSteps = {
+type StepGates = Parameters<typeof computeActiveSteps>[0];
+
+const allSteps: StepGates = {
hasGithubIntegration: undefined,
+ cliReady: undefined,
projectCount: 2,
consentRequired: true,
};
@@ -37,14 +40,27 @@ describe("computeActiveSteps", () => {
);
});
- it("drops install-cli only on a confirmed github connection", () => {
- expect(
- computeActiveSteps({ ...allSteps, hasGithubIntegration: true }),
- ).not.toContain("install-cli");
+ it.each<{ name: string; options: Partial<StepGates> }>([
+ {
+ name: "a confirmed github connection",
+ options: { hasGithubIntegration: true },
+ },
+ { name: "a ready local toolchain", options: { cliReady: true } },
+ ])("drops install-cli on $name", ({ options }) => {
+ expect(computeActiveSteps({ ...allSteps, ...options })).not.toContain(
+ "install-cli",
+ );
+ });
+
+ it("keeps install-cli until a skip reason is confirmed", () => {
+ expect(computeActiveSteps(allSteps)).toContain("install-cli");
expect(
- computeActiveSteps({ ...allSteps, hasGithubIntegration: false }),
+ computeActiveSteps({
+ ...allSteps,
+ hasGithubIntegration: false,
+ cliReady: false,
+ }),
).toContain("install-cli");
- expect(computeActiveSteps(allSteps)).toContain("install-cli");
});
it("includes consent from the sampled requirement", () => {
@@ -63,6 +79,7 @@ describe("computeActiveSteps", () => {
describe("nearestActiveStep", () => {
const withoutConditionals = computeActiveSteps({
hasGithubIntegration: true,
+ cliReady: undefined,
projectCount: 2,
consentRequired: true,
});
@@ -97,6 +114,7 @@ describe("nearestActiveStep", () => {
describe("step navigation", () => {
const steps = computeActiveSteps({
hasGithubIntegration: undefined,
+ cliReady: undefined,
projectCount: 2,
consentRequired: true,
});
diff --git a/products/desktop/packages/core/src/onboarding/steps.ts b/products/desktop/packages/core/src/onboarding/steps.ts
index 3bd140fd2bc7..6a4f51ce3af5 100644
--- a/products/desktop/packages/core/src/onboarding/steps.ts
+++ b/products/desktop/packages/core/src/onboarding/steps.ts
@@ -24,6 +24,8 @@ export interface DetectedRepo {
export function computeActiveSteps(options: {
/** Undefined while the integrations query is loading; the step only drops on a confirmed connection. */
hasGithubIntegration: boolean | undefined;
+ /** Undefined while the local git and gh checks are loading. */
+ cliReady: boolean | undefined;
/** Undefined until the project list has loaded, so a slow list cannot skip a real choice. */
projectCount: number | undefined;
consentRequired: boolean | undefined;
@@ -31,7 +33,12 @@ export function computeActiveSteps(options: {
return ONBOARDING_STEPS.filter((step) => {
if (step === "project-select" && options.projectCount === 1) return false;
if (step === "consent" && options.consentRequired === false) return false;
- if (step === "install-cli" && options.hasGithubIntegration === true) {
+ // Two independent reasons to skip: a GitHub integration means tasks run in
+ // the cloud, and a ready local toolchain leaves the step nothing to offer.
+ if (
+ step === "install-cli" &&
+ (options.hasGithubIntegration === true || options.cliReady === true)
+ ) {
return false;
}
return true;
diff --git a/products/desktop/packages/ui/src/features/auth/OAuthControls.tsx b/products/desktop/packages/ui/src/features/auth/OAuthControls.tsx
index 2376b69f80fc..9d986f57f398 100644
--- a/products/desktop/packages/ui/src/features/auth/OAuthControls.tsx
+++ b/products/desktop/packages/ui/src/features/auth/OAuthControls.tsx
@@ -1,17 +1,17 @@
import type { CloudRegion } from "@posthog/shared";
-import { Callout, Flex, Spinner } from "@radix-ui/themes";
-import posthogIcon from "./assets/posthog-icon.svg";
+import { Callout, Spinner } from "@radix-ui/themes";
import { RegionSelect } from "./RegionSelect";
import { useOAuthFlow } from "./useOAuthFlow";
interface OAuthControlsProps {
onAuthInitiated?: (region: CloudRegion) => void;
+ /** Defaults to the dev build, which is the only place a local instance is worth offering. */
includeDevRegion?: boolean;
}
export function OAuthControls({
onAuthInitiated,
- includeDevRegion = false,
+ includeDevRegion = import.meta.env.DEV,
}: OAuthControlsProps = {}) {
const {
region,
@@ -32,14 +32,7 @@ export function OAuthControls({
};
return (
- <Flex direction="column" gap="3" className="w-full">
- <RegionSelect
- region={region}
- onRegionChange={handleRegionChange}
- disabled={isPending}
- includeDevRegion={includeDevRegion}
- />
-
+ <div className="flex w-full flex-col gap-3">
{errorMessage && (
<Callout.Root color="red" size="1">
<Callout.Text>{errorMessage}</Callout.Text>
@@ -67,13 +60,16 @@ export function OAuthControls({
transition: "opacity 150ms ease, box-shadow 100ms ease",
}}
>
- {isPending ? (
- <Spinner size="1" />
- ) : (
- <img src={posthogIcon} alt="" className="h-[20px] w-[20px]" />
- )}
- {isPending ? "Cancel" : "Sign in / sign up with PostHog"}
+ {isPending && <Spinner size="1" />}
+ {isPending ? "Cancel" : "Sign in with PostHog"}
</button>
- </Flex>
+
+ <RegionSelect
+ region={region}
+ onRegionChange={handleRegionChange}
+ disabled={isPending}
+ includeDevRegion={includeDevRegion}
+ />
+ </div>
);
}
diff --git a/products/desktop/packages/ui/src/features/auth/RegionSelect.stories.tsx b/products/desktop/packages/ui/src/features/auth/RegionSelect.stories.tsx
new file mode 100644
index 000000000000..58953c21c16a
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/auth/RegionSelect.stories.tsx
@@ -0,0 +1,57 @@
+import type { CloudRegion } from "@posthog/shared";
+import { RegionSelect } from "@posthog/ui/features/auth/RegionSelect";
+import { ProductWordmark } from "@posthog/ui/primitives/ProductWordmark";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { useState } from "react";
+
+const meta: Meta<typeof RegionSelect> = {
+ title: "Auth/RegionSelect",
+ component: RegionSelect,
+};
+
+export default meta;
+
+/** Mirrors SignInCard's layout without the OAuth hook, so the whole block is visible. */
+function SignInCardPreview({
+ includeDevRegion,
+}: {
+ includeDevRegion: boolean;
+}) {
+ const [region, setRegion] = useState<CloudRegion>("us");
+ return (
+ <div className="w-[420px] p-8">
+ <div className="flex flex-col gap-6">
+ <div className="flex justify-center">
+ <ProductWordmark />
+ </div>
+ <div className="flex w-full flex-col gap-3">
+ <button
+ type="button"
+ className="flex h-[44px] w-full cursor-pointer items-center justify-center gap-[8px] rounded-[6px] font-medium text-[15px]"
+ style={{
+ border: "1.5px solid var(--accent-8)",
+ backgroundColor: "var(--accent-9)",
+ color: "var(--accent-contrast)",
+ boxShadow: "0 3px 0 -1px var(--accent-8)",
+ }}
+ >
+ Sign in with PostHog
+ </button>
+ <RegionSelect
+ region={region}
+ onRegionChange={setRegion}
+ includeDevRegion={includeDevRegion}
+ />
+ </div>
+ </div>
+ </div>
+ );
+}
+
+export const SignInBlock: StoryObj = {
+ render: () => <SignInCardPreview includeDevRegion={false} />,
+};
+
+export const WithDevRegion: StoryObj = {
+ render: () => <SignInCardPreview includeDevRegion={true} />,
+};
diff --git a/products/desktop/packages/ui/src/features/auth/RegionSelect.tsx b/products/desktop/packages/ui/src/features/auth/RegionSelect.tsx
index 591a4adad04c..2ed2fb785a6d 100644
--- a/products/desktop/packages/ui/src/features/auth/RegionSelect.tsx
+++ b/products/desktop/packages/ui/src/features/auth/RegionSelect.tsx
@@ -1,5 +1,13 @@
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ Text,
+} from "@posthog/quill";
import { type CloudRegion, REGION_LABELS } from "@posthog/shared";
-import { Flex, Text } from "@radix-ui/themes";
+import { Tooltip } from "@posthog/ui/primitives/Tooltip";
interface RegionSelectProps {
region: CloudRegion;
@@ -9,7 +17,17 @@ interface RegionSelectProps {
includeDevRegion?: boolean;
}
-const LOGIN_GRID_REGIONS: CloudRegion[] = ["us", "eu"];
+const CLOUD_REGIONS: CloudRegion[] = ["us", "eu"];
+
+function RegionOptionLabel({ region }: { region: CloudRegion }) {
+ const { flag, label } = REGION_LABELS[region];
+ return (
+ <span className="flex items-center gap-2">
+ <span className="shrink-0 leading-none">{flag}</span>
+ <span>{label}</span>
+ </span>
+ );
+}
export function RegionSelect({
region,
@@ -17,68 +35,44 @@ export function RegionSelect({
disabled = false,
includeDevRegion = false,
}: RegionSelectProps) {
- return (
- <Flex direction="column" gap="2" className="w-full">
- <Flex justify="between" align="center">
- <Text className="font-medium text-(--gray-12) text-sm">
- PostHog region
- </Text>
- <Text className="text-(--gray-11) text-xs">
- Pick where your data lives
- </Text>
- </Flex>
- <div className="grid w-full grid-cols-2 gap-2">
- {LOGIN_GRID_REGIONS.map((regionKey) => (
- <RegionPickerOptionButton
- key={regionKey}
- regionKey={regionKey}
- selected={regionKey === region}
- disabled={disabled}
- onSelect={() => onRegionChange(regionKey)}
- />
- ))}
- </div>
- {includeDevRegion && (
- <RegionPickerOptionButton
- regionKey="dev"
- selected={region === "dev"}
- disabled={disabled}
- onSelect={() => onRegionChange("dev")}
- />
- )}
- </Flex>
- );
-}
+ const offered: CloudRegion[] = includeDevRegion
+ ? [...CLOUD_REGIONS, "dev"]
+ : CLOUD_REGIONS;
-function RegionPickerOptionButton({
- regionKey,
- selected,
- disabled,
- onSelect,
-}: {
- regionKey: CloudRegion;
- selected: boolean;
- disabled: boolean;
- onSelect: () => void;
-}) {
- const { flag, label, hint } = REGION_LABELS[regionKey];
return (
- <button
- type="button"
- aria-pressed={selected}
- onClick={onSelect}
- disabled={disabled}
- className={`flex w-full flex-col items-start gap-[2px] rounded-[8px] border-[1.5px] px-3 py-2 text-left transition-colors ${
- selected
- ? "border-(--accent-9) bg-(--accent-3) text-(--gray-12)"
- : "border-(--gray-6) bg-transparent text-(--gray-12) hover:border-(--gray-8)"
- } ${disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer"}`}
- >
- <Flex align="center" gap="2" className="w-full">
- <span className="text-[18px] leading-none">{flag}</span>
- <Text className="font-semibold text-(--gray-12) text-sm">{label}</Text>
- </Flex>
- <Text className="pl-[26px] text-(--gray-11) text-xs">{hint}</Text>
- </button>
+ <div className="flex items-center justify-center gap-2">
+ <Tooltip content="Where your PostHog data is stored. You can migrate later.">
+ <Text className="text-(--gray-11) text-xs">Data region</Text>
+ </Tooltip>
+ <Select
+ value={region}
+ onValueChange={(next: CloudRegion | null) =>
+ next && onRegionChange(next)
+ }
+ items={offered.map((candidate) => ({
+ value: candidate,
+ label: REGION_LABELS[candidate].label,
+ }))}
+ >
+ {/* Fixed width so switching regions never reflows the row beneath the button. */}
+ <SelectTrigger
+ size="sm"
+ disabled={disabled}
+ aria-label="Data region"
+ className="w-[176px]"
+ >
+ <SelectValue>
+ <RegionOptionLabel region={region} />
+ </SelectValue>
+ </SelectTrigger>
+ <SelectContent align="center" side="bottom" sideOffset={6}>
+ {offered.map((candidate) => (
+ <SelectItem key={candidate} value={candidate}>
+ <RegionOptionLabel region={candidate} />
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
);
}
diff --git a/products/desktop/packages/ui/src/features/auth/SignInCard.tsx b/products/desktop/packages/ui/src/features/auth/SignInCard.tsx
index 39648fff1bf5..bf8f5ab19ecd 100644
--- a/products/desktop/packages/ui/src/features/auth/SignInCard.tsx
+++ b/products/desktop/packages/ui/src/features/auth/SignInCard.tsx
@@ -1,37 +1,25 @@
import type { CloudRegion } from "@posthog/shared";
-import { OnboardingHogTip } from "@posthog/ui/primitives/OnboardingHogTip";
-import { Flex, Text } from "@radix-ui/themes";
+import { ProductWordmark } from "@posthog/ui/primitives/ProductWordmark";
import { OAuthControls } from "./OAuthControls";
interface SignInCardProps {
- hogSrc: string;
- hogMessage: string;
- subtitle: string;
onAuthInitiated?: (region: CloudRegion) => void;
- /** Defaults to the dev build, which is the only place a local instance is worth offering. */
includeDevRegion?: boolean;
}
export function SignInCard({
- hogSrc,
- hogMessage,
- subtitle,
onAuthInitiated,
- includeDevRegion = import.meta.env.DEV,
+ includeDevRegion,
}: SignInCardProps) {
return (
- <Flex direction="column" gap="4">
- <Flex direction="column" gap="2">
- <Text className="font-bold text-(--gray-12) text-2xl">
- Sign in / sign up with PostHog
- </Text>
- <Text className="text-(--gray-11) text-sm">{subtitle}</Text>
- </Flex>
+ <div className="flex flex-col gap-6">
+ <div className="flex justify-center">
+ <ProductWordmark />
+ </div>
<OAuthControls
onAuthInitiated={onAuthInitiated}
includeDevRegion={includeDevRegion}
/>
- <OnboardingHogTip hogSrc={hogSrc} message={hogMessage} />
- </Flex>
+ </div>
);
}
diff --git a/products/desktop/packages/ui/src/features/auth/components/AuthScreen.tsx b/products/desktop/packages/ui/src/features/auth/components/AuthScreen.tsx
index 8f3411660446..2fc2488e80db 100644
--- a/products/desktop/packages/ui/src/features/auth/components/AuthScreen.tsx
+++ b/products/desktop/packages/ui/src/features/auth/components/AuthScreen.tsx
@@ -1,4 +1,3 @@
-import { happyHog } from "@posthog/ui/assets/hedgehogs";
import { SignInCard } from "@posthog/ui/features/auth/SignInCard";
import { FullScreenLayout } from "@posthog/ui/primitives/FullScreenLayout";
import { Callout, Flex } from "@radix-ui/themes";
@@ -30,11 +29,7 @@ export function AuthScreen() {
</Callout.Text>
</Callout.Root>
)}
- <SignInCard
- hogSrc={happyHog}
- hogMessage="Welcome back. Let's get shipping."
- subtitle="Connect your PostHog account to continue."
- />
+ <SignInCard />
</Flex>
</Flex>
</Flex>
diff --git a/products/desktop/packages/ui/src/features/consent/ConsentStep.tsx b/products/desktop/packages/ui/src/features/consent/ConsentStep.tsx
index 6243b8a74e1b..200e398a8ad9 100644
--- a/products/desktop/packages/ui/src/features/consent/ConsentStep.tsx
+++ b/products/desktop/packages/ui/src/features/consent/ConsentStep.tsx
@@ -34,7 +34,7 @@ export function ConsentStep({
<div className="flex h-full items-center px-8">
<div className="flex h-full w-full flex-col items-center pt-[24px] pb-[40px]">
<div className="flex min-h-0 flex-1 flex-col overflow-y-auto">
- <div className="m-auto w-full max-w-[560px]">
+ <div className="m-auto w-full max-w-[480px]">
<AnimatePresence mode="wait" initial={false}>
<motion.div
key={consent.status}
diff --git a/products/desktop/packages/ui/src/features/folder-picker/GitHubRepoPicker.tsx b/products/desktop/packages/ui/src/features/folder-picker/GitHubRepoPicker.tsx
index 522845674fe4..6464a1bbe00f 100644
--- a/products/desktop/packages/ui/src/features/folder-picker/GitHubRepoPicker.tsx
+++ b/products/desktop/packages/ui/src/features/folder-picker/GitHubRepoPicker.tsx
@@ -1,5 +1,6 @@
import {
ArrowClockwise,
+ CaretDown,
GithubLogo,
MagnifyingGlass,
} from "@phosphor-icons/react";
@@ -18,6 +19,7 @@ import {
Text,
} from "@posthog/quill";
import { Tooltip } from "@posthog/ui/primitives/Tooltip";
+import { FIELD_TRIGGER_CLASS } from "@posthog/ui/styles/fieldTrigger";
import { defaultFilter } from "cmdk";
import { type RefObject, useEffect, useMemo, useRef, useState } from "react";
@@ -61,6 +63,8 @@ interface GitHubRepoPickerProps {
hasMore?: boolean;
onLoadMore?: () => void;
triggerClassName?: string;
+ /** "field" matches FolderPicker's select-style trigger. */
+ variant?: "button" | "field";
}
export function GitHubRepoPicker({
@@ -83,6 +87,7 @@ export function GitHubRepoPicker({
hasMore: controlledHasMore,
onLoadMore,
triggerClassName,
+ variant = "button",
}: GitHubRepoPickerProps) {
const buttonSize = size === "2" ? "lg" : "sm";
const buttonTextClass = size === "2" ? "text-[13px]" : "";
@@ -221,17 +226,38 @@ export function GitHubRepoPicker({
>
<ComboboxTrigger
render={
- <Button
- ref={triggerRef}
- variant="outline"
- size={buttonSize}
- disabled={disabled}
- aria-label="Repository"
- className={`${buttonTextClass} ${triggerClassName ?? ""}`}
- >
- <GithubLogo size={14} weight="regular" className="shrink-0" />
- <span className="min-w-0 truncate">{value ?? placeholder}</span>
- </Button>
+ variant === "field" ? (
+ <button
+ ref={triggerRef}
+ type="button"
+ disabled={disabled}
+ aria-label="Repository"
+ className={`${FIELD_TRIGGER_CLASS} ${triggerClassName ?? ""}`}
+ >
+ <div className="flex min-w-0 flex-1 items-center gap-2">
+ <GithubLogo size={16} className="shrink-0 text-(--gray-12)" />
+ <span
+ className="min-w-0 max-w-full truncate text-left font-medium text-(--gray-12)"
+ title={value ?? undefined}
+ >
+ {value ?? placeholder}
+ </span>
+ </div>
+ <CaretDown size={14} className="shrink-0 text-(--gray-9)" />
+ </button>
+ ) : (
+ <Button
+ ref={triggerRef}
+ variant="outline"
+ size={buttonSize}
+ disabled={disabled}
+ aria-label="Repository"
+ className={`${buttonTextClass} ${triggerClassName ?? ""}`}
+ >
+ <GithubLogo size={14} weight="regular" className="shrink-0" />
+ <span className="min-w-0 truncate">{value ?? placeholder}</span>
+ </Button>
+ )
}
/>
<ComboboxContent
diff --git a/products/desktop/packages/ui/src/features/mission-control/MissionControlOverlay.tsx b/products/desktop/packages/ui/src/features/mission-control/MissionControlOverlay.tsx
index 9b9254e6a53e..4128829fda00 100644
--- a/products/desktop/packages/ui/src/features/mission-control/MissionControlOverlay.tsx
+++ b/products/desktop/packages/ui/src/features/mission-control/MissionControlOverlay.tsx
@@ -42,12 +42,7 @@ export function MissionControlOverlay() {
data-testid="mission-control-overlay"
className={`pointer-events-none fixed inset-0 z-[300] flex flex-col items-center justify-center gap-[2.5vh] bg-(--gray-1)/10 backdrop-blur-sm transition-opacity duration-150 ease-out motion-reduce:transition-none ${visible ? "opacity-100" : "opacity-0"}`}
>
- {/* The logo-only variant reserves room for the wordmark, so crop to the
- logomark's own 52:28 box. */}
- <div
- className="w-[min(18vw,160px)] overflow-hidden [&>svg]:h-auto [&>svg]:w-full"
- style={{ aspectRatio: "52 / 28" }}
- >
+ <div className="w-[min(18vw,160px)] [&>svg]:h-auto [&>svg]:w-full">
<LogosLandscape wordmark={false} />
</div>
<p className="font-semibold text-(--gray-12) text-[clamp(16px,2.2vw,28px)] leading-none tracking-tight">
diff --git a/products/desktop/packages/ui/src/features/onboarding/components/ConnectGitHubStep.tsx b/products/desktop/packages/ui/src/features/onboarding/components/ConnectGitHubStep.tsx
index bf7c77bc4d93..096501fc8a03 100644
--- a/products/desktop/packages/ui/src/features/onboarding/components/ConnectGitHubStep.tsx
+++ b/products/desktop/packages/ui/src/features/onboarding/components/ConnectGitHubStep.tsx
@@ -1,16 +1,13 @@
-import {
- ArrowLeft,
- ArrowRight,
- CheckCircle,
- Cloud,
- GitPullRequest,
-} from "@phosphor-icons/react";
+import { ArrowLeft, ArrowRight } from "@phosphor-icons/react";
+import { isAnyIntegrationStale } from "@posthog/core/onboarding/githubConnectPanel";
import type { OnboardingStepCompletedProperties } from "@posthog/shared/analytics-events";
-import { builderHog } from "@posthog/ui/assets/hedgehogs";
-import { useUserGithubIntegrations } from "@posthog/ui/features/integrations/useIntegrations";
+import {
+ useUserGithubIntegrations,
+ useUserRepositoryIntegration,
+} from "@posthog/ui/features/integrations/useIntegrations";
+import { GithubConnectionLink } from "@posthog/ui/features/onboarding/components/GithubConnectionLink";
import { OptionalBadge } from "@posthog/ui/features/onboarding/components/OptionalBadge";
import { StepActions } from "@posthog/ui/features/onboarding/components/StepActions";
-import { OnboardingHogTip } from "@posthog/ui/primitives/OnboardingHogTip";
import { Button, Flex, Text } from "@radix-ui/themes";
import { motion } from "framer-motion";
import { GitHubConnectPanel } from "./GitHubConnectPanel";
@@ -24,67 +21,59 @@ interface ConnectGitHubStepProps {
export function ConnectGitHubStep({ onNext, onBack }: ConnectGitHubStepProps) {
const { data: githubUserIntegrations = [] } = useUserGithubIntegrations();
+ const { failedInstallationIds } = useUserRepositoryIntegration();
+ // A revoked installation still leaves its row behind, so the link must not
+ // read as healthy while the card below says it needs reconnecting.
+ const isConnected =
+ githubUserIntegrations.length > 0 &&
+ !isAnyIntegrationStale(githubUserIntegrations, failedInstallationIds);
const handleContinue = () => {
- onNext({ github_connected: githubUserIntegrations.length > 0 });
+ onNext({ github_connected: isConnected });
};
return (
- <Flex align="center" height="100%" px="8">
+ <Flex align="center" justify="center" height="100%" px="8">
<Flex
direction="column"
align="center"
- className="h-full w-full pt-[24px] pb-[40px]"
+ className="h-full w-full max-w-[480px] pt-[24px] pb-[40px]"
>
- <Flex direction="column" className="min-h-0 flex-1 overflow-y-auto">
+ <Flex
+ direction="column"
+ align="center"
+ className="min-h-0 w-full flex-1 overflow-y-auto"
+ >
<Flex
direction="column"
gap="5"
- className="m-auto w-full max-w-[560px]"
+ style={{ margin: "auto 0" }}
+ className="w-full"
>
- <Flex direction="column" gap="5" className="w-full">
+ <Flex direction="column" gap="4" className="w-full">
<motion.div
initial={{ opacity: 0, y: 8 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.3 }}
>
- <Flex direction="column" gap="2">
- <Flex align="center" gap="2">
- <Text className="font-bold text-(--gray-12) text-2xl">
- Connect GitHub
- </Text>
- <OptionalBadge />
- </Flex>
- <Text className="text-(--gray-11) text-sm">
- Unlocks the parts of PostHog that leave your machine.
- </Text>
- </Flex>
+ <GithubConnectionLink connected={isConnected} />
</motion.div>
<motion.div
initial={{ opacity: 0, y: 8 }}
animate={{ opacity: 1, y: 0 }}
- transition={{ duration: 0.3, delay: 0.03 }}
+ transition={{ duration: 0.3, delay: 0.02 }}
>
<Flex direction="column" gap="2">
<Flex align="center" gap="2">
- <Cloud size={16} className="text-(--gray-11)" />
- <Text className="text-(--gray-11) text-sm">
- Run tasks in cloud sandboxes instead of your machine.
- </Text>
- </Flex>
- <Flex align="center" gap="2">
- <GitPullRequest size={16} className="text-(--gray-11)" />
- <Text className="text-(--gray-11) text-sm">
- Push branches and open pull requests from agents.
- </Text>
- </Flex>
- <Flex align="center" gap="2">
- <CheckCircle size={16} className="text-(--gray-11)" />
- <Text className="text-(--gray-11) text-sm">
- Review PR comments and reply to threads from inside the
- app.
+ <Text className="font-bold text-(--gray-12) text-2xl">
+ Connect GitHub
</Text>
+ <OptionalBadge />
</Flex>
+ <Text className="text-(--gray-11) text-sm">
+ Allows agents to run tasks in the cloud, push branches, and
+ open pull requests.
+ </Text>
</Flex>
</motion.div>
@@ -97,12 +86,6 @@ export function ConnectGitHubStep({ onNext, onBack }: ConnectGitHubStepProps) {
<GitHubConnectPanel />
</motion.div>
</Flex>
-
- <OnboardingHogTip
- hogSrc={builderHog}
- message="You can skip this and still use local tasks. Come back any time to unlock cloud runs."
- delay={0.15}
- />
</Flex>
</Flex>
@@ -113,8 +96,13 @@ export function ConnectGitHubStep({ onNext, onBack }: ConnectGitHubStepProps) {
Back
</Button>
)}
- <Button size="3" onClick={handleContinue}>
- Continue
+ <Button
+ size="3"
+ variant={isConnected ? "solid" : "outline"}
+ color={isConnected ? undefined : "gray"}
+ onClick={handleContinue}
+ >
+ {isConnected ? "Continue" : "Skip for now"}
<ArrowRight size={16} weight="bold" />
</Button>
</StepActions>
diff --git a/products/desktop/packages/ui/src/features/onboarding/components/GitHubConnectPanel.tsx b/products/desktop/packages/ui/src/features/onboarding/components/GitHubConnectPanel.tsx
index cb581e9758f6..73858e2b889d 100644
--- a/products/desktop/packages/ui/src/features/onboarding/components/GitHubConnectPanel.tsx
+++ b/products/desktop/packages/ui/src/features/onboarding/components/GitHubConnectPanel.tsx
@@ -3,13 +3,14 @@ import {
ArrowsClockwise,
CheckCircle,
GearSix,
- GithubLogo,
Plus,
+ Trash,
} from "@phosphor-icons/react";
import {
GITHUB_CONNECT_PENDING_APPROVAL_CODE,
isGithubConnectPendingApproval,
} from "@posthog/core/integrations/connectErrors";
+import { githubInvalidationKeys } from "@posthog/core/integrations/connectMachine";
import {
buildConnectAbandonedProps,
buildConnectFailedProps,
@@ -41,18 +42,16 @@ import {
useUserGithubIntegrations,
useUserRepositoryIntegration,
} from "@posthog/ui/features/integrations/useIntegrations";
-import { OptionalBadge } from "@posthog/ui/features/onboarding/components/OptionalBadge";
-import { PANEL_SHADOW } from "@posthog/ui/features/onboarding/components/onboardingStyles";
import { useProjectsWithIntegrations } from "@posthog/ui/features/onboarding/hooks/useProjectsWithIntegrations";
import { useOnboardingStore } from "@posthog/ui/features/onboarding/onboardingStore";
+import { Tooltip } from "@posthog/ui/primitives/Tooltip";
import { track } from "@posthog/ui/shell/analytics";
import { openExternalUrl } from "@posthog/ui/shell/openExternal";
import {
AlertDialog,
- Box,
Button,
- DropdownMenu,
Flex,
+ IconButton,
Skeleton,
Spinner,
Text,
@@ -68,9 +67,6 @@ export function GitHubConnectPanel() {
const manuallySelectedProjectId = useOnboardingStore(
(state) => state.selectedProjectId,
);
- const setSelectedProjectId = useOnboardingStore(
- (state) => state.selectProjectId,
- );
const selectedProjectId = useMemo(
() =>
resolveSelectedProjectId(
@@ -228,9 +224,20 @@ export function GitHubConnectPanel() {
),
[hasGitIntegration, projectsWithGithub, selectedProjectId],
);
- const [selectedAlternativeId, setSelectedAlternativeId] = useState<
- number | null
- >(null);
+ const [selectedAlternativeId] = useState<number | null>(null);
+ const [isRefreshing, setIsRefreshing] = useState(false);
+ const refreshGithubState = async () => {
+ setIsRefreshing(true);
+ try {
+ await Promise.all(
+ githubInvalidationKeys(selectedProjectId).map((queryKey) =>
+ queryClient.invalidateQueries({ queryKey: [...queryKey] }),
+ ),
+ );
+ } finally {
+ setIsRefreshing(false);
+ }
+ };
const selectedAlternative = useMemo(() => {
if (!alternativeConnectedProjects.length) return null;
return (
@@ -240,158 +247,104 @@ export function GitHubConnectPanel() {
);
}, [alternativeConnectedProjects, selectedAlternativeId]);
+ // Which connect path applies. The user presses the same button either way.
+ const teamConnectFlow: OnboardingGithubConnectFlow | null =
+ selectedProject?.hasGithubIntegration
+ ? "team_existing"
+ : selectedAlternative && selectedProject
+ ? "team_alternative"
+ : null;
+
+ const [reconnectingInstallationId, setReconnectingInstallationId] = useState<
+ string | null
+ >(null);
const [disconnectTarget, setDisconnectTarget] = useState<{
installationId: string;
accountName: string;
} | null>(null);
- const [reconnectingInstallationId, setReconnectingInstallationId] = useState<
- string | null
- >(null);
const { disconnect, isDisconnecting, reconnect } =
useGithubDisconnect(selectedProjectId);
return (
- <>
- <Box
- p="5"
- style={{ boxShadow: PANEL_SHADOW }}
- className="rounded-[12px] border border-(--gray-a3) bg-(--color-panel-solid)"
- >
- <Flex direction="column" gap="4">
- <Flex direction="column" gap="1">
- <Flex align="center" justify="between" gap="2">
- <Flex align="center" gap="2">
- <GithubLogo size={18} className="text-(--gray-12)" />
- <Text className="font-bold text-(--gray-12) text-base">
- Connect GitHub
- </Text>
- </Flex>
- {isLoading || githubUserIntegrationsLoading ? (
- <Skeleton className="h-[16px] w-[80px]" />
- ) : hasGitIntegration ? (
- anyIntegrationStale ? (
- <Text className="text-(--amber-11) text-[13px]">
- Reconnect needed
- </Text>
- ) : (
- <Flex align="center" gap="1">
- <CheckCircle
- size={14}
- weight="fill"
- className="text-(--green-9)"
- />
- <Text className="text-(--green-11) text-[13px]">
- {githubUserIntegrations.length > 1
- ? `Connected (${githubUserIntegrations.length})`
- : "Connected"}
- </Text>
- </Flex>
- )
- ) : (
- <OptionalBadge />
- )}
- </Flex>
- {!hasGitIntegration &&
- !isLoading &&
- !githubUserIntegrationsLoading &&
- (selectedProject?.hasGithubIntegration && canTakeAction ? (
- <Text className="text-(--gray-11) text-sm">
- GitHub is already set up on{" "}
- <Text className="font-bold">{selectedProject.name}</Text>.
- Sign in with one click to link your account, no admin approval
- needed.
- </Text>
- ) : selectedAlternative && selectedProject && canTakeAction ? (
- <Text className="text-(--gray-11) text-sm">
- GitHub is already connected on{" "}
- {alternativeConnectedProjects.length > 1 ? (
- <DropdownMenu.Root>
- <DropdownMenu.Trigger>
- <button
- type="button"
- className="cursor-pointer border-0 bg-transparent p-0 font-bold text-(--gray-12) underline"
- >
- {selectedAlternative.name} +{" "}
- {alternativeConnectedProjects.length - 1} more
- </button>
- </DropdownMenu.Trigger>
- <DropdownMenu.Content size="1" align="start">
- {alternativeConnectedProjects.map((p) => (
- <DropdownMenu.Item
- key={p.id}
- onSelect={() => setSelectedAlternativeId(p.id)}
- >
- <Text className="text-[13px]">{p.name}</Text>
- <Text className="ml-2 text-(--gray-10) text-[13px]">
- {p.organization.name}
- </Text>
- </DropdownMenu.Item>
- ))}
- </DropdownMenu.Content>
- </DropdownMenu.Root>
- ) : (
- <>
- <Text className="font-bold">
- {selectedAlternative.name}
- </Text>{" "}
- ({selectedAlternative.organization.name})
- </>
- )}
- .
- </Text>
- ) : isAwaitingApproval ? (
- <GithubApprovalNotice state="awaiting" className="pt-3" />
- ) : isApprovedNotLinked ? (
- <GithubApprovalNotice state="approved" className="pt-3" />
- ) : (
- <Text
- className={
- hasConnectError
- ? "text-(--red-11) text-sm"
- : "text-(--gray-11) text-sm"
- }
+ <div>
+ <Flex direction="column" gap="3">
+ <Flex direction="column" gap="1" className="empty:hidden">
+ {(isLoading || githubUserIntegrationsLoading) && (
+ <Skeleton className="h-[16px] w-[80px]" />
+ )}
+ {!isLoading &&
+ !githubUserIntegrationsLoading &&
+ hasGitIntegration &&
+ anyIntegrationStale && (
+ <Text className="text-(--amber-11) text-[13px]">
+ Reconnect needed
+ </Text>
+ )}
+ {!hasGitIntegration &&
+ !isLoading &&
+ !githubUserIntegrationsLoading &&
+ (isAwaitingApproval ? (
+ <GithubApprovalNotice state="awaiting" className="pt-3" />
+ ) : isApprovedNotLinked ? (
+ <GithubApprovalNotice state="approved" className="pt-3" />
+ ) : defaultPanelMessage ? (
+ <Text
+ className={
+ hasConnectError
+ ? "text-(--red-11) text-sm"
+ : "text-(--gray-11) text-sm"
+ }
+ >
+ {defaultPanelMessage}
+ </Text>
+ ) : null)}
+ </Flex>
+ {hasGitIntegration ? (
+ <Flex direction="column" gap="3">
+ {githubUserIntegrations.map((integration) => {
+ const installationId = integration.installation_id;
+ const accountName = formatGithubAccountLabel(
+ integration.account,
+ installationId,
+ );
+ const installRepos = reposByInstallationId[installationId];
+ const isLoadingInstallRepos = installRepos === undefined;
+ const isStale = failedInstallationIds.includes(installationId);
+ const isReconnecting =
+ reconnectingInstallationId === installationId;
+ return (
+ <Flex
+ key={integration.id}
+ direction="column"
+ gap="2"
+ p="3"
+ className="rounded-[10px] border border-(--gray-a4) bg-(--color-panel-solid)"
>
- {defaultPanelMessage}
- </Text>
- ))}
- </Flex>
- {hasGitIntegration ? (
- <Flex direction="column" gap="3">
- {githubUserIntegrations.map((integration) => {
- const installationId = integration.installation_id;
- const accountName = formatGithubAccountLabel(
- integration.account,
- installationId,
- );
- const installRepos = reposByInstallationId[installationId];
- const isLoadingInstallRepos = installRepos === undefined;
- const isStale = failedInstallationIds.includes(installationId);
- const isReconnecting =
- reconnectingInstallationId === installationId;
- return (
- <Flex
- key={integration.id}
- direction="column"
- gap="2"
- p="3"
- className="rounded-[8px] border border-(--gray-a3)"
- >
- <Flex align="center" justify="between" gap="2" wrap="wrap">
- <Flex align="center" gap="2">
- <Text className="font-bold text-(--gray-12) text-sm">
- {accountName}
- </Text>
- <Text className="text-(--gray-10) text-[12px]">
- {integration.account?.type === "Organization"
- ? "org"
- : "personal"}
- </Text>
- </Flex>
- {isStale ? (
- <Text className="text-(--amber-11) text-[12px]">
- Reconnect needed
- </Text>
- ) : (
+ <Flex align="center" justify="between" gap="2" wrap="wrap">
+ <Flex align="center" gap="2">
+ {!isStale && (
+ <CheckCircle
+ size={15}
+ weight="fill"
+ className="shrink-0 text-(--green-9)"
+ />
+ )}
+ <Text className="font-bold text-(--gray-12) text-sm">
+ {accountName}
+ </Text>
+ <Text className="text-(--gray-10) text-[12px]">
+ {integration.account?.type === "Organization"
+ ? "org"
+ : "personal"}
+ </Text>
+ </Flex>
+ {isStale && (
+ <Text className="text-(--amber-11) text-[12px]">
+ Reconnect needed
+ </Text>
+ )}
+ <Flex align="center" gap="3">
+ {!isStale && (
<Text className="text-(--gray-10) text-[12px]">
{isLoadingInstallRepos
? "Loading…"
@@ -400,183 +353,180 @@ export function GitHubConnectPanel() {
: `${installRepos.length} repos`}
</Text>
)}
- </Flex>
- <Flex align="center" gap="3" wrap="wrap">
- {isStale && (
- <Button
+ <Tooltip content="Manage on GitHub">
+ <IconButton
size="1"
- variant="solid"
- loading={isReconnecting}
- disabled={
- reconnectingInstallationId !== null &&
- !isReconnecting
- }
- onClick={async () => {
- markConnectStarted("user_new", true);
- setReconnectingInstallationId(installationId);
- try {
- await reconnect(
+ variant="ghost"
+ color="gray"
+ aria-label={`Manage ${accountName} on GitHub`}
+ onClick={() =>
+ openExternalUrl(
+ buildInstallationSettingsUrl(
+ integration.account,
installationId,
- handleConnectGitHub,
- );
- } catch {
- // The pre-connect disconnect failed, so no
- // connect flow ever started; a later unmount
- // must not report this as user abandonment.
- inFlightConnectRef.current = null;
- } finally {
- setReconnectingInstallationId(null);
- }
- }}
+ ),
+ )
+ }
>
- Reconnect
- <ArrowSquareOut size={12} />
- </Button>
- )}
+ <GearSix size={14} />
+ </IconButton>
+ </Tooltip>
+ <Tooltip content="Disconnect">
+ <IconButton
+ size="1"
+ variant="ghost"
+ color="gray"
+ aria-label={`Disconnect ${accountName}`}
+ onClick={() =>
+ setDisconnectTarget({ installationId, accountName })
+ }
+ >
+ <Trash size={14} />
+ </IconButton>
+ </Tooltip>
+ </Flex>
+ </Flex>
+ <Flex
+ align="center"
+ gap="3"
+ wrap="wrap"
+ className="empty:hidden"
+ >
+ {isStale && (
<Button
size="1"
- variant="soft"
- color="gray"
- onClick={() => {
- openExternalUrl(
- buildInstallationSettingsUrl(
- integration.account,
+ variant="solid"
+ loading={isReconnecting}
+ disabled={
+ reconnectingInstallationId !== null && !isReconnecting
+ }
+ onClick={async () => {
+ markConnectStarted("user_new", true);
+ setReconnectingInstallationId(installationId);
+ try {
+ await reconnect(
installationId,
- ),
- );
+ handleConnectGitHub,
+ );
+ } catch {
+ // The pre-connect disconnect failed, so no
+ // connect flow ever started; a later unmount
+ // must not report this as user abandonment.
+ inFlightConnectRef.current = null;
+ } finally {
+ setReconnectingInstallationId(null);
+ }
}}
>
- <GearSix size={12} />
- Settings
- </Button>
- <Button
- size="1"
- variant="soft"
- color="red"
- onClick={() =>
- setDisconnectTarget({ installationId, accountName })
- }
- >
- Disconnect
+ Reconnect
+ <ArrowSquareOut size={12} />
</Button>
- </Flex>
+ )}
</Flex>
- );
- })}
- <Flex align="center" gap="3" wrap="wrap">
- <Button
- size="1"
- variant="soft"
- color="gray"
- onClick={() => {
- queryClient.invalidateQueries({
- queryKey: ["integrations"],
- });
- queryClient.invalidateQueries({
- queryKey: ["user-github-integrations"],
- });
- }}
- >
- <ArrowsClockwise size={12} />
- Refresh
- </Button>
- <Button
- size="1"
- variant="ghost"
- color="gray"
- onClick={() => initiateConnect("user_new")}
- loading={isConnecting}
- >
- <Plus size={12} />
- Add another GitHub org
- </Button>
- </Flex>
+ </Flex>
+ );
+ })}
+ <Flex align="center" gap="3" wrap="wrap">
+ <Button
+ size="1"
+ variant="soft"
+ color="gray"
+ loading={isRefreshing}
+ onClick={() => void refreshGithubState()}
+ >
+ <ArrowsClockwise size={12} />
+ Refresh
+ </Button>
+ <Button
+ size="1"
+ variant="ghost"
+ color="gray"
+ onClick={() => initiateConnect("user_new")}
+ loading={isConnecting}
+ >
+ <Plus size={12} />
+ Add another GitHub org
+ </Button>
</Flex>
- ) : isAwaitingApproval ? null : isApprovedNotLinked ? (
- <QuillButton
- variant="primary"
- size="sm"
- className="self-start"
- loading={isConnecting}
- onClick={() => initiateConnect("user_new")}
+ </Flex>
+ ) : isAwaitingApproval ? (
+ <Button
+ size="2"
+ variant="soft"
+ color="gray"
+ className="self-start"
+ loading={isRefreshing}
+ onClick={() => void refreshGithubState()}
+ >
+ <ArrowsClockwise size={12} />
+ Check again
+ </Button>
+ ) : isApprovedNotLinked ? (
+ <QuillButton
+ variant="primary"
+ size="lg"
+ className="h-[44px] w-full"
+ loading={isConnecting}
+ onClick={() => initiateConnect("user_new")}
+ >
+ Sign in with GitHub
+ <ArrowSquareOut size={12} />
+ </QuillButton>
+ ) : !isLoading && !githubUserIntegrationsLoading ? (
+ teamConnectFlow && canTakeAction ? (
+ <Button
+ size="3"
+ variant="solid"
+ onClick={() => initiateConnect(teamConnectFlow)}
+ className="w-full"
>
- Connect GitHub
+ Sign in with GitHub
<ArrowSquareOut size={12} />
- </QuillButton>
- ) : !isLoading && !githubUserIntegrationsLoading ? (
- selectedProject?.hasGithubIntegration && canTakeAction ? (
+ </Button>
+ ) : (
+ <Flex direction="column" gap="2" className="w-full">
<Button
- size="2"
+ size="3"
variant="solid"
- onClick={() => initiateConnect("team_existing")}
- className="self-start"
+ onClick={() => {
+ const { isRetry, shouldReset } = deriveConnectButtonState({
+ isConnecting,
+ hasConnectError,
+ timedOut,
+ });
+ if (shouldReset) resetConnect();
+ initiateConnect("user_new", isRetry);
+ }}
+ loading={isConnecting}
+ className="w-full"
>
- Sign in with GitHub
+ {
+ deriveConnectButtonState({
+ isConnecting,
+ hasConnectError,
+ timedOut,
+ }).label
+ }
<ArrowSquareOut size={12} />
</Button>
- ) : selectedAlternative && selectedProject && canTakeAction ? (
- <Flex direction="column" gap="2" align="start">
- <Button
- size="2"
- variant="solid"
- onClick={() => initiateConnect("team_alternative")}
- >
- Connect GitHub on {selectedProject.name}
- <ArrowSquareOut size={12} />
- </Button>
+ {hasConnectError && (
<Button
size="1"
variant="ghost"
color="gray"
- onClick={() => setSelectedProjectId(selectedAlternative.id)}
+ onClick={resetConnect}
+ className="self-start"
>
- Switch to {selectedAlternative.name}
+ Dismiss
</Button>
- </Flex>
- ) : (
- <Flex gap="2" align="center">
- <Button
- size="2"
- variant="solid"
- onClick={() => {
- const { isRetry, shouldReset } = deriveConnectButtonState({
- isConnecting,
- hasConnectError,
- timedOut,
- });
- if (shouldReset) resetConnect();
- initiateConnect("user_new", isRetry);
- }}
- loading={isConnecting}
- >
- {
- deriveConnectButtonState({
- isConnecting,
- hasConnectError,
- timedOut,
- }).label
- }
- <ArrowSquareOut size={12} />
- </Button>
- {hasConnectError && (
- <Button
- size="2"
- variant="ghost"
- color="gray"
- onClick={resetConnect}
- >
- Dismiss
- </Button>
- )}
- </Flex>
- )
- ) : null}
- </Flex>
- </Box>
-
+ )}
+ </Flex>
+ )
+ ) : null}
+ </Flex>
<AlertDialog.Root
open={disconnectTarget !== null}
- onOpenChange={(next) => {
+ onOpenChange={(next: boolean) => {
if (!next && !isDisconnecting) {
setDisconnectTarget(null);
}
@@ -590,7 +540,7 @@ export function GitHubConnectPanel() {
<AlertDialog.Description className="text-sm">
This removes your personal GitHub authorization from PostHog. You
can reconnect at any time. The GitHub App itself stays installed in
- your org — uninstall it on GitHub if you want to remove that too.
+ your org, so uninstall it on GitHub if you want to remove that too.
</AlertDialog.Description>
<Flex gap="3" mt="4" justify="end">
<AlertDialog.Cancel>
@@ -614,6 +564,6 @@ export function GitHubConnectPanel() {
</Flex>
</AlertDialog.Content>
</AlertDialog.Root>
- </>
+ </div>
);
}
diff --git a/products/desktop/packages/ui/src/features/onboarding/components/GithubConnectionLink.stories.tsx b/products/desktop/packages/ui/src/features/onboarding/components/GithubConnectionLink.stories.tsx
new file mode 100644
index 000000000000..ae3799ade443
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/onboarding/components/GithubConnectionLink.stories.tsx
@@ -0,0 +1,15 @@
+import { GithubConnectionLink } from "@posthog/ui/features/onboarding/components/GithubConnectionLink";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+
+const meta: Meta<typeof GithubConnectionLink> = {
+ title: "Onboarding/GithubConnectionLink",
+ component: GithubConnectionLink,
+};
+export default meta;
+
+type Story = StoryObj<typeof GithubConnectionLink>;
+
+export const Disconnected: Story = { args: { connected: false } };
+export const Connected: Story = {
+ args: { connected: true, accountLabel: "Connected as adboio" },
+};
diff --git a/products/desktop/packages/ui/src/features/onboarding/components/GithubConnectionLink.tsx b/products/desktop/packages/ui/src/features/onboarding/components/GithubConnectionLink.tsx
new file mode 100644
index 000000000000..b5bf0d5ec35d
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/onboarding/components/GithubConnectionLink.tsx
@@ -0,0 +1,62 @@
+import { GithubLogo } from "@phosphor-icons/react";
+import { cn } from "@posthog/quill";
+import Logo from "@posthog/ui/primitives/Logo";
+import { Flex, Text } from "@radix-ui/themes";
+import type { ReactNode } from "react";
+
+function Tile({ children }: { children: ReactNode }) {
+ return (
+ <Flex
+ align="center"
+ justify="center"
+ className="size-[48px] shrink-0 rounded-[12px] border border-(--gray-a4) bg-(--color-panel-solid)"
+ >
+ {children}
+ </Flex>
+ );
+}
+
+interface GithubConnectionLinkProps {
+ connected: boolean;
+ /** Shown under the link once a connection exists. */
+ accountLabel?: string | null;
+}
+
+/** The link between the two marks carries the connection state. */
+export function GithubConnectionLink({
+ connected,
+ accountLabel,
+}: GithubConnectionLinkProps) {
+ return (
+ <Flex direction="column" align="center" gap="2">
+ <Flex align="center">
+ <Tile>
+ <span className="[&>svg]:h-[17px] [&>svg]:w-auto">
+ <Logo wordmark={false} />
+ </span>
+ </Tile>
+ <div
+ className={cn(
+ "w-[56px] border-t-2 transition-colors duration-300",
+ connected
+ ? "border-(--green-9) border-solid"
+ : "border-(--gray-a6) border-dashed",
+ )}
+ />
+ <Tile>
+ <GithubLogo
+ size={26}
+ weight="fill"
+ className={cn(
+ "transition-colors duration-300",
+ connected ? "text-(--gray-12)" : "text-(--gray-9)",
+ )}
+ />
+ </Tile>
+ </Flex>
+ {connected && accountLabel && (
+ <Text className="text-(--green-11) text-[13px]">{accountLabel}</Text>
+ )}
+ </Flex>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/onboarding/components/InstallCliStep.tsx b/products/desktop/packages/ui/src/features/onboarding/components/InstallCliStep.tsx
index 8c9fa7f9e21f..8fe1927c9c97 100644
--- a/products/desktop/packages/ui/src/features/onboarding/components/InstallCliStep.tsx
+++ b/products/desktop/packages/ui/src/features/onboarding/components/InstallCliStep.tsx
@@ -267,7 +267,7 @@ export function InstallCliStep({ onNext, onBack }: InstallCliStepProps) {
<Flex
direction="column"
gap="5"
- className="m-auto w-full max-w-[560px]"
+ className="m-auto w-full max-w-[480px]"
>
<Flex direction="column" gap="5" className="w-full">
<motion.div
diff --git a/products/desktop/packages/ui/src/features/onboarding/components/OnboardingFlow.tsx b/products/desktop/packages/ui/src/features/onboarding/components/OnboardingFlow.tsx
index e0a9970578d1..dc93b99e4239 100644
--- a/products/desktop/packages/ui/src/features/onboarding/components/OnboardingFlow.tsx
+++ b/products/desktop/packages/ui/src/features/onboarding/components/OnboardingFlow.tsx
@@ -26,7 +26,6 @@ import { ConsentStep } from "@posthog/ui/features/consent/ConsentStep";
import { useUserGithubIntegrations } from "@posthog/ui/features/integrations/useIntegrations";
import { ConnectGitHubStep } from "@posthog/ui/features/onboarding/components/ConnectGitHubStep";
import { InstallCliStep } from "@posthog/ui/features/onboarding/components/InstallCliStep";
-import { StepIndicator } from "@posthog/ui/features/onboarding/components/StepIndicator";
import { useOnboardingFlow } from "@posthog/ui/features/onboarding/hooks/useOnboardingFlow";
import { useOnboardingStore } from "@posthog/ui/features/onboarding/onboardingStore";
import { useSettingsStore } from "@posthog/ui/features/settings/settingsStore";
@@ -39,7 +38,7 @@ import { logger } from "@posthog/ui/shell/logger";
import { useHostCapabilities } from "@posthog/ui/shell/useHostCapabilities";
import { Button, Flex } from "@radix-ui/themes";
import { useQueryClient } from "@tanstack/react-query";
-import { AnimatePresence, LayoutGroup, motion } from "framer-motion";
+import { AnimatePresence, motion } from "framer-motion";
import { useEffect, useRef, useState } from "react";
import { useHotkeys } from "react-hotkeys-hook";
import { ProjectSelectStep } from "./ProjectSelectStep";
@@ -312,7 +311,7 @@ export function OnboardingFlow({ onOpenSupport }: OnboardingFlowProps) {
Log out
</Button>
)}
- {IS_DEV && (
+ {IS_DEV && isAuthenticated && (
<Button
size="1"
variant="ghost"
@@ -329,101 +328,97 @@ export function OnboardingFlow({ onOpenSupport }: OnboardingFlowProps) {
return (
<FullScreenLayout footerRight={footerRight} onOpenSupport={onOpenSupport}>
- <LayoutGroup>
- <AnimatePresence mode="wait" custom={direction}>
- {currentStep === "project-select" && (
- <motion.div
- key="project-select"
- custom={direction}
- initial="enter"
- animate="center"
- exit="exit"
- variants={stepVariants}
- transition={{ duration: 0.3 }}
- className="min-h-0 w-full flex-1"
- >
- <ProjectSelectStep onNext={handleNext} onBack={onBack} />
- </motion.div>
- )}
+ <AnimatePresence mode="wait" custom={direction}>
+ {currentStep === "project-select" && (
+ <motion.div
+ key="project-select"
+ custom={direction}
+ initial="enter"
+ animate="center"
+ exit="exit"
+ variants={stepVariants}
+ transition={{ duration: 0.3 }}
+ className="min-h-0 w-full flex-1"
+ >
+ <ProjectSelectStep onNext={handleNext} onBack={onBack} />
+ </motion.div>
+ )}
- {currentStep === "consent" && (
- <motion.div
- key="consent"
- custom={direction}
- initial="enter"
- animate="center"
- exit="exit"
- variants={stepVariants}
- transition={{ duration: 0.3 }}
- className="min-h-0 w-full flex-1"
- >
- <ConsentStep
- onNext={handleNext}
- onBack={onBack}
- requirements={consentRequirement}
- onSubmittingChange={setConsentSubmitting}
- />
- </motion.div>
- )}
+ {currentStep === "consent" && (
+ <motion.div
+ key="consent"
+ custom={direction}
+ initial="enter"
+ animate="center"
+ exit="exit"
+ variants={stepVariants}
+ transition={{ duration: 0.3 }}
+ className="min-h-0 w-full flex-1"
+ >
+ <ConsentStep
+ onNext={handleNext}
+ onBack={onBack}
+ requirements={consentRequirement}
+ onSubmittingChange={setConsentSubmitting}
+ />
+ </motion.div>
+ )}
- {currentStep === "connect-github" && (
- <motion.div
- key="connect-github"
- custom={direction}
- initial="enter"
- animate="center"
- exit="exit"
- variants={stepVariants}
- transition={{ duration: 0.3 }}
- className="min-h-0 w-full flex-1"
- >
- <ConnectGitHubStep onNext={handleNext} onBack={onBack} />
- </motion.div>
- )}
+ {currentStep === "connect-github" && (
+ <motion.div
+ key="connect-github"
+ custom={direction}
+ initial="enter"
+ animate="center"
+ exit="exit"
+ variants={stepVariants}
+ transition={{ duration: 0.3 }}
+ className="min-h-0 w-full flex-1"
+ >
+ <ConnectGitHubStep onNext={handleNext} onBack={onBack} />
+ </motion.div>
+ )}
- {currentStep === "install-cli" && (
- <motion.div
- key="install-cli"
- custom={direction}
- initial="enter"
- animate="center"
- exit="exit"
- variants={stepVariants}
- transition={{ duration: 0.3 }}
- className="min-h-0 w-full flex-1"
- >
- <InstallCliStep onNext={handleNext} onBack={handleBack} />
- </motion.div>
- )}
+ {currentStep === "install-cli" && (
+ <motion.div
+ key="install-cli"
+ custom={direction}
+ initial="enter"
+ animate="center"
+ exit="exit"
+ variants={stepVariants}
+ transition={{ duration: 0.3 }}
+ className="min-h-0 w-full flex-1"
+ >
+ <InstallCliStep onNext={handleNext} onBack={handleBack} />
+ </motion.div>
+ )}
- {currentStep === "select-repo" && (
- <motion.div
- key="select-repo"
- custom={direction}
- initial="enter"
- animate="center"
- exit="exit"
- variants={stepVariants}
- transition={{ duration: 0.3 }}
- className="min-h-0 w-full flex-1"
- >
- <SelectRepoStep
- onComplete={handleComplete}
- onBack={handleBack}
- selectedDirectory={selectedDirectory}
- detectedRepo={detectedRepo}
- isDetectingRepo={isDetectingRepo}
- onDirectoryChange={handleDirectoryChange}
- selectedCloudRepo={selectedCloudRepo}
- onCloudRepoChange={handleCloudRepoChange}
- hasGithubIntegration={hasGithubIntegration}
- />
- </motion.div>
- )}
- </AnimatePresence>
-
- <StepIndicator currentStep={currentStep} activeSteps={activeSteps} />
- </LayoutGroup>
+ {currentStep === "select-repo" && (
+ <motion.div
+ key="select-repo"
+ custom={direction}
+ initial="enter"
+ animate="center"
+ exit="exit"
+ variants={stepVariants}
+ transition={{ duration: 0.3 }}
+ className="min-h-0 w-full flex-1"
+ >
+ <SelectRepoStep
+ onComplete={handleComplete}
+ onBack={handleBack}
+ selectedDirectory={selectedDirectory}
+ detectedRepo={detectedRepo}
+ isDetectingRepo={isDetectingRepo}
+ onDirectoryChange={handleDirectoryChange}
+ selectedCloudRepo={selectedCloudRepo}
+ onCloudRepoChange={handleCloudRepoChange}
+ hasGithubIntegration={hasGithubIntegration}
+ />
+ </motion.div>
+ )}
+ </AnimatePresence>
</FullScreenLayout>
);
}
diff --git a/products/desktop/packages/ui/src/features/onboarding/components/ProjectSelectStep.tsx b/products/desktop/packages/ui/src/features/onboarding/components/ProjectSelectStep.tsx
index f8761098cd3c..ffbf3530b781 100644
--- a/products/desktop/packages/ui/src/features/onboarding/components/ProjectSelectStep.tsx
+++ b/products/desktop/packages/ui/src/features/onboarding/components/ProjectSelectStep.tsx
@@ -6,32 +6,32 @@ import {
} from "@phosphor-icons/react";
import {
Combobox,
+ ComboboxCollection,
ComboboxContent,
ComboboxEmpty,
+ ComboboxGroup,
ComboboxInput,
ComboboxItem,
+ ComboboxLabel,
ComboboxList,
ComboboxTrigger,
} from "@posthog/quill";
+import { REGION_LABELS } from "@posthog/shared";
import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";
-import { happyHog } from "@posthog/ui/assets/hedgehogs";
import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
-import { SignInCard } from "@posthog/ui/features/auth/SignInCard";
+import { OAuthControls } from "@posthog/ui/features/auth/OAuthControls";
import {
useAuthStateFetched,
useAuthStateValue,
} from "@posthog/ui/features/auth/store";
-import {
- useSelectProjectMutation,
- useSwitchOrgMutation,
-} from "@posthog/ui/features/auth/useAuthMutations";
+import { useSelectProjectMutation } from "@posthog/ui/features/auth/useAuthMutations";
import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";
import { StepActions } from "@posthog/ui/features/onboarding/components/StepActions";
import {
type ProjectInfo,
useProjects,
} from "@posthog/ui/features/projects/useProjects";
-import { OnboardingHogTip } from "@posthog/ui/primitives/OnboardingHogTip";
+import { ProductWordmark } from "@posthog/ui/primitives/ProductWordmark";
import { track } from "@posthog/ui/shell/analytics";
import { logger } from "@posthog/ui/shell/logger";
import {
@@ -39,16 +39,16 @@ import {
FIELD_TRIGGER_CLASS,
} from "@posthog/ui/styles/fieldTrigger";
import { Button, Flex, Spinner, Text } from "@radix-ui/themes";
-import { useMutation } from "@tanstack/react-query";
import { AnimatePresence, motion } from "framer-motion";
-import { useEffect, useMemo, useRef, useState } from "react";
+import { useMemo, useRef, useState } from "react";
const log = logger.scope("project-select-step");
-interface Org {
- id: string;
- name: string;
- slug: string;
+/** Base UI reads nested options from `items`, so groups carry that field. */
+interface ProjectGroup {
+ orgId: string;
+ orgName: string;
+ items: ProjectInfo[];
}
interface ProjectSelectStepProps {
@@ -56,72 +56,72 @@ interface ProjectSelectStepProps {
onBack?: () => void;
}
+/** The sign-in button resolves into this, so signing in reads as a completed line. */
+function SignedInRow({ email }: { email: string | undefined }) {
+ const cloudRegion = useAuthStateValue((state) => state.cloudRegion);
+ const region = cloudRegion ? REGION_LABELS[cloudRegion].label : null;
+ return (
+ <Flex
+ align="center"
+ gap="2"
+ className="h-[44px] w-full rounded-[6px] border border-(--gray-a4) px-[14px]"
+ >
+ <CheckCircle
+ size={16}
+ weight="fill"
+ className="shrink-0 text-(--green-9)"
+ />
+ <Text className="min-w-0 truncate text-(--gray-12) text-sm">
+ Signed in as {email ?? "your PostHog account"}
+ </Text>
+ {region && (
+ <Text className="ml-auto shrink-0 text-(--gray-11) text-xs">
+ {region}
+ </Text>
+ )}
+ </Flex>
+ );
+}
+
export function ProjectSelectStep({ onNext, onBack }: ProjectSelectStepProps) {
const authFetched = useAuthStateFetched();
const isAuthenticated =
useAuthStateValue((state) => state.status) === "authenticated";
const selectProjectMutation = useSelectProjectMutation();
const currentProjectId = useAuthStateValue((state) => state.currentProjectId);
- const { projects, currentProject } = useProjects();
+ const { projects, currentProject, groupedProjects } = useProjects();
const [projectOpen, setProjectOpen] = useState(false);
- const [orgOpen, setOrgOpen] = useState(false);
- const [isSwitchingOrg, setIsSwitchingOrg] = useState(false);
- const orgAnchorRef = useRef<HTMLButtonElement>(null);
const projectAnchorRef = useRef<HTMLButtonElement>(null);
const client = useOptionalAuthenticatedClient();
- const { data: fullUser, isLoading } = useCurrentUser({
- client,
- });
- const switchOrgTrpcMutation = useSwitchOrgMutation();
+ const { data: fullUser, isLoading } = useCurrentUser({ client });
- const organizations = useMemo<Org[]>(() => {
- if (!fullUser?.organizations) return [];
- return fullUser.organizations as Org[];
- }, [fullUser]);
+ const hasMultipleOrgs = (fullUser?.organizations?.length ?? 0) > 1;
- const currentOrg = fullUser?.organization as
- | { id: string; name: string }
- | undefined;
- const hasMultipleOrgs = organizations.length > 1;
-
- const sortedOrgs = useMemo(
- () => [...organizations].sort((a, b) => a.name.localeCompare(b.name)),
- [organizations],
- );
const sortedProjects = useMemo(
- () => [...projects].sort((a, b) => a.name.localeCompare(b.name)),
+ () => projects.toSorted((a, b) => a.name.localeCompare(b.name)),
[projects],
);
-
- const selectedOrg = useMemo(
- () => sortedOrgs.find((o) => o.id === currentOrg?.id) ?? null,
- [sortedOrgs, currentOrg?.id],
+ // Selecting a project already switches the org for it (AuthService.selectProject),
+ // so the list stays grouped rather than gated behind a separate org picker.
+ const sortedGroups = useMemo(
+ () =>
+ groupedProjects
+ .toSorted((a, b) => a.orgName.localeCompare(b.orgName))
+ .map((group) => ({
+ orgId: group.orgId,
+ orgName: group.orgName,
+ items: group.projects.toSorted((a, b) =>
+ a.name.localeCompare(b.name),
+ ),
+ })),
+ [groupedProjects],
);
const selectedProject = useMemo(
() => sortedProjects.find((p) => p.id === currentProjectId) ?? null,
[sortedProjects, currentProjectId],
);
- const switchOrgMutation = useMutation({
- mutationFn: async (orgId: string) => {
- await switchOrgTrpcMutation.mutateAsync(orgId);
- },
- onMutate: () => {
- setIsSwitchingOrg(true);
- },
- onError: (err) => {
- setIsSwitchingOrg(false);
- log.error("Failed to switch organization", err);
- },
- });
-
- useEffect(() => {
- if (isSwitchingOrg && !switchOrgMutation.isPending && !isLoading) {
- setIsSwitchingOrg(false);
- }
- }, [isSwitchingOrg, switchOrgMutation.isPending, isLoading]);
-
return (
<Flex align="center" justify="center" height="100%" px="8">
<Flex
@@ -136,245 +136,148 @@ export function ProjectSelectStep({ onNext, onBack }: ProjectSelectStepProps) {
>
<Flex
direction="column"
- align="start"
- gap="5"
+ gap="6"
style={{ margin: "auto 0" }}
className="w-full"
>
- {/* Header + form */}
- <Flex direction="column" gap="5" className="w-full">
- {/* Section 1: Sign in */}
- <Flex direction="column" gap="3" className="w-full">
- <AnimatePresence mode="wait">
- {isAuthenticated ? (
- <motion.div
- key="signed-in"
- initial={{ opacity: 0, y: 4 }}
- animate={{ opacity: 1, y: 0 }}
- transition={{ duration: 0.2 }}
- >
- <Flex direction="column" gap="2">
- <Text className="font-bold text-(--gray-12) text-2xl">
- Pick your PostHog home base
- </Text>
- <Text className="text-(--gray-11) text-sm">
- Choose the organization and project you want to work
- in.
- </Text>
- </Flex>
- </motion.div>
- ) : authFetched ? (
- <motion.div
- key="oauth"
- initial={{ opacity: 1 }}
- exit={{ opacity: 0, y: -4 }}
- transition={{ duration: 0.2 }}
- >
- <SignInCard
- hogSrc={happyHog}
- hogMessage="I don't bite. Just need to know who I'm working with."
- subtitle="Connect your account to get started."
- onAuthInitiated={(region) =>
- track(ANALYTICS_EVENTS.ONBOARDING_SIGN_IN_INITIATED, {
- region,
- })
- }
- />
- </motion.div>
- ) : null}
- </AnimatePresence>
- </Flex>
+ <div className="flex justify-center">
+ <ProductWordmark />
+ </div>
- {/* Sections 2+3: Org & project selectors (authenticated only) */}
- {isAuthenticated && (isLoading || isSwitchingOrg) && (
- <Flex align="center" justify="center" className="h-[80px]">
- <Spinner size="3" />
- </Flex>
- )}
-
- {isAuthenticated && !isSwitchingOrg && hasMultipleOrgs && (
+ <AnimatePresence mode="wait">
+ {isAuthenticated ? (
<motion.div
- initial={{ opacity: 0, y: 8 }}
+ key="signed-in"
+ initial={{ opacity: 0, y: 4 }}
animate={{ opacity: 1, y: 0 }}
- transition={{ duration: 0.3 }}
+ transition={{ duration: 0.2 }}
className="w-full"
>
- <Flex direction="column" gap="2" className="w-full">
- <Text className="font-medium text-(--gray-11) text-sm">
- Organization
- </Text>
-
- <Combobox<Org>
- items={sortedOrgs}
- value={selectedOrg}
- onValueChange={(value) => {
- const org = value as Org | null;
- if (org && org.id !== currentOrg?.id) {
- switchOrgMutation.mutate(org.id);
- }
- setOrgOpen(false);
- }}
- open={orgOpen}
- onOpenChange={setOrgOpen}
- itemToStringLabel={(org) => org.name}
- itemToStringValue={(org) => org.id}
- >
- <ComboboxTrigger
- render={
- <button
- ref={orgAnchorRef}
- type="button"
- className={FIELD_TRIGGER_CLASS}
- >
- <Text className="min-w-0 flex-1 truncate text-left font-medium text-(--gray-12)">
- {currentOrg?.name ?? "Select organization..."}
- </Text>
- <CaretDown
- size={14}
- className="shrink-0 text-(--gray-9)"
- />
- </button>
- }
- />
- <ComboboxContent
- anchor={orgAnchorRef}
- side="bottom"
- align="start"
- sideOffset={4}
- className={FIELD_CONTENT_CLASS}
- >
- <ComboboxInput
- placeholder="Search organizations..."
- showTrigger={false}
- />
- <ComboboxEmpty>No organizations found.</ComboboxEmpty>
- <ComboboxList className="max-h-[240px]">
- {(org: Org) => (
- <ComboboxItem
- key={org.id}
- value={org}
- title={org.name}
- >
- <Text>{org.name}</Text>
- </ComboboxItem>
- )}
- </ComboboxList>
- </ComboboxContent>
- </Combobox>
- </Flex>
+ <SignedInRow email={fullUser?.email} />
</motion.div>
- )}
-
- {/* Section 3: Project selector (only when authenticated, not switching, and loaded) */}
- {isAuthenticated && !isSwitchingOrg && !isLoading && (
+ ) : authFetched ? (
<motion.div
- initial={{ opacity: 0, y: 8 }}
- animate={{ opacity: 1, y: 0 }}
- transition={{ duration: 0.3, delay: 0.05 }}
+ key="oauth"
+ initial={{ opacity: 1 }}
+ exit={{ opacity: 0, y: -4 }}
+ transition={{ duration: 0.2 }}
className="w-full"
>
- <Flex direction="column" gap="2" className="w-full">
- <Text className="font-medium text-(--gray-11) text-sm">
- Project
- </Text>
- <Combobox<ProjectInfo>
- items={sortedProjects}
- value={selectedProject}
- onValueChange={(value) => {
- const project = value as ProjectInfo | null;
- if (project) {
- selectProjectMutation.mutate(project.id);
- }
- setProjectOpen(false);
- }}
- open={projectOpen}
- onOpenChange={setProjectOpen}
- itemToStringLabel={(project) => project.name}
- itemToStringValue={(project) => String(project.id)}
- >
- <ComboboxTrigger
- render={
- <button
- ref={projectAnchorRef}
- type="button"
- className={FIELD_TRIGGER_CLASS}
- >
- <Flex
- direction="column"
- gap="1"
- align="start"
- className="min-w-0 flex-1 text-left"
- >
- <Text className="min-w-0 max-w-full truncate font-medium text-(--gray-12)">
- {currentProject?.name ?? "Select a project..."}
- </Text>
- {currentProject && !hasMultipleOrgs && (
- <Text className="min-w-0 max-w-full truncate text-(--gray-11) text-[13px]">
- {currentProject.organization.name}
- </Text>
- )}
- </Flex>
- <CaretDown
- size={14}
- className="shrink-0 text-(--gray-9)"
- />
- </button>
- }
- />
- <ComboboxContent
- anchor={projectAnchorRef}
- side="bottom"
- align="start"
- sideOffset={4}
- className={FIELD_CONTENT_CLASS}
- >
- <ComboboxInput
- placeholder="Search projects..."
- showTrigger={false}
- />
- <ComboboxEmpty>No projects found.</ComboboxEmpty>
- <ComboboxList className="max-h-[240px]">
- {(project: ProjectInfo) => (
- <ComboboxItem
- key={project.id}
- value={project}
- title={project.name}
- >
- <Text>{project.name}</Text>
- </ComboboxItem>
- )}
- </ComboboxList>
- </ComboboxContent>
- </Combobox>
- </Flex>
+ <OAuthControls
+ onAuthInitiated={(region) =>
+ track(ANALYTICS_EVENTS.ONBOARDING_SIGN_IN_INITIATED, {
+ region,
+ })
+ }
+ />
</motion.div>
- )}
+ ) : null}
+ </AnimatePresence>
- {/* Signed in confirmation */}
- {isAuthenticated && !isLoading && !isSwitchingOrg && (
- <Flex
- align="center"
- gap="2"
- className="self-start rounded-[8px] border border-(--green-a5) bg-(--green-a2) px-[12px] py-[8px]"
- >
- <CheckCircle
- size={16}
- weight="fill"
- className="text-(--green-9)"
- />
- <Text className="text-(--green-11) text-sm">
- Signed in as {fullUser?.email}
+ {isAuthenticated && isLoading && (
+ <Flex align="center" justify="center" className="h-[80px]">
+ <Spinner size="3" />
+ </Flex>
+ )}
+
+ {isAuthenticated && !isLoading && (
+ <motion.div
+ initial={{ opacity: 0, y: 8 }}
+ animate={{ opacity: 1, y: 0 }}
+ transition={{ duration: 0.3 }}
+ className="w-full"
+ >
+ <Flex direction="column" gap="2" className="w-full">
+ <Text className="font-medium text-(--gray-11) text-sm">
+ Project
</Text>
+ <Combobox
+ items={sortedGroups}
+ value={selectedProject}
+ onValueChange={(value) => {
+ const project = value as ProjectInfo | null;
+ if (project) {
+ selectProjectMutation.mutate(project.id, {
+ onError: (error) =>
+ log.error("Failed to select project", error),
+ });
+ }
+ setProjectOpen(false);
+ }}
+ open={projectOpen}
+ onOpenChange={setProjectOpen}
+ disabled={selectProjectMutation.isPending}
+ itemToStringLabel={(project) => project.name}
+ itemToStringValue={(project) => String(project.id)}
+ >
+ <ComboboxTrigger
+ render={
+ <button
+ ref={projectAnchorRef}
+ type="button"
+ className={FIELD_TRIGGER_CLASS}
+ >
+ <Flex
+ direction="column"
+ gap="1"
+ align="start"
+ className="min-w-0 flex-1 text-left"
+ >
+ <Text className="min-w-0 max-w-full truncate font-medium text-(--gray-12)">
+ {currentProject?.name ?? "Select a project..."}
+ </Text>
+ {currentProject && (
+ <Text className="min-w-0 max-w-full truncate text-(--gray-11) text-[13px]">
+ {currentProject.organization.name}
+ </Text>
+ )}
+ </Flex>
+ <CaretDown
+ size={14}
+ className="shrink-0 text-(--gray-9)"
+ />
+ </button>
+ }
+ />
+ <ComboboxContent
+ anchor={projectAnchorRef}
+ side="bottom"
+ align="start"
+ sideOffset={4}
+ className={FIELD_CONTENT_CLASS}
+ >
+ <ComboboxInput
+ placeholder="Search projects..."
+ showTrigger={false}
+ />
+ <ComboboxEmpty>No projects found.</ComboboxEmpty>
+ <ComboboxList className="max-h-[240px]">
+ {(group: ProjectGroup) => (
+ <ComboboxGroup key={group.orgId} items={group.items}>
+ <ComboboxLabel>{group.orgName}</ComboboxLabel>
+ <ComboboxCollection>
+ {(project: ProjectInfo) => (
+ <ComboboxItem
+ key={project.id}
+ value={project}
+ title={project.name}
+ >
+ <Text>{project.name}</Text>
+ </ComboboxItem>
+ )}
+ </ComboboxCollection>
+ </ComboboxGroup>
+ )}
+ </ComboboxList>
+ </ComboboxContent>
+ </Combobox>
+ {selectProjectMutation.isError && (
+ <Text className="text-(--red-11) text-[13px]">
+ Couldn't switch to that project. Try again.
+ </Text>
+ )}
</Flex>
- )}
- </Flex>
-
- {/* Hog tip */}
- {isAuthenticated && !isLoading && !isSwitchingOrg && (
- <OnboardingHogTip
- hogSrc={happyHog}
- message="I'll use data from this project to help drive product decisions."
- />
+ </motion.div>
)}
</Flex>
</Flex>
@@ -396,7 +299,10 @@ export function ProjectSelectStep({ onNext, onBack }: ProjectSelectStepProps) {
});
onNext();
}}
- disabled={currentProjectId == null}
+ loading={selectProjectMutation.isPending}
+ disabled={
+ currentProjectId == null || selectProjectMutation.isPending
+ }
>
Continue
<ArrowRight size={16} weight="bold" />
diff --git a/products/desktop/packages/ui/src/features/onboarding/components/SelectRepoStep.tsx b/products/desktop/packages/ui/src/features/onboarding/components/SelectRepoStep.tsx
index e07842d4abba..7c0f3ac5d153 100644
--- a/products/desktop/packages/ui/src/features/onboarding/components/SelectRepoStep.tsx
+++ b/products/desktop/packages/ui/src/features/onboarding/components/SelectRepoStep.tsx
@@ -3,23 +3,18 @@ import {
ArrowRight,
CheckCircle,
CircleNotch,
- FolderOpen,
- Lightbulb,
} from "@phosphor-icons/react";
import { repoMatchesGitHubRepos } from "@posthog/core/onboarding/repoProvider";
import { cn } from "@posthog/quill";
import { useHostCapabilities } from "@posthog/ui/shell/useHostCapabilities";
-import { Box, Button, Flex, Text } from "@radix-ui/themes";
+import { Button, Flex, Text } from "@radix-ui/themes";
import { AnimatePresence, motion } from "framer-motion";
import { useMemo, useState } from "react";
-import { builderHog } from "../../../assets/hedgehogs";
-import { OnboardingHogTip } from "../../../primitives/OnboardingHogTip";
import { FolderPicker } from "../../folder-picker/FolderPicker";
import { GitHubRepoPicker } from "../../folder-picker/GitHubRepoPicker";
import { useUserRepositoryIntegration } from "../../integrations/useIntegrations";
import type { DetectedRepo } from "../types";
import { OptionalBadge } from "./OptionalBadge";
-import { PANEL_SHADOW } from "./onboardingStyles";
import { StepActions } from "./StepActions";
interface SelectRepoStepProps {
@@ -74,212 +69,175 @@ export function SelectRepoStep({
: !!selectedDirectory;
return (
- <Flex align="center" height="100%" px="8">
+ <Flex align="center" justify="center" height="100%" px="8">
<Flex
direction="column"
align="center"
- className="h-full w-full pt-[24px] pb-[40px]"
+ className="h-full w-full max-w-[480px] pt-[24px] pb-[40px]"
>
- <Flex direction="column" className="min-h-0 flex-1 overflow-y-auto">
+ <Flex
+ direction="column"
+ align="center"
+ className="min-h-0 w-full flex-1 overflow-y-auto"
+ >
<Flex
direction="column"
gap="5"
- className="m-auto w-full max-w-[560px]"
+ style={{ margin: "auto 0" }}
+ className="w-full"
>
- <Flex direction="column" gap="5" className="w-full">
- <motion.div
- initial={{ opacity: 0, y: 8 }}
- animate={{ opacity: 1, y: 0 }}
- transition={{ duration: 0.3 }}
- >
- <Flex direction="column" gap="2">
- <Flex align="center" gap="2">
- <Text className="font-bold text-(--gray-12) text-2xl">
- Pick a repo to get started
- </Text>
- <OptionalBadge />
- </Flex>
- <Text className="text-(--gray-11) text-sm">
- We'll scan it and suggest some first things to work on. You
- can also skip this and start from a blank task.
+ <motion.div
+ initial={{ opacity: 0, y: 8 }}
+ animate={{ opacity: 1, y: 0 }}
+ transition={{ duration: 0.3 }}
+ >
+ <Flex direction="column" gap="2">
+ <Flex align="center" gap="2">
+ <Text className="font-bold text-(--gray-12) text-2xl">
+ Pick a repo
</Text>
+ <OptionalBadge />
</Flex>
- </motion.div>
+ <Text className="text-(--gray-11) text-sm">
+ New tasks use this repo by default. You can change it any time
+ from the home screen.
+ </Text>
+ </Flex>
+ </motion.div>
- <motion.div
- initial={{ opacity: 0, y: 8 }}
- animate={{ opacity: 1, y: 0 }}
- transition={{ duration: 0.3, delay: 0.05 }}
- >
- <Box
- p="5"
- style={{ boxShadow: PANEL_SHADOW }}
- className="rounded-[12px] border border-(--gray-a3) bg-(--color-panel-solid)"
- >
- <Flex direction="column" gap="4">
- <Flex direction="column" gap="1">
+ <motion.div
+ initial={{ opacity: 0, y: 8 }}
+ animate={{ opacity: 1, y: 0 }}
+ transition={{ duration: 0.3, delay: 0.05 }}
+ >
+ <Flex direction="column" gap="2" className="w-full">
+ {repoSource === "github" ? (
+ <GitHubRepoPicker
+ value={
+ localWorkspaces
+ ? selectedCloudRepo
+ : selectedDirectory || null
+ }
+ onChange={(repo) =>
+ localWorkspaces
+ ? onCloudRepoChange(repo)
+ : onDirectoryChange(repo ?? "")
+ }
+ repositories={repositories}
+ isLoading={isLoadingRepos}
+ onRefresh={refreshRepositories}
+ isRefreshing={isRefreshingRepos}
+ placeholder="Select repository..."
+ variant="field"
+ />
+ ) : (
+ <FolderPicker
+ variant="field"
+ value={selectedDirectory}
+ onChange={onDirectoryChange}
+ placeholder="Select repository..."
+ />
+ )}
+
+ <AnimatePresence mode="wait">
+ {repoSource === "local" && isDetectingRepo && (
+ <motion.div
+ key="detecting"
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ transition={{ duration: 0.15 }}
+ >
<Flex align="center" gap="2">
- <FolderOpen size={18} className="text-(--gray-12)" />
- <Text className="font-bold text-(--gray-12) text-base">
- Choose your repository
+ <CircleNotch
+ size={14}
+ className="animate-spin text-(--gray-9)"
+ />
+ <Text className="text-(--gray-9) text-[13px]">
+ Detecting repository...
</Text>
</Flex>
- <Text className="text-(--gray-11) text-sm">
- {repoSource === "github"
- ? "Pick a repository from your connected GitHub organizations. Tasks on it run in cloud sandboxes."
- : "Select a single repository folder, not a parent folder that contains multiple repos."}
- </Text>
- </Flex>
- {repoSource === "github" ? (
- <GitHubRepoPicker
- value={
- localWorkspaces
- ? selectedCloudRepo
- : selectedDirectory || null
- }
- onChange={(repo) =>
- localWorkspaces
- ? onCloudRepoChange(repo)
- : onDirectoryChange(repo ?? "")
- }
- repositories={repositories}
- isLoading={isLoadingRepos}
- onRefresh={refreshRepositories}
- isRefreshing={isRefreshingRepos}
- placeholder="Select repository..."
- />
- ) : (
- <FolderPicker
- variant="field"
- value={selectedDirectory}
- onChange={onDirectoryChange}
- placeholder="Select repository..."
- />
+ </motion.div>
+ )}
+ {repoSource === "local" &&
+ !isDetectingRepo &&
+ selectedDirectory &&
+ detectedRepo && (
+ <motion.div
+ key="detected"
+ initial={{ opacity: 0, y: 4 }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ opacity: 0 }}
+ transition={{ duration: 0.2 }}
+ >
+ <Flex align="center" gap="2">
+ <CheckCircle
+ size={14}
+ weight="fill"
+ className={
+ repoMatchesGitHub
+ ? "text-(--green-9)"
+ : "text-(--gray-9)"
+ }
+ />
+ <Text
+ className={cn(
+ "text-[13px]",
+ repoMatchesGitHub
+ ? "text-(--green-11)"
+ : "text-(--gray-11)",
+ )}
+ >
+ {repoMatchesGitHub
+ ? `Linked to ${detectedRepo.fullName} on GitHub`
+ : `Detected ${detectedRepo.fullName}`}
+ </Text>
+ </Flex>
+ </motion.div>
)}
- {showSourceSwitch && (
- <button
- type="button"
- onClick={() => {
- const nextSource =
- repoSource === "github" ? "local" : "github";
- // Clear the source being left so a later Skip cannot
- // silently assign or persist a repo the user
- // navigated away from.
- if (nextSource === "local") {
- onCloudRepoChange(null);
- } else {
- onDirectoryChange("");
- }
- setChosenSource(nextSource);
- }}
- className="cursor-pointer self-start border-0 bg-transparent p-0 text-(--gray-10) text-[13px] underline hover:text-(--gray-11)"
+ {repoSource === "local" &&
+ !isDetectingRepo &&
+ selectedDirectory &&
+ !detectedRepo && (
+ <motion.div
+ key="no-repo"
+ initial={{ opacity: 0, y: 4 }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ opacity: 0 }}
+ transition={{ duration: 0.2 }}
>
- {repoSource === "github"
- ? "Use a local folder instead"
- : "Back to GitHub repos"}
- </button>
+ <Text className="text-(--gray-9) text-[13px]">
+ No git remote detected. You can still continue.
+ </Text>
+ </motion.div>
)}
- <AnimatePresence mode="wait">
- {repoSource === "local" && isDetectingRepo && (
- <motion.div
- key="detecting"
- initial={{ opacity: 0 }}
- animate={{ opacity: 1 }}
- exit={{ opacity: 0 }}
- transition={{ duration: 0.15 }}
- >
- <Flex align="center" gap="2">
- <CircleNotch
- size={14}
- className="animate-spin text-(--gray-9)"
- />
- <Text className="text-(--gray-9) text-[13px]">
- Detecting repository...
- </Text>
- </Flex>
- </motion.div>
- )}
- {repoSource === "local" &&
- !isDetectingRepo &&
- selectedDirectory &&
- detectedRepo && (
- <motion.div
- key="detected"
- initial={{ opacity: 0, y: 4 }}
- animate={{ opacity: 1, y: 0 }}
- exit={{ opacity: 0 }}
- transition={{ duration: 0.2 }}
- >
- <Flex align="center" gap="2">
- <CheckCircle
- size={14}
- weight="fill"
- className={
- repoMatchesGitHub
- ? "text-(--green-9)"
- : "text-(--gray-9)"
- }
- />
- <Text
- className={cn(
- "text-[13px]",
- repoMatchesGitHub
- ? "text-(--green-11)"
- : "text-(--gray-11)",
- )}
- >
- {repoMatchesGitHub
- ? `Linked to ${detectedRepo.fullName} on GitHub`
- : `Detected ${detectedRepo.fullName}`}
- </Text>
- </Flex>
- </motion.div>
- )}
- {repoSource === "local" &&
- !isDetectingRepo &&
- selectedDirectory &&
- !detectedRepo && (
- <motion.div
- key="no-repo"
- initial={{ opacity: 0, y: 4 }}
- animate={{ opacity: 1, y: 0 }}
- exit={{ opacity: 0 }}
- transition={{ duration: 0.2 }}
- >
- <Text className="text-(--gray-9) text-[13px]">
- No git remote detected. You can still continue.
- </Text>
- </motion.div>
- )}
- </AnimatePresence>
- </Flex>
- </Box>
- </motion.div>
-
- <motion.div
- initial={{ opacity: 0, y: 8 }}
- animate={{ opacity: 1, y: 0 }}
- transition={{ duration: 0.3, delay: 0.08 }}
- >
- <Flex align="start" gap="2">
- <Lightbulb
- size={16}
- className="mt-[2px] shrink-0 text-(--gray-10)"
- />
- <Text className="text-(--gray-10) text-[13px]">
- Once you pick a repo we'll look for things like stale
- feature flags, missing tracking, and other low-effort wins
- to start from.
- </Text>
- </Flex>
- </motion.div>
- </Flex>
+ </AnimatePresence>
- <OnboardingHogTip
- hogSrc={builderHog}
- message="No repo? No problem. You can always add one later from the home screen."
- delay={0.15}
- />
+ {showSourceSwitch && (
+ <button
+ type="button"
+ onClick={() => {
+ const nextSource =
+ repoSource === "github" ? "local" : "github";
+ // Clear the source being left so a later Skip cannot
+ // silently assign or persist a repo the user
+ // navigated away from.
+ if (nextSource === "local") {
+ onCloudRepoChange(null);
+ } else {
+ onDirectoryChange("");
+ }
+ setChosenSource(nextSource);
+ }}
+ className="cursor-pointer self-start border-0 bg-transparent p-0 text-(--gray-10) text-[13px] underline hover:text-(--gray-11)"
+ >
+ {repoSource === "github"
+ ? "Use a local folder instead"
+ : "Back to GitHub repos"}
+ </button>
+ )}
+ </Flex>
+ </motion.div>
</Flex>
</Flex>
diff --git a/products/desktop/packages/ui/src/features/onboarding/components/StepIndicator.tsx b/products/desktop/packages/ui/src/features/onboarding/components/StepIndicator.tsx
deleted file mode 100644
index c7f7298531c3..000000000000
--- a/products/desktop/packages/ui/src/features/onboarding/components/StepIndicator.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import { Flex } from "@radix-ui/themes";
-import type { OnboardingStep } from "../types";
-
-interface StepIndicatorProps {
- currentStep: OnboardingStep;
- activeSteps: OnboardingStep[];
-}
-
-export function StepIndicator({
- currentStep,
- activeSteps,
-}: StepIndicatorProps) {
- const displaySteps = activeSteps;
- const currentIndex = displaySteps.indexOf(currentStep);
-
- return (
- <Flex align="center" gap="2" justify="center" py="6">
- {displaySteps.map((step, index) => (
- <div
- key={step}
- style={{
- borderRadius: "50%",
- backgroundColor:
- index <= currentIndex ? "var(--accent-9)" : "var(--gray-5)",
- transition: "background-color 0.3s ease",
- }}
- className="h-[8px] w-[8px]"
- />
- ))}
- </Flex>
- );
-}
diff --git a/products/desktop/packages/ui/src/features/onboarding/hooks/useOnboardingFlow.ts b/products/desktop/packages/ui/src/features/onboarding/hooks/useOnboardingFlow.ts
index 964d56351044..8912317bbd25 100644
--- a/products/desktop/packages/ui/src/features/onboarding/hooks/useOnboardingFlow.ts
+++ b/products/desktop/packages/ui/src/features/onboarding/hooks/useOnboardingFlow.ts
@@ -13,7 +13,7 @@ import {
type OnboardingStep,
stepDirection,
} from "@posthog/core/onboarding/steps";
-import { useHostTRPCClient } from "@posthog/host-router/react";
+import { useHostTRPC, useHostTRPCClient } from "@posthog/host-router/react";
import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";
import {
useAuthStateFetched,
@@ -26,6 +26,7 @@ import { useSettingsStore } from "@posthog/ui/features/settings/settingsStore";
import { useActiveRepoStore } from "@posthog/ui/shell/activeRepoStore";
import { track } from "@posthog/ui/shell/analytics";
import { useHostCapabilities } from "@posthog/ui/shell/useHostCapabilities";
+import { useQuery } from "@tanstack/react-query";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
type ConsentRequirement,
@@ -134,6 +135,36 @@ export function useOnboardingFlow() {
);
const { data: githubUserIntegrations } = useUserGithubIntegrations();
+ // The install-cli step only offers git and gh, so a ready toolchain skips it.
+ // InstallCliStep reuses these cached results when the step does render.
+ const trpc = useHostTRPC();
+ // Cloud-only hosts serve no git procedures, and the CLI step is moot there.
+ const { data: gitStatus } = useQuery(
+ trpc.git.getGitStatus.queryOptions(undefined, {
+ staleTime: 30_000,
+ enabled: localWorkspaces,
+ }),
+ );
+ const { data: ghStatus } = useQuery(
+ trpc.git.getGhStatus.queryOptions(undefined, {
+ staleTime: 30_000,
+ enabled: localWorkspaces,
+ }),
+ );
+ // Sampled on the first resolved check and held. Installing the tools while
+ // standing on the step would otherwise drop it and advance the user mid-read.
+ const [cliReady, setCliReady] = useState<boolean | undefined>(undefined);
+ useEffect(() => {
+ if (cliReady !== undefined) return;
+ if (!localWorkspaces) {
+ setCliReady(true);
+ return;
+ }
+ if (gitStatus === undefined || ghStatus === undefined) return;
+ setCliReady(
+ gitStatus.installed && ghStatus.installed && ghStatus.authenticated,
+ );
+ }, [cliReady, localWorkspaces, gitStatus, ghStatus]);
const hasGithubIntegration = githubUserIntegrations
? githubUserIntegrations.length > 0
: undefined;
@@ -187,10 +218,11 @@ export function useOnboardingFlow() {
() =>
computeActiveSteps({
hasGithubIntegration,
+ cliReady,
projectCount,
consentRequired,
}),
- [hasGithubIntegration, projectCount, consentRequired],
+ [hasGithubIntegration, cliReady, projectCount, consentRequired],
);
useEffect(() => {
diff --git a/products/desktop/packages/ui/src/primitives/Logo.tsx b/products/desktop/packages/ui/src/primitives/Logo.tsx
index 4b8ec803130a..5faecdfdabb5 100644
--- a/products/desktop/packages/ui/src/primitives/Logo.tsx
+++ b/products/desktop/packages/ui/src/primitives/Logo.tsx
@@ -2,7 +2,7 @@
// landscape, w/ "code": 229 x 28
// stacked, no "code": 52 x 47
// stacked, w/ "code": 52 x 59
-// no wordmark (logo only): 52 x 47
+// no wordmark (logo only): 52 x 28
export default function LogosLandscape({
code = true,
@@ -10,7 +10,7 @@ export default function LogosLandscape({
wordmark = true,
}) {
const width = !wordmark ? 52 : stacked ? 52 : code ? 229 : 160;
- const height = !wordmark ? 47 : stacked ? (code ? 59 : 47) : 28;
+ const height = !wordmark ? 28 : stacked ? (code ? 59 : 47) : 28;
return (
<svg
width={width}
diff --git a/products/desktop/packages/ui/src/primitives/ProductWordmark.tsx b/products/desktop/packages/ui/src/primitives/ProductWordmark.tsx
new file mode 100644
index 000000000000..060e83d53cb7
--- /dev/null
+++ b/products/desktop/packages/ui/src/primitives/ProductWordmark.tsx
@@ -0,0 +1,20 @@
+import { Text } from "@posthog/quill";
+import Logo from "@posthog/ui/primitives/Logo";
+
+/**
+ * The hedgehog mark beside the product name. Logo's own wordmark is brand
+ * lettering inside the SVG, so setting only part of the name as text cannot
+ * match it. The whole name is text instead.
+ */
+export function ProductWordmark() {
+ return (
+ <div className="flex items-center gap-2">
+ <span className="flex [&>svg]:h-[26px] [&>svg]:w-auto">
+ <Logo wordmark={false} />
+ </span>
+ <Text className="font-bold text-(--gray-12) text-[25px] leading-none tracking-[-0.05em]">
+ PostHog Desktop
+ </Text>
+ </div>
+ );
+}