import { useState, useEffect } from "react"; import { IconChevronUp, IconStack2, IconFileCode } from "@tabler/icons-react"; import { useChatStore } from "@/stores"; import { bridge, Events } from "@/services"; import { cn } from "@/lib/utils"; import { FileChangesPanel } from "./FileChangesPanel"; import { QueuedMessagesPanel } from "./QueuedMessagesPanel"; import { ApprovalDialog } from "./ApprovalDialog"; import { QuestionDialog } from "./QuestionDialog"; import type { FileChange } from "shared/types"; type TabId = "queue" | "changes" | null; export function BottomToolbar() { const { queue } = useChatStore(); const [activeTab, setActiveTab] = useState(null); const [fileChanges, setFileChanges] = useState([]); useEffect(() => { return bridge.on(Events.FileChangesUpdated, setFileChanges); }, []); // Auto-close tab when data becomes empty useEffect(() => { if (activeTab === "queue" && queue.length === 0) { setActiveTab(null); } if (activeTab === "changes" && fileChanges.length === 0) { setActiveTab(null); } }, [activeTab, queue.length, fileChanges.length]); const hasQueue = queue.length > 0; const hasChanges = fileChanges.length > 0; const hasTabs = hasQueue || hasChanges; const toggleTab = (tab: TabId) => { setActiveTab((prev) => (prev === tab ? null : tab)); }; const fileStats = fileChanges.reduce((a, c) => ({ additions: a.additions + c.additions, deletions: a.deletions + c.deletions }), { additions: 0, deletions: 0 }); return (
{/* ApprovalDialog and QuestionDialog - priority, shrink-0 */} {/* Queue/Changes panel - takes remaining space */} {activeTab && (
{activeTab === "queue" && } {activeTab === "changes" && }
)} {/* Tab bar - always at bottom, shrink-0 */} {hasTabs && (
{hasQueue && ( )} {hasChanges && ( )}
)}
); }