Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(themes): reflect cmdk in theme settings (#4842)
Aidan Holloway-Bidwellee1d17259989
diff --git a/apps/web/src/components/app/GlobalHotkeys.tsx b/apps/web/src/components/app/GlobalHotkeys.tsxindex 118e4b2fad..2b4a419d50 100644--- a/apps/web/src/components/app/GlobalHotkeys.tsx+++ b/apps/web/src/components/app/GlobalHotkeys.tsx@@ -46,6 +46,8 @@ import { useMutationUndoContext } from '@queries/undo';import { debounce } from '@solid-primitives/scheduled';import { ThemeChips } from '@theme/components/ThemeChips';import {+ darkModeTheme,+ lightModeTheme,setDarkModeTheme,setLightModeTheme,setThemeMode,@@ -55,11 +57,14 @@ import {} from '@theme/signals/themeSignals';import type { ThemeV2 } from '@theme/types/themeTypes';import {+ applySystemTheme,applyTheme,clearThemePreview,+ pinTheme,previewTheme,+ resolveActiveThemeId,} from '@theme/utils/themeUtils';-import { type Component, onCleanup } from 'solid-js';+import { type Component, onCleanup, Show } from 'solid-js';import { useSplitLayout } from './split-layout/layout';const COMMAND_MENU_CATEGORY_HOTKEYS: Array<{@@ -367,12 +372,50 @@ export default function GlobalShortcuts() {</div>);+ // The per-mode theme the OS scheme currently resolves to — shown as the+ // "System preference" option's swatch and previewed on highlight.+ const systemResolvedTheme = (): ThemeV2 | undefined =>+ themes().find(+ (theme) =>+ theme.id ===+ (systemMode() === 'dark' ? darkModeTheme() : lightModeTheme())+ );++ // "System preference" mirrors the Active-theme dropdown's first option: follow+ // the OS scheme rather than pinning a fixed theme.+ registerHotkey({+ scopeId: setThemeScope.commandScopeId,+ description: 'System preference',+ keyDownHandler: () => {+ applySystemTheme();+ analytics.track('theme_changed', { themeId: 'system' });+ return true;+ },+ runWithInputFocused: true,+ displayComponent: () => (+ <div class="flex items-center gap-2">+ System preference+ <Show when={systemResolvedTheme()}>+ {(theme) => <ThemeChips theme={theme()} size="sm" />}+ </Show>+ </div>+ ),+ onHighlight: () => {+ const theme = systemResolvedTheme();+ if (theme) previewTheme(theme.id);+ },+ onHighlightEnd: clearThemePreview,+ });+themes().forEach((theme) => {registerHotkey({scopeId: setThemeScope.commandScopeId,description: `${theme.name}`,keyDownHandler: () => {- applyTheme(theme.id);+ // Pin the theme (mode + per-mode theme) so the choice shows up in the+ // Appearance settings, then apply it live.+ pinTheme(theme);+ applyTheme(resolveActiveThemeId());analytics.track('theme_changed', { themeId: theme.id });return true;},diff --git a/apps/web/src/features/settings/Appearance.tsx b/apps/web/src/features/settings/Appearance.tsxindex 38cc18b67b..b27b90849b 100644--- a/apps/web/src/features/settings/Appearance.tsx+++ b/apps/web/src/features/settings/Appearance.tsx@@ -30,6 +30,7 @@ import {exportTheme,getLiveTheme,isTokensDark,+ pinTheme,previewTheme,resolveActiveThemeId,saveTheme,@@ -593,16 +594,6 @@ function ActiveThemeSelect(props: {* theme, so resolveActiveThemeId / systemThemeEffect apply it live.*/function ActiveThemeRow() {- const pinTheme = (theme: ThemeV2) => {- if (isTokensDark(theme.tokens)) {- setDarkModeTheme(theme.id);- setThemeMode('dark');- } else {- setLightModeTheme(theme.id);- setThemeMode('light');- }- };-// Saving a new theme from the editor pins it as the active theme.const editor = createThemeEditorController((id) => {const theme = themes().find((t) => t.id === id);diff --git a/apps/web/src/features/theme/utils/themeUtils.ts b/apps/web/src/features/theme/utils/themeUtils.tsindex 1eedbe6c85..acf1d81eaf 100644--- a/apps/web/src/features/theme/utils/themeUtils.ts+++ b/apps/web/src/features/theme/utils/themeUtils.ts@@ -1,4 +1,4 @@-import { currentThemeId, darkModeTheme, lightModeTheme, setCurrentThemeId, setDarkModeTheme, setHtmlColor, setIsThemeSaved, setLightModeTheme, setThemeDepth, setUserThemes, systemMode, themeDepth, themeMode, themes, userThemes} from '../signals/themeSignals';+import { currentThemeId, darkModeTheme, lightModeTheme, setCurrentThemeId, setDarkModeTheme, setHtmlColor, setIsThemeSaved, setLightModeTheme, setThemeDepth, setThemeMode, setUserThemes, systemMode, themeDepth, themeMode, themes, userThemes} from '../signals/themeSignals';import { semanticTokens, type ThemeV2, type ThemeV2Tokens } from '../types/themeTypes';import { themeReactive } from '../signals/themeReactive';import { toast } from '@core/component/Toast/Toast';@@ -297,6 +297,29 @@ export function isTokensDark(tokens: ThemeV2Tokens): boolean {return tokens.c0.l > tokens.b0.l;}+/** Pins a theme as the "Active theme": makes it the stored theme for its+ * intrinsic light/dark mode and switches the mode to match, so+ * resolveActiveThemeId / systemThemeEffect apply it live. Shared by the settings+ * Active-theme picker and the command-palette "Change theme" action so choosing+ * a theme in either place is reflected in the other. */+export function pinTheme(theme: ThemeV2): void {+ if (isTokensDark(theme.tokens)) {+ setDarkModeTheme(theme.id);+ setThemeMode('dark');+ } else {+ setLightModeTheme(theme.id);+ setThemeMode('light');+ }+}++/** Follows the OS color scheme (the "System preference" option): switches the+ * mode to 'system' and applies whichever per-mode theme the OS currently+ * resolves to. Shared by the settings picker and the command palette. */+export function applySystemTheme(): void {+ setThemeMode('system');+ applyTheme(resolveActiveThemeId());+}+/** Checks if the theme contrast is too low, and if so, applies a readable theme. This is to prevent malicious actors sending "Theme Viruses" which make a user's theme unusable. */export function ensureMinimalThemeContrast() {const spec = themes().find((t) => t.id === currentThemeId())?.tokens;