import { useState, useCallback, type ReactNode } from 'react'; import { Command } from '@/components/ui/command'; import { ScrollArea } from '@/components/ui/scroll-area'; import { SidebarActions } from './SidebarActions'; import { SidebarActivityTicker, type SidebarActivityAction } from './SidebarActivityTicker'; import { SidebarBrand } from './SidebarBrand'; import { SidebarBulkBar } from './SidebarBulkBar'; import { SidebarFilterChips, type FilterCounts } from './SidebarFilterChips'; import { SidebarSearch } from './SidebarSearch'; import { StackList, type StackListProps } from './StackList'; import type { FilterChip } from './sidebar-types'; import type { BulkAction } from '@/hooks/useBulkStackActions'; import type { SidebarActivitySummary } from './useSidebarActivitySummary'; export interface StackSidebarProps { isDarkMode: boolean; nodeSwitcherSlot: ReactNode; createStackSlot: ReactNode | null; onScan: () => void; isScanning: boolean; canCreate: boolean; searchQuery: string; onSearchChange: (v: string) => void; filterChip: FilterChip; filterCounts: FilterCounts; onFilterChipChange: (chip: FilterChip) => void; list: StackListProps; activitySummary: SidebarActivitySummary; onActivityAction: (action: SidebarActivityAction) => void; bulkMode: boolean; selectedFiles: Set; onToggleBulkMode: () => void; onToggleSelect: (file: string) => void; onClearSelection: () => void; onBulkAction: (action: BulkAction) => void; } export function StackSidebar(props: StackSidebarProps) { const { isDarkMode, nodeSwitcherSlot, createStackSlot, onScan, isScanning, canCreate, searchQuery, onSearchChange, filterChip, filterCounts, onFilterChipChange, list, activitySummary, onActivityAction, bulkMode, selectedFiles, onToggleBulkMode, onToggleSelect, onClearSelection, onBulkAction, } = props; const [filtersVisible, setFiltersVisible] = useState(() => { try { const v = window.localStorage.getItem('sencho:sidebar:filters-visible'); return v === null ? true : v !== 'false'; } catch { return true; } }); const handleToggleFilters = useCallback(() => { setFiltersVisible(prev => { const next = !prev; try { window.localStorage.setItem('sencho:sidebar:filters-visible', String(next)); } catch { /* localStorage unavailable */ } return next; }); }, []); return (
{/* On mobile the status masthead leads (it carries the node switcher as its kicker chip), so the in-sidebar brand and node rows are redundant there and hidden to save vertical space. */}
{nodeSwitcherSlot}
{canCreate && createStackSlot !== null && ( )} {selectedFiles.size > 0 && ( )}
); }