: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): labeled nav rail with size setting, settings as a dialog (#105267)
Adam Leith386842e45cf7
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsFab.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsFab.tsxindex 222832b601b6..e9d78fce2ad6 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsFab.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsFab.tsx@@ -25,6 +25,7 @@ import {} from "@posthog/ui/features/command/keyboard-shortcuts";import { isContentEmpty } from "@posthog/ui/features/message-editor/content";import { useDraftStore } from "@posthog/ui/features/message-editor/draftStore";+import { useNavRailMetrics } from "@posthog/ui/features/sidebar/navRailSize";import { isTaskInputSessionId } from "@posthog/ui/features/task-detail/taskInputSession";import { openTaskInput } from "@posthog/ui/router/useOpenTask";import { track } from "@posthog/ui/shell/analytics";@@ -47,6 +48,7 @@ export function ChannelsFab({}) {const channelsLayout = useChannelsLayout();const inRail = placement === "rail";+ const { iconSize: railIconSize } = useNavRailMetrics();const [modalOpen, setModalOpen] = useState(false);const hasDraft = useDraftStore((state) =>Object.entries(state.drafts).some(@@ -93,7 +95,7 @@ export function ChannelsFab({const trigger = (<Buttonvariant="primary"- size={inRail ? "icon" : "icon-lg"}+ size="icon-lg"aria-label={label}className={inRail@@ -102,13 +104,13 @@ export function ChannelsFab({}onClick={newTaskOnly ? newTask : undefined}>- <PlusIcon size={inRail ? 16 : 20} weight="bold" />+ <PlusIcon size={inRail ? railIconSize : 20} weight="bold" />{draftDot}</Button>);const tooltip = (- <TooltipContent side={inRail ? "right" : "top"} align="center">+ <TooltipContent side={inRail ? "right" : "top"} sideOffset={-310}>{channelsLayout ? (<>{/* The draft dot needs saying out loud, and the button is where@@ -124,10 +126,12 @@ export function ChannelsFab({if (newTaskOnly) {return (- <Tooltip>- <TooltipTrigger render={trigger} />- {tooltip}- </Tooltip>+ <div className="flex h-12 w-full items-center justify-center">+ <Tooltip>+ <TooltipTrigger render={trigger} />+ {tooltip}+ </Tooltip>+ </div>);}diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsxindex cbb4464f60a6..abbe0ba93429 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx@@ -44,10 +44,8 @@ import { SidebarMenu } from "@posthog/ui/features/sidebar/components/SidebarMenuimport { SidebarNavSection } from "@posthog/ui/features/sidebar/components/SidebarNavSection";import { TasksHeader } from "@posthog/ui/features/sidebar/components/TasksHeader";import { UpdateBanner } from "@posthog/ui/features/sidebar/components/UpdateBanner";-import {- CHANNELS_SIDEBAR_MIN_WIDTH,- NAV_RAIL_WIDTH,-} from "@posthog/ui/features/sidebar/constants";+import { CHANNELS_SIDEBAR_MIN_WIDTH } from "@posthog/ui/features/sidebar/constants";+import { useNavRailMetrics } from "@posthog/ui/features/sidebar/navRailSize";import {beginSidebarPeek,cancelSidebarPeek,@@ -242,6 +240,7 @@ function ChannelsSidebarImpl() {}, [workspacesFetched, workspaces, hasCompletedOnboarding, setOpenAuto]);const channelsLayout = useChannelsLayout();+ const { width: navRailWidth } = useNavRailMetrics();const peek = useSidebarPeekStore((s) => s.peek);useSidebarEdgeHoverPeek({enabled: !open && !isResizing,@@ -249,7 +248,7 @@ function ChannelsSidebarImpl() {side: "left",width,// Hovering a rail button is not a request to slide the sidebar out.- offset: channelsLayout ? NAV_RAIL_WIDTH : 0,+ offset: channelsLayout ? navRailWidth : 0,onReveal: beginSidebarPeek,onClose: () => endSidebarPeek(),});diff --git a/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsxindex ac39c2eefa86..c3483425ca18 100644--- a/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsx@@ -263,7 +263,7 @@ describe("NavRail", () => {["/", "Home"],["/activity", "Activity"],["/inbox/pulls/$reportId", "Self-driving"],- ["/command-center", "Command Center"],+ ["/command-center", "More"],["/spaces", "Spaces"],["/spaces/$channelId/loops", "Spaces"],["/spaces/$channelId/context", "Spaces"],diff --git a/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx b/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsxindex 8d0f12b8479b..beffb0b00412 100644--- a/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx@@ -1,9 +1,15 @@-import { BellIcon, GearSix, MagnifyingGlass } from "@phosphor-icons/react";+import {+ BellIcon,+ DotsThree,+ GearSix,+ MagnifyingGlass,+} from "@phosphor-icons/react";import {Button,cn,Kbd,Popover,+ PopoverContent,PopoverTrigger,Tooltip,TooltipContent,@@ -32,7 +38,10 @@ import { useProjectTaskFeeds } from "@posthog/ui/features/canvas/hooks/useProjecimport { useRailPane } from "@posthog/ui/features/canvas/hooks/useRailSurface";import { useTaskActivity } from "@posthog/ui/features/canvas/hooks/useTaskActivity";import { useWorkLayout } from "@posthog/ui/features/canvas/hooks/useWorkLayout";-import { railPaneFoldsIntoWork } from "@posthog/ui/features/canvas/railPane";+import {+ type NavRailPane,+ railPaneFoldsIntoWork,+} from "@posthog/ui/features/canvas/railPane";import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";import {@@ -49,13 +58,15 @@ import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlaimport { useInboxAvailable } from "@posthog/ui/features/feature-flags/useInboxAvailable";import { useInboxDecisionCount } from "@posthog/ui/features/inbox/hooks/useInboxDecisionCount";import { openSettings } from "@posthog/ui/features/settings/hooks/useOpenSettings";+import { NavRailTile } from "@posthog/ui/features/sidebar/components/NavRailTile";import { ProjectSwitcher } from "@posthog/ui/features/sidebar/components/ProjectSwitcher";-import { NAV_RAIL_WIDTH } from "@posthog/ui/features/sidebar/constants";+import { useNavRailMetrics } from "@posthog/ui/features/sidebar/navRailSize";import { CountBadge } from "@posthog/ui/primitives/CountBadge";import { track } from "@posthog/ui/shell/analytics";import { useCommandMenuStore } from "@posthog/ui/shell/commandMenuStore";import {type ComponentPropsWithRef,+ type MouseEvent,type MouseEventHandler,memo,type ReactElement,@@ -65,12 +76,21 @@ import {const ICON_BADGE_CLASS ="-top-1 -right-1 absolute h-3.5 min-w-3.5 w-auto px-1 font-semibold text-[9px] ring-2 ring-chrome";-const NOTIFICATION_DOT_CLASS =- "top-0 right-0 absolute ring-2 ring-chrome size-2 bg-primary rounded-full";++function NotificationDot() {+ return (+ <span+ data-slot="dot"+ className="absolute top-0 right-0 size-2 rounded-full bg-primary ring-2 ring-chrome"+ aria-hidden+ />+ );+}function NavIcon({icon,label,+ caption,shortcut,isActive,onClick,@@ -78,6 +98,7 @@ function NavIcon({}: {icon: ReactNode;label: string;+ caption?: string;shortcut?: string;isActive: boolean;onClick: MouseEventHandler<HTMLButtonElement>;@@ -87,20 +108,17 @@ function NavIcon({<Tooltip><TooltipTriggerrender={- <Button- variant="default"- size="icon"- aria-label={label}- data-selected={isActive || undefined}+ <NavButton+ icon={icon}+ label={label}+ caption={caption}+ isActive={isActive}onClick={onClick}- className="group relative shrink-0 pl-0 text-muted-foreground data-selected:bg-fill-selected data-selected:text-foreground"- >- {icon}- {badge}- </Button>+ badge={badge}+ />}/>- <TooltipContent side="right">+ <TooltipContent side="right" alignOffset={-10}>{label}{shortcut && <Kbd>{shortcut}</Kbd>}</TooltipContent>@@ -111,6 +129,7 @@ function NavIcon({interface NavButtonProps extends ComponentPropsWithRef<"button"> {icon: ReactNode;label: string;+ caption?: string;isActive: boolean;badge?: ReactNode;}@@ -118,31 +137,21 @@ interface NavButtonProps extends ComponentPropsWithRef<"button"> {function NavButton({icon,label,+ caption,isActive,- onClick,badge,- className,- ref,...buttonProps}: NavButtonProps) {return (- <Button+ <NavRailTile{...buttonProps}- ref={ref}- type="button"- variant="default"- size="icon"aria-label={label}+ caption={caption ?? label}data-selected={isActive || undefined}- onClick={onClick}- className={cn(- "relative shrink-0 text-muted-foreground data-selected:bg-fill-selected data-selected:text-foreground",- className,- )}>{icon}{badge}- </Button>+ </NavRailTile>);}@@ -165,6 +174,75 @@ function ActivityHoverPopover({ trigger }: { trigger: ReactElement }) {);}+function MoreNavItem({+ destinations,+ railPane,+ counts,+ onPick,+}: {+ destinations: readonly RailDestination[];+ railPane: NavRailPane;+ counts: RailCounts;+ onPick: (+ destination: RailDestination,+ ) => (event: MouseEvent<HTMLElement>) => void;+}) {+ const { iconSize } = useNavRailMetrics();+ const [open, setOpen] = useState(false);+ const isActive = destinations.some(({ pane }) => pane === railPane);+ const hasCount = destinations.some(({ count }) => (count?.(counts) ?? 0) > 0);++ return (+ <Popover open={open} onOpenChange={setOpen}>+ <PopoverTrigger+ openOnHover+ delay={150}+ closeDelay={100}+ render={+ <NavButton+ icon={<DotsThree size={iconSize} weight="bold" />}+ label="More"+ isActive={isActive || open}+ badge={hasCount ? <NotificationDot /> : null}+ />+ }+ />+ <PopoverContent+ side="right"+ align="start"+ sideOffset={8}+ className="w-52 gap-0.5 p-1"+ >+ {destinations.map((destination) => {+ const { pane, label, Icon, count, countTone } = destination;+ const pick = onPick(destination);+ return (+ <Button+ key={pane}+ variant="default"+ size="sm"+ data-selected={railPane === pane || undefined}+ className="w-full justify-start data-selected:bg-fill-selected"+ onClick={(event) => {+ setOpen(false);+ pick(event);+ }}+ >+ <Icon size={16} weight={railPane === pane ? "fill" : "regular"} />+ {label}+ <CountBadge+ count={count?.(counts) ?? 0}+ tone={countTone}+ className="ml-auto"+ />+ </Button>+ );+ })}+ </PopoverContent>+ </Popover>+ );+}+// No peek once Activity is the destination: the feed is already beside you.function ActivityNavItem({isActive,@@ -175,14 +253,14 @@ function ActivityNavItem({badge: ReactNode;onClick: MouseEventHandler<HTMLButtonElement>;}) {+ const { iconSize } = useNavRailMetrics();const bell = (<NavButton- icon={<BellIcon size={16} weight={isActive ? "fill" : "regular"} />}+ icon={<BellIcon size={iconSize} weight={isActive ? "fill" : "regular"} />}label="Activity"isActive={isActive}onClick={onClick}badge={badge}- className="pl-0"/>);@@ -195,6 +273,7 @@ function ActivityNavItem({* that sidebar leaves the destinations reachable.*/function NavRailImpl() {+ const { width, iconSize, gapClassName } = useNavRailMetrics();const homeEnabled = useFeatureFlag(DESKTOP_HOME_FLAG);const loopsEnabled = useFeatureFlag(LOOPS_FLAG);const contextEnabled = useContextLayerFlag();@@ -221,7 +300,10 @@ function NavRailImpl() {? visibleWorkRailDestinations(railFlags): visibleRailDestinations(railFlags);const topDestinations = destinations.filter(- ({ placement }) => placement !== "bottom",+ ({ placement }) => placement === undefined || placement === "top",+ );+ const moreDestinations = destinations.filter(+ ({ placement }) => placement === "more",);const bottomDestinations = destinations.filter(({ placement }) => placement === "bottom",@@ -248,11 +330,11 @@ function NavRailImpl() {const currentChannelId = useCurrentChannelStore((s) => s.currentChannelId);const pick =- (destination: RailDestination): MouseEventHandler<HTMLButtonElement> =>- (event) => {+ (destination: RailDestination) =>+ (event: MouseEvent<HTMLElement>): void => {track(ANALYTICS_EVENTS.SIDEBAR_NAV_ITEM_CLICKED, {item: destination.analyticsId,- in_more: false,+ in_more: destination.placement === "more",layout: "channels",});if (tabsEnabled && (event.metaKey || event.ctrlKey)) {@@ -288,14 +370,7 @@ function NavRailImpl() {const usesNotificationDot = pane === "activity" || pane === "inbox";let badge: ReactNode;if (usesNotificationDot) {- badge =- destinationCount > 0 ? (- <span- data-slot="dot"- className={NOTIFICATION_DOT_CLASS}- aria-hidden- />- ) : null;+ badge = destinationCount > 0 ? <NotificationDot /> : null;} else {badge = (<CountBadge@@ -322,12 +397,12 @@ function NavRailImpl() {key={pane}icon={<Icon- className={pane === "spaces" && !workLayout ? "size-5" : undefined}- size={pane === "spaces" && !workLayout ? 20 : 16}+ size={pane === "spaces" && !workLayout ? iconSize + 4 : iconSize}weight={isActive ? "fill" : "regular"}/>}label={label}+ caption={destination.shortLabel}shortcut={destination.shortcut}isActive={isActive}onClick={onClick}@@ -342,11 +417,27 @@ function NavRailImpl() {<TooltipProvider delay={400}><divdata-testid="nav-rail"- className="relative z-[60] flex h-full shrink-0 flex-col items-center gap-1.5 bg-chrome py-2"- style={{ width: NAV_RAIL_WIDTH }}+ className={cn(+ "relative z-[60] flex h-full shrink-0 flex-col items-center overflow-y-auto overflow-x-hidden bg-chrome px-1 pt-1 pb-2 [scrollbar-width:none]",+ gapClassName,+ )}+ style={{ width }}>{topDestinations.map(renderDestination)}- <div className="mt-auto flex flex-col items-center gap-1.5">+ {moreDestinations.length > 0 && (+ <MoreNavItem+ destinations={moreDestinations}+ railPane={railPane}+ counts={counts}+ onPick={pick}+ />+ )}+ <div+ className={cn(+ "mt-auto flex w-full flex-col items-center",+ gapClassName,+ )}+ >{bottomDestinations.map(renderDestination)}{/* Every destination keeps the rail, sidebar or not, so the createbutton is reachable from all of them here. */}@@ -355,7 +446,7 @@ function NavRailImpl() {placement="rail"/><NavIcon- icon={<MagnifyingGlass size={16} />}+ icon={<MagnifyingGlass size={iconSize} />}label="Search"shortcut={formatHotkey(SHORTCUTS.COMMAND_MENU)}isActive={false}@@ -369,7 +460,7 @@ function NavRailImpl() {}}/><NavIcon- icon={<GearSix size={16} />}+ icon={<GearSix size={iconSize} />}label="Settings"shortcut={formatHotkey(SHORTCUTS.SETTINGS)}isActive={false}@@ -382,7 +473,6 @@ function NavRailImpl() {openSettings();}}/>- <div className="my-0.5 w-5 shrink-0 border-border border-t" /><ProjectSwitcher appearance="icon" /></div></div>diff --git a/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts b/products/desktop/packages/ui/src/features/canvas/components/railDestinations.tsindex a42cfead5e34..867dcdb18281 100644--- a/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts+++ b/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts@@ -57,6 +57,7 @@ export interface RailCounts {export interface RailDestination {pane: NavRailPane;label: string;+ shortLabel?: string;analyticsId: SidebarNavItem;Icon: ComponentType<IconProps>;/** Root opened by an explicit Cmd/Ctrl-click. */@@ -68,7 +69,8 @@ export interface RailDestination {* from landing on its root. Defaults to `onPick`.*/onReclick?: () => void;- placement?: "top" | "bottom";+ /** `more` files the destination under the rail's overflow menu. */+ placement?: "top" | "bottom" | "more";shortcut?: string;count?: (counts: RailCounts) => number;countTone?: CountBadgeTone;@@ -235,6 +237,7 @@ const RAIL_DESTINATIONS: readonly RailDestination[] = [onPick: navigateToCommandCenter,count: (counts) => counts.commandCenter,countTone: "neutral",+ placement: "more",},{pane: "loops",@@ -248,6 +251,7 @@ const RAIL_DESTINATIONS: readonly RailDestination[] = [{pane: "feeds",label: "Saved searches",+ shortLabel: "Saved",analyticsId: "search",Icon: ListMagnifyingGlassIcon,href: "/feeds",diff --git a/products/desktop/packages/ui/src/features/settings/SettingsDialog.tsx b/products/desktop/packages/ui/src/features/settings/SettingsDialog.tsxindex 61751966feba..6bc970c5d109 100644--- a/products/desktop/packages/ui/src/features/settings/SettingsDialog.tsx+++ b/products/desktop/packages/ui/src/features/settings/SettingsDialog.tsx@@ -1,6 +1,10 @@+import { SettingsDialogFrame } from "@posthog/ui/features/settings/components/SettingsDialogFrame";import { SettingsPanel } from "@posthog/ui/features/settings/components/SettingsPanel";import { useSettingsPageStore } from "@posthog/ui/features/settings/stores/settingsPageStore";-import type { SettingsCategory } from "@posthog/ui/features/settings/types";+import {+ type SettingsCategory,+ settingsPageRevealsApp,+} from "@posthog/ui/features/settings/types";import { useEffect, useState } from "react";/**@@ -51,30 +55,18 @@ function useSettingsDialogState(): DialogState {export function SettingsDialog() {const { isOpen, category } = useSettingsDialogState();- useEffect(() => {- if (!isOpen) return;- const handleEscape = (e: KeyboardEvent) => {- if (e.key === "Escape") {- e.preventDefault();- closeSettingsDialog();- }- };- window.addEventListener("keydown", handleEscape);- return () => window.removeEventListener("keydown", handleEscape);- }, [isOpen]);-if (!isOpen) return null;return (- <div- className="absolute inset-0 z-[100] flex bg-(--color-background)"- data-overlay="settings"+ <SettingsDialogFrame+ onDismiss={closeSettingsDialog}+ seeThrough={settingsPageRevealsApp(category)}><SettingsPanelactiveCategory={category}onClose={closeSettingsDialog}onCategoryChange={(cat) => publish({ isOpen: true, category: cat })}/>- </div>+ </SettingsDialogFrame>);}diff --git a/products/desktop/packages/ui/src/features/settings/components/SettingsDialogFrame.tsx b/products/desktop/packages/ui/src/features/settings/components/SettingsDialogFrame.tsxnew file mode 100644index 000000000000..8f8f4c610c39--- /dev/null+++ b/products/desktop/packages/ui/src/features/settings/components/SettingsDialogFrame.tsx@@ -0,0 +1,61 @@+import { cn } from "@posthog/quill";+import { useDialogFocus } from "@posthog/ui/features/settings/components/useDialogFocus";+import { type ReactNode, useRef } from "react";+import { createPortal } from "react-dom";+import { useHotkeys } from "react-hotkeys-hook";++/**+ * Portaled into `#portal-container` rather than a quill `Dialog`, which+ * portals to `body`: settings pages still use Radix Themes, whose styles only+ * apply inside the `<Theme>` root that container sits in.+ */+export function SettingsDialogFrame({+ onDismiss,+ onEscape = onDismiss,+ seeThrough = false,+ children,+}: {+ onDismiss: () => void;+ onEscape?: () => void;+ seeThrough?: boolean;+ children: ReactNode;+}) {+ useHotkeys("escape", onEscape, {+ enableOnContentEditable: true,+ enableOnFormTags: true,+ preventDefault: true,+ });++ const dialogRef = useRef<HTMLDivElement>(null);+ const trapTab = useDialogFocus(dialogRef);++ const container =+ document.getElementById("portal-container") ?? document.body;+ return createPortal(+ <div+ className="absolute inset-0 z-[100] flex items-center justify-center p-12"+ data-overlay="settings"+ >+ <div+ aria-hidden+ className={cn(+ "absolute inset-0 transition-colors duration-200",+ seeThrough ? "bg-transparent" : "bg-blackA-8 dark:bg-blackA-10",+ )}+ onClick={onDismiss}+ />+ <div+ ref={dialogRef}+ role="dialog"+ tabIndex={-1}+ onKeyDown={trapTab}+ aria-modal="true"+ aria-label="Settings"+ className="relative flex h-[min(760px,100%)] w-[min(1080px,100%)] flex-col overflow-hidden rounded-lg border border-border bg-background shadow-2xl outline-none"+ >+ {children}+ </div>+ </div>,+ container,+ );+}diff --git a/products/desktop/packages/ui/src/features/settings/components/SettingsLayout.tsx b/products/desktop/packages/ui/src/features/settings/components/SettingsLayout.tsxindex 02ad5445b7ed..27bf0b869588 100644--- a/products/desktop/packages/ui/src/features/settings/components/SettingsLayout.tsx+++ b/products/desktop/packages/ui/src/features/settings/components/SettingsLayout.tsx@@ -1,11 +1,15 @@import { AnnouncementBanner } from "@posthog/ui/features/announcements/AnnouncementBanner";import { ConnectivityBanner } from "@posthog/ui/features/connectivity/ConnectivityBanner";+import { SettingsDialogFrame } from "@posthog/ui/features/settings/components/SettingsDialogFrame";import { SettingsPanel } from "@posthog/ui/features/settings/components/SettingsPanel";-import type { SettingsCategory } from "@posthog/ui/features/settings/types";+import { closeSettings } from "@posthog/ui/features/settings/hooks/useOpenSettings";+import {+ type SettingsCategory,+ settingsPageRevealsApp,+} from "@posthog/ui/features/settings/types";import { navigateToSettings } from "@posthog/ui/router/navigationBridge";import { getRouterOrNull } from "@posthog/ui/router/routerRef";import type { ReactNode } from "react";-import { createPortal } from "react-dom";export function SettingsLayout({category,@@ -23,38 +27,41 @@ export function SettingsLayout({*/childBackHref?: string;}) {- const container =- document.getElementById("portal-container") ?? document.body;- return createPortal(- <div- className="absolute inset-0 z-[100] flex flex-col bg-(--color-background)"- data-overlay="settings"+ const back = children+ ? childBackHref+ ? // Same shape as leaving settings for a recorded source: push the href+ // and keep this tab's tag, so the composer session keyed on it+ // survives.+ () => {+ const router = getRouterOrNull();+ router?.history.push(childBackHref, {+ tabId: router.history.location.state.tabId,+ });+ }+ : () => navigateToSettings(category)+ : undefined;++ // A report opened inside settings sits on its own route, where+ // `closeSettings` has no settings route to leave; step back out instead.+ const dismiss = back ?? closeSettings;++ return (+ <SettingsDialogFrame+ onDismiss={dismiss}+ onEscape={back}+ seeThrough={!children && settingsPageRevealsApp(category)}><ConnectivityBanner /><AnnouncementBanner /><div className="flex min-h-0 flex-1"><SettingsPanelactiveCategory={category}- onClose={- children- ? childBackHref- ? // Same shape as leaving settings for a recorded source: push- // the href and keep this tab's tag, so the composer session- // keyed on it survives.- () => {- const router = getRouterOrNull();- router?.history.push(childBackHref, {- tabId: router.history.location.state.tabId,- });- }- : () => navigateToSettings(category)- : undefined- }+ onClose={dismiss}+ onBack={back}>{children}</SettingsPanel></div>- </div>,- container,+ </SettingsDialogFrame>);}diff --git a/products/desktop/packages/ui/src/features/settings/components/SettingsPageContent.tsx b/products/desktop/packages/ui/src/features/settings/components/SettingsPageContent.tsxindex 36e8168a7d01..6ba7f8e46c68 100644--- a/products/desktop/packages/ui/src/features/settings/components/SettingsPageContent.tsx+++ b/products/desktop/packages/ui/src/features/settings/components/SettingsPageContent.tsx@@ -2,6 +2,7 @@ import { CostManagementSettings } from "@posthog/ui/features/cost-management/Cosimport { McpServersView } from "@posthog/ui/features/mcp-servers/components/McpServersView";import { AdvancedSettings } from "@posthog/ui/features/settings/sections/AdvancedSettings";import { AgentsSettings } from "@posthog/ui/features/settings/sections/AgentsSettings";+import { AppearanceSettings } from "@posthog/ui/features/settings/sections/AppearanceSettings";import { DiscordSettings } from "@posthog/ui/features/settings/sections/DiscordSettings";import { EnvironmentsSettings } from "@posthog/ui/features/settings/sections/environments/EnvironmentsSettings";import { GeneralSettings } from "@posthog/ui/features/settings/sections/GeneralSettings";@@ -46,6 +47,7 @@ function defineSettingsPage(const SETTINGS_PAGES: Record<SettingsCategory, SettingsPageDefinition> = {general: defineSettingsPage("General", GeneralSettings),+ appearance: defineSettingsPage("Appearance", AppearanceSettings),notifications: defineSettingsPage("Notifications", NotificationsSettings),"plan-usage": defineSettingsPage("Plan & usage", PlanUsageSettings),"cost-management": defineSettingsPage(diff --git a/products/desktop/packages/ui/src/features/settings/components/SettingsPanel.tsx b/products/desktop/packages/ui/src/features/settings/components/SettingsPanel.tsxindex 2892d4d62946..789d960c138d 100644--- a/products/desktop/packages/ui/src/features/settings/components/SettingsPanel.tsx+++ b/products/desktop/packages/ui/src/features/settings/components/SettingsPanel.tsx@@ -13,6 +13,7 @@ import {Keyboard,Lightbulb,Lightning,+ PaintBrush,Palette,Plugs,Robot,@@ -22,12 +23,9 @@ import {TrafficSignal,TreeStructure,Wrench,+ X,} from "@phosphor-icons/react";-import { Input, MenuLabel } from "@posthog/quill";-import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";-import { useAuthStateValue } from "@posthog/ui/features/auth/store";-import { UserAvatar } from "@posthog/ui/features/auth/UserAvatar";-import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";+import { Button, Input, MenuLabel } from "@posthog/quill";import { useQuickAskAvailable } from "@posthog/ui/features/quick-ask/useQuickAskAvailable";import { SettingsPageContent } from "@posthog/ui/features/settings/components/SettingsPageContent";import { closeSettings } from "@posthog/ui/features/settings/hooks/useOpenSettings";@@ -42,11 +40,9 @@ import {SETTINGS_PAGE_LABELS,type SettingsCategory,} from "@posthog/ui/features/settings/types";-import { ProjectSwitcher } from "@posthog/ui/features/sidebar/components/ProjectSwitcher";import * as nav from "@posthog/ui/router/navigationBridge";import { useHostCapabilities } from "@posthog/ui/shell/useHostCapabilities";import { type ReactNode, useState } from "react";-import { useHotkeys } from "react-hotkeys-hook";interface SidebarItem {id: SettingsCategory;@@ -67,6 +63,7 @@ const SIDEBAR_GROUPS: SidebarGroup[] = [label: "App",items: [{ id: "general", icon: <GearSix size={16} /> },+ { id: "appearance", icon: <PaintBrush size={16} /> },{ id: "notifications", icon: <Bell size={16} /> },{ id: "personalization", icon: <Palette size={16} /> },{ id: "shortcuts", icon: <Keyboard size={16} /> },@@ -123,8 +120,10 @@ export interface SettingsPanelProps {* pre-router `ConsentScreen` shell where RouterProvider isn't mounted.*/activeCategory?: SettingsCategory;- /** Override the close handler. Defaults to router history back. */+ /** Leave settings. Defaults to router history back. */onClose?: () => void;+ /** Step back out of a page opened inside settings. Shows a Back button. */+ onBack?: () => void;/** Override the category-change handler. Defaults to router navigation. */onCategoryChange?: (category: SettingsCategory) => void;children?: ReactNode;@@ -133,6 +132,7 @@ export interface SettingsPanelProps {export function SettingsPanel({activeCategory: activeCategoryProp,onClose,+ onBack,onCategoryChange,children,}: SettingsPanelProps = {}) {@@ -143,11 +143,6 @@ export function SettingsPanel({const setCategory =onCategoryChange ??((cat: SettingsCategory) => nav.navigateToSettings(cat, { replace: true }));- const isAuthenticated = useAuthStateValue(- (state) => state.status === "authenticated",- );- const client = useOptionalAuthenticatedClient();- const { data: user } = useCurrentUser({ client });const { localWorkspaces } = useHostCapabilities();const quickAskAvailable = useQuickAskAvailable();const backupAvailable = useSettingsBackupAvailable();@@ -179,13 +174,6 @@ export function SettingsPanel({? "environments": resolvedCategory;- useHotkeys("escape", close, {- enabled: true,- enableOnContentEditable: true,- enableOnFormTags: true,- preventDefault: true,- });-const activeCategoryIcon = SIDEBAR_ITEMS.find((item) => item.id === activeSidebarCategory,)?.icon;@@ -193,26 +181,17 @@ export function SettingsPanel({return (<div className="flex h-full w-full bg-background" data-page="settings"><div className="flex h-full w-[256px] shrink-0 flex-col border-border border-r bg-chrome">- <div className="drag h-[36px] shrink-0 border-b border-b-border" />-- {isAuthenticated && user && (- <div className="flex h-14 items-center gap-3 border-b border-b-border px-3">- <UserAvatar user={user} />- <div className="flex min-w-0 flex-col">- <span className="truncate font-medium text-sm">{user.email}</span>- </div>- </div>+ {onBack && (+ <button+ type="button"+ className="mt-2 flex cursor-pointer items-center gap-2 border-0 bg-transparent px-3 py-2 text-left text-[13px] text-foreground transition-colors hover:bg-fill-hover"+ onClick={onBack}+ >+ <ArrowLeft size={14} />+ <span>Back</span>+ </button>)}- <button- type="button"- className="mt-2 flex cursor-pointer items-center gap-2 border-0 bg-transparent px-3 py-2 text-left text-[13px] text-foreground transition-colors hover:bg-fill-hover"- onClick={close}- >- <ArrowLeft size={14} />- <span>{children ? "Back" : "Back to app"}</span>- </button>-<SettingsSearchInputquery={searchQuery}onQueryChange={setSearchQuery}@@ -257,16 +236,19 @@ export function SettingsPanel({</div>)}</div>-- {isAuthenticated && (- <div className="border-border border-t p-2">- <ProjectSwitcher onNavigateToSettings={setCategory} />- </div>- )}</div><div className="relative flex flex-1 flex-col overflow-hidden">- <div className="drag h-[36px] shrink-0 border-b border-b-border" />+ <div className="flex h-10 shrink-0 items-center justify-end border-b border-b-border px-2">+ <Button+ variant="default"+ size="icon-sm"+ aria-label="Close settings"+ onClick={close}+ >+ <X size={14} />+ </Button>+ </div><div className="relative flex flex-1 justify-center overflow-hidden"><svgaria-hidden="true"@@ -325,7 +307,7 @@ function SettingsSearchInput({value={query}onChange={(e) => onQueryChange(e.currentTarget.value)}onKeyDown={(e) => {- // Escape clears the query before the panel-level hotkey can close+ // Escape clears the query before the dialog's hotkey can close// settings; a second Escape (empty query) closes as usual.if (e.key === "Escape" && query) {e.preventDefault();diff --git a/products/desktop/packages/ui/src/features/settings/components/useDialogFocus.ts b/products/desktop/packages/ui/src/features/settings/components/useDialogFocus.tsnew file mode 100644index 000000000000..e4801f7463bd--- /dev/null+++ b/products/desktop/packages/ui/src/features/settings/components/useDialogFocus.ts@@ -0,0 +1,42 @@+import { type KeyboardEvent, type RefObject, useEffect } from "react";++const TABBABLE =+ 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';++// Only Tab pressed inside the dialog is caught, so menus portaled out of it+// keep their own focus.+export function useDialogFocus(+ dialogRef: RefObject<HTMLElement | null>,+): (event: KeyboardEvent<HTMLElement>) => void {+ useEffect(() => {+ const dialog = dialogRef.current;+ if (!dialog) return;+ const opener =+ document.activeElement instanceof HTMLElement+ ? document.activeElement+ : null;+ if (!dialog.contains(document.activeElement)) {+ (dialog.querySelector<HTMLElement>(TABBABLE) ?? dialog).focus();+ }+ return () => {+ if (opener?.isConnected) opener.focus();+ };+ }, [dialogRef]);++ return (event) => {+ if (event.key !== "Tab" || !dialogRef.current) return;+ const tabbable = [+ ...dialogRef.current.querySelectorAll<HTMLElement>(TABBABLE),+ ].filter((el) => el.offsetParent !== null);+ const first = tabbable[0];+ const last = tabbable[tabbable.length - 1];+ if (!first || !last) return;+ if (event.shiftKey && document.activeElement === first) {+ event.preventDefault();+ last.focus();+ } else if (!event.shiftKey && document.activeElement === last) {+ event.preventDefault();+ first.focus();+ }+ };+}diff --git a/products/desktop/packages/ui/src/features/settings/sections/AppearanceSettings.tsx b/products/desktop/packages/ui/src/features/settings/sections/AppearanceSettings.tsxnew file mode 100644index 000000000000..e6048a1e2e24--- /dev/null+++ b/products/desktop/packages/ui/src/features/settings/sections/AppearanceSettings.tsx@@ -0,0 +1,126 @@+import { useServiceOptional } from "@posthog/di/react";+import { Switch } from "@posthog/quill";+import { ANALYTICS_EVENTS } from "@posthog/shared";+import {+ MISSION_CONTROL_CLIENT,+ type MissionControlClient,+} from "@posthog/ui/features/mission-control/identifiers";+import {+ SettingsCard,+ SettingsCardRow,+} from "@posthog/ui/features/settings/components/SettingsCard";+import { SettingsSegmented } from "@posthog/ui/features/settings/components/SettingsSegmented";+import { ThemePicker } from "@posthog/ui/features/settings/components/ThemePicker";+import {+ type NavRailSize,+ useSettingsStore,+} from "@posthog/ui/features/settings/settingsStore";+import { track } from "@posthog/ui/shell/analytics";+import type { ThemePreference } from "@posthog/ui/shell/themeStore";+import { useThemeStore } from "@posthog/ui/shell/themeStore";+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";+import { useCallback } from "react";++export function AppearanceSettings() {+ const theme = useThemeStore((state) => state.theme);+ const setTheme = useThemeStore((state) => state.setTheme);++ // Mission Control overlay state. The client is bound on desktop only, so on+ // other hosts this resolves to null and the setting is hidden.+ const queryClient = useQueryClient();+ const missionControl = useServiceOptional<MissionControlClient>(+ MISSION_CONTROL_CLIENT,+ );+ const { data: missionControlSupported } = useQuery({+ queryKey: ["missionControlOverlay", "supported"],+ queryFn: () => missionControl?.isSupported() ?? false,+ enabled: missionControl != null,+ });+ const { data: missionControlEnabled } = useQuery({+ queryKey: ["missionControlOverlay", "enabled"],+ queryFn: () => missionControl?.getEnabled() ?? false,+ enabled: missionControl != null && missionControlSupported === true,+ });+ const missionControlMutation = useMutation({+ mutationFn: (enabled: boolean) =>+ missionControl?.setEnabled(enabled) ?? Promise.resolve(),+ });++ const handleMissionControlOverlayChange = useCallback(+ (checked: boolean) => {+ track(ANALYTICS_EVENTS.SETTING_CHANGED, {+ setting_name: "mission_control_overlay",+ new_value: checked,+ old_value: !checked,+ });+ queryClient.setQueryData(["missionControlOverlay", "enabled"], checked);+ missionControlMutation.mutate(checked);+ },+ [missionControlMutation, queryClient],+ );++ const navRailSize = useSettingsStore((state) => state.navRailSize);+ const setNavRailSize = useSettingsStore((state) => state.setNavRailSize);+ const handleNavRailSizeChange = useCallback(+ (value: NavRailSize) => {+ track(ANALYTICS_EVENTS.SETTING_CHANGED, {+ setting_name: "nav_rail_size",+ new_value: value,+ old_value: navRailSize,+ });+ setNavRailSize(value);+ },+ [navRailSize, setNavRailSize],+ );++ const handleThemeChange = useCallback(+ (value: ThemePreference) => {+ track(ANALYTICS_EVENTS.SETTING_CHANGED, {+ setting_name: "theme",+ new_value: value,+ old_value: theme,+ });+ setTheme(value);+ },+ [theme, setTheme],+ );++ return (+ <div className="flex flex-col gap-3">+ <ThemePicker value={theme} onChange={handleThemeChange} />+ <SettingsCard>+ <SettingsCardRow+ label="Navigation rail"+ description="Size of the icons down the left edge. Small hides their labels."+ >+ <SettingsSegmented+ ariaLabel="Navigation rail size"+ value={navRailSize}+ options={[+ { value: "small", label: "Small" },+ { value: "medium", label: "Medium" },+ { value: "large", label: "Large" },+ ]}+ onValueChange={(value) =>+ handleNavRailSizeChange(value as NavRailSize)+ }+ />+ </SettingsCardRow>+ </SettingsCard>+ {missionControl != null && missionControlSupported === true && (+ <SettingsCard>+ <SettingsCardRow+ label="Mission Control overlay"+ description="Show the PostHog logo over the window in macOS Mission Control"+ >+ <Switch+ size="sm"+ checked={missionControlEnabled ?? false}+ onCheckedChange={handleMissionControlOverlayChange}+ />+ </SettingsCardRow>+ </SettingsCard>+ )}+ </div>+ );+}diff --git a/products/desktop/packages/ui/src/features/settings/sections/GeneralSettings.tsx b/products/desktop/packages/ui/src/features/settings/sections/GeneralSettings.tsxindex 96f547e0b89a..f784ec2e5978 100644--- a/products/desktop/packages/ui/src/features/settings/sections/GeneralSettings.tsx+++ b/products/desktop/packages/ui/src/features/settings/sections/GeneralSettings.tsx@@ -1,4 +1,3 @@-import { useServiceOptional } from "@posthog/di/react";import { useHostTRPC } from "@posthog/host-router/react";import { Switch } from "@posthog/quill";import { ANALYTICS_EVENTS } from "@posthog/shared";@@ -7,10 +6,6 @@ import {EFFORT_LEVEL_LABELS,EFFORT_LEVELS,} from "@posthog/shared/domain-types";-import {- MISSION_CONTROL_CLIENT,- type MissionControlClient,-} from "@posthog/ui/features/mission-control/identifiers";import {ReasoningLevelDropdown,type ReasoningLevelOption,@@ -22,7 +17,6 @@ import {} from "@posthog/ui/features/settings/components/SettingsCard";import { SettingsSegmented } from "@posthog/ui/features/settings/components/SettingsSegmented";import { SettingsSelect } from "@posthog/ui/features/settings/components/SettingsSelect";-import { ThemePicker } from "@posthog/ui/features/settings/components/ThemePicker";import { AccountSection } from "@posthog/ui/features/settings/sections/AccountSettings";import { UpdatesSection } from "@posthog/ui/features/settings/sections/UpdatesSettings";import {@@ -35,10 +29,8 @@ import {useSettingsStore,} from "@posthog/ui/features/settings/settingsStore";import { track } from "@posthog/ui/shell/analytics";-import type { ThemePreference } from "@posthog/ui/shell/themeStore";-import { useThemeStore } from "@posthog/ui/shell/themeStore";import { useHostCapabilities } from "@posthog/ui/shell/useHostCapabilities";-import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";+import { useMutation, useQuery } from "@tanstack/react-query";import { useCallback, useEffect } from "react";const DEFAULT_EFFORT_OPTIONS: ReasoningLevelOption[] = [@@ -58,9 +50,6 @@ const MESSAGING_MODE_OPTIONS = [export function GeneralSettings() {const hostTRPC = useHostTRPC();- const theme = useThemeStore((state) => state.theme);- const setTheme = useThemeStore((state) => state.setTheme);-const { localWorkspaces } = useHostCapabilities();const { preventSleepWhileRunning, setPreventSleepWhileRunning } =useSettingsStore();@@ -97,40 +86,6 @@ export function GeneralSettings() {[setPreventSleepWhileRunning, preventSleepMutation],);- // Mission Control overlay state. The client is bound on desktop only, so on- // other hosts this resolves to null and the setting is hidden.- const queryClient = useQueryClient();- const missionControl = useServiceOptional<MissionControlClient>(- MISSION_CONTROL_CLIENT,- );- const { data: missionControlSupported } = useQuery({- queryKey: ["missionControlOverlay", "supported"],- queryFn: () => missionControl?.isSupported() ?? false,- enabled: missionControl != null,- });- const { data: missionControlEnabled } = useQuery({- queryKey: ["missionControlOverlay", "enabled"],- queryFn: () => missionControl?.getEnabled() ?? false,- enabled: missionControl != null && missionControlSupported === true,- });- const missionControlMutation = useMutation({- mutationFn: (enabled: boolean) =>- missionControl?.setEnabled(enabled) ?? Promise.resolve(),- });-- const handleMissionControlOverlayChange = useCallback(- (checked: boolean) => {- track(ANALYTICS_EVENTS.SETTING_CHANGED, {- setting_name: "mission_control_overlay",- new_value: checked,- old_value: !checked,- });- queryClient.setQueryData(["missionControlOverlay", "enabled"], checked);- missionControlMutation.mutate(checked);- },- [missionControlMutation, queryClient],- );-const {autoConvertLongText,defaultInitialTaskMode,@@ -148,18 +103,6 @@ export function GeneralSettings() {setSendMessagesWith,} = useSettingsStore();- const handleThemeChange = useCallback(- (value: ThemePreference) => {- track(ANALYTICS_EVENTS.SETTING_CHANGED, {- setting_name: "theme",- new_value: value,- old_value: theme,- });- setTheme(value);- },- [theme, setTheme],- );-const handleAutoConvertLongTextChange = useCallback((value: AutoConvertLongText) => {track(ANALYTICS_EVENTS.SETTING_CHANGED, {@@ -248,27 +191,6 @@ export function GeneralSettings() {<div className="flex flex-col gap-7"><AccountSection />- <SettingsSection- label="Appearance"- description="Theme and how the app looks"- >- <ThemePicker value={theme} onChange={handleThemeChange} />- {missionControl != null && missionControlSupported === true && (- <SettingsCard>- <SettingsCardRow- label="Mission Control overlay"- description="Show the PostHog logo over the window in macOS Mission Control"- >- <Switch- size="sm"- checked={missionControlEnabled ?? false}- onCheckedChange={handleMissionControlOverlayChange}- />- </SettingsCardRow>- </SettingsCard>- )}- </SettingsSection>-<SettingsSectionlabel="New tasks"description="Defaults for every new task; you can change any of these per task in the composer"diff --git a/products/desktop/packages/ui/src/features/settings/settingsSearch.ts b/products/desktop/packages/ui/src/features/settings/settingsSearch.tsindex 76b19d869906..c16894c469a8 100644--- a/products/desktop/packages/ui/src/features/settings/settingsSearch.ts+++ b/products/desktop/packages/ui/src/features/settings/settingsSearch.ts@@ -15,7 +15,7 @@ export interface SettingsSearchEntry {// display names come from SETTINGS_PAGE_LABELS, not repeated per entry.const SETTINGS_SEARCH_INDEX: SettingsSearchEntry[] = [{- category: "general",+ category: "appearance",label: "Theme",keywords: ["appearance", "light", "dark", "system"],},@@ -30,7 +30,12 @@ const SETTINGS_SEARCH_INDEX: SettingsSearchEntry[] = [keywords: ["billing", "manage account", "email"],},{- category: "general",+ category: "appearance",+ label: "Navigation rail",+ keywords: ["nav rail", "sidebar", "icon size", "labels", "compact"],+ },+ {+ category: "appearance",label: "Mission Control overlay",keywords: ["macos", "logo"],},diff --git a/products/desktop/packages/ui/src/features/settings/settingsStore.ts b/products/desktop/packages/ui/src/features/settings/settingsStore.tsindex 44b2e0b9008d..c7edcd6952e0 100644--- a/products/desktop/packages/ui/src/features/settings/settingsStore.ts+++ b/products/desktop/packages/ui/src/features/settings/settingsStore.ts@@ -40,6 +40,8 @@ export type DefaultReasoningEffort = EffortLevel | "last_used";export type SendMessagesWith = "enter" | "cmd+enter";export type AutoConvertLongText = "off" | "1000" | "2500" | "5000" | "10000";export type DiffOpenMode = "auto" | "split" | "same-pane" | "last-active-pane";+export type NavRailSize = "small" | "medium" | "large";+export const DEFAULT_NAV_RAIL_SIZE: NavRailSize = "large";// When spoken notifications are allowed to talk, relative to what's on screen:// - always: speak regardless of what the user is looking at@@ -253,6 +255,9 @@ export interface SettingsStore {diffOpenMode: DiffOpenMode;setDiffOpenMode: (mode: DiffOpenMode) => void;+ navRailSize: NavRailSize;+ setNavRailSize: (size: NavRailSize) => void;+// Spend limits. A warn line only notifies; a stop line pauses new agent// messages in this app, and the monthly stop also syncs to the gateway// where deployments enforce it.@@ -519,6 +524,9 @@ export const useSettingsStore = create<SettingsStore>()(diffOpenMode: "auto",setDiffOpenMode: (mode) => set({ diffOpenMode: mode }),+ navRailSize: DEFAULT_NAV_RAIL_SIZE,+ setNavRailSize: (size) => set({ navRailSize: size }),+// Spend limitsspendLimits: EMPTY_SPEND_LIMITS,spendNoticesSeen: {},@@ -711,6 +719,7 @@ export const useSettingsStore = create<SettingsStore>()(// Diff viewerdiffOpenMode: state.diffOpenMode,+ navRailSize: state.navRailSize,// Spend limitsspendLimits: state.spendLimits,diff --git a/products/desktop/packages/ui/src/features/settings/types.ts b/products/desktop/packages/ui/src/features/settings/types.tsindex 76ec6e51001d..12f2391a14f7 100644--- a/products/desktop/packages/ui/src/features/settings/types.ts+++ b/products/desktop/packages/ui/src/features/settings/types.ts@@ -1,5 +1,6 @@export type SettingsCategory =| "general"+ | "appearance"| "notifications"| "plan-usage"| "cost-management"@@ -24,6 +25,7 @@ export type SettingsCategory =const SETTINGS_CATEGORIES: readonly SettingsCategory[] = ["general",+ "appearance","notifications","plan-usage","cost-management",@@ -56,6 +58,7 @@ export function isSettingsCategory(value: string): value is SettingsCategory {// can't ship without a name. `cloud-environments` shares the Environments page.export const SETTINGS_PAGE_LABELS: Record<SettingsCategory, string> = {general: "General",+ appearance: "Appearance",notifications: "Notifications","plan-usage": "Plan & usage","cost-management": "Cost management",@@ -79,6 +82,16 @@ export const SETTINGS_PAGE_LABELS: Record<SettingsCategory, string> = {discord: "Discord",};+// Pages whose changes show in the app itself, so the dialog drops its backdrop+// to let the reader watch them land.+const APP_REVEALING_PAGES: ReadonlySet<SettingsCategory> = new Set([+ "appearance",+]);++export function settingsPageRevealsApp(category: SettingsCategory): boolean {+ return APP_REVEALING_PAGES.has(category);+}+// The app restores the last location on startup, so a renamed category has to// keep resolving for anyone whose remembered URL still names the old one.const RENAMED_SETTINGS_CATEGORIES: Readonly<Record<string, SettingsCategory>> =diff --git a/products/desktop/packages/ui/src/features/sidebar/components/NavRailTile.tsx b/products/desktop/packages/ui/src/features/sidebar/components/NavRailTile.tsxnew file mode 100644index 000000000000..aa7f5d29a241--- /dev/null+++ b/products/desktop/packages/ui/src/features/sidebar/components/NavRailTile.tsx@@ -0,0 +1,49 @@+import { cn } from "@posthog/quill";+import { useNavRailMetrics } from "@posthog/ui/features/sidebar/navRailSize";+import type { ComponentPropsWithRef, ReactNode } from "react";++interface NavRailTileProps extends ComponentPropsWithRef<"button"> {+ children: ReactNode;+ caption: string;+ tileClassName?: string;+}++export function NavRailTile({+ children,+ caption,+ tileClassName,+ className,+ ref,+ ...buttonProps+}: NavRailTileProps) {+ const metrics = useNavRailMetrics();+ return (+ <button+ {...buttonProps}+ ref={ref}+ type="button"+ className={cn(+ "group flex w-full shrink-0 cursor-pointer flex-col items-center gap-0.5 text-muted-foreground outline-none hover:text-foreground aria-expanded:text-foreground data-selected:text-foreground",+ className,+ )}+ >+ <span+ className={cn(+ "relative flex items-center justify-center rounded-md group-hover:bg-fill-hover group-focus-visible:ring-2 group-focus-visible:ring-ring group-aria-expanded:bg-fill-selected group-data-selected:bg-fill-selected",+ metrics.tileClassName,+ tileClassName,+ )}+ >+ {children}+ </span>+ {metrics.captionClassName && (+ <span+ aria-hidden+ className={cn("max-w-full truncate px-0.5", metrics.captionClassName)}+ >+ {caption}+ </span>+ )}+ </button>+ );+}diff --git a/products/desktop/packages/ui/src/features/sidebar/components/ProjectSwitcher.tsx b/products/desktop/packages/ui/src/features/sidebar/components/ProjectSwitcher.tsxindex 1a331691574d..42d35b09c7a5 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/ProjectSwitcher.tsx+++ b/products/desktop/packages/ui/src/features/sidebar/components/ProjectSwitcher.tsx@@ -14,7 +14,6 @@ import {SignOut,} from "@phosphor-icons/react";import {- Button,DropdownMenu,DropdownMenuContent,DropdownMenuGroup,@@ -54,6 +53,7 @@ import { useFeedbackStore } from "@posthog/ui/features/feedback/feedbackStore";import { useProjects } from "@posthog/ui/features/projects/useProjects";import { openSettings } from "@posthog/ui/features/settings/hooks/useOpenSettings";import type { SettingsCategory } from "@posthog/ui/features/settings/types";+import { NavRailTile } from "@posthog/ui/features/sidebar/components/NavRailTile";import { useHoldSidebarPeek } from "@posthog/ui/features/sidebar/useHoldSidebarPeek";import { useWhatsNewStore } from "@posthog/ui/features/updates/whatsNewStore";import {@@ -263,14 +263,13 @@ export function ProjectSwitcher({<DropdownMenuTriggerrender={isIcon ? (- <Button- variant="outline"- size="icon"+ <NavRailTilearia-label={projectName}- className="shrink-0 font-semibold text-[11px] text-muted-foreground uppercase hover:bg-fill-selected aria-expanded:bg-fill-active"+ caption={projectName}+ tileClassName="border border-border bg-fill-secondary font-semibold text-xs uppercase">{projectInitials}- </Button>+ </NavRailTile>) : (<Itemsize="xs"diff --git a/products/desktop/packages/ui/src/features/sidebar/constants.ts b/products/desktop/packages/ui/src/features/sidebar/constants.tsindex cc696996daf5..84c4c16a4777 100644--- a/products/desktop/packages/ui/src/features/sidebar/constants.ts+++ b/products/desktop/packages/ui/src/features/sidebar/constants.ts@@ -10,10 +10,6 @@ export const SIDEBAR_MIN_WIDTH = 240;*/export const CHANNELS_SIDEBAR_MIN_WIDTH = 272;-/** Sits outside the sidebar, so anything measuring from the window's left edge- * has to add it. */-export const NAV_RAIL_WIDTH = 44;-export const NAV_ITEMS = [{ id: "inbox", label: "Self-driving", analyticsId: "inbox" },{ id: "activity", label: "Activity", analyticsId: "activity" },diff --git a/products/desktop/packages/ui/src/features/sidebar/navRailSize.ts b/products/desktop/packages/ui/src/features/sidebar/navRailSize.tsnew file mode 100644index 000000000000..67148175b66e--- /dev/null+++ b/products/desktop/packages/ui/src/features/sidebar/navRailSize.ts@@ -0,0 +1,46 @@+import {+ DEFAULT_NAV_RAIL_SIZE,+ type NavRailSize,+ useSettingsStore,+} from "@posthog/ui/features/settings/settingsStore";++export interface NavRailMetrics {+ /** Sits outside the sidebar, so anything measuring from the window's left+ * edge has to add it. */+ width: number;+ iconSize: number;+ tileClassName: string;+ captionClassName: string | null;+ gapClassName: string;+}++// Full class strings, so Tailwind's scanner sees every one of them.+export const NAV_RAIL_METRICS: Readonly<Record<NavRailSize, NavRailMetrics>> = {+ small: {+ width: 44,+ iconSize: 16,+ tileClassName: "size-8",+ captionClassName: null,+ gapClassName: "gap-1.5",+ },+ medium: {+ width: 54,+ iconSize: 18,+ tileClassName: "size-7",+ captionClassName: "font-bold text-[7px] leading-2",+ gapClassName: "gap-2",+ },+ large: {+ width: 64,+ iconSize: 20,+ tileClassName: "size-9",+ captionClassName: "font-medium text-[9px] leading-2",+ gapClassName: "gap-2",+ },+};++export function useNavRailMetrics(): NavRailMetrics {+ const size = useSettingsStore((state) => state.navRailSize);+ // A persisted value from a build with different sizes falls back.+ return NAV_RAIL_METRICS[size] ?? NAV_RAIL_METRICS[DEFAULT_NAV_RAIL_SIZE];+}diff --git a/products/desktop/packages/ui/src/router/routes/__root.tsx b/products/desktop/packages/ui/src/router/routes/__root.tsxindex 254cd0bb184d..fd46334a0239 100644--- a/products/desktop/packages/ui/src/router/routes/__root.tsx+++ b/products/desktop/packages/ui/src/router/routes/__root.tsx@@ -49,7 +49,7 @@ import {UpdateBanner,useUpdateBannerVisible,} from "@posthog/ui/features/sidebar/components/UpdateBanner";-import { NAV_RAIL_WIDTH } from "@posthog/ui/features/sidebar/constants";+import { useNavRailMetrics } from "@posthog/ui/features/sidebar/navRailSize";import {beginSidebarPeek,cancelSidebarPeek,@@ -201,6 +201,7 @@ function RootLayout() {// The new channels layout has exactly one gate: its feature flag (no// sidebar toggle). When on it subsumes the channels alpha entirely.const channelsLayout = useChannelsLayout();+ const { width: navRailWidth } = useNavRailMetrics();const { hasSidebar } = useRailSurface();// When the sidebar is collapsed (Cmd+B) the title bar's left block shrinks to// fit its own controls so the tab strip flushes left with the content pane.@@ -419,7 +420,7 @@ function RootLayout() {{!sidebarOpen && (<Boxaria-hidden- style={{ left: channelsLayout ? NAV_RAIL_WIDTH : 0 }}+ style={{ left: channelsLayout ? navRailWidth : 0 }}// The radix preset replaces Tailwind's palette, so plain// `bg-black/*` doesn't exist — use the radix black-alpha scale// (--black-a2 = 10%, --black-a5 = 30%).