: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
perf(desktop): stop whole-document restyles and svg spinner churn (#91360)
Charles Vien6ba1f62e841f
diff --git a/products/desktop/docs/CONVENTIONS.md b/products/desktop/docs/CONVENTIONS.mdindex 88f4ca2a1d5d..41175e769147 100644--- a/products/desktop/docs/CONVENTIONS.md+++ b/products/desktop/docs/CONVENTIONS.md@@ -166,6 +166,12 @@ When creating reusable styled components, accept both `className?: string` and `Default line heights are set in [packages/ui/src/styles/globals.css](../packages/ui/src/styles/globals.css). Add `leading-*` only when the component needs a non-default line height. Pair arbitrary body text sizes with `leading-snug`; pair titles with `leading-tight`.+Spinning icons go through `Spin` or `Spinner` from [packages/ui/src/primitives/Spinner.tsx](../packages/ui/src/primitives/Spinner.tsx). Never put `animate-spin` on an `<svg>`: Chromium animates SVG transforms on the main thread, so one visible spinner costs a style recalc and a layerize pass on every frame. Stop the animation (`spinning={false}`) or unmount the spinner when it is hidden behind `opacity-0`.++Do not write a `:has()` rule with `html` or `body` as the anchor and a descendant subject (`body:has(...) .thing`). Chromium re-checks such a rule after DOM mutations anywhere and restyles the whole document. Set custom properties on the anchor instead and consume them where the style applies, as the quill portal rule in `globals.css` does.++Animate `transform` and `opacity` only. Keyframes on `left`, `width`, or `height` force a layout every frame.+## LoggingDo not use `console.*` in source. Inject `ROOT_LOGGER` as `RootLogger`, then scope it.diff --git a/products/desktop/packages/ui/src/features/autoresearch/AutoresearchPanel.test.tsx b/products/desktop/packages/ui/src/features/autoresearch/AutoresearchPanel.test.tsxindex 844a24548d43..8bd5fff9c60e 100644--- a/products/desktop/packages/ui/src/features/autoresearch/AutoresearchPanel.test.tsx+++ b/products/desktop/packages/ui/src/features/autoresearch/AutoresearchPanel.test.tsx@@ -57,9 +57,12 @@ describe("PreBaselineState", () => {});expect(screen.getByText("Establishing the baseline")).toBeVisible();+ expect(+ screen.getByRole("status", { name: "Loading" }).parentElement,+ ).toHaveClass("animate-spin", "motion-reduce:animate-none");expect(screen.getByRole("status", { name: "Loading" })).toHaveClass(- "motion-safe:animate-spin",- "motion-reduce:animate-none",+ "size-5",+ "animate-none",);const metrics = screen.getByRole("status", {name: "Loading autoresearch metrics",diff --git a/products/desktop/packages/ui/src/features/autoresearch/PreBaselineState.tsx b/products/desktop/packages/ui/src/features/autoresearch/PreBaselineState.tsxindex 3183710c8ed2..df43ef988e41 100644--- a/products/desktop/packages/ui/src/features/autoresearch/PreBaselineState.tsx+++ b/products/desktop/packages/ui/src/features/autoresearch/PreBaselineState.tsx@@ -1,6 +1,7 @@import { MagnifyingGlass } from "@phosphor-icons/react";import type { AutoresearchRun } from "@posthog/core/autoresearch/schemas";import { Spinner } from "@posthog/quill";+import { Spin } from "@posthog/ui/primitives/Spinner";import { Badge, Skeleton, Text } from "@radix-ui/themes";export interface SessionActivity {@@ -24,7 +25,9 @@ export function PreBaselineState({<div className="flex items-start gap-3 rounded-md border border-blue-6 bg-blue-2 px-3 py-3">{live && (<span className="relative mt-0.5 size-5 shrink-0">- <Spinner className="size-5 motion-safe:animate-spin motion-reduce:animate-none" />+ <Spin className="size-5 motion-reduce:animate-none">+ <Spinner className="size-5 animate-none" />+ </Spin></span>)}<div>diff --git a/products/desktop/packages/ui/src/features/canvas/freeform/CanvasBuildStatus.tsx b/products/desktop/packages/ui/src/features/canvas/freeform/CanvasBuildStatus.tsxindex 819194490a0b..1d4e089e2a1c 100644--- a/products/desktop/packages/ui/src/features/canvas/freeform/CanvasBuildStatus.tsx+++ b/products/desktop/packages/ui/src/features/canvas/freeform/CanvasBuildStatus.tsx@@ -21,6 +21,7 @@ import {TooltipTrigger,} from "@posthog/quill";import type { CanvasDiagnostic } from "@posthog/shared";+import { Spin } from "@posthog/ui/primitives/Spinner";import { toast } from "@posthog/ui/primitives/toast";import { useMutation, useQueryClient } from "@tanstack/react-query";import { useEffect, useState } from "react";@@ -106,7 +107,9 @@ export function CanvasBuildStatus({className="flex items-center gap-1"data-testid="canvas-build-active">- <SpinnerGapIcon size={14} className="animate-spin text-gray-9" />+ <Spin className="text-gray-9">+ <SpinnerGapIcon size={14} />+ </Spin><Text size="xs" variant="muted">{active.buildStatus === "queued" ? "Queued" : "Building"} · {elapsed}</Text>diff --git a/products/desktop/packages/ui/src/features/canvas/freeform/CanvasSidePanel.tsx b/products/desktop/packages/ui/src/features/canvas/freeform/CanvasSidePanel.tsxindex 25f24b2fa82e..f02265793500 100644--- a/products/desktop/packages/ui/src/features/canvas/freeform/CanvasSidePanel.tsx+++ b/products/desktop/packages/ui/src/features/canvas/freeform/CanvasSidePanel.tsx@@ -18,6 +18,7 @@ import { useCanvasChatPanelStore } from "@posthog/ui/features/canvas/stores/canvimport type { EditorHandle } from "@posthog/ui/features/message-editor/types";import { EmbeddedSessionView } from "@posthog/ui/features/sessions/components/EmbeddedSessionView";import { taskDetailQuery } from "@posthog/ui/features/tasks/queries";+import { Spin } from "@posthog/ui/primitives/Spinner";import { useQuery } from "@tanstack/react-query";import { type Ref, useEffect, useRef } from "react";@@ -165,7 +166,9 @@ function CanvasChatLoader({ taskId }: { taskId: string }) {if (!task) {return (<div className="flex h-full items-center justify-center">- <SpinnerGapIcon size={18} className="animate-spin text-gray-9" />+ <Spin className="text-gray-9">+ <SpinnerGapIcon size={18} />+ </Spin></div>);}@@ -193,7 +196,9 @@ function CanvasCommentsLoader({if (!task) {return (<div className="flex h-full items-center justify-center">- <SpinnerGapIcon size={18} className="animate-spin text-gray-9" />+ <Spin className="text-gray-9">+ <SpinnerGapIcon size={18} />+ </Spin></div>);}diff --git a/products/desktop/packages/ui/src/features/canvas/freeform/FreeformCanvasView.tsx b/products/desktop/packages/ui/src/features/canvas/freeform/FreeformCanvasView.tsxindex 3cba1a0c6803..dae4c63adcf1 100644--- a/products/desktop/packages/ui/src/features/canvas/freeform/FreeformCanvasView.tsx+++ b/products/desktop/packages/ui/src/features/canvas/freeform/FreeformCanvasView.tsx@@ -77,6 +77,7 @@ import { useCommentsQuery } from "@posthog/ui/features/sessions/components/useCoimport { useSessionForTask } from "@posthog/ui/features/sessions/useSession";import { taskDetailQuery } from "@posthog/ui/features/tasks/queries";import { ResizableSidebar } from "@posthog/ui/primitives/ResizableSidebar";+import { Spin } from "@posthog/ui/primitives/Spinner";import { toast } from "@posthog/ui/primitives/toast";import { track } from "@posthog/ui/shell/analytics";import {@@ -924,10 +925,9 @@ export function FreeformCanvasView({{interactive &&(isGenerating && effectiveTaskId ? (<>- <SpinnerGapIcon- size={14}- className="animate-spin text-accent-9"- />+ <Spin className="text-accent-9">+ <SpinnerGapIcon size={14} />+ </Spin><Text size="1" className="text-gray-10">Generating</Text>@@ -1293,7 +1293,9 @@ function LoadingState() {<Empty className="h-full"><EmptyHeader><EmptyMedia variant="icon">- <SpinnerGapIcon size={18} className="animate-spin text-accent-9" />+ <Spin className="text-accent-9">+ <SpinnerGapIcon size={18} />+ </Spin></EmptyMedia><EmptyTitle>Loading canvas</EmptyTitle></EmptyHeader>@@ -1314,7 +1316,9 @@ function GeneratingState({<Empty className="h-full border-0"><EmptyHeader><EmptyMedia variant="icon">- <SpinnerGapIcon size={18} className="animate-spin text-accent-9" />+ <Spin className="text-accent-9">+ <SpinnerGapIcon size={18} />+ </Spin></EmptyMedia><EmptyTitle>Generating</EmptyTitle><EmptyDescription>An agent is building this canvas.</EmptyDescription>diff --git a/products/desktop/packages/ui/src/features/connectivity/ConnectivityBanner.tsx b/products/desktop/packages/ui/src/features/connectivity/ConnectivityBanner.tsxindex 9d3020bed6f5..aa9aa18f83c9 100644--- a/products/desktop/packages/ui/src/features/connectivity/ConnectivityBanner.tsx+++ b/products/desktop/packages/ui/src/features/connectivity/ConnectivityBanner.tsx@@ -1,6 +1,7 @@import { ArrowsClockwise, WifiHigh, WifiSlash } from "@phosphor-icons/react";import { useService } from "@posthog/di/react";import { useConnectivity } from "@posthog/ui/hooks/useConnectivity";+import { Spin } from "@posthog/ui/primitives/Spinner";import { Box } from "@radix-ui/themes";import { AnimatePresence, motion } from "framer-motion";import { useEffect, useRef, useState } from "react";@@ -101,10 +102,9 @@ function OfflineRow({onClick={onRetry}className="flex shrink-0 items-center gap-1.5 rounded-2 bg-(--amber-a4) px-2 py-1 font-medium text-(--amber-11) text-[12px] transition-colors hover:bg-(--amber-a5) disabled:opacity-60">- <ArrowsClockwise- size={13}- className={isChecking ? "animate-spin" : undefined}- />+ <Spin spinning={isChecking}>+ <ArrowsClockwise size={13} />+ </Spin>{isChecking ? "Checking…" : "Retry"}</button></div>diff --git a/products/desktop/packages/ui/src/features/folder-picker/FolderPicker.tsx b/products/desktop/packages/ui/src/features/folder-picker/FolderPicker.tsxindex 67849b72363b..40cf21ae1fef 100644--- a/products/desktop/packages/ui/src/features/folder-picker/FolderPicker.tsx+++ b/products/desktop/packages/ui/src/features/folder-picker/FolderPicker.tsx@@ -28,6 +28,7 @@ import {} from "@posthog/quill";import type { RegisteredFolder } from "@posthog/ui/features/folders/types";import { useFolders } from "@posthog/ui/features/folders/useFolders";+import { Spin } from "@posthog/ui/primitives/Spinner";import { toast } from "@posthog/ui/primitives/toast";import { FIELD_TRIGGER_CLASS } from "@posthog/ui/styles/fieldTrigger";import { Text } from "@radix-ui/themes";@@ -178,10 +179,9 @@ export function FolderPicker({</Text></div>{isOpening ? (- <CircleNotch- size={14}- className="shrink-0 animate-spin text-(--gray-9)"- />+ <Spin className="shrink-0 text-(--gray-9)">+ <CircleNotch size={14} />+ </Spin>) : (<CaretDown size={14} className="shrink-0 text-(--gray-9)" />)}@@ -195,7 +195,9 @@ export function FolderPicker({{isOpening ? "Opening..." : displayValue || placeholder}</span>{isOpening ? (- <CircleNotch size={10} className="animate-spin text-muted-foreground" />+ <Spin className="text-muted-foreground">+ <CircleNotch size={10} />+ </Spin>) : (<CaretDown size={10} weight="bold" className="text-muted-foreground" />)}diff --git a/products/desktop/packages/ui/src/features/folder-picker/GitHubRepoPicker.tsx b/products/desktop/packages/ui/src/features/folder-picker/GitHubRepoPicker.tsxindex 6464a1bbe00f..7ee6c7ee82cb 100644--- a/products/desktop/packages/ui/src/features/folder-picker/GitHubRepoPicker.tsx+++ b/products/desktop/packages/ui/src/features/folder-picker/GitHubRepoPicker.tsx@@ -18,6 +18,7 @@ import {Spinner,Text,} from "@posthog/quill";+import { Spin } from "@posthog/ui/primitives/Spinner";import { Tooltip } from "@posthog/ui/primitives/Tooltip";import { FIELD_TRIGGER_CLASS } from "@posthog/ui/styles/fieldTrigger";import { defaultFilter } from "cmdk";@@ -290,10 +291,9 @@ export function GitHubRepoPicker({onRefresh();}}>- <ArrowClockwise- size={14}- className={isRefreshing ? "animate-spin" : undefined}- />+ <Spin spinning={isRefreshing}>+ <ArrowClockwise size={14} />+ </Spin></InputGroupButton></InputGroupAddon>) : null}diff --git a/products/desktop/packages/ui/src/features/git-interaction/components/BranchSelector.tsx b/products/desktop/packages/ui/src/features/git-interaction/components/BranchSelector.tsxindex 22d257678ad1..0baf3c66cab6 100644--- a/products/desktop/packages/ui/src/features/git-interaction/components/BranchSelector.tsx+++ b/products/desktop/packages/ui/src/features/git-interaction/components/BranchSelector.tsx@@ -4,7 +4,6 @@ import {Check,GitBranch,Plus,- Spinner,} from "@phosphor-icons/react";import { useService } from "@posthog/di/react";import { useHostTRPC } from "@posthog/host-router/react";@@ -26,6 +25,7 @@ import type {GitBusyOperation,GitBusyState,} from "@posthog/shared/domain-types";+import { Spin, Spinner } from "@posthog/ui/primitives/Spinner";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { type RefObject, useEffect, useMemo, useRef, useState } from "react";import { Tooltip } from "../../../primitives/Tooltip";@@ -59,7 +59,7 @@ const USE_INPUT_BRANCH_ACTION = "__use_input_branch__";function LoadingRow({ label }: { label: string }) {return (<div className="flex items-center gap-1 px-2 py-1.5 text-muted-foreground text-xs">- <Spinner size={12} className="animate-spin" />+ <Spinner size={12} />{label}</div>);@@ -386,7 +386,7 @@ export function BranchSelector({className="min-w-0 max-w-[250px] shrink">{showSpinner ? (- <Spinner size={14} className="shrink-0 animate-spin" />+ <Spinner size={14} className="shrink-0" />) : (<GitBranch size={14} weight="regular" className="shrink-0" />)}@@ -470,10 +470,9 @@ export function BranchSelector({onRefresh();}}>- <ArrowClockwise- size={14}- className={isRefreshing ? "animate-spin" : undefined}- />+ <Spin spinning={isRefreshing}>+ <ArrowClockwise size={14} />+ </Spin></InputGroupButton>) : null}</InputGroupAddon>@@ -586,7 +585,7 @@ export function BranchSelector({>{cloudBranchesFetchingMore ? (<>- <Spinner size={14} className="animate-spin" />+ <Spinner size={14} />Loading more…</>) : (diff --git a/products/desktop/packages/ui/src/features/inbox/components/ResponderAgentRoster.tsx b/products/desktop/packages/ui/src/features/inbox/components/ResponderAgentRoster.tsxindex a93c745f62e8..3355d95498e0 100644--- a/products/desktop/packages/ui/src/features/inbox/components/ResponderAgentRoster.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/ResponderAgentRoster.tsx@@ -14,6 +14,7 @@ import type { SignalSourceValues } from "@posthog/ui/features/inbox/components/Simport { InboxBadge } from "@posthog/ui/features/inbox/components/utils/InboxBadge";import { getSourceProductMeta } from "@posthog/ui/features/inbox/components/utils/source-product-icons";import { Badge } from "@posthog/ui/primitives/Badge";+import { Spin } from "@posthog/ui/primitives/Spinner";import { Box, Flex, Spinner, Switch, Text } from "@radix-ui/themes";import { type ComponentType, memo, useCallback } from "react";@@ -225,10 +226,9 @@ const ResponderAgentCard = memo(function ResponderAgentCard({{armed && agent.source === "session_replay" && status === "syncing" ? (<Flex align="center" gap="2" className="mt-2 ml-8">- <CircleNotchIcon- size={14}- className="animate-spin text-(--accent-11)"- />+ <Spin className="text-(--accent-11)">+ <CircleNotchIcon size={14} />+ </Spin><Text className="text-(--accent-11) text-[13px]">Session analysis run in progress…</Text>diff --git a/products/desktop/packages/ui/src/features/inbox/components/SignalSourceToggles.tsx b/products/desktop/packages/ui/src/features/inbox/components/SignalSourceToggles.tsxindex 224c0b59b6f9..2cd542553566 100644--- a/products/desktop/packages/ui/src/features/inbox/components/SignalSourceToggles.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/SignalSourceToggles.tsx@@ -21,6 +21,7 @@ import {import { GitHubSourceRepositoriesDialog } from "@posthog/ui/features/inbox/components/GitHubSourceRepositoriesDialog";import { getSourceProductMeta } from "@posthog/ui/features/inbox/components/utils/source-product-icons";import { Badge } from "@posthog/ui/primitives/Badge";+import { Spin } from "@posthog/ui/primitives/Spinner";import { memo, useCallback, useState } from "react";export type SignalSourceValues = Record<ToggleableSourceProduct, boolean>;@@ -317,7 +318,9 @@ function SourceRunningIndicator({}return (<div className="mt-2 flex items-center gap-2">- <CircleNotchIcon size={14} className="animate-spin text-(--accent-11)" />+ <Spin className="text-(--accent-11)">+ <CircleNotchIcon size={14} />+ </Spin><span className="text-(--accent-11) text-[13px]">{message}</span></div>);diff --git a/products/desktop/packages/ui/src/features/loops/components/LoopRunRow.tsx b/products/desktop/packages/ui/src/features/loops/components/LoopRunRow.tsxindex 869e64e3a566..216fd0215980 100644--- a/products/desktop/packages/ui/src/features/loops/components/LoopRunRow.tsx+++ b/products/desktop/packages/ui/src/features/loops/components/LoopRunRow.tsx@@ -16,6 +16,7 @@ import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";import { StopCloudRunDialog } from "@posthog/ui/features/sessions/components/StopCloudRunDialog";import { Badge } from "@posthog/ui/primitives/Badge";import { Button } from "@posthog/ui/primitives/Button";+import { Spin } from "@posthog/ui/primitives/Spinner";import { toast } from "@posthog/ui/primitives/toast";import { navigateToTaskDetail } from "@posthog/ui/router/navigationBridge";import { track } from "@posthog/ui/shell/analytics";@@ -145,11 +146,9 @@ export function LoopRunRow({<Flex direction="column" className="min-w-0 gap-1.5"><Flex align="center" gap="2" wrap="wrap"><Badge color={statusColor(run.status)}>- <StatusIcon- size={10}- weight="bold"- className={cn(run.status === "in_progress" && "animate-spin")}- />+ <Spin spinning={run.status === "in_progress"}>+ <StatusIcon size={10} weight="bold" />+ </Spin>{run.status.replaceAll("_", " ")}</Badge><Textdiff --git a/products/desktop/packages/ui/src/features/onboarding/components/CliCheckPanel.tsx b/products/desktop/packages/ui/src/features/onboarding/components/CliCheckPanel.tsxindex 1f620eecd81f..25505f38c892 100644--- a/products/desktop/packages/ui/src/features/onboarding/components/CliCheckPanel.tsx+++ b/products/desktop/packages/ui/src/features/onboarding/components/CliCheckPanel.tsx@@ -1,5 +1,6 @@import { CheckCircle, CircleNotch } from "@phosphor-icons/react";import { PANEL_SHADOW } from "@posthog/ui/features/onboarding/components/onboardingStyles";+import { Spin } from "@posthog/ui/primitives/Spinner";import { Box, Flex, Text } from "@radix-ui/themes";import type { ReactNode } from "react";@@ -33,7 +34,9 @@ export function CliCheckPanel({</Text></Flex>{isLoading ? (- <CircleNotch size={14} className="animate-spin text-(--gray-9)" />+ <Spin className="text-(--gray-9)">+ <CircleNotch size={14} />+ </Spin>) : (statusBadge)}diff --git a/products/desktop/packages/ui/src/features/onboarding/components/SelectRepoStep.tsx b/products/desktop/packages/ui/src/features/onboarding/components/SelectRepoStep.tsxindex 7c0f3ac5d153..da56a684a915 100644--- a/products/desktop/packages/ui/src/features/onboarding/components/SelectRepoStep.tsx+++ b/products/desktop/packages/ui/src/features/onboarding/components/SelectRepoStep.tsx@@ -6,6 +6,7 @@ import {} from "@phosphor-icons/react";import { repoMatchesGitHubRepos } from "@posthog/core/onboarding/repoProvider";import { cn } from "@posthog/quill";+import { Spin } from "@posthog/ui/primitives/Spinner";import { useHostCapabilities } from "@posthog/ui/shell/useHostCapabilities";import { Button, Flex, Text } from "@radix-ui/themes";import { AnimatePresence, motion } from "framer-motion";@@ -149,10 +150,9 @@ export function SelectRepoStep({transition={{ duration: 0.15 }}><Flex align="center" gap="2">- <CircleNotch- size={14}- className="animate-spin text-(--gray-9)"- />+ <Spin className="text-(--gray-9)">+ <CircleNotch size={14} />+ </Spin><Text className="text-(--gray-9) text-[13px]">Detecting repository...</Text>diff --git a/products/desktop/packages/ui/src/features/pi-sessions/PiSessionControls.tsx b/products/desktop/packages/ui/src/features/pi-sessions/PiSessionControls.tsxindex 751e12254fb8..2be5502ab9a5 100644--- a/products/desktop/packages/ui/src/features/pi-sessions/PiSessionControls.tsx+++ b/products/desktop/packages/ui/src/features/pi-sessions/PiSessionControls.tsx@@ -1,10 +1,4 @@-import {- CaretDown,- Lightning,- PiIcon,- Spinner,- Stack,-} from "@phosphor-icons/react";+import { CaretDown, Lightning, PiIcon, Stack } from "@phosphor-icons/react";import type {PiModelSelection,PiThinkingLevel,@@ -31,6 +25,7 @@ import {ModelCostFooter,} from "@posthog/ui/features/sessions/components/ModelCostChip";import type { MessagingMode } from "@posthog/ui/features/sessions/messagingModeStore";+import { Spinner } from "@posthog/ui/primitives/Spinner";import { useState } from "react";type PiModelOption = PiModelSelection & { name?: string };@@ -97,7 +92,7 @@ export function PiModelSelector({<span className="text-muted-foreground"><PiIcon size={14} weight="bold" className="translate-y-px" /></span>- <Spinner size={12} className="animate-spin" />+ <Spinner size={12} />Loading...</Button>}@@ -121,7 +116,7 @@ export function PiModelSelector({/>)}<DropdownMenuItem disabled>- <Spinner size={12} className="animate-spin" />+ <Spinner size={12} />Loading models...</DropdownMenuItem></DropdownMenuContent>diff --git a/products/desktop/packages/ui/src/features/pr-review/PrChecksSection.tsx b/products/desktop/packages/ui/src/features/pr-review/PrChecksSection.tsxindex b0f3af955227..5fec6ab82da8 100644--- a/products/desktop/packages/ui/src/features/pr-review/PrChecksSection.tsx+++ b/products/desktop/packages/ui/src/features/pr-review/PrChecksSection.tsx@@ -10,6 +10,7 @@ import {import type { PrCheck, PrCheckBucket } from "@posthog/core/git/router-schemas";import { Spinner } from "@posthog/quill";import { DetailSection } from "@posthog/ui/features/inbox/components/DetailSection";+import { Spin } from "@posthog/ui/primitives/Spinner";import { useMemo } from "react";import { openExternalUrl } from "../../shell/openExternal";import { usePrChecks } from "./usePrChecks";@@ -178,10 +179,9 @@ function CheckBucketIcon({ bucket }: { bucket: PrCheckBucket }) {return <ProhibitIcon size={14} className="shrink-0 text-(--gray-9)" />;case "pending":return (- <CircleNotchIcon- size={14}- className="shrink-0 animate-spin text-(--amber-9)"- />+ <Spin className="shrink-0 text-(--amber-9)">+ <CircleNotchIcon size={14} />+ </Spin>);case "pass":return (diff --git a/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsx b/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsxindex c07f3f4184bd..bcde8c65fc23 100644--- a/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsx+++ b/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsx@@ -17,6 +17,7 @@ import {DropdownMenuTrigger,Spinner,} from "@posthog/quill";+import { Spin } from "@posthog/ui/primitives/Spinner";import { useState } from "react";import { PrChecksSection } from "./PrChecksSection";import { useApprovePr } from "./useApprovePr";@@ -115,7 +116,9 @@ export function PrDecisionBlock({ prUrl }: PrDecisionBlockProps) {</span>) : gate.pendingChecks > 0 ? (<span className="flex items-center gap-1.5 text-(--amber-11)">- <CircleNotchIcon size={14} className="animate-spin" />+ <Spin>+ <CircleNotchIcon size={14} />+ </Spin>Checks running</span>) : gate.totalChecks === 0 ? (diff --git a/products/desktop/packages/ui/src/features/sessions/components/CloudSessionLifecycle.tsx b/products/desktop/packages/ui/src/features/sessions/components/CloudSessionLifecycle.tsxindex 37f6e0ac2d03..1fd80c3729b6 100644--- a/products/desktop/packages/ui/src/features/sessions/components/CloudSessionLifecycle.tsx+++ b/products/desktop/packages/ui/src/features/sessions/components/CloudSessionLifecycle.tsx@@ -1,4 +1,5 @@-import { Spinner, Warning } from "@phosphor-icons/react";+import { Warning } from "@phosphor-icons/react";+import { Spinner } from "@posthog/ui/primitives/Spinner";import { Button, Flex, Text } from "@radix-ui/themes";interface CloudStreamDisconnectedBannerProps {@@ -52,10 +53,10 @@ export function CloudStreamDisconnectedBanner({);}-export function ConnectingToAgent() {+export function ConnectingToAgent({ spinning = true }: { spinning?: boolean }) {return (<>- <Spinner size={28} className="animate-spin text-gray-9" />+ <Spinner size={28} spinning={spinning} className="text-gray-9" /><Text color="gray" className="text-base">Connecting to agent...</Text>diff --git a/products/desktop/packages/ui/src/features/sessions/components/ReasoningLevelSelector.tsx b/products/desktop/packages/ui/src/features/sessions/components/ReasoningLevelSelector.tsxindex c4f8dfc9c250..39e100641e33 100644--- a/products/desktop/packages/ui/src/features/sessions/components/ReasoningLevelSelector.tsx+++ b/products/desktop/packages/ui/src/features/sessions/components/ReasoningLevelSelector.tsx@@ -2,11 +2,7 @@ import type {SessionConfigOption,SessionConfigSelectGroup,} from "@agentclientprotocol/sdk";-import {- ArrowCounterClockwise,- Lightning,- Spinner,-} from "@phosphor-icons/react";+import { ArrowCounterClockwise, Lightning } from "@phosphor-icons/react";import {getCapabilityLadder,getReasoningEffortOptions,@@ -44,6 +40,7 @@ import { ModelCostFooter } from "@posthog/ui/features/sessions/components/ModelCimport { ModelRadioItem } from "@posthog/ui/features/sessions/components/ModelRadioItem";import type { AgentAdapter } from "@posthog/ui/features/settings/settingsStore";import { AnimatedHeight } from "@posthog/ui/primitives/AnimatedHeight";+import { Spinner } from "@posthog/ui/primitives/Spinner";import { AnimatePresence, motion } from "framer-motion";import { Fragment, useRef, useState } from "react";import { flattenSelectOptions } from "../sessionStore";@@ -163,7 +160,7 @@ export function ReasoningLevelSelector({<DropdownMenuTriggerrender={<Button type="button" variant="default" size="sm">- <Spinner size={12} className="animate-spin" />+ <Spinner size={12} />Loading...</Button>}@@ -183,7 +180,7 @@ export function ReasoningLevelSelector({/>)}<DropdownMenuItem disabled>- <Spinner size={12} className="animate-spin" />+ <Spinner size={12} />Loading models...</DropdownMenuItem></DropdownMenuContent>diff --git a/products/desktop/packages/ui/src/features/sessions/components/SessionInitializingView.tsx b/products/desktop/packages/ui/src/features/sessions/components/SessionInitializingView.tsxindex 7ee16c32773d..3e555a856598 100644--- a/products/desktop/packages/ui/src/features/sessions/components/SessionInitializingView.tsx+++ b/products/desktop/packages/ui/src/features/sessions/components/SessionInitializingView.tsx@@ -1,5 +1,5 @@-import { Spinner } from "@phosphor-icons/react";import type { TaskRunStatus } from "@posthog/shared/domain-types";+import { Spinner } from "@posthog/ui/primitives/Spinner";import { Flex, Text } from "@radix-ui/themes";import { useEffect, useState } from "react";import zenHedgehog from "../../../assets/images/zen.png";@@ -66,7 +66,7 @@ export function SessionInitializingView({justify="center"className="absolute inset-0 bg-background">- <Spinner size={32} className="animate-spin text-gray-9" />+ <Spinner size={32} className="text-gray-9" /></Flex>);}@@ -84,7 +84,7 @@ export function SessionInitializingView({</div><Flex direction="column" align="center" gap="2"><Flex align="center" gap="2">- <Spinner size={16} className="animate-spin text-gray-9" />+ <Spinner size={16} className="text-gray-9" /><Text className="font-medium text-base">{visibleHeading}</Text></Flex><Text color="gray" className="text-sm">diff --git a/products/desktop/packages/ui/src/features/sessions/components/SessionView.tsx b/products/desktop/packages/ui/src/features/sessions/components/SessionView.tsxindex 49e021d7f194..645935fc8441 100644--- a/products/desktop/packages/ui/src/features/sessions/components/SessionView.tsx+++ b/products/desktop/packages/ui/src/features/sessions/components/SessionView.tsx@@ -1,4 +1,4 @@-import { Pause, Spinner, Warning } from "@phosphor-icons/react";+import { Pause, Warning } from "@phosphor-icons/react";import type { FileAttachment } from "@posthog/core/message-editor/content";import { hasSessionPromptEvent } from "@posthog/core/sessions/sessionEvents";import {@@ -87,6 +87,7 @@ import type { Plan } from "@posthog/ui/features/sessions/types";import { useSettingsStore } from "@posthog/ui/features/settings/settingsStore";import { useIsWorkspaceCloudRun } from "@posthog/ui/features/workspace/useWorkspace";import { useConnectivity } from "@posthog/ui/hooks/useConnectivity";+import { Spinner } from "@posthog/ui/primitives/Spinner";import { toast } from "@posthog/ui/primitives/toast";import { captureException, track } from "@posthog/ui/shell/analytics";import {@@ -728,7 +729,7 @@ export function SessionView({>{isRestoring ? (<>- <Spinner size={14} className="animate-spin" />+ <Spinner size={14} />Restoring...</>) : (@@ -757,7 +758,7 @@ export function SessionView({justify="center"className="absolute inset-0 bg-background">- <Spinner size={32} className="animate-spin text-gray-9" />+ <Spinner size={32} className="text-gray-9" /></Flex>)) : (@@ -858,7 +859,7 @@ export function SessionView({: "opacity-100"}`}>- <ConnectingToAgent />+ <ConnectingToAgent spinning={!isRunning} /></Box><BoxclassName={`transition-all duration-300 ease-out ${diff --git a/products/desktop/packages/ui/src/features/sessions/components/SideQuestionCard.tsx b/products/desktop/packages/ui/src/features/sessions/components/SideQuestionCard.tsxindex 5d2386796695..abc689b841a9 100644--- a/products/desktop/packages/ui/src/features/sessions/components/SideQuestionCard.tsx+++ b/products/desktop/packages/ui/src/features/sessions/components/SideQuestionCard.tsx@@ -1,5 +1,6 @@-import { ChatCircleDots, Spinner, X } from "@phosphor-icons/react";+import { ChatCircleDots, X } from "@phosphor-icons/react";import { useSideQuestionStore } from "@posthog/ui/features/sessions/sideQuestionStore";+import { Spinner } from "@posthog/ui/primitives/Spinner";import { Box, Flex, IconButton, Text, Tooltip } from "@radix-ui/themes";import { MarkdownRenderer } from "../../editor/components/MarkdownRenderer";@@ -45,7 +46,7 @@ export function SideQuestionCard({ taskId, taskRunId }: SideQuestionCardProps) {<Box className="mt-1 pl-6" role="status" aria-live="polite">{entry.status === "pending" && (<Flex align="center" gap="2">- <Spinner size={14} className="animate-spin text-gray-9" />+ <Spinner size={14} className="text-gray-9" /><Text className="text-[13px] text-gray-9">Answering…</Text></Flex>)}diff --git a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.tsx b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.tsxindex 26a66b7599f2..8c7027e4229a 100644--- a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.tsx+++ b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatMarkdown.tsx@@ -26,6 +26,7 @@ import {looksLikeBareFilename,} from "@posthog/ui/features/sessions/components/session-update/fileLinkChips";import { HighlightedCode } from "@posthog/ui/primitives/HighlightedCode";+import { Spin } from "@posthog/ui/primitives/Spinner";import { useCopy } from "@posthog/ui/primitives/useCopy";import { parseArtifactLink } from "@posthog/ui/utils/artifactLinks";import {@@ -91,7 +92,9 @@ const components: Components = {aria-label="Link loading">{children}- <CircleNotch className="size-3 animate-spin" aria-hidden="true" />+ <Spin>+ <CircleNotch size={12} aria-hidden="true" />+ </Spin></output>);}diff --git a/products/desktop/packages/ui/src/features/sessions/components/session-update/StatusNotificationView.tsx b/products/desktop/packages/ui/src/features/sessions/components/session-update/StatusNotificationView.tsxindex 10fcef5fd9fc..2432b2d84a00 100644--- a/products/desktop/packages/ui/src/features/sessions/components/session-update/StatusNotificationView.tsx+++ b/products/desktop/packages/ui/src/features/sessions/components/session-update/StatusNotificationView.tsx@@ -1,10 +1,6 @@-import {- ArrowsClockwise,- ShieldWarning,- Spinner,- XCircle,-} from "@phosphor-icons/react";+import { ArrowsClockwise, ShieldWarning, XCircle } from "@phosphor-icons/react";import { ChatMarker, ChatMarkerContent } from "@posthog/quill";+import { Spin, Spinner } from "@posthog/ui/primitives/Spinner";import { Box, Callout, Flex, Text } from "@radix-ui/themes";import { useEffect, useState } from "react";import { useChatThreadChrome } from "../chat-thread/chatThreadChrome";@@ -248,7 +244,9 @@ function RetryingStatusView({<ChatMarker variant="separator"><ChatMarkerContent><Flex align="center" gap="2">- <ArrowsClockwise size={13} className="animate-spin text-amber-9" />+ <Spin className="text-amber-9">+ <ArrowsClockwise size={13} />+ </Spin><Text className="text-[13px] text-gray-11">{retryLabel}</Text></Flex></ChatMarkerContent>@@ -289,7 +287,7 @@ function CompactingStatusView({return (<Box className="my-1 border-blue-6 border-l-2 px-3 py-1 dark:border-blue-8"><Flex align="center" gap="2">- <Spinner size={14} className="animate-spin text-blue-9" />+ <Spinner size={14} className="text-blue-9" /><Text className="text-[13px] text-gray-11">{label}</Text><Text className="text-[13px] text-gray-10 tabular-nums">{formatDuration(elapsed, 1)}diff --git a/products/desktop/packages/ui/src/features/settings/sections/AccountSettings.tsx b/products/desktop/packages/ui/src/features/settings/sections/AccountSettings.tsxindex 76098e924cf5..5c9bb92c1a6c 100644--- a/products/desktop/packages/ui/src/features/settings/sections/AccountSettings.tsx+++ b/products/desktop/packages/ui/src/features/settings/sections/AccountSettings.tsx@@ -18,6 +18,7 @@ import {SettingsCardRow,SettingsSection,} from "@posthog/ui/features/settings/components/SettingsCard";+import { Spin } from "@posthog/ui/primitives/Spinner";import { Tooltip } from "@posthog/ui/primitives/Tooltip";import { useCallback, useState } from "react";@@ -130,10 +131,9 @@ export function ProfilePictureRow({disabled={checking}onClick={onRefresh}>- <ArrowsClockwise- size={12}- className={cn(checking && "motion-safe:animate-spin")}- />+ <Spin spinning={checking} className="motion-reduce:animate-none">+ <ArrowsClockwise size={12} />+ </Spin></Button></Tooltip><Buttondiff --git a/products/desktop/packages/ui/src/features/sidebar/components/GroupWorktreesSection.tsx b/products/desktop/packages/ui/src/features/sidebar/components/GroupWorktreesSection.tsxindex 3ef47021e9e3..d3404452593a 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/GroupWorktreesSection.tsx+++ b/products/desktop/packages/ui/src/features/sidebar/components/GroupWorktreesSection.tsx@@ -1,9 +1,10 @@-import { GitBranch, Spinner, TreeStructure } from "@phosphor-icons/react";+import { GitBranch, TreeStructure } from "@phosphor-icons/react";import { SidebarItem } from "@posthog/ui/features/sidebar/components/SidebarItem";import { SidebarSection } from "@posthog/ui/features/sidebar/components/SidebarSection";import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";import { useAdoptableWorktrees } from "@posthog/ui/features/sidebar/useAdoptableWorktrees";import { useStartTaskFromWorktree } from "@posthog/ui/features/sidebar/useStartTaskFromWorktree";+import { Spinner } from "@posthog/ui/primitives/Spinner";interface GroupWorktreesSectionProps {groupId: string;@@ -50,7 +51,7 @@ export function GroupWorktreesSection({disabled={isStarting}endContent={isStarting ? (- <Spinner size={12} className="animate-spin text-gray-10" />+ <Spinner size={12} className="text-gray-10" />) : undefined}onClick={() => void startTask(worktree.branch)}diff --git a/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.tsx b/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.tsxindex de4d008d946b..2fb8aaec27ff 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.tsx+++ b/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.tsx@@ -1,4 +1,4 @@-import { ArrowsClockwise, Gift, Spinner, X } from "@phosphor-icons/react";+import { ArrowsClockwise, Gift, X } from "@phosphor-icons/react";import { useSettingsStore } from "@posthog/ui/features/settings/settingsStore";import { useUpdateBannerStore } from "@posthog/ui/features/updates/updateBannerStore";import { useUpdateModalStore } from "@posthog/ui/features/updates/updateModalStore";@@ -6,6 +6,7 @@ import {useInstallUpdate,useUpdateView,} from "@posthog/ui/features/updates/updateStore";+import { Spin, Spinner } from "@posthog/ui/primitives/Spinner";import { Box } from "@radix-ui/themes";import { AnimatePresence, motion } from "framer-motion";@@ -71,7 +72,7 @@ export function UpdateBanner({ variant = "sidebar" }: UpdateBannerProps) {className="flex items-center gap-1.5 text-(--green-11) text-[13px] opacity-70"onClick={openModal}>- <Spinner size={14} className="animate-spin" />+ <Spinner size={14} /><span>Downloading update... {percent}%</span></button>)}@@ -96,7 +97,9 @@ export function UpdateBanner({ variant = "sidebar" }: UpdateBannerProps) {{status === "installing" && (<div className="flex items-center gap-1.5 text-(--green-11) text-[13px] opacity-70">- <ArrowsClockwise size={14} className="animate-spin" />+ <Spin>+ <ArrowsClockwise size={14} />+ </Spin><span>Restarting...</span></div>)}@@ -222,10 +225,9 @@ export function UpdateBanner({ variant = "sidebar" }: UpdateBannerProps) {{status === "installing" && (<BannerCard key="installing"><div className="flex w-full items-center gap-2 rounded-md border border-[var(--green-a5)] bg-[var(--green-a3)] px-3 py-2.5 text-[13px] text-[var(--green-11)]">- <ArrowsClockwise- size={16}- className="shrink-0 animate-spin"- />+ <Spin className="shrink-0">+ <ArrowsClockwise size={16} />+ </Spin><span className="font-medium">Restarting...</span></div></BannerCard>diff --git a/products/desktop/packages/ui/src/primitives/Spinner.tsx b/products/desktop/packages/ui/src/primitives/Spinner.tsxnew file mode 100644index 000000000000..cd93cf04e4b4--- /dev/null+++ b/products/desktop/packages/ui/src/primitives/Spinner.tsx@@ -0,0 +1,37 @@+import { type IconProps, Spinner as SpinnerIcon } from "@phosphor-icons/react";+import { cn } from "@posthog/quill";+import type { ReactNode } from "react";++interface SpinProps {+ spinning?: boolean;+ className?: string;+ children: ReactNode;+}++// Chromium animates transforms on <svg> elements on the main thread, which costs a style+// recalc and layerize pass every frame; on an HTML wrapper the compositor runs it for free.+export function Spin({ spinning = true, className, children }: SpinProps) {+ return (+ <span+ className={cn(+ "inline-flex shrink-0",+ spinning && "animate-spin",+ className,+ )}+ >+ {children}+ </span>+ );+}++interface SpinnerProps extends IconProps {+ spinning?: boolean;+}++export function Spinner({ spinning, className, ...iconProps }: SpinnerProps) {+ return (+ <Spin spinning={spinning} className={className}>+ <SpinnerIcon {...iconProps} />+ </Spin>+ );+}diff --git a/products/desktop/packages/ui/src/primitives/StepList.tsx b/products/desktop/packages/ui/src/primitives/StepList.tsxindex 9ce7e8998a12..713475219f41 100644--- a/products/desktop/packages/ui/src/primitives/StepList.tsx+++ b/products/desktop/packages/ui/src/primitives/StepList.tsx@@ -6,6 +6,7 @@ import {XCircle,} from "@phosphor-icons/react";import { Button, Text } from "@posthog/quill";+import { Spin } from "@posthog/ui/primitives/Spinner";import { openExternalUrl } from "@posthog/ui/shell/openExternal";export type StepStatus = "pending" | "in_progress" | "completed" | "failed";@@ -25,7 +26,11 @@ interface StepIconProps {export function StepIcon({ status, size = 14 }: StepIconProps) {switch (status) {case "in_progress":- return <CircleNotch size={size} className="animate-spin text-blue-9" />;+ return (+ <Spin className="text-blue-9">+ <CircleNotch size={size} />+ </Spin>+ );case "completed":return <CheckCircle size={size} weight="fill" className="text-green-9" />;case "failed":diff --git a/products/desktop/packages/ui/src/styles/globals.css b/products/desktop/packages/ui/src/styles/globals.cssindex 97f5ccb7391a..de4b6991fd57 100644--- a/products/desktop/packages/ui/src/styles/globals.css+++ b/products/desktop/packages/ui/src/styles/globals.css@@ -84,30 +84,28 @@position: absolute;top: 0;left: 0;- width: 50%;+ width: 33.333%;height: 100%;content: "";background: var(--primary);- animation: quill-section-loading-swoop 1.5s linear infinite;+ transform: translateX(-100%);}.quill-section-loading--active {height: 0.125rem;}+.quill-section-loading--active::after {+ animation: quill-section-loading-swoop 1.5s linear infinite;+}++/* Transform only: animating `left`/`width` forced a layout on every frame. */@keyframes quill-section-loading-swoop {- 0% {- left: 0;- width: 33.333%;+ from {transform: translateX(-100%);}- 50% {- width: 50%;- }- 100% {- left: 100%;- width: 33.333%;- transform: translateX(100%);+ to {+ transform: translateX(400%);}}@@ -131,7 +129,7 @@position: absolute;top: 0;left: 0;- width: 50%;+ width: 33.333%;height: 100%;content: "";border-radius: 9999px;@@ -174,11 +172,24 @@* pointer events on the dialog DismissableLayer. Quill portals are separate* body children, so they stay inert unless we set pointer-events here.* (Radix Select/Popover add their own DismissableLayer; Quill does not.)+ *+ * The `:has()` rule keeps `body` as its subject and only sets custom properties+ * there. Chromium re-checks a `:has()` anchored on body after mutations anywhere+ * in the document, and a descendant rule (`body:has(...) [data-quill-portal]`)+ * made each re-check restyle the whole document.*/-body:has([data-overlay="settings"]) [data-quill-portal],-body:has(.rt-DialogOverlay[data-state="open"]) [data-quill-portal] {- z-index: 101;- pointer-events: auto;+body:has([data-overlay="settings"]),+body:has(.rt-DialogOverlay[data-state="open"]) {+ --quill-z-popover: 101;+ --quill-z-tooltip: 101;+ --quill-z-modal: 101;+ --quill-z-overlay: 101;+ --quill-z-toast: 101;+ --quill-portal-pointer-events: auto;+}++[data-quill-portal] {+ pointer-events: var(--quill-portal-pointer-events, inherit);}@config "../../tailwind.config.js";