feat(frontend): add Spotlight-style command palette with recent tracking

- Add CommandPalette component with keyboard navigation (arrows, Enter, Shift+Enter, Esc)
- Add useCommandPaletteStore Zustand store with localStorage-persisted recently viewed
- Show two distinct sections: Library results and TMDB Results (no duplicates)
- Exclude library entries from TMDB Results section by TMDB ID index
- Add "View all" links: Library section → /library, TMDB section → /search
- Persist non-library TMDB entries in localStorage for recently viewed support
- Register global Ctrl+P / Cmd+P / slash shortcuts in AppLayout
- Track entry visits in EntryDetailsPage for recently viewed
- Track TMDB preview visits in TmdbPreviewPage for recently viewed
- Updated related docs files

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Mohammed AbadandCopilot committed 2026-05-04 08:33:27 +01:00
1 parent 4303b33677
commit 3448142242
9 files changed
+710 -3

No files matched your search

+54 -1
View File
@@ -16,8 +16,10 @@ All in `react_frontend/src/components/`. Organized by domain.
| Component | File | Description |
|---|---|---|
| `AppLayout` | `layout/AppLayout.tsx` | Root layout with Sidebar + main area |
| `AppLayout` | `layout/AppLayout.tsx` | Root layout with Sidebar + main area; registers global `Ctrl+P` / `/` shortcut for the command palette |
| `Sidebar` | `layout/Sidebar.tsx` | Left navigation sidebar |
| `TitleBar` | `layout/TitleBar.tsx` | Custom frameless title bar (Electron only) |
| `CommandPalette` | `CommandPalette.tsx` | Spotlight-style command palette — see [[Search#Command Palette]] |
## Entry Components
@@ -74,6 +76,57 @@ See [[Statistics]] for data details.
`HomeSkeleton`, `LibrarySkeleton`, `WatchlistSkeleton`, `DashboardSkeleton`, `CollectionsSkeleton`, `CollectionDetailsSkeleton`, `MediaSkeleton`, `CalendarSkeleton`, `EntryDetailsSkeleton`, `SeasonSkeleton`, `EpisodeSkeleton`, `PeopleSkeleton`, `PersonDetailsSkeleton`, `SettingsSkeleton`
## Command Palette
> [!info] File: `components/CommandPalette.tsx`
Spotlight / Raycast-style command palette rendered at root level inside `AppLayout`.
### Trigger
| Shortcut | Condition |
|---|---|
| `Ctrl+P` / `Cmd+P` | Always |
| `/` | When focus is not on an input or textarea |
### Sections (when searching)
| Section | Source | Behaviour |
|---|---|---|
| Quick Actions / Commands | Static list | Navigation commands (Library, Watchlist, Stats, Calendar, People, Settings, Favorites) |
| Library | [[Stores\|useLibraryStore]] | Client-side fuzzy search — results appear instantly |
| TMDB Results | `tmdbApi.search()` (debounced 250 ms) | Entries already in library are **fully excluded** |
**View all links:**
- Library → `/library?search=<query>`
- TMDB Results → `/search?q=<query>`
### Recently Viewed (empty query)
Shown when the search input is empty. Populated by:
- `EntryDetailsPage` on mount → saves library entry with `id: "lib-{id}"`
- `TmdbPreviewPage` on mount → saves TMDB-only entry with `id: "tmdb-{tmdbId}"`
Persisted to `localStorage` via [[Stores\|useCommandPaletteStore]].
### Keyboard Navigation
| Key | Action |
|---|---|
| `↑` / `↓` | Move selection |
| `Enter` | Open selected item |
| `Shift+Enter` | Quick-add to library (TMDB items only) |
| `Esc` | Close palette |
### Selection Behaviour
- **Command** → navigate to route
- **Library item** → navigate to `/entry/:id`
- **TMDB item (Enter)** → navigate to `/entry/tmdb/:type/:tmdbId` (preview)
- **TMDB item (Shift+Enter)** → `useCreateEntry` mutation, then navigate to new entry
---
## UI Primitives (shadcn/ui)
Base components from shadcn/ui in `components/ui/`:
+1 -1
View File
@@ -81,7 +81,7 @@ react_frontend/src/
│ ├── normalizers.ts → [[Normalizers]]
│ └── utils.ts → cn() helper
├── pages/ → [[Pages]] (17 route pages)
├── stores/ → [[Stores]] (2 Zustand stores)
├── stores/ → [[Stores]] (3 Zustand stores)
└── types/ → [[Types]] (TypeScript interfaces)
```
+17
View File
@@ -74,7 +74,24 @@ Detail pages use `mx-auto max-w-4xl` for consistent max width:
/entry/:id/season/:seasonId/episode/:episodeId → EpisodePage (episode detail)
```
## Command Palette
A global Spotlight-style command palette (`Ctrl+P` / `/`) is available on every page. See [[Components#Command Palette]] for full details.
### Quick navigation commands
| Command | Destination |
|---|---|
| Go to Library | `/library` |
| Go to Watchlist | `/watchlist` |
| Go to Statistics | `/dashboard` |
| Go to Calendar | `/calendar` |
| Go to People | `/people` |
| Go to Settings | `/settings` |
| Go to Favorites | `/library?filter=favorites` |
## See Also
- [[Routing]] — All routes
- [[Pages]] — Page components
- [[Components#Command Palette]] — Palette implementation details
+41
View File
@@ -99,6 +99,47 @@ Uses Zustand `persist` middleware:
---
## useCommandPaletteStore
> [!info] File: `stores/useCommandPaletteStore.ts`
Manages [[Components#Command Palette|CommandPalette]] open/close state and recently viewed history.
### State
| Field | Type | Description |
|---|---|---|
| `isOpen` | `boolean` | Whether the palette is currently visible |
| `recentlyViewed` | `RecentItem[]` | Up to 10 recently visited entries (library + TMDB-only) |
### RecentItem Shape
```typescript
interface RecentItem {
id: string; // "lib-{id}" or "tmdb-{tmdbId}"
title: string;
type: 'movie' | 'tv';
poster_path: string | null;
libraryId?: number; // set for library entries
tmdbId?: number; // set for TMDB or library entries
}
```
### Actions
| Action | Description |
|---|---|
| `open()` | Open the palette |
| `close()` | Close the palette |
| `toggle()` | Toggle open/close |
| `addRecentlyViewed(item)` | Prepend to recents list (deduped by `id`, capped at 10) |
### Persistence
`recentlyViewed` is read from and written to `localStorage` key `showy-recent-viewed` on every `addRecentlyViewed` call (no Zustand persist middleware — manual).
---
## useLibraryFiltersStore
> [!info] File: `stores/useLibraryFiltersStore.ts`