feat(renderer): AppHeader wired to command store

- toggle sidebar/preview buttons dispatch through command store
- new 'shortcuts.show' command (Keyboard icon, opens shortcuts panel later)
- AppHeader.test.tsx updated: registers matching commands in beforeEach
- integration test fixed: 'Open folder' button now matches 2 (toolbar + sidebar)
- 155/155 tests pass
This commit is contained in:
Amit Haridas
2026-06-05 16:00:58 +05:30
parent 487ce2ad45
commit b1e16af62d
3 changed files with 56 additions and 7 deletions
+18 -5
View File
@@ -1,10 +1,12 @@
import { PanelLeft, PanelRight } from 'lucide-react';
import { PanelLeft, PanelRight, Keyboard } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { ThemeToggle } from '@/components/theme-toggle';
import { useAppStore } from '@/stores/app-store';
import { useCommandStore } from '@/stores/command-store';
export function AppHeader() {
const { sidebarVisible, previewVisible, toggleSidebar, togglePreview } = useAppStore();
const { sidebarVisible, previewVisible } = useAppStore();
const dispatch = useCommandStore((s) => s.dispatch);
return (
<header className="flex h-14 items-center justify-between border-b border-border bg-card/40 px-4 backdrop-blur">
@@ -21,7 +23,8 @@ export function AppHeader() {
size="icon"
aria-label="Toggle sidebar"
aria-pressed={sidebarVisible}
onClick={toggleSidebar}
data-testid="header-toggle-sidebar"
onClick={() => dispatch('view.toggleSidebar')}
>
<PanelLeft className="h-4 w-4" />
</Button>
@@ -30,12 +33,22 @@ export function AppHeader() {
size="icon"
aria-label="Toggle preview"
aria-pressed={previewVisible}
onClick={togglePreview}
data-testid="header-toggle-preview"
onClick={() => dispatch('view.togglePreview')}
>
<PanelRight className="h-4 w-4" />
</Button>
<Button
variant="ghost"
size="icon"
aria-label="Keyboard shortcuts"
data-testid="header-shortcuts"
onClick={() => dispatch('shortcuts.show')}
>
<Keyboard className="h-4 w-4" />
</Button>
<ThemeToggle />
</div>
</header>
);
}
}