2026-02-24 23:41:54 +01:00
|
|
|
import { useMemo } from 'react'
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
import type { SidebarSelection, VaultEntry } from '../types'
|
2026-03-18 03:43:23 +01:00
|
|
|
import type { NoteListFilter } from '../utils/noteListHelpers'
|
2026-02-24 23:41:54 +01:00
|
|
|
import type { ViewMode } from './useViewMode'
|
2026-03-29 22:59:54 +02:00
|
|
|
import { buildNavigationCommands } from './commands/navigationCommands'
|
|
|
|
|
import { buildNoteCommands } from './commands/noteCommands'
|
|
|
|
|
import { buildGitCommands } from './commands/gitCommands'
|
|
|
|
|
import { buildViewCommands } from './commands/viewCommands'
|
|
|
|
|
import { buildSettingsCommands } from './commands/settingsCommands'
|
|
|
|
|
import { buildTypeCommands, extractVaultTypes } from './commands/typeCommands'
|
|
|
|
|
import { buildFilterCommands } from './commands/filterCommands'
|
|
|
|
|
|
|
|
|
|
// Re-export types and helpers for backward compatibility
|
|
|
|
|
export type { CommandAction, CommandGroup } from './commands/types'
|
|
|
|
|
export { groupSortKey } from './commands/types'
|
|
|
|
|
export { pluralizeType, extractVaultTypes, buildTypeCommands } from './commands/typeCommands'
|
|
|
|
|
export { buildViewCommands } from './commands/viewCommands'
|
2026-02-24 23:41:54 +01:00
|
|
|
|
|
|
|
|
interface CommandRegistryConfig {
|
|
|
|
|
activeTabPath: string | null
|
|
|
|
|
entries: VaultEntry[]
|
|
|
|
|
modifiedCount: number
|
2026-03-17 22:42:55 +01:00
|
|
|
activeNoteHasIcon?: boolean
|
2026-03-04 13:11:58 +01:00
|
|
|
mcpStatus?: string
|
|
|
|
|
onInstallMcp?: () => void
|
2026-03-09 00:35:21 +01:00
|
|
|
onReloadVault?: () => void
|
2026-03-07 12:39:55 +01:00
|
|
|
onRepairVault?: () => void
|
2026-03-17 22:42:55 +01:00
|
|
|
onSetNoteIcon?: () => void
|
|
|
|
|
onRemoveNoteIcon?: () => void
|
2026-03-19 08:47:25 +01:00
|
|
|
onOpenInNewWindow?: () => void
|
2026-04-03 17:20:33 +02:00
|
|
|
onToggleFavorite?: (path: string) => void
|
2026-04-04 20:54:16 +02:00
|
|
|
onToggleOrganized?: (path: string) => void
|
2026-02-24 23:41:54 +01:00
|
|
|
onQuickOpen: () => void
|
|
|
|
|
onCreateNote: () => void
|
2026-02-28 19:13:29 +01:00
|
|
|
onCreateNoteOfType: (type: string) => void
|
2026-02-24 23:41:54 +01:00
|
|
|
onSave: () => void
|
|
|
|
|
onOpenSettings: () => void
|
2026-03-01 16:04:51 +01:00
|
|
|
onOpenVault?: () => void
|
2026-03-03 00:31:10 +01:00
|
|
|
onCreateType?: () => void
|
2026-04-06 12:21:56 +02:00
|
|
|
onDeleteNote: (path: string) => void
|
2026-02-24 23:41:54 +01:00
|
|
|
onArchiveNote: (path: string) => void
|
|
|
|
|
onUnarchiveNote: (path: string) => void
|
|
|
|
|
onCommitPush: () => void
|
2026-03-19 09:51:06 +01:00
|
|
|
onPull?: () => void
|
2026-03-03 02:27:42 +01:00
|
|
|
onResolveConflicts?: () => void
|
2026-02-24 23:41:54 +01:00
|
|
|
onSetViewMode: (mode: ViewMode) => void
|
|
|
|
|
onToggleInspector: () => void
|
2026-03-03 02:00:48 +01:00
|
|
|
onToggleDiff?: () => void
|
2026-03-02 18:38:25 +01:00
|
|
|
onToggleRawEditor?: () => void
|
2026-03-02 05:00:29 +01:00
|
|
|
onToggleAIChat?: () => void
|
2026-03-03 02:00:48 +01:00
|
|
|
activeNoteModified: boolean
|
2026-03-02 23:48:01 +01:00
|
|
|
onCheckForUpdates?: () => void
|
2026-02-28 12:41:57 +01:00
|
|
|
onZoomIn: () => void
|
|
|
|
|
onZoomOut: () => void
|
|
|
|
|
onZoomReset: () => void
|
|
|
|
|
zoomLevel: number
|
2026-02-24 23:41:54 +01:00
|
|
|
onSelect: (sel: SidebarSelection) => void
|
2026-03-02 03:08:15 +01:00
|
|
|
onOpenDailyNote: () => void
|
2026-02-25 19:39:12 +01:00
|
|
|
onGoBack?: () => void
|
|
|
|
|
onGoForward?: () => void
|
|
|
|
|
canGoBack?: boolean
|
|
|
|
|
canGoForward?: boolean
|
2026-03-03 02:26:41 +01:00
|
|
|
onRemoveActiveVault?: () => void
|
|
|
|
|
onRestoreGettingStarted?: () => void
|
|
|
|
|
isGettingStartedHidden?: boolean
|
|
|
|
|
vaultCount?: number
|
2026-03-18 03:43:23 +01:00
|
|
|
selection?: SidebarSelection
|
|
|
|
|
noteListFilter?: NoteListFilter
|
|
|
|
|
onSetNoteListFilter?: (filter: NoteListFilter) => void
|
2026-02-24 23:41:54 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-29 22:59:54 +02:00
|
|
|
export function useCommandRegistry(config: CommandRegistryConfig): import('./commands/types').CommandAction[] {
|
2026-02-24 23:41:54 +01:00
|
|
|
const {
|
2026-03-05 18:18:52 +01:00
|
|
|
activeTabPath, entries, modifiedCount,
|
2026-02-28 19:13:29 +01:00
|
|
|
onQuickOpen, onCreateNote, onCreateNoteOfType, onSave, onOpenSettings,
|
2026-04-06 12:21:56 +02:00
|
|
|
onDeleteNote, onArchiveNote, onUnarchiveNote,
|
2026-03-19 09:51:06 +01:00
|
|
|
onCommitPush, onPull, onResolveConflicts, onSetViewMode, onToggleInspector, onToggleDiff, onToggleRawEditor, onToggleAIChat, onOpenVault,
|
2026-03-03 02:00:48 +01:00
|
|
|
activeNoteModified,
|
2026-02-28 12:41:57 +01:00
|
|
|
onZoomIn, onZoomOut, onZoomReset, zoomLevel,
|
refactor: remove tab bar — single note open at a time
Replace the multi-tab model with single-note navigation. One note is
open at a time; clicking any note (sidebar, wikilink, relationship)
replaces the current note in the editor. Back/Forward history still
works via Cmd+[/].
Removed: TabBar component, useClosedTabHistory, tab reorder/close/
reopen logic, Cmd+W/Cmd+Shift+T shortcuts, Close Tab and Reopen
Closed Tab menu items, tabLayout utility, and all related tests.
Simplified: useTabManagement (single-note), useAppNavigation (no tab
lookup), useKeyboardNavigation (note nav only), useNoteCreation (no
close-tab cleanup), useDeleteActions (deselect instead of close tab),
Editor (no TabBar render), Rust menu (removed 2 menu items).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 17:24:49 +01:00
|
|
|
onSelect, onOpenDailyNote,
|
2026-02-25 19:39:12 +01:00
|
|
|
onGoBack, onGoForward, canGoBack, canGoForward,
|
2026-03-29 22:59:54 +02:00
|
|
|
onCheckForUpdates, onCreateType,
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
onRemoveActiveVault, onRestoreGettingStarted, isGettingStartedHidden, vaultCount,
|
2026-04-06 12:21:56 +02:00
|
|
|
mcpStatus, onInstallMcp,
|
2026-03-29 22:59:54 +02:00
|
|
|
onReloadVault, onRepairVault,
|
|
|
|
|
onSetNoteIcon, onRemoveNoteIcon, activeNoteHasIcon,
|
2026-04-04 20:54:16 +02:00
|
|
|
onOpenInNewWindow, onToggleFavorite, onToggleOrganized,
|
2026-03-18 03:43:23 +01:00
|
|
|
selection, noteListFilter, onSetNoteListFilter,
|
2026-02-24 23:41:54 +01:00
|
|
|
} = config
|
|
|
|
|
|
|
|
|
|
const hasActiveNote = activeTabPath !== null
|
|
|
|
|
|
|
|
|
|
const activeEntry = useMemo(
|
|
|
|
|
() => (hasActiveNote ? entries.find(e => e.path === activeTabPath) : undefined),
|
|
|
|
|
[entries, activeTabPath, hasActiveNote],
|
|
|
|
|
)
|
|
|
|
|
const isArchived = activeEntry?.archived ?? false
|
2026-04-03 17:20:33 +02:00
|
|
|
const isFavorite = activeEntry?.favorite ?? false
|
2026-03-29 22:59:54 +02:00
|
|
|
const isSectionGroup = selection?.kind === 'sectionGroup'
|
2026-02-24 23:41:54 +01:00
|
|
|
|
2026-02-28 19:13:29 +01:00
|
|
|
const vaultTypes = useMemo(() => extractVaultTypes(entries), [entries])
|
|
|
|
|
|
2026-03-29 22:59:54 +02:00
|
|
|
return useMemo(() => [
|
|
|
|
|
...buildNavigationCommands({ onQuickOpen, onSelect, onOpenDailyNote, onGoBack, onGoForward, canGoBack, canGoForward }),
|
|
|
|
|
...buildNoteCommands({
|
2026-04-06 12:21:56 +02:00
|
|
|
hasActiveNote, activeTabPath, isArchived,
|
2026-03-29 22:59:54 +02:00
|
|
|
onCreateNote, onCreateType, onOpenDailyNote, onSave,
|
2026-04-06 12:21:56 +02:00
|
|
|
onDeleteNote, onArchiveNote, onUnarchiveNote,
|
|
|
|
|
onSetNoteIcon, onRemoveNoteIcon, activeNoteHasIcon, onOpenInNewWindow, onToggleFavorite, isFavorite,
|
2026-04-04 20:54:16 +02:00
|
|
|
onToggleOrganized, isOrganized: activeEntry?.organized ?? false,
|
2026-03-29 22:59:54 +02:00
|
|
|
}),
|
|
|
|
|
...buildGitCommands({ modifiedCount, onCommitPush, onPull, onResolveConflicts, onSelect }),
|
|
|
|
|
...buildViewCommands({
|
|
|
|
|
hasActiveNote, activeNoteModified, onSetViewMode, onToggleInspector,
|
|
|
|
|
onToggleDiff, onToggleRawEditor, onToggleAIChat, zoomLevel, onZoomIn, onZoomOut, onZoomReset,
|
|
|
|
|
}),
|
|
|
|
|
...buildSettingsCommands({
|
|
|
|
|
mcpStatus, vaultCount, isGettingStartedHidden,
|
|
|
|
|
onOpenSettings, onOpenVault, onRemoveActiveVault, onRestoreGettingStarted,
|
|
|
|
|
onCheckForUpdates, onInstallMcp, onReloadVault, onRepairVault,
|
|
|
|
|
}),
|
|
|
|
|
...buildTypeCommands(vaultTypes, onCreateNoteOfType, onSelect),
|
|
|
|
|
...buildFilterCommands({ isSectionGroup, noteListFilter, onSetNoteListFilter }),
|
|
|
|
|
], [
|
2026-04-06 12:21:56 +02:00
|
|
|
hasActiveNote, activeTabPath, isArchived, modifiedCount, activeNoteModified,
|
2026-03-03 00:31:10 +01:00
|
|
|
onQuickOpen, onCreateNote, onCreateNoteOfType, onCreateType, onSave, onOpenSettings,
|
2026-04-06 12:21:56 +02:00
|
|
|
onDeleteNote, onArchiveNote, onUnarchiveNote,
|
2026-03-19 09:51:06 +01:00
|
|
|
onCommitPush, onPull, onResolveConflicts, onSetViewMode, onToggleInspector, onToggleDiff, onToggleRawEditor, onToggleAIChat, onOpenVault,
|
2026-03-03 16:46:47 +01:00
|
|
|
onCheckForUpdates,
|
2026-02-28 12:41:57 +01:00
|
|
|
onZoomIn, onZoomOut, onZoomReset, zoomLevel,
|
refactor: remove tab bar — single note open at a time
Replace the multi-tab model with single-note navigation. One note is
open at a time; clicking any note (sidebar, wikilink, relationship)
replaces the current note in the editor. Back/Forward history still
works via Cmd+[/].
Removed: TabBar component, useClosedTabHistory, tab reorder/close/
reopen logic, Cmd+W/Cmd+Shift+T shortcuts, Close Tab and Reopen
Closed Tab menu items, tabLayout utility, and all related tests.
Simplified: useTabManagement (single-note), useAppNavigation (no tab
lookup), useKeyboardNavigation (note nav only), useNoteCreation (no
close-tab cleanup), useDeleteActions (deselect instead of close tab),
Editor (no TabBar render), Rust menu (removed 2 menu items).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 17:24:49 +01:00
|
|
|
onSelect, onOpenDailyNote,
|
2026-02-25 19:39:12 +01:00
|
|
|
onGoBack, onGoForward, canGoBack, canGoForward,
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
vaultTypes,
|
2026-03-03 02:48:10 +01:00
|
|
|
onRemoveActiveVault, onRestoreGettingStarted, isGettingStartedHidden, vaultCount,
|
2026-04-06 12:21:56 +02:00
|
|
|
mcpStatus, onInstallMcp,
|
refactor: remove QMD semantic indexing — keep keyword search only
Remove the entire QMD search engine (semantic indexing, hybrid search,
vector embeddings) and replace with a simple walkdir-based keyword
search. QMD never worked reliably in production, added bundle bloat,
and showed "Index failed" in the status bar.
What changed:
- Rust: deleted indexing.rs, rewrote search.rs as pure keyword search
- Frontend: removed useIndexing hook, IndexingBadge, hybrid search
- Menu: removed "Reindex Vault" command from palette and menu bar
- Config: removed qmd from bundle resources and build script
- Deleted tools/qmd/ (QMD CLI tool, MCP server, tests)
- Updated docs (ARCHITECTURE, ABSTRACTIONS, GETTING-STARTED)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 16:18:05 +01:00
|
|
|
onReloadVault, onRepairVault,
|
2026-03-17 22:42:55 +01:00
|
|
|
onSetNoteIcon, onRemoveNoteIcon, activeNoteHasIcon,
|
2026-03-18 03:43:23 +01:00
|
|
|
isSectionGroup, noteListFilter, onSetNoteListFilter,
|
2026-04-03 17:20:33 +02:00
|
|
|
onOpenInNewWindow, onToggleFavorite, isFavorite,
|
2026-04-04 20:54:16 +02:00
|
|
|
onToggleOrganized, activeEntry,
|
2026-02-24 23:41:54 +01:00
|
|
|
])
|
|
|
|
|
}
|