feat: Add 'Restore Default Themes' command for vaults missing theme structure
- New restore_default_themes() Rust fn: seeds both _themes/ and theme/ dirs - Per-file idempotent: never overwrites existing files with content - Fixed ensure_vault_themes() to include minimal.md (was missing) - New 'Restore Default Themes' command in Cmd+K Appearance group - 3 new Rust tests + 4 new frontend tests - 1676 frontend tests passed
This commit is contained in:
@@ -62,6 +62,7 @@ interface AppCommandsConfig {
|
||||
onCheckForUpdates?: () => void
|
||||
onRemoveActiveVault?: () => void
|
||||
onRestoreGettingStarted?: () => void
|
||||
onRestoreDefaultThemes?: () => void
|
||||
isGettingStartedHidden?: boolean
|
||||
vaultCount?: number
|
||||
mcpStatus?: string
|
||||
@@ -172,6 +173,7 @@ export function useAppCommands(config: AppCommandsConfig): CommandAction[] {
|
||||
onCheckForUpdates: config.onCheckForUpdates,
|
||||
onRemoveActiveVault: config.onRemoveActiveVault,
|
||||
onRestoreGettingStarted: config.onRestoreGettingStarted,
|
||||
onRestoreDefaultThemes: config.onRestoreDefaultThemes,
|
||||
isGettingStartedHidden: config.isGettingStartedHidden,
|
||||
vaultCount: config.vaultCount,
|
||||
mcpStatus: config.mcpStatus,
|
||||
|
||||
@@ -703,6 +703,41 @@ describe('useCommandRegistry', () => {
|
||||
expect(cmd!.keywords).toContain('demo')
|
||||
})
|
||||
})
|
||||
|
||||
describe('restore-default-themes command', () => {
|
||||
it('has restore-default-themes command in Appearance group', () => {
|
||||
const onRestoreDefaultThemes = vi.fn()
|
||||
const { result } = renderHook(() => useCommandRegistry(makeConfig({ onRestoreDefaultThemes })))
|
||||
const cmd = result.current.find(c => c.id === 'restore-default-themes')
|
||||
expect(cmd).toBeDefined()
|
||||
expect(cmd!.label).toBe('Restore Default Themes')
|
||||
expect(cmd!.group).toBe('Appearance')
|
||||
expect(cmd!.enabled).toBe(true)
|
||||
})
|
||||
|
||||
it('is disabled 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)
|
||||
})
|
||||
|
||||
it('calls onRestoreDefaultThemes when executed', () => {
|
||||
const onRestoreDefaultThemes = vi.fn()
|
||||
const { result } = renderHook(() => useCommandRegistry(makeConfig({ onRestoreDefaultThemes })))
|
||||
result.current.find(c => c.id === 'restore-default-themes')!.execute()
|
||||
expect(onRestoreDefaultThemes).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('has relevant keywords for discoverability', () => {
|
||||
const onRestoreDefaultThemes = vi.fn()
|
||||
const { result } = renderHook(() => useCommandRegistry(makeConfig({ onRestoreDefaultThemes })))
|
||||
const cmd = result.current.find(c => c.id === 'restore-default-themes')
|
||||
expect(cmd!.keywords).toContain('theme')
|
||||
expect(cmd!.keywords).toContain('restore')
|
||||
expect(cmd!.keywords).toContain('default')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('pluralizeType', () => {
|
||||
|
||||
@@ -60,6 +60,7 @@ interface CommandRegistryConfig {
|
||||
onOpenTheme?: (themeId: string) => void
|
||||
onRemoveActiveVault?: () => void
|
||||
onRestoreGettingStarted?: () => void
|
||||
onRestoreDefaultThemes?: () => void
|
||||
isGettingStartedHidden?: boolean
|
||||
vaultCount?: number
|
||||
}
|
||||
@@ -194,7 +195,7 @@ export function useCommandRegistry(config: CommandRegistryConfig): CommandAction
|
||||
themes, activeThemeId, onSwitchTheme, onCreateTheme, onOpenTheme,
|
||||
onCheckForUpdates,
|
||||
onCreateType,
|
||||
onRemoveActiveVault, onRestoreGettingStarted, isGettingStartedHidden, vaultCount,
|
||||
onRemoveActiveVault, onRestoreGettingStarted, onRestoreDefaultThemes, isGettingStartedHidden, vaultCount,
|
||||
mcpStatus, onInstallMcp,
|
||||
} = config
|
||||
|
||||
@@ -248,6 +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?.() },
|
||||
|
||||
// Settings
|
||||
{ id: 'open-settings', label: 'Open Settings', group: 'Settings', shortcut: '⌘,', keywords: ['preferences', 'config'], enabled: true, execute: onOpenSettings },
|
||||
@@ -271,7 +273,7 @@ export function useCommandRegistry(config: CommandRegistryConfig): CommandAction
|
||||
onZoomIn, onZoomOut, onZoomReset, zoomLevel,
|
||||
onSelect, onOpenDailyNote, onCloseTab,
|
||||
onGoBack, onGoForward, canGoBack, canGoForward,
|
||||
vaultTypes, themes, activeThemeId, onSwitchTheme, onCreateTheme, onOpenTheme,
|
||||
vaultTypes, themes, activeThemeId, onSwitchTheme, onCreateTheme, onOpenTheme, onRestoreDefaultThemes,
|
||||
onRemoveActiveVault, onRestoreGettingStarted, isGettingStartedHidden, vaultCount,
|
||||
mcpStatus, onInstallMcp,
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user