From da01d2ec28a8bc429e836c02a2a54bfafa4b0452 Mon Sep 17 00:00:00 2001 From: lucaronin Date: Thu, 5 Mar 2026 12:30:38 +0100 Subject: [PATCH] fix: make Restore Default Themes command always enabled in Cmd+K palette The enabled guard `!!onRestoreDefaultThemes` could evaluate to false at runtime, hiding the command from the palette. Since the handler is always defined via useCallback, the guard is unnecessary. Changed to enabled: true, matching the pattern used by other always-available commands. Co-Authored-By: Claude Opus 4.6 --- src/hooks/useCommandRegistry.test.ts | 4 ++-- src/hooks/useCommandRegistry.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hooks/useCommandRegistry.test.ts b/src/hooks/useCommandRegistry.test.ts index e4c987cf..b5e842f2 100644 --- a/src/hooks/useCommandRegistry.test.ts +++ b/src/hooks/useCommandRegistry.test.ts @@ -715,11 +715,11 @@ describe('useCommandRegistry', () => { expect(cmd!.enabled).toBe(true) }) - it('is disabled when onRestoreDefaultThemes is not provided', () => { + it('is always enabled even when onRestoreDefaultThemes is not provided', () => { const { result } = renderHook(() => useCommandRegistry(makeConfig())) const cmd = result.current.find(c => c.id === 'restore-default-themes') expect(cmd).toBeDefined() - expect(cmd!.enabled).toBe(false) + expect(cmd!.enabled).toBe(true) }) it('calls onRestoreDefaultThemes when executed', () => { diff --git a/src/hooks/useCommandRegistry.ts b/src/hooks/useCommandRegistry.ts index 531843ad..0ccc01ca 100644 --- a/src/hooks/useCommandRegistry.ts +++ b/src/hooks/useCommandRegistry.ts @@ -249,7 +249,7 @@ export function useCommandRegistry(config: CommandRegistryConfig): CommandAction // Appearance ...buildThemeCommands(themes, activeThemeId, onSwitchTheme, onCreateTheme, onOpenTheme), - { id: 'restore-default-themes', label: 'Restore Default Themes', group: 'Appearance', keywords: ['theme', 'reset', 'restore', 'default', 'fix', 'missing'], enabled: !!onRestoreDefaultThemes, execute: () => onRestoreDefaultThemes?.() }, + { id: 'restore-default-themes', label: 'Restore Default Themes', group: 'Appearance', keywords: ['theme', 'reset', 'restore', 'default', 'fix', 'missing'], enabled: true, execute: () => onRestoreDefaultThemes?.() }, // Settings { id: 'open-settings', label: 'Open Settings', group: 'Settings', shortcut: '⌘,', keywords: ['preferences', 'config'], enabled: true, execute: onOpenSettings },