| gio | 678746b | 2025-07-06 14:45:27 +0000 | [diff] [blame] | 1 | import { Canvas } from "./Canvas"; |
| 2 | import { Details } from "./Details"; |
| 3 | import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "./components/ui/resizable"; |
| 4 | import { Tools } from "./Tools"; |
| 5 | import { Agent } from "./Agent"; |
| 6 | import { useBuildMode, useLeadAgent } from "./lib/state"; |
| 7 | import { Overview } from "./Overview"; |
| 8 | import { useMemo } from "react"; |
| 9 | |
| 10 | export function Build() { |
| 11 | const leadAgent = useLeadAgent(); |
| 12 | const buildMode = useBuildMode(); |
| 13 | const mainWidth = useMemo(() => { |
| 14 | let ret = 100; |
| 15 | if (leadAgent) { |
| 16 | ret -= 25; |
| 17 | } |
| 18 | if (buildMode === "canvas") { |
| 19 | ret -= 20; |
| 20 | } |
| 21 | return ret; |
| 22 | }, [leadAgent, buildMode]); |
| 23 | return ( |
| 24 | <ResizablePanelGroup direction="horizontal" className="w-full h-full"> |
| 25 | {leadAgent && ( |
| 26 | <> |
| 27 | <ResizablePanel defaultSize={25}> |
| gio | 007c857 | 2025-07-08 04:27:35 +0000 | [diff] [blame] | 28 | <Agent agent={leadAgent} compact={true} /> |
| gio | 678746b | 2025-07-06 14:45:27 +0000 | [diff] [blame] | 29 | </ResizablePanel> |
| 30 | <ResizableHandle withHandle /> |
| 31 | </> |
| 32 | )} |
| 33 | <ResizablePanel defaultSize={mainWidth}> |
| 34 | <ResizablePanelGroup direction="vertical"> |
| 35 | <ResizablePanel defaultSize={80}> |
| 36 | <OverviewOrCanvas /> |
| 37 | </ResizablePanel> |
| 38 | <ResizableHandle withHandle /> |
| 39 | <ResizablePanel defaultSize={20}> |
| 40 | <Tools /> |
| 41 | </ResizablePanel> |
| 42 | </ResizablePanelGroup> |
| 43 | </ResizablePanel> |
| 44 | {buildMode === "canvas" && ( |
| 45 | <> |
| 46 | <ResizableHandle withHandle /> |
| 47 | <ResizablePanel defaultSize={20} className="!overflow-y-auto !overflow-x-hidden"> |
| 48 | <Details /> |
| 49 | </ResizablePanel> |
| 50 | </> |
| 51 | )} |
| 52 | </ResizablePanelGroup> |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | function OverviewOrCanvas() { |
| 57 | const buildMode = useBuildMode(); |
| 58 | switch (buildMode) { |
| 59 | case "overview": |
| 60 | return <Overview />; |
| 61 | case "canvas": |
| 62 | return <Canvas />; |
| 63 | default: |
| 64 | throw new Error(`Unknown build mode: ${buildMode}`); |
| 65 | } |
| 66 | } |