From 3c48b2ceb74525261b5233b85b381435aea24c6f Mon Sep 17 00:00:00 2001 From: James Date: Mon, 22 Dec 2025 12:40:56 -0500 Subject: [PATCH] add more robust util fn --- .../layout/sidebar/components/sidebar-header.tsx | 5 +---- apps/ui/src/lib/utils.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/ui/src/components/layout/sidebar/components/sidebar-header.tsx b/apps/ui/src/components/layout/sidebar/components/sidebar-header.tsx index 72e14a68..d209988e 100644 --- a/apps/ui/src/components/layout/sidebar/components/sidebar-header.tsx +++ b/apps/ui/src/components/layout/sidebar/components/sidebar-header.tsx @@ -1,11 +1,8 @@ import type { NavigateOptions } from '@tanstack/react-router'; -import { cn } from '@/lib/utils'; +import { cn, isMac } from '@/lib/utils'; import { AutomakerLogo } from './automaker-logo'; import { BugReportButton } from './bug-report-button'; -// Detect if running on macOS for traffic light button spacing -const isMac = typeof navigator !== 'undefined' && /Mac/.test(navigator.userAgent); - interface SidebarHeaderProps { sidebarOpen: boolean; navigate: (opts: NavigateOptions) => void; diff --git a/apps/ui/src/lib/utils.ts b/apps/ui/src/lib/utils.ts index 6d65e3e7..9aba7991 100644 --- a/apps/ui/src/lib/utils.ts +++ b/apps/ui/src/lib/utils.ts @@ -52,3 +52,13 @@ export function pathsEqual(p1: string | undefined | null, p2: string | undefined if (!p1 || !p2) return p1 === p2; return normalizePath(p1) === normalizePath(p2); } + +/** + * Detect if running on macOS. + * Checks Electron process.platform first, then falls back to navigator APIs. + */ +export const isMac = + typeof process !== 'undefined' && process.platform === 'darwin' + ? true + : typeof navigator !== 'undefined' && + (/Mac/.test(navigator.userAgent) || navigator.platform?.toLowerCase().includes('mac'));