: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): remove repository selection from onboarding (#101184)
Adam Bowker0c81aa06435a
diff --git a/products/desktop/packages/core/src/onboarding/analytics.test.ts b/products/desktop/packages/core/src/onboarding/analytics.test.tsindex 5e9be600b02b..ee3137611c49 100644--- a/products/desktop/packages/core/src/onboarding/analytics.test.ts+++ b/products/desktop/packages/core/src/onboarding/analytics.test.ts@@ -15,17 +15,17 @@ describe("durationSeconds", () => {describe("buildStepCompletedProps", () => {it("computes duration and merges context", () => {const props = buildStepCompletedProps({- stepId: "select-repo",- stepIndex: 4,- totalSteps: 5,+ stepId: "install-cli",+ stepIndex: 3,+ totalSteps: 4,stepEnteredAtMs: 1000,nowMs: 6000,context: { github_connected: true },});expect(props).toEqual({- step_id: "select-repo",- step_index: 4,- total_steps: 5,+ step_id: "install-cli",+ step_index: 3,+ total_steps: 4,duration_seconds: 5,github_connected: true,});@@ -39,12 +39,10 @@ describe("buildCompletedProps", () => {flowStartedAtMs: 0,nowMs: 10000,githubConnected: true,- repoSkipped: false,}),).toEqual({duration_seconds: 10,github_connected: true,- repo_skipped: false,});});});diff --git a/products/desktop/packages/core/src/onboarding/analytics.ts b/products/desktop/packages/core/src/onboarding/analytics.tsindex b0d711734b46..7c377997b3be 100644--- a/products/desktop/packages/core/src/onboarding/analytics.ts+++ b/products/desktop/packages/core/src/onboarding/analytics.ts@@ -35,12 +35,10 @@ export function buildCompletedProps(opts: {flowStartedAtMs: number;nowMs: number;githubConnected: boolean;- repoSkipped: boolean;}): OnboardingCompletedProperties {return {duration_seconds: durationSeconds(opts.flowStartedAtMs, opts.nowMs),github_connected: opts.githubConnected,- repo_skipped: opts.repoSkipped,};}diff --git a/products/desktop/packages/core/src/onboarding/repoProvider.test.ts b/products/desktop/packages/core/src/onboarding/repoProvider.test.tsdeleted file mode 100644index a5732e8560f3..000000000000--- a/products/desktop/packages/core/src/onboarding/repoProvider.test.ts+++ /dev/null@@ -1,80 +0,0 @@-import { describe, expect, it } from "vitest";-import {- inferRepositoryProvider,- repoMatchesGitHubRepos,- toDetectedRepo,-} from "./repoProvider";--describe("inferRepositoryProvider", () => {- it("returns local when there is no remote", () => {- expect(inferRepositoryProvider(undefined)).toBe("local");- });-- it("classifies github and gitlab hosts", () => {- expect(inferRepositoryProvider("[email protected]:acme/app.git")).toBe(- "github",- );- expect(inferRepositoryProvider("https://gitlab.com/acme/app.git")).toBe(- "gitlab",- );- });-- it("returns none for other hosts", () => {- expect(inferRepositoryProvider("https://bitbucket.org/acme/app")).toBe(- "none",- );- });-});--describe("toDetectedRepo", () => {- it("returns null for empty input", () => {- expect(toDetectedRepo(null)).toBeNull();- expect(toDetectedRepo(undefined)).toBeNull();- });-- it("shapes the detect result into a DetectedRepo", () => {- expect(- toDetectedRepo({- organization: "acme",- repository: "app",- remote: "[email protected]:acme/app.git",- branch: "main",- }),- ).toEqual({- organization: "acme",- repository: "app",- fullName: "acme/app",- remote: "[email protected]:acme/app.git",- branch: "main",- });- });-- it("coerces null remote/branch to undefined", () => {- const repo = toDetectedRepo({- organization: "acme",- repository: "app",- remote: null,- branch: null,- });- expect(repo?.remote).toBeUndefined();- expect(repo?.branch).toBeUndefined();- });-});--describe("repoMatchesGitHubRepos", () => {- const detected = {- organization: "acme",- repository: "app",- fullName: "acme/app",- };-- it("returns false without a detected repo or repositories", () => {- expect(repoMatchesGitHubRepos(null, ["acme/app"])).toBe(false);- expect(repoMatchesGitHubRepos(detected, [])).toBe(false);- });-- it("matches case-insensitively", () => {- expect(repoMatchesGitHubRepos(detected, ["ACME/App"])).toBe(true);- expect(repoMatchesGitHubRepos(detected, ["other/repo"])).toBe(false);- });-});diff --git a/products/desktop/packages/core/src/onboarding/repoProvider.ts b/products/desktop/packages/core/src/onboarding/repoProvider.tsdeleted file mode 100644index 361222cd4b06..000000000000--- a/products/desktop/packages/core/src/onboarding/repoProvider.ts+++ /dev/null@@ -1,43 +0,0 @@-import type { RepositoryProvider } from "@posthog/shared/analytics-events";-import type { DetectedRepo } from "./steps";--export interface DetectRepoResult {- organization: string;- repository: string;- remote?: string | null;- branch?: string | null;-}--export function inferRepositoryProvider(- remote: string | undefined,-): RepositoryProvider {- if (!remote) return "local";- const host = remote- .match(/^(?:[a-z]+:\/\/)?(?:[^@/]+@)?([a-z0-9.-]+)[:/]/i)?.[1]- ?.toLowerCase();- if (host === "gitlab.com") return "gitlab";- if (host === "github.com") return "github";- return "none";-}--export function toDetectedRepo(- result: DetectRepoResult | null | undefined,-): DetectedRepo | null {- if (!result) return null;- return {- organization: result.organization,- repository: result.repository,- fullName: `${result.organization}/${result.repository}`,- remote: result.remote ?? undefined,- branch: result.branch ?? undefined,- };-}--export function repoMatchesGitHubRepos(- detectedRepo: DetectedRepo | null,- repositories: string[],-): boolean {- if (!detectedRepo || repositories.length === 0) return false;- const target = detectedRepo.fullName.toLowerCase();- return repositories.some((repo) => repo.toLowerCase() === target);-}diff --git a/products/desktop/packages/core/src/onboarding/spaceRepoAssignment.test.ts b/products/desktop/packages/core/src/onboarding/spaceRepoAssignment.test.tsdeleted file mode 100644index 29a1ceb25628..000000000000--- a/products/desktop/packages/core/src/onboarding/spaceRepoAssignment.test.ts+++ /dev/null@@ -1,110 +0,0 @@-import { describe, expect, it } from "vitest";-import {- type AssignableChannel,- planSpaceRepoAssignments,- resolveRepoIntegrationId,-} from "./spaceRepoAssignment";--function channel(overrides: Partial<AssignableChannel>): AssignableChannel {- return {- id: "id",- name: "name",- channel_type: "public",- system_role: null,- ...overrides,- };-}--const personal = channel({- id: "personal-id",- name: "me",- channel_type: "personal",- system_role: "personal",-});-const general = channel({- id: "general-id",- name: "general",- system_role: "general",-});--describe("spaceRepoAssignment", () => {- const bothCreated = { personalCreated: true, generalCreated: true };- const nothingCreated = { personalCreated: false, generalCreated: false };-- describe("planSpaceRepoAssignments", () => {- it("targets both just-created spaces", () => {- expect(- planSpaceRepoAssignments([personal, general], bothCreated),- ).toEqual(["personal-id", "general-id"]);- });-- it("still fills an unconfigured pre-existing personal space", () => {- expect(- planSpaceRepoAssignments([personal, general], nothingCreated),- ).toEqual(["personal-id"]);- });-- it("keeps a configured personal space on re-onboarding", () => {- // Wiped local storage re-runs onboarding; the pick must not clobber the- // repos the user already configured on their own space.- const configured = channel({- ...personal,- repositories: ["example/mine"],- });- expect(- planSpaceRepoAssignments([configured, general], nothingCreated),- ).toEqual([]);- });-- it("skips an inherited #general even when its repository list is empty", () => {- expect(- planSpaceRepoAssignments([personal, general], {- personalCreated: true,- generalCreated: false,- }),- ).toEqual(["personal-id"]);- });-- it("skips a just-created #general that a teammate already configured", () => {- const configured = channel({- ...general,- repositories: ["example/app"],- });- expect(- planSpaceRepoAssignments([personal, configured], bothCreated),- ).toEqual(["personal-id"]);- });-- it("returns no targets when neither space exists", () => {- expect(- planSpaceRepoAssignments(- [channel({ id: "other", name: "random" })],- bothCreated,- ),- ).toEqual([]);- });- });-- describe("resolveRepoIntegrationId", () => {- const integrations = [- { id: 1, config: { account: { name: "ExampleOrg" } } },- { id: 2, config: { account: { name: "other" } } },- ];-- it("matches the repo owner to the integration account", () => {- expect(resolveRepoIntegrationId("exampleorg/app", integrations)).toBe(1);- });-- it("falls back to a sole integration when the owner does not match", () => {- expect(resolveRepoIntegrationId("unrelated/app", [integrations[0]])).toBe(- 1,- );- });-- it("refuses to guess between several non-matching integrations", () => {- expect(resolveRepoIntegrationId("unrelated/app", integrations)).toBe(- null,- );- });- });-});diff --git a/products/desktop/packages/core/src/onboarding/spaceRepoAssignment.ts b/products/desktop/packages/core/src/onboarding/spaceRepoAssignment.tsdeleted file mode 100644index 717b887c04a1..000000000000--- a/products/desktop/packages/core/src/onboarding/spaceRepoAssignment.ts+++ /dev/null@@ -1,68 +0,0 @@-import {- type ChannelIdentity,- isGeneralChannel,- isPersonalChannel,-} from "../canvas/channelName";--export interface AssignableChannel extends ChannelIdentity {- id: string;- repositories?: string[];-}--export interface AssignableGithubIntegration {- id: number;- config?: { account?: { name?: string | null } | null };-}--/**- * Matched by account name, falling back to a sole integration. Returns null- * rather than guessing between several that do not match the owner.- */-export function resolveRepoIntegrationId(- repo: string,- integrations: AssignableGithubIntegration[],-): number | null {- const owner = repo.split("/")[0]?.toLowerCase();- if (owner) {- const match = integrations.find(- (integration) =>- integration.config?.account?.name?.toLowerCase() === owner,- );- if (match) return match.id;- }- return integrations.length === 1 ? integrations[0].id : null;-}--export interface SpaceRepoAssignmentFlags {- personalCreated: boolean;- generalCreated: boolean;-}--/**- * Which spaces the onboarding repo pick becomes the default for. Re-onboarding- * (wiped local storage) must not clobber what a user or their team set up, and- * an empty inherited #general is not the same signal as a just-created one:- * a teammate may have emptied it on purpose.- */-export function planSpaceRepoAssignments(- channels: AssignableChannel[],- flags: SpaceRepoAssignmentFlags,-): string[] {- const targets: string[] = [];- const personal = channels.find((channel) => isPersonalChannel(channel));- if (- personal &&- (flags.personalCreated || (personal.repositories ?? []).length === 0)- ) {- targets.push(personal.id);- }- const general = channels.find((channel) => isGeneralChannel(channel));- if (- general &&- flags.generalCreated &&- (general.repositories ?? []).length === 0- ) {- targets.push(general.id);- }- return targets;-}diff --git a/products/desktop/packages/core/src/onboarding/steps.test.ts b/products/desktop/packages/core/src/onboarding/steps.test.tsindex 2b8e6e33d3a6..7009e21ce934 100644--- a/products/desktop/packages/core/src/onboarding/steps.test.ts+++ b/products/desktop/packages/core/src/onboarding/steps.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from "vitest";import {computeActiveSteps,+ isFinalActiveStepRemoved,isFirstStep,isLastStep,nearestActiveStep,@@ -97,12 +98,9 @@ describe("stepGatePending", () => {);});- it.each<OnboardingStep>(["connect-github", "select-repo"])(- "never holds %s, which no gate can drop",- (step) => {- expect(stepGatePending(step, allSteps)).toBe(false);- },- );+ it("never holds connect-github, which no gate can drop", () => {+ expect(stepGatePending("connect-github", allSteps)).toBe(false);+ });});describe("nearestActiveStep", () => {@@ -119,24 +117,19 @@ describe("nearestActiveStep", () => {);});- it.each<{ removed: OnboardingStep; expected: OnboardingStep }>([- // install-cli vanished under the user: continue forward to select-repo,- // not back to the start (the regression that reset onboarding mid-flow).- { removed: "install-cli", expected: "select-repo" },- ])(- "moves forward to $expected when $removed drops out",- ({ removed, expected }) => {- expect(nearestActiveStep(withoutConditionals, removed)).toBe(expected);- },- );+ it("moves forward when install-cli drops out", () => {+ expect(nearestActiveStep(withoutConditionals, "install-cli")).toBe(+ "connect-github",+ );+ });it("falls back to the closest earlier step when nothing follows", () => {const onlyEarlySteps: OnboardingStep[] = ["project-select", "consent"];- expect(nearestActiveStep(onlyEarlySteps, "select-repo")).toBe("consent");+ expect(nearestActiveStep(onlyEarlySteps, "connect-github")).toBe("consent");});it("returns the step itself when no steps are active", () => {- expect(nearestActiveStep([], "select-repo")).toBe("select-repo");+ expect(nearestActiveStep([], "connect-github")).toBe("connect-github");});});@@ -155,6 +148,40 @@ describe("step navigation", () => {expect(isLastStep(steps, 0)).toBe(false);});+ it.each([+ {+ gates: { hasGithubIntegration: true, cliReady: false },+ finalStep: "connect-github",+ },+ {+ gates: { hasGithubIntegration: false, cliReady: false },+ finalStep: "install-cli",+ },+ ] as const)(+ "ends with $finalStep for the resolved gates",+ ({ gates, finalStep }) => {+ const activeSteps = computeActiveSteps({ ...allSteps, ...gates });+ expect(activeSteps.at(-1)).toBe(finalStep);+ },+ );++ it("identifies when a final active step is removed", () => {+ const previousActiveSteps = computeActiveSteps({+ ...allSteps,+ hasGithubIntegration: false,+ cliReady: false,+ });+ const activeSteps = computeActiveSteps({+ ...allSteps,+ hasGithubIntegration: true,+ cliReady: false,+ });++ expect(+ isFinalActiveStepRemoved(previousActiveSteps, activeSteps, "install-cli"),+ ).toBe(true);+ });+it("advances and retreats within bounds", () => {expect(nextStep(steps, 0)).toBe(steps[1]);expect(nextStep(steps, steps.length - 1)).toBeNull();diff --git a/products/desktop/packages/core/src/onboarding/steps.ts b/products/desktop/packages/core/src/onboarding/steps.tsindex d13eccdf27d9..486a6da2263a 100644--- a/products/desktop/packages/core/src/onboarding/steps.ts+++ b/products/desktop/packages/core/src/onboarding/steps.ts@@ -2,25 +2,15 @@ export type OnboardingStep =| "project-select"| "consent"| "connect-github"- | "install-cli"- | "select-repo";+ | "install-cli";export const ONBOARDING_STEPS: OnboardingStep[] = ["project-select","consent","connect-github","install-cli",- "select-repo",];-export interface DetectedRepo {- organization: string;- repository: string;- fullName: string;- remote?: string;- branch?: string;-}-export interface StepGates {/** Undefined while the integrations query is loading; the step only drops on a confirmed connection. */hasGithubIntegration: boolean | undefined;@@ -74,8 +64,7 @@ export function stepGatePending(* gates resolve). Prefers the next remaining step in canonical order — the* user was moving forward — and falls back to the closest earlier one, so a* vanishing step never resets progress to the start of the flow. Returns- * `step` unchanged when it is still active, or when `activeSteps` is empty- * (degenerate input: the flow always keeps at least the select-repo step).+ * `step` unchanged when it is still active, or when `activeSteps` is empty.*/export function nearestActiveStep(activeSteps: OnboardingStep[],@@ -105,6 +94,17 @@ export function isLastStep(return currentIndex === activeSteps.length - 1;}+export function isFinalActiveStepRemoved(+ previousActiveSteps: OnboardingStep[],+ activeSteps: OnboardingStep[],+ currentStep: OnboardingStep,+): boolean {+ return (+ previousActiveSteps.at(-1) === currentStep &&+ !activeSteps.includes(currentStep)+ );+}+export function nextStep(activeSteps: OnboardingStep[],currentIndex: number,diff --git a/products/desktop/packages/shared/src/analytics-events.ts b/products/desktop/packages/shared/src/analytics-events.tsindex 13cd760aed48..d52ed8ad4c50 100644--- a/products/desktop/packages/shared/src/analytics-events.ts+++ b/products/desktop/packages/shared/src/analytics-events.ts@@ -572,10 +572,9 @@ export type OnboardingStepId =| "project-select"| "consent"| "connect-github"- | "install-cli"- | "select-repo";+ | "install-cli";-type OnboardingSkipReason = "no_repo_selected" | "dev_skip";+type OnboardingSkipReason = "dev_skip";export interface OnboardingStepViewedProperties {step_id: OnboardingStepId;@@ -609,11 +608,6 @@ export interface OnboardingProjectSelectedProperties {had_multiple_projects: boolean;}-export interface OnboardingFolderSelectedProperties {- has_git_remote: boolean;- repository_provider: RepositoryProvider;-}-export interface OnboardingCliCheckCompletedProperties {git_installed: boolean;gh_installed: boolean;@@ -628,7 +622,6 @@ export interface OnboardingCliRunCompletedProperties {export interface OnboardingCompletedProperties {duration_seconds: number;github_connected: boolean;- repo_skipped: boolean;}export type OnboardingGithubConnectFlow =@@ -1663,7 +1656,6 @@ export const ANALYTICS_EVENTS = {ONBOARDING_STEP_SKIPPED: "Onboarding step skipped",ONBOARDING_SIGN_IN_INITIATED: "Onboarding sign in initiated",ONBOARDING_PROJECT_SELECTED: "Onboarding project selected",- ONBOARDING_FOLDER_SELECTED: "Onboarding folder selected",ONBOARDING_GITHUB_CONNECT_STARTED: "Onboarding github connect started",ONBOARDING_GITHUB_CONNECT_FAILED: "Onboarding github connect failed",ONBOARDING_GITHUB_CONNECT_PENDING_ADMIN:@@ -1877,7 +1869,6 @@ export type EventPropertyMap = {[ANALYTICS_EVENTS.ONBOARDING_STEP_SKIPPED]: OnboardingStepSkippedProperties;[ANALYTICS_EVENTS.ONBOARDING_SIGN_IN_INITIATED]: OnboardingSignInInitiatedProperties;[ANALYTICS_EVENTS.ONBOARDING_PROJECT_SELECTED]: OnboardingProjectSelectedProperties;- [ANALYTICS_EVENTS.ONBOARDING_FOLDER_SELECTED]: OnboardingFolderSelectedProperties;[ANALYTICS_EVENTS.ONBOARDING_GITHUB_CONNECT_STARTED]: OnboardingGithubConnectStartedProperties;[ANALYTICS_EVENTS.ONBOARDING_GITHUB_CONNECT_FAILED]: OnboardingGithubConnectFailedProperties;[ANALYTICS_EVENTS.ONBOARDING_GITHUB_CONNECT_PENDING_ADMIN]: OnboardingGithubConnectPendingAdminProperties;diff --git a/products/desktop/packages/ui/src/features/onboarding/components/OnboardingFlow.tsx b/products/desktop/packages/ui/src/features/onboarding/components/OnboardingFlow.tsxindex 15561234e0f0..8e196d40f5be 100644--- a/products/desktop/packages/ui/src/features/onboarding/components/OnboardingFlow.tsx+++ b/products/desktop/packages/ui/src/features/onboarding/components/OnboardingFlow.tsx@@ -5,13 +5,13 @@ import {Lifebuoy,SignOut,} from "@phosphor-icons/react";-import { getAuthIdentity } from "@posthog/core/auth/authIdentity";import {buildAbandonedProps,buildCompletedProps,buildStepCompletedProps,type StepCompletedContext,} from "@posthog/core/onboarding/analytics";+import type { OnboardingStep } from "@posthog/core/onboarding/steps";import {Button,ButtonGroup,@@ -33,29 +33,20 @@ import { ConnectGitHubStep } from "@posthog/ui/features/onboarding/components/Coimport { InstallCliStep } from "@posthog/ui/features/onboarding/components/InstallCliStep";import { useOnboardingFlow } from "@posthog/ui/features/onboarding/hooks/useOnboardingFlow";import { useOnboardingStore } from "@posthog/ui/features/onboarding/onboardingStore";-import { saveOnboardingRepository } from "@posthog/ui/features/onboarding/saveOnboardingRepository";-import type { OnboardingStep } from "@posthog/ui/features/onboarding/types";import { useSettingsStore } from "@posthog/ui/features/settings/settingsStore";import { shipIt } from "@posthog/ui/primitives/confetti";import { FullScreenLayout } from "@posthog/ui/primitives/FullScreenLayout";import { ProductWordmark } from "@posthog/ui/primitives/ProductWordmark";import { openTaskInput } from "@posthog/ui/router/useOpenTask";import { track } from "@posthog/ui/shell/analytics";-import { firstRun } from "@posthog/ui/shell/firstRun";-import { logger } from "@posthog/ui/shell/logger";-import { useHostCapabilities } from "@posthog/ui/shell/useHostCapabilities";import { isMac, isWindows } from "@posthog/ui/utils/platform";-import { useQueryClient } from "@tanstack/react-query";import { AnimatePresence, motion } from "framer-motion";-import { useEffect, useRef, useState } from "react";+import { useCallback, useEffect, useRef, useState } from "react";import { useHotkeys } from "react-hotkeys-hook";import { ProjectSelectStep } from "./ProjectSelectStep";-import { SelectRepoStep } from "./SelectRepoStep";const IS_DEV = import.meta.env.DEV;-const log = logger.scope("onboarding-flow");-const stepVariants = {enter: (dir: number) => ({ opacity: 0, x: dir * 20 }),center: { opacity: 1, x: 0 },@@ -223,21 +214,16 @@ function OnboardingHeader({export function OnboardingFlow({ onOpenSupport }: OnboardingFlowProps) {const [consentSubmitting, setConsentSubmitting] = useState(false);const [isCompleting, setIsCompleting] = useState(false);- const queryClient = useQueryClient();+ const completionStartedRef = useRef(false);const {currentStep,currentIndex,activeSteps,direction,+ isLastStep,+ finalActiveStepWasRemoved,next,back,- selectedDirectory,- detectedRepo,- isDetectingRepo,- handleDirectoryChange,- selectedCloudRepo,- handleCloudRepoChange,- hasGithubIntegration,consentSatisfied,consentRequirement,currentStepPending,@@ -256,28 +242,6 @@ export function OnboardingFlow({ onOpenSupport }: OnboardingFlowProps) {);const apiClient = useOptionalAuthenticatedClient();const { data: currentUser } = useCurrentUser({ client: apiClient });- const { localWorkspaces } = useHostCapabilities();- const startupIdentity = useAuthStateValue(getAuthIdentity);-- // Best-effort. This also seeds the cache that the first screen reads.- const assignRepoToSpaces = async (): Promise<void> => {- if (!apiClient || !startupIdentity) return;- // Cloud-only hosts store the GitHub repository in selectedDirectory.- // Local-workspace hosts keep cloud and local selections separate.- const cloudRepo = localWorkspaces- ? selectedCloudRepo- : selectedDirectory || null;- if (!cloudRepo) return;- const provisioned = await firstRun(startupIdentity, apiClient).provisioned;- if (!provisioned) return;- await saveOnboardingRepository({- client: apiClient,- provisioned,- queryClient,- repository: cloudRepo,- });- };-const flowStartedAtRef = useRef(Date.now());const stepEnteredAtRef = useRef(Date.now());@@ -293,7 +257,7 @@ export function OnboardingFlow({ onOpenSupport }: OnboardingFlowProps) {}, [currentStep]);const viewedStepRef = useRef<OnboardingStep | null>(null);- const recordStepViewed = () => {+ const recordStepViewed = useCallback(() => {if (currentIndex < 0 || viewedStepRef.current === currentStep) return;viewedStepRef.current = currentStep;track(ANALYTICS_EVENTS.ONBOARDING_STEP_VIEWED, {@@ -301,7 +265,7 @@ export function OnboardingFlow({ onOpenSupport }: OnboardingFlowProps) {step_index: currentIndex,total_steps: activeSteps.length,});- };+ }, [activeSteps.length, currentIndex, currentStep]);// The ordinary path: the step settles while the person is reading it. This// also covers a step entered by the self-heal in useOnboardingFlow, which@@ -327,19 +291,58 @@ export function OnboardingFlow({ onOpenSupport }: OnboardingFlowProps) {return () => window.removeEventListener("beforeunload", handleBeforeUnload);}, [currentStep]);- const trackStepCompleted = (context?: StepCompletedContext) => {- track(- ANALYTICS_EVENTS.ONBOARDING_STEP_COMPLETED,- buildStepCompletedProps({- stepId: currentStep,- stepIndex: currentIndex,- totalSteps: activeSteps.length,- stepEnteredAtMs: stepEnteredAtRef.current,- nowMs: Date.now(),- context,- }),- );- };+ const trackStepCompleted = useCallback(+ (context?: StepCompletedContext) => {+ track(+ ANALYTICS_EVENTS.ONBOARDING_STEP_COMPLETED,+ buildStepCompletedProps({+ stepId: currentStep,+ stepIndex: currentIndex,+ totalSteps: activeSteps.length,+ stepEnteredAtMs: stepEnteredAtRef.current,+ nowMs: Date.now(),+ context,+ }),+ );+ },+ [activeSteps.length, currentIndex, currentStep],+ );++ const handleComplete = useCallback(+ (context?: StepCompletedContext, includeStepCompletion = true) => {+ if (isCompleting || completionStartedRef.current) return;+ completionStartedRef.current = true;+ setIsCompleting(true);+ const githubConnected =+ context?.github_connected === true || githubUserIntegrations.length > 0;+ if (includeStepCompletion) {+ recordStepViewed();+ trackStepCompleted(context);+ }+ track(+ ANALYTICS_EVENTS.ONBOARDING_COMPLETED,+ buildCompletedProps({+ flowStartedAtMs: flowStartedAtRef.current,+ nowMs: Date.now(),+ githubConnected,+ }),+ );+ if (githubConnected) {+ setLastUsedWorkspaceMode("cloud");+ }+ shipIt();+ completeOnboarding();+ openTaskInput();+ },+ [+ completeOnboarding,+ githubUserIntegrations.length,+ isCompleting,+ recordStepViewed,+ setLastUsedWorkspaceMode,+ trackStepCompleted,+ ],+ );const handleNext = (context?: StepCompletedContext) => {if (@@ -348,24 +351,28 @@ export function OnboardingFlow({ onOpenSupport }: OnboardingFlowProps) {) {return;}- // `onClick={onNext}` would pass the click event here; a DOM event spread- // into capture properties poisons the whole analytics batch.const safeContext =context && "nativeEvent" in context ? undefined : context;- // A person can leave a step before its gate answers, which the effect above- // skips. Record the view first, so a completion never arrives without one.+ if (isLastStep) {+ handleComplete(safeContext);+ return;+ }recordStepViewed();trackStepCompleted(safeContext);next();};+ useEffect(() => {+ if (finalActiveStepWasRemoved) {+ handleComplete(undefined, false);+ }+ }, [finalActiveStepWasRemoved, handleComplete]);+const handleBack = () => {if (currentStep === "consent" && consentSubmitting) return;back();};- // The first active step has nowhere to go back to, and which step that is- // shifts as the conditional steps resolve.const onBack = currentIndex <= 0 ? undefined : handleBack;useHotkeys("right", () => handleNext(), { enableOnFormTags: false }, [@@ -373,48 +380,6 @@ export function OnboardingFlow({ onOpenSupport }: OnboardingFlowProps) {]);useHotkeys("left", handleBack, { enableOnFormTags: false }, [handleBack]);- const handleComplete = async (repoSkipped: boolean) => {- if (isCompleting) return;- setIsCompleting(true);- recordStepViewed();- if (repoSkipped) {- track(ANALYTICS_EVENTS.ONBOARDING_STEP_SKIPPED, {- step_id: currentStep,- step_index: currentIndex,- reason: "no_repo_selected",- });- } else {- trackStepCompleted();- }- track(- ANALYTICS_EVENTS.ONBOARDING_COMPLETED,- buildCompletedProps({- flowStartedAtMs: flowStartedAtRef.current,- nowMs: Date.now(),- githubConnected: githubUserIntegrations.length > 0,- repoSkipped,- }),- );- if (githubUserIntegrations.length > 0) {- // GitHub connected defaults the run mode to cloud (overriding a local- // mode left behind by an earlier session), but an explicit local folder- // pick in this step must win over that default. On cloud-only hosts- // selectedDirectory holds an "owner/repo" value, not a local path, so- // only treat it as a local pick on local-workspace hosts.- const pickedLocalRepo =- localWorkspaces && !selectedCloudRepo && !!selectedDirectory;- setLastUsedWorkspaceMode(pickedLocalRepo ? "local" : "cloud");- }- try {- await assignRepoToSpaces();- } catch (error) {- log.warn("Failed to save onboarding repo to spaces", { error });- }- shipIt();- completeOnboarding();- openTaskInput();- };-const handleSkip = () => {if (isCompleting) return;track(ANALYTICS_EVENTS.ONBOARDING_STEP_SKIPPED, {@@ -530,32 +495,6 @@ export function OnboardingFlow({ onOpenSupport }: OnboardingFlowProps) {<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="w-full"- >- <SelectRepoStep- onComplete={handleComplete}- onBack={handleBack}- selectedDirectory={selectedDirectory}- detectedRepo={detectedRepo}- isDetectingRepo={isDetectingRepo}- onDirectoryChange={handleDirectoryChange}- selectedCloudRepo={selectedCloudRepo}- onCloudRepoChange={handleCloudRepoChange}- hasGithubIntegration={hasGithubIntegration}- isCompleting={isCompleting}- />- </motion.div>- )}</AnimatePresence></div></div>diff --git a/products/desktop/packages/ui/src/features/onboarding/components/SelectRepoStep.tsx b/products/desktop/packages/ui/src/features/onboarding/components/SelectRepoStep.tsxdeleted file mode 100644index 77de8bfc93c6..000000000000--- a/products/desktop/packages/ui/src/features/onboarding/components/SelectRepoStep.tsx+++ /dev/null@@ -1,287 +0,0 @@-import {- ArrowLeft,- ArrowRight,- CheckCircle,- FolderOpen,-} from "@phosphor-icons/react";-import { repoMatchesGitHubRepos } from "@posthog/core/onboarding/repoProvider";-import {- Button,- cn,- Empty,- EmptyContent,- EmptyDescription,- EmptyHeader,- EmptyMedia,- EmptyTitle,- Heading,- Item,- ItemContent,- ItemDescription,- ItemMedia,- ItemTitle,- Text,-} from "@posthog/quill";-import { FolderPicker } from "@posthog/ui/features/folder-picker/FolderPicker";-import { GitHubRepoPicker } from "@posthog/ui/features/folder-picker/GitHubRepoPicker";-import { useFolders } from "@posthog/ui/features/folders/useFolders";-import { useUserRepositoryIntegration } from "@posthog/ui/features/integrations/useIntegrations";-import { Spinner } from "@posthog/ui/primitives/Spinner";-import { useHostCapabilities } from "@posthog/ui/shell/useHostCapabilities";-import { getFilePath } from "@posthog/ui/utils/getFilePath";-import { motion, useReducedMotion } from "framer-motion";-import { type DragEvent, useMemo, useRef, useState } from "react";-import type { DetectedRepo } from "../types";-import { OptionalBadge } from "./OptionalBadge";-import { StepActions } from "./StepActions";--function handleDragOver(event: DragEvent<HTMLDivElement>): void {- if (!event.dataTransfer.types.includes("Files")) return;- event.preventDefault();- event.dataTransfer.dropEffect = "copy";-}--interface SelectRepoStepProps {- onComplete: (skipped: boolean) => void | Promise<void>;- onBack: () => void;- selectedDirectory: string;- detectedRepo: DetectedRepo | null;- isDetectingRepo: boolean;- onDirectoryChange: (path: string) => void;- selectedCloudRepo: string | null;- onCloudRepoChange: (repo: string | null) => void;- hasGithubIntegration: boolean | undefined;- isCompleting: boolean;-}--export function SelectRepoStep({- onComplete,- onBack,- selectedDirectory,- detectedRepo,- isDetectingRepo,- onDirectoryChange,- selectedCloudRepo,- onCloudRepoChange,- hasGithubIntegration,- isCompleting,-}: SelectRepoStepProps) {- const shouldReduceMotion = useReducedMotion() === true;- const { localWorkspaces } = useHostCapabilities();- const { addFolder } = useFolders();- const {- repositories,- isLoadingRepos,- isRefreshingRepos,- refreshRepositories,- } = useUserRepositoryIntegration();- const [isDraggingFolder, setIsDraggingFolder] = useState(false);- const [dropError, setDropError] = useState<string | null>(null);- const dragDepthRef = useRef(0);-- const useGithubRepository = !localWorkspaces || hasGithubIntegration === true;- const hasSelection = useGithubRepository- ? localWorkspaces- ? selectedCloudRepo !== null- : selectedDirectory !== ""- : selectedDirectory !== "";- const repoMatchesGitHub = useMemo(- () => repoMatchesGitHubRepos(detectedRepo, repositories),- [detectedRepo, repositories],- );-- const handleDragEnter = (event: DragEvent<HTMLDivElement>) => {- if (!event.dataTransfer.types.includes("Files")) return;- event.preventDefault();- dragDepthRef.current += 1;- setIsDraggingFolder(true);- };-- const handleDragLeave = (event: DragEvent<HTMLDivElement>) => {- event.preventDefault();- dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);- if (dragDepthRef.current === 0) setIsDraggingFolder(false);- };-- const handleFolderDrop = async (event: DragEvent<HTMLDivElement>) => {- event.preventDefault();- dragDepthRef.current = 0;- setIsDraggingFolder(false);- setDropError(null);-- const item = event.dataTransfer.items[0];- const entry = item?.webkitGetAsEntry?.();- if (entry && !entry.isDirectory) {- setDropError("Drop a folder, not a file.");- return;- }-- const file = event.dataTransfer.files[0];- const path = file ? getFilePath(file) : "";- if (!path) {- setDropError(- "This folder path is not available. Choose the folder instead.",- );- return;- }-- try {- await addFolder(path);- onDirectoryChange(path);- } catch {- setDropError(- "PostHog could not add this folder. Choose the folder instead.",- );- }- };-- const localFolderStatus = selectedDirectory ? (- <Item- variant="muted"- size="sm"- tone={- isDetectingRepo- ? "default"- : detectedRepo && repoMatchesGitHub- ? "success"- : "info"- }- aria-live="polite"- >- <ItemMedia variant="icon">- {isDetectingRepo ? (- <Spinner />- ) : detectedRepo ? (- <CheckCircle size={15} weight="fill" />- ) : (- <FolderOpen size={15} weight="fill" />- )}- </ItemMedia>- <ItemContent>- <ItemTitle>- {isDetectingRepo- ? "Checking folder"- : detectedRepo- ? repoMatchesGitHub- ? `Linked to ${detectedRepo.fullName} on GitHub`- : `Detected ${detectedRepo.fullName}`- : "Folder ready"}- </ItemTitle>- {!isDetectingRepo && !detectedRepo && (- <ItemDescription>- No Git remote was detected. You can still use this folder.- </ItemDescription>- )}- </ItemContent>- </Item>- ) : null;-- return (- <main className="w-full">- <div className="mx-auto flex w-full max-w-[480px] flex-col gap-4">- <motion.div- initial={shouldReduceMotion ? false : { opacity: 0, y: 8 }}- animate={{ opacity: 1, y: 0 }}- transition={{ duration: 0.25, ease: "easeOut" }}- className="flex flex-col gap-1.5"- >- <div className="flex items-center gap-2">- {/* biome-ignore lint/a11y/useHeadingContent: Quill supplies the heading text through this render target. */}- <Heading size="xl" render={<h1 className="font-bold" />}>- Pick a repo- </Heading>- <OptionalBadge />- </div>- <Text size="sm" variant="muted">- New tasks use this repo by default. Change it anytime from home.- </Text>- </motion.div>-- <motion.div- initial={shouldReduceMotion ? false : { opacity: 0, y: 8 }}- animate={{ opacity: 1, y: 0 }}- transition={{ duration: 0.25, delay: 0.03, ease: "easeOut" }}- className="flex flex-col gap-4"- >- {useGithubRepository ? (- <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"- disabled={isCompleting}- />- ) : (- <Empty- className={cn("py-6", isDraggingFolder && "bg-muted")}- aria-live="polite"- onDragEnter={handleDragEnter}- onDragLeave={handleDragLeave}- onDragOver={handleDragOver}- onDrop={(event) => void handleFolderDrop(event)}- >- <EmptyHeader>- <EmptyMedia variant="icon">- <FolderOpen size={18} weight="fill" />- </EmptyMedia>- <EmptyTitle>- {isDraggingFolder- ? "Drop your folder"- : "Choose a local folder"}- </EmptyTitle>- <EmptyDescription>- Drop a folder here, or choose one from your computer.- </EmptyDescription>- </EmptyHeader>- <EmptyContent className="w-full max-w-none">- <FolderPicker- value={selectedDirectory}- onChange={(path) => {- setDropError(null);- onDirectoryChange(path);- }}- placeholder="Choose folder…"- />- {dropError && (- <Text size="xs" variant="destructive">- {dropError}- </Text>- )}- {localFolderStatus}- </EmptyContent>- </Empty>- )}-- <StepActions- primaryAction={- <Button- size="lg"- variant={hasSelection ? "primary" : "outline"}- loading={isCompleting}- onClick={() => void onComplete(!hasSelection)}- >- {hasSelection ? "Get started" : "Skip & get started"}- <ArrowRight size={16} weight="bold" />- </Button>- }- >- <Button size="lg" disabled={isCompleting} onClick={onBack}>- <ArrowLeft size={16} weight="bold" />- Back- </Button>- </StepActions>- </motion.div>- </div>- </main>- );-}diff --git a/products/desktop/packages/ui/src/features/onboarding/hooks/useOnboardingFlow.ts b/products/desktop/packages/ui/src/features/onboarding/hooks/useOnboardingFlow.tsindex e6c7f8eda514..0ad206ded641 100644--- a/products/desktop/packages/ui/src/features/onboarding/hooks/useOnboardingFlow.ts+++ b/products/desktop/packages/ui/src/features/onboarding/hooks/useOnboardingFlow.ts@@ -1,137 +1,34 @@-import {- inferRepositoryProvider,- toDetectedRepo,-} from "@posthog/core/onboarding/repoProvider";import {computeActiveSteps,isFirstStep as computeIsFirstStep,isLastStep as computeIsLastStep,nextStep as computeNextStep,previousStep as computePreviousStep,- type DetectedRepo,+ isFinalActiveStepRemoved,nearestActiveStep,type OnboardingStep,stepDirection,stepGatePending,} from "@posthog/core/onboarding/steps";-import { useHostTRPC, useHostTRPCClient } from "@posthog/host-router/react";-import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";+import { useHostTRPC } from "@posthog/host-router/react";import { useAuthStateValue } from "@posthog/ui/features/auth/store";import { useOrgConsent } from "@posthog/ui/features/consent/useOrgConsent";import { useUserGithubIntegrations } from "@posthog/ui/features/integrations/useIntegrations";import { useOnboardingStore } from "@posthog/ui/features/onboarding/onboardingStore";-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 { useEffect, useMemo, useRef, useState } from "react";import {type ConsentRequirement,sampleConsentRequirement,} from "./consentRequirement";-export type { DetectedRepo };-export function useOnboardingFlow() {- const hostClient = useHostTRPCClient();const { localWorkspaces } = useHostCapabilities();const currentStep = useOnboardingStore((state) => state.currentStep);const setCurrentStep = useOnboardingStore((state) => state.setCurrentStep);- const selectedDirectory = useActiveRepoStore((state) => state.path);- const setSelectedDirectory = useActiveRepoStore((state) => state.setPath);- const setLastUsedCloudRepository = useSettingsStore(- (state) => state.setLastUsedCloudRepository,- );const directionRef = useRef<1 | -1>(1);- const [detectedRepo, setDetectedRepo] = useState<DetectedRepo | null>(null);- const [isDetectingRepo, setIsDetectingRepo] = useState(false);- const hasRehydrated = useRef(false);-- useEffect(() => {- // Cloud-only hosts have no local git to detect against.- if (!localWorkspaces) return;- if (hasRehydrated.current || !selectedDirectory) return;- hasRehydrated.current = true;- setIsDetectingRepo(true);- hostClient.git.detectRepo- .query({ directoryPath: selectedDirectory })- .then((result) => setDetectedRepo(toDetectedRepo(result)))- .catch(() => {})- .finally(() => setIsDetectingRepo(false));- }, [selectedDirectory, hostClient, localWorkspaces]);-- const [selectedCloudRepo, setSelectedCloudRepo] = useState<string | null>(- null,- );- const handleCloudRepoChange = useCallback(- (repo: string | null) => {- setSelectedCloudRepo(repo);- setLastUsedCloudRepository(repo);- if (repo) {- setSelectedDirectory("");- setDetectedRepo(null);- track(ANALYTICS_EVENTS.ONBOARDING_FOLDER_SELECTED, {- has_git_remote: true,- repository_provider: "github",- });- }- },- [setLastUsedCloudRepository, setSelectedDirectory],- );-- const handleDirectoryChange = useCallback(- async (path: string) => {- setSelectedDirectory(path);- setDetectedRepo(null);-- // Cloud-only: `path` is a remote "owner/repo" reference. Persist it as the- // last-used cloud repository so the task input prefills it.- if (!localWorkspaces) {- setLastUsedCloudRepository(path || null);- track(ANALYTICS_EVENTS.ONBOARDING_FOLDER_SELECTED, {- has_git_remote: !!path,- repository_provider: "github",- });- return;- }-- setSelectedCloudRepo(null);- setLastUsedCloudRepository(null);-- if (!path) return;-- setIsDetectingRepo(true);- try {- const result = await hostClient.git.detectRepo.query({- directoryPath: path,- });- const repo = toDetectedRepo(result);- setDetectedRepo(repo);- track(ANALYTICS_EVENTS.ONBOARDING_FOLDER_SELECTED, {- has_git_remote: !!repo,- repository_provider: repo- ? inferRepositoryProvider(repo.remote)- : "local",- });- } catch {- track(ANALYTICS_EVENTS.ONBOARDING_FOLDER_SELECTED, {- has_git_remote: false,- repository_provider: "local",- });- } finally {- setIsDetectingRepo(false);- }- },- [- setSelectedDirectory,- setLastUsedCloudRepository,- hostClient,- localWorkspaces,- ],- );-const { data: githubUserIntegrations, isPending: githubIntegrationsPending } =useUserGithubIntegrations();// The install-cli step only offers git and gh, so a ready toolchain skips it.@@ -230,6 +127,16 @@ export function useOnboardingFlow() {[hasGithubIntegration, cliReady, projectCount, consentRequired],);const activeSteps = useMemo(() => computeActiveSteps(stepGates), [stepGates]);+ const previousActiveStepsRef = useRef(activeSteps);+ const finalActiveStepWasRemoved = isFinalActiveStepRemoved(+ previousActiveStepsRef.current,+ activeSteps,+ currentStep,+ );++ useEffect(() => {+ previousActiveStepsRef.current = activeSteps;+ }, [activeSteps]);useEffect(() => {if (!activeSteps.includes(currentStep)) {@@ -270,16 +177,11 @@ export function useOnboardingFlow() {activeSteps,isFirstStep,isLastStep,+ finalActiveStepWasRemoved,direction: directionRef.current,next,back,goTo,- selectedDirectory,- detectedRepo,- isDetectingRepo,- handleDirectoryChange,- selectedCloudRepo,- handleCloudRepoChange,hasGithubIntegration,consentSatisfied,consentRequirement: sampledConsentRequirement,diff --git a/products/desktop/packages/ui/src/features/onboarding/onboardingStore.test.ts b/products/desktop/packages/ui/src/features/onboarding/onboardingStore.test.tsindex 883e5f97a6d0..ee4b999f4e8e 100644--- a/products/desktop/packages/ui/src/features/onboarding/onboardingStore.test.ts+++ b/products/desktop/packages/ui/src/features/onboarding/onboardingStore.test.ts@@ -24,9 +24,10 @@ describe("migrateOnboardingState", () => {},);- it("leaves a step of the current flow alone", () => {- expect(migrateOnboardingState(persisted("select-repo")).currentStep).toBe(- "select-repo",- );+ it("completes onboarding for a persisted select-repo step", () => {+ expect(migrateOnboardingState(persisted("select-repo"))).toMatchObject({+ currentStep: "select-repo",+ hasCompletedOnboarding: true,+ });});});diff --git a/products/desktop/packages/ui/src/features/onboarding/onboardingStore.ts b/products/desktop/packages/ui/src/features/onboarding/onboardingStore.tsindex 08b08a7e2b73..b395e844ef22 100644--- a/products/desktop/packages/ui/src/features/onboarding/onboardingStore.ts+++ b/products/desktop/packages/ui/src/features/onboarding/onboardingStore.ts@@ -1,5 +1,7 @@-import { ONBOARDING_STEPS } from "@posthog/core/onboarding/steps";-import type { OnboardingStep } from "@posthog/ui/features/onboarding/types";+import {+ ONBOARDING_STEPS,+ type OnboardingStep,+} from "@posthog/core/onboarding/steps";import { logger } from "@posthog/ui/shell/logger";import { create } from "zustand";import { persist } from "zustand/middleware";@@ -35,6 +37,9 @@ export function migrateOnboardingState(persistedState: unknown,): OnboardingStore {const state = persistedState as OnboardingStore;+ if ((state.currentStep as string) === "select-repo") {+ return { ...state, hasCompletedOnboarding: true };+ }if ((state.currentStep as string) === "invite-code") {return { ...state, currentStep: "consent" };}@@ -67,7 +72,7 @@ export const useOnboardingStore = create<OnboardingStore>()(}),{name: "onboarding-store",- version: 2,+ version: 3,migrate: migrateOnboardingState,partialize: (state) => ({currentStep: state.currentStep,diff --git a/products/desktop/packages/ui/src/features/onboarding/saveOnboardingRepository.test.ts b/products/desktop/packages/ui/src/features/onboarding/saveOnboardingRepository.test.tsdeleted file mode 100644index 07d350f43470..000000000000--- a/products/desktop/packages/ui/src/features/onboarding/saveOnboardingRepository.test.ts+++ /dev/null@@ -1,113 +0,0 @@-import type { TaskChannel } from "@posthog/shared/domain-types";-import { TASK_CHANNELS_QUERY_KEY } from "@posthog/ui/features/canvas/hooks/useTaskChannels";-import { QueryClient } from "@tanstack/react-query";-import { describe, expect, it, vi } from "vitest";-import { saveOnboardingRepository } from "./saveOnboardingRepository";--function channel(overrides: Partial<TaskChannel>): TaskChannel {- return {- id: "channel-id",- name: "channel",- channel_type: "public",- starred: false,- created_at: "2026-01-01T00:00:00Z",- system_role: null,- ...overrides,- };-}--describe("saveOnboardingRepository", () => {- it("updates empty system spaces and their shared cache", async () => {- const personal = channel({- id: "personal-id",- name: "me",- channel_type: "personal",- system_role: "personal",- });- const general = channel({- id: "general-id",- name: "general",- system_role: "general",- });- const updatedChannels = [personal, general].map((item) => ({- ...item,- github_integration: 12,- repositories: ["posthog/posthog"],- }));- const updateTaskChannelRepositories = vi- .fn()- .mockImplementation((channelId: string) =>- Promise.resolve(updatedChannels.find((item) => item.id === channelId)),- );- const client = {- getIntegrations: vi.fn().mockResolvedValue([- {- id: 12,- kind: "github",- config: { account: { name: "PostHog" } },- },- ]),- updateTaskChannelRepositories,- };- const queryClient = new QueryClient();-- await expect(- saveOnboardingRepository({- client,- provisioned: {- channels: [personal, general],- personal_created: true,- general_created: true,- },- queryClient,- repository: "posthog/posthog",- }),- ).resolves.toBe(2);-- expect(updateTaskChannelRepositories).toHaveBeenCalledTimes(2);- expect(updateTaskChannelRepositories).toHaveBeenCalledWith(- "personal-id",- 12,- ["posthog/posthog"],- );- expect(updateTaskChannelRepositories).toHaveBeenCalledWith(- "general-id",- 12,- ["posthog/posthog"],- );- expect(- queryClient.getQueryData<TaskChannel[]>(TASK_CHANNELS_QUERY_KEY),- ).toEqual(updatedChannels);- });-- it("keeps the provisioned cache when no team integration matches", async () => {- const general = channel({- id: "general-id",- name: "general",- system_role: "general",- });- const client = {- getIntegrations: vi.fn().mockResolvedValue([]),- updateTaskChannelRepositories: vi.fn(),- };- const queryClient = new QueryClient();-- await expect(- saveOnboardingRepository({- client,- provisioned: {- channels: [general],- personal_created: false,- general_created: true,- },- queryClient,- repository: "posthog/posthog",- }),- ).resolves.toBe(0);-- expect(client.updateTaskChannelRepositories).not.toHaveBeenCalled();- expect(queryClient.getQueryData(TASK_CHANNELS_QUERY_KEY)).toEqual([- general,- ]);- });-});diff --git a/products/desktop/packages/ui/src/features/onboarding/saveOnboardingRepository.ts b/products/desktop/packages/ui/src/features/onboarding/saveOnboardingRepository.tsdeleted file mode 100644index 3a065882d9d7..000000000000--- a/products/desktop/packages/ui/src/features/onboarding/saveOnboardingRepository.ts+++ /dev/null@@ -1,74 +0,0 @@-import type { PostHogAPIClient } from "@posthog/api-client/posthog-client";-import { integrationKeys } from "@posthog/core/integrations/repositoryKeys";-import {- classifyIntegrations,- type Integration,-} from "@posthog/core/integrations/selectors";-import {- planSpaceRepoAssignments,- resolveRepoIntegrationId,-} from "@posthog/core/onboarding/spaceRepoAssignment";-import type {- ProvisionedTaskChannels,- TaskChannel,-} from "@posthog/shared/domain-types";-import { AUTH_SCOPED_QUERY_META } from "@posthog/ui/features/auth/useCurrentUser";-import { TASK_CHANNELS_QUERY_KEY } from "@posthog/ui/features/canvas/hooks/useTaskChannels";-import type { QueryClient } from "@tanstack/react-query";--type OnboardingRepositoryClient = Pick<- PostHogAPIClient,- "getIntegrations" | "updateTaskChannelRepositories"->;--interface SaveOnboardingRepositoryInput {- client: OnboardingRepositoryClient;- provisioned: ProvisionedTaskChannels;- queryClient: QueryClient;- repository: string;-}--/** Save the onboarding repository in each empty system space and its cache. */-export async function saveOnboardingRepository({- client,- provisioned,- queryClient,- repository,-}: SaveOnboardingRepositoryInput): Promise<number> {- queryClient.setQueryDefaults(TASK_CHANNELS_QUERY_KEY, {- meta: AUTH_SCOPED_QUERY_META,- });- queryClient.setQueryData(TASK_CHANNELS_QUERY_KEY, provisioned.channels);-- const integrations = await queryClient.fetchQuery({- queryKey: integrationKeys.list(),- queryFn: () => client.getIntegrations() as Promise<Integration[]>,- staleTime: 60_000,- meta: AUTH_SCOPED_QUERY_META,- });- const integrationId = resolveRepoIntegrationId(- repository,- classifyIntegrations(integrations).githubIntegrations,- );- if (integrationId === null) return 0;-- const targetIds = planSpaceRepoAssignments(provisioned.channels, {- personalCreated: provisioned.personal_created,- generalCreated: provisioned.general_created,- });- const updatedChannels = await Promise.all(- targetIds.map((channelId) =>- client.updateTaskChannelRepositories(channelId, integrationId, [- repository,- ]),- ),- );- const updatedById = new Map(- updatedChannels.map((channel) => [channel.id, channel]),- );- queryClient.setQueryData<TaskChannel[]>(TASK_CHANNELS_QUERY_KEY, (channels) =>- channels?.map((channel) => updatedById.get(channel.id) ?? channel),- );-- return updatedChannels.length;-}diff --git a/products/desktop/packages/ui/src/features/onboarding/types.ts b/products/desktop/packages/ui/src/features/onboarding/types.tsdeleted file mode 100644index 7473aebc4594..000000000000--- a/products/desktop/packages/ui/src/features/onboarding/types.ts+++ /dev/null@@ -1,4 +0,0 @@-export type {- DetectedRepo,- OnboardingStep,-} from "@posthog/core/onboarding/steps";