| 1 | import { useState } from "react"; |
| 2 | import useLLMLog from "../../hooks/useLLMLog"; |
| 3 | import Details from "./Details"; |
| 4 | import List from "./List"; |
| 5 | import TotalUsage from "./TotalUsage"; |
| 6 | |
| 7 | export default function Layout() { |
| 8 | const llmLog = useLLMLog(); |
| 9 | |
| 10 | const [selectedId, setSelectedId] = useState<string | undefined>(undefined); |
| 11 | const [showTotalUsage, setShowTotalUsage] = useState(false); |
| 12 | |
| 13 | const interaction = selectedId |
| 14 | ? llmLog.interactions.get(selectedId) |
| 15 | : undefined; |
| 16 | |
| 17 | return llmLog.loading ? ( |
| 18 | <div>Loading...</div> |
| 19 | ) : ( |
| 20 | <div className="flex h-full w-full"> |
| 21 | <div className="flex h-full w-full flex-col"> |
| 22 | {/* <div className="flex-shrink-0 border-b border-[color:var(--vscode-panel-border)] p-3"> |
| 23 | <button |
| 24 | onClick={() => setShowTotalUsage(true)} |
| 25 | className="float-right cursor-pointer border-none bg-transparent text-sm text-[color:var(--vscode-textLink-foreground)] underline hover:text-[color:var(--vscode-textLink-activeForeground)]" |
| 26 | > |
| 27 | View Total Usage Summary |
| 28 | </button> |
| 29 | </div> */} |
| 30 | <div className="flex min-h-0 flex-1 overflow-hidden"> |
| 31 | <List |
| 32 | llmLog={llmLog} |
| 33 | onClickInteraction={(interactionId) => { |
| 34 | setSelectedId(interactionId); |
| 35 | }} |
| 36 | ></List> |
| 37 | {interaction && ( |
| 38 | <Details key="{selectedId}" interaction={interaction}></Details> |
| 39 | )} |
| 40 | </div> |
| 41 | </div> |
| 42 | |
| 43 | {/* Full-screen popover for TotalUsage */} |
| 44 | {showTotalUsage && ( |
| 45 | <div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50"> |
| 46 | <div className="relative h-full w-full max-w-6xl overflow-hidden bg-[color:var(--vscode-panel-background)] shadow-2xl"> |
| 47 | {/* Close button */} |
| 48 | <button |
| 49 | onClick={() => setShowTotalUsage(false)} |
| 50 | className="absolute right-4 top-4 z-10 flex h-8 w-8 items-center justify-center rounded-full bg-[color:var(--vscode-button-background)] text-[color:var(--vscode-button-foreground)] transition-colors hover:bg-[color:var(--vscode-button-hoverBackground)]" |
| 51 | > |
| 52 | × |
| 53 | </button> |
| 54 | |
| 55 | {/* Content container with scroll */} |
| 56 | <div className="h-full overflow-y-auto p-6"> |
| 57 | <TotalUsage llmLog={llmLog} /> |
| 58 | </div> |
| 59 | </div> |
| 60 | </div> |
| 61 | )} |
| 62 | </div> |
| 63 | ); |
| 64 | } |