diff --git a/gui/src/components/console/Details.tsx b/gui/src/components/console/Details.tsx
index 73989f683..dafa647da 100644
--- a/gui/src/components/console/Details.tsx
+++ b/gui/src/components/console/Details.tsx
@@ -117,11 +117,11 @@ export default function Details({ interaction }: DetailsProps) {
format={(v: number) => v.toFixed(1)}
>
- {/**summary.costBreakdown && (
+ {summary.costBreakdown && (
(undefined);
+ const [showTotalUsage, setShowTotalUsage] = useState(false);
const interaction = selectedId
? llmLog.interactions.get(selectedId)
@@ -16,14 +18,46 @@ export default function Layout() {
Loading...
) : (
-
{
- setSelectedId(interactionId);
- }}
- >
- {interaction && (
-
+
+
+
+
+
+ {
+ setSelectedId(interactionId);
+ }}
+ >
+ {interaction && (
+
+ )}
+
+
+
+ {/* Full-screen popover for TotalUsage */}
+ {showTotalUsage && (
+
+
+ {/* Close button */}
+
+
+ {/* Content container with scroll */}
+
+
+
+
+
)}
);
diff --git a/gui/src/components/console/TotalUsage.tsx b/gui/src/components/console/TotalUsage.tsx
new file mode 100644
index 000000000..41f3843ee
--- /dev/null
+++ b/gui/src/components/console/TotalUsage.tsx
@@ -0,0 +1,161 @@
+import React, { useState } from "react";
+import { LLMLog } from "../../hooks/useLLMLog";
+import useTotalUsage from "../../hooks/useTotalUsage";
+
+interface TotalUsageProps {
+ llmLog: LLMLog;
+}
+
+const StatCard: React.FC<{ label: string; value: number; color?: string }> = ({
+ label,
+ value,
+ color = "var(--vscode-foreground)",
+}) => (
+
+
+ {label}
+
+
+ {value.toLocaleString()}
+
+
+);
+
+const TotalUsage: React.FC
= ({ llmLog }) => {
+ const totalUsage = useTotalUsage(llmLog);
+ const [showCostBreakdown, setShowCostBreakdown] = useState(false);
+
+ return (
+
+
+
+ Total Usage Summary
+
+
+ {totalUsage.totalCost > 0 && (
+
+ )}
+
+ {totalUsage.totalInteractions} interactions
+
+
+
+
+ {showCostBreakdown && totalUsage.costBreakdowns.length > 0 && (
+
+
+ Cost Breakdown
+
+
+ {totalUsage.costBreakdowns.map((breakdown, index) => (
+
+
+ {breakdown.breakdown}
+
+
+ ))}
+
+
+ )}
+
+
+
+
+
+
+
+
+ {totalUsage.totalCost > 0 && (
+
+
+
+ Total Cost
+
+
+ ${totalUsage.totalCost.toFixed(6)}
+
+
+ {totalUsage.costBreakdowns.length} cost calculations
+
+
+
+ )}
+
+ {totalUsage.totalCacheWriteTokens > 0 && (
+
+
+
+
+ Cache Hit Rate:{" "}
+ {totalUsage.totalPromptTokens > 0
+ ? (
+ (totalUsage.totalCachedTokens /
+ totalUsage.totalPromptTokens) *
+ 100
+ ).toFixed(1)
+ : "0"}
+ %
+
+
+
+ )}
+
+
+
+
+ {totalUsage.totalSuccessfulInteractions}
+
+
+ Success
+
+
+
+
+ {totalUsage.totalErrorInteractions}
+
+
+ Error
+
+
+
+
+ {totalUsage.totalCancelledInteractions}
+
+
+ Cancelled
+
+
+
+
+ );
+};
+
+export default TotalUsage;
diff --git a/gui/src/console.tsx b/gui/src/console.tsx
index beb7c4e53..8c026f184 100644
--- a/gui/src/console.tsx
+++ b/gui/src/console.tsx
@@ -3,7 +3,7 @@ import ReactDOM from "react-dom/client";
import Layout from "./components/console/Layout";
import "./indexConsole.css";
-(async () => {
+void (async () => {
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
diff --git a/gui/src/hooks/useTotalUsage.ts b/gui/src/hooks/useTotalUsage.ts
new file mode 100644
index 000000000..0d70591e2
--- /dev/null
+++ b/gui/src/hooks/useTotalUsage.ts
@@ -0,0 +1,102 @@
+import {
+ calculateRequestCost,
+ CostBreakdown,
+} from "core/llm/utils/calculateRequestCost";
+import { useMemo } from "react";
+import { LLMLog } from "./useLLMLog";
+
+export interface TotalUsage {
+ totalPromptTokens: number;
+ totalGeneratedTokens: number;
+ totalThinkingTokens: number;
+ totalCachedTokens: number;
+ totalCacheWriteTokens: number;
+ totalInteractions: number;
+ totalSuccessfulInteractions: number;
+ totalErrorInteractions: number;
+ totalCancelledInteractions: number;
+ totalCost: number;
+ costBreakdowns: CostBreakdown[];
+}
+
+/**
+ * Hook to calculate total usage across all interactions in the LLM log
+ */
+export default function useTotalUsage(llmLog: LLMLog): TotalUsage {
+ return useMemo(() => {
+ let totalPromptTokens = 0;
+ let totalGeneratedTokens = 0;
+ let totalThinkingTokens = 0;
+ let totalCachedTokens = 0;
+ let totalCacheWriteTokens = 0;
+ let totalInteractions = 0;
+ let totalSuccessfulInteractions = 0;
+ let totalErrorInteractions = 0;
+ let totalCancelledInteractions = 0;
+ let totalCost = 0;
+ const costBreakdowns: CostBreakdown[] = [];
+
+ // Iterate through all interactions
+ for (const interaction of llmLog.interactions.values()) {
+ if (interaction.end) {
+ totalInteractions++;
+
+ // Add basic token counts
+ totalPromptTokens += interaction.end.promptTokens || 0;
+ totalGeneratedTokens += interaction.end.generatedTokens || 0;
+ totalThinkingTokens += interaction.end.thinkingTokens || 0;
+
+ // Add cache-related tokens from usage if available
+ if (interaction.end.usage) {
+ const usage = interaction.end.usage;
+ totalCachedTokens += usage.promptTokensDetails?.cachedTokens || 0;
+ totalCacheWriteTokens +=
+ usage.promptTokensDetails?.cacheWriteTokens || 0;
+
+ // Calculate cost if we have the necessary information
+ if (
+ interaction.start?.provider &&
+ interaction.start?.options?.model
+ ) {
+ const costBreakdown = calculateRequestCost(
+ interaction.start.provider,
+ interaction.start.options.model,
+ usage,
+ );
+ if (costBreakdown) {
+ totalCost += costBreakdown.cost;
+ costBreakdowns.push(costBreakdown);
+ }
+ }
+ }
+
+ // Count interaction outcomes
+ switch (interaction.end.kind) {
+ case "success":
+ totalSuccessfulInteractions++;
+ break;
+ case "error":
+ totalErrorInteractions++;
+ break;
+ case "cancel":
+ totalCancelledInteractions++;
+ break;
+ }
+ }
+ }
+
+ return {
+ totalPromptTokens,
+ totalGeneratedTokens,
+ totalThinkingTokens,
+ totalCachedTokens,
+ totalCacheWriteTokens,
+ totalInteractions,
+ totalSuccessfulInteractions,
+ totalErrorInteractions,
+ totalCancelledInteractions,
+ totalCost,
+ costBreakdowns,
+ };
+ }, [llmLog]);
+}