diff --git a/packages/review-editor/components/ReviewHeaderMenu.tsx b/packages/review-editor/components/ReviewHeaderMenu.tsx index 35dcf5f96..585ab21d0 100644 --- a/packages/review-editor/components/ReviewHeaderMenu.tsx +++ b/packages/review-editor/components/ReviewHeaderMenu.tsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import React from 'react'; import { ActionMenu, ActionMenuDivider, @@ -6,6 +6,8 @@ import { ActionMenuSectionLabel, } from '@plannotator/ui/components/ActionMenu'; import { useTheme } from '@plannotator/ui/components/ThemeProvider'; +import { SunIcon, MoonIcon, SystemIcon } from '@plannotator/ui/components/icons/themeIcons'; +import { getUnsupportedMode } from '@plannotator/ui/utils/themeRegistry'; import { MenuVersionSection } from '@plannotator/ui/components/MenuVersionSection'; import { TextShimmer } from '@plannotator/ui/components/TextShimmer'; import { modKey } from '@plannotator/ui/utils/platform'; @@ -37,10 +39,12 @@ export const ReviewHeaderMenu: React.FC = ({ origin, isWSL = false, }) => { - const { theme, resolvedMode, setTheme } = useTheme(); - const activeTheme = useMemo<'light' | 'dark'>(() => { - return theme === 'system' ? resolvedMode : theme; - }, [resolvedMode, theme]); + const { theme, setTheme, colorTheme } = useTheme(); + const unsupportedMode = getUnsupportedMode(colorTheme); + // When the palette can't render the stored mode, the UI is forced to the + // opposite — highlight the mode actually shown instead of the dead one. + const highlightedTheme = + theme === unsupportedMode ? (unsupportedMode === 'light' ? 'dark' : 'light') : theme; const showUpdateDot = !!updateInfo?.updateAvailable && !updateInfo.dismissed; @@ -80,20 +84,24 @@ export const ReviewHeaderMenu: React.FC = ({
Theme
- {(['light', 'dark'] as const).map((mode) => ( + {(['light', 'dark', 'system'] as const).map((mode) => ( ))} @@ -181,19 +189,6 @@ const ExportIcon = () => ( ); -const SunIcon = () => ( - - - - -); - -const MoonIcon = () => ( - - - -); - const FileTreeMenuIcon = () => ( diff --git a/packages/ui/components/ActionMenu.tsx b/packages/ui/components/ActionMenu.tsx index 3ca1f8883..fd6eb26ad 100644 --- a/packages/ui/components/ActionMenu.tsx +++ b/packages/ui/components/ActionMenu.tsx @@ -50,7 +50,7 @@ export const ActionMenu: React.FC = ({ })} {isOpen && ( -
+
{children({ closeMenu: () => setIsOpen(false) })}
)} diff --git a/packages/ui/components/PlanHeaderMenu.tsx b/packages/ui/components/PlanHeaderMenu.tsx index d5243b36e..940550207 100644 --- a/packages/ui/components/PlanHeaderMenu.tsx +++ b/packages/ui/components/PlanHeaderMenu.tsx @@ -7,6 +7,7 @@ import { } from './ActionMenu'; import { useTheme } from './ThemeProvider'; import { SunIcon, MoonIcon, SystemIcon } from './icons/themeIcons'; +import { getUnsupportedMode } from '../utils/themeRegistry'; import { ReviewAgentsIcon } from './ReviewAgentsIcon'; import { MenuVersionSection } from './MenuVersionSection'; import { TextShimmer } from './TextShimmer'; @@ -58,7 +59,12 @@ export const PlanHeaderMenu: React.FC = ({ bearConfigured, octarineConfigured, }) => { - const { theme, setTheme } = useTheme(); + const { theme, setTheme, colorTheme } = useTheme(); + const unsupportedMode = getUnsupportedMode(colorTheme); + // When the palette can't render the stored mode, the UI is forced to the + // opposite — highlight the mode actually shown instead of the dead one. + const highlightedTheme = + theme === unsupportedMode ? (unsupportedMode === 'light' ? 'dark' : 'light') : theme; const showUpdateDot = !!updateInfo?.updateAvailable && !updateInfo.dismissed; @@ -104,14 +110,18 @@ export const PlanHeaderMenu: React.FC = ({ {(['light', 'dark', 'system'] as const).map((mode) => (