claude-session-dashboard 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/client/assets/_dashboard-Job6DOd1.js +1 -0
  2. package/dist/client/assets/_sessionId-CIFXqjVa.js +12 -0
  3. package/dist/client/assets/app-CkRVT69z.css +1 -0
  4. package/dist/client/assets/{createServerFn-BLR4iNR3.js → createServerFn-6SJrpRCO.js} +1 -1
  5. package/dist/client/assets/index-DDr2smLW.js +1 -0
  6. package/dist/client/assets/main-B6FohBFQ.js +69 -0
  7. package/dist/client/assets/sessions.queries-ClgzoOt4.js +1 -0
  8. package/dist/client/assets/settings-DQD2EaIq.js +1 -0
  9. package/dist/client/assets/{settings.types-DHC6rkil.js → settings.types-LYd9Z8Y1.js} +1 -1
  10. package/dist/client/assets/stats-CrWQ_y2R.js +4 -0
  11. package/dist/client/assets/{useSessionCost-BikgEmWy.js → useSessionCost-Drt0v6oj.js} +1 -1
  12. package/dist/server/assets/{_dashboard-smfIqyQC.js → _dashboard-61fpMMMe.js} +7 -7
  13. package/dist/server/assets/{_sessionId-DIUMcrWR.js → _sessionId-B_O50OfN.js} +17 -17
  14. package/dist/server/assets/_tanstack-start-manifest_v-Dva5sIpS.js +4 -0
  15. package/dist/server/assets/{app-info.server-CXcS0a5s.js → app-info.api-CdaWsxHl.js} +2 -2
  16. package/dist/server/assets/{index-hFrIPkke.js → index-BYcFI9Ho.js} +6 -6
  17. package/dist/server/assets/{project-analytics.server-Bxk8-NnT.js → project-analytics.api-QnhRRs7T.js} +4 -4
  18. package/dist/server/assets/{router-5hznwWqr.js → router-BvYNknMb.js} +80 -12
  19. package/dist/server/assets/{session-detail.server-BIoOQwSE.js → session-detail.api-8plxSeB0.js} +3 -3
  20. package/dist/server/assets/{session-parser-B0pdBvgT.js → session-parser-DxLcS8VW.js} +2 -2
  21. package/dist/server/assets/{session-scanner-CpgOq5m1.js → session-scanner-DRGzVO2T.js} +1 -1
  22. package/dist/server/assets/{sessions.server-Biq8gbAJ.js → sessions.api-DRmOjipJ.js} +8 -8
  23. package/dist/server/assets/{sessions.queries-B5ZBiVJy.js → sessions.queries-CvAnVbE8.js} +3 -3
  24. package/dist/server/assets/{settings-D0FgLIR5.js → settings-Ct2BZGxb.js} +33 -5
  25. package/dist/server/assets/{settings.server-6B2PvLgf.js → settings.api-C9L2GoIE.js} +4 -4
  26. package/dist/server/assets/{settings.queries-DSQd324O.js → settings.queries-BVEZA-1G.js} +2 -2
  27. package/dist/server/assets/{stats-Ae6umrPI.js → stats-CZEpvzmd.js} +51 -37
  28. package/dist/server/assets/{stats.server-DhzOihwM.js → stats.api-CH-wTCGE.js} +4 -4
  29. package/dist/server/assets/{useSessionCost-CYs5UOX-.js → useSessionCost-CyWBuljV.js} +1 -1
  30. package/dist/server/server.js +40 -29
  31. package/package.json +4 -1
  32. package/dist/client/assets/_dashboard-DLFGahko.js +0 -1
  33. package/dist/client/assets/_sessionId-xiPzwrlf.js +0 -12
  34. package/dist/client/assets/app-DREGBD44.css +0 -1
  35. package/dist/client/assets/index-D_9sS4oJ.js +0 -1
  36. package/dist/client/assets/main-BcKPK-4E.js +0 -56
  37. package/dist/client/assets/sessions.queries-CHKiZnLm.js +0 -1
  38. package/dist/client/assets/settings-B2tG1vy0.js +0 -1
  39. package/dist/client/assets/stats-BlA0NIHc.js +0 -4
  40. package/dist/server/assets/_tanstack-start-manifest_v-Dmhlhehg.js +0 -4
@@ -25,9 +25,9 @@ function getSettingsDir() {
25
25
  return path.join(os.homedir(), SETTINGS_DIR);
26
26
  }
27
27
  const getSettings_createServerFn_handler = createServerRpc({
28
- id: "810657681a273df5b4e58f0d8fcc6a5451598b489431b9bcaa98eea0ad815da8",
28
+ id: "72f81ef9e8fa751bab60a8bdabd7e77816e2a6723a5e6e26e03712c01b3a249c",
29
29
  name: "getSettings",
30
- filename: "src/features/settings/settings.server.ts"
30
+ filename: "src/features/settings/settings.api.ts"
31
31
  }, (opts) => getSettings.__executeServer(opts));
32
32
  const getSettings = createServerFn({
33
33
  method: "GET"
@@ -47,9 +47,9 @@ const getSettings = createServerFn({
47
47
  }
48
48
  });
49
49
  const saveSettings_createServerFn_handler = createServerRpc({
50
- id: "3050115d92ca91ab1fd8fd698e33076328aae80dc64ca27c088eee16cebccc1a",
50
+ id: "7fe8c2b131c4fc81aa9a2570aec79640ff84603fe0060d13c24928b7329cb236",
51
51
  name: "saveSettings",
52
- filename: "src/features/settings/settings.server.ts"
52
+ filename: "src/features/settings/settings.api.ts"
53
53
  }, (opts) => saveSettings.__executeServer(opts));
54
54
  const saveSettings = createServerFn({
55
55
  method: "POST"
@@ -4,13 +4,13 @@ import { S as SettingsSchema } from "./settings.types-DntadCHo.js";
4
4
  import { c as createServerFn } from "../server.js";
5
5
  const getSettings = createServerFn({
6
6
  method: "GET"
7
- }).handler(createSsrRpc("810657681a273df5b4e58f0d8fcc6a5451598b489431b9bcaa98eea0ad815da8"));
7
+ }).handler(createSsrRpc("72f81ef9e8fa751bab60a8bdabd7e77816e2a6723a5e6e26e03712c01b3a249c"));
8
8
  const saveSettings = createServerFn({
9
9
  method: "POST"
10
10
  }).inputValidator((input) => {
11
11
  const result = SettingsSchema.parse(input);
12
12
  return result;
13
- }).handler(createSsrRpc("3050115d92ca91ab1fd8fd698e33076328aae80dc64ca27c088eee16cebccc1a"));
13
+ }).handler(createSsrRpc("7fe8c2b131c4fc81aa9a2570aec79640ff84603fe0060d13c24928b7329cb236"));
14
14
  const settingsQuery = queryOptions({
15
15
  queryKey: ["settings"],
16
16
  queryFn: () => getSettings(),
@@ -8,8 +8,8 @@ import { format, addDays, getDay, parseISO, startOfISOWeek } from "date-fns";
8
8
  import { createPortal } from "react-dom";
9
9
  import { f as formatTokenCount, a as formatDuration, b as formatRelativeTime, c as formatUSD } from "./format-DIZHV7IJ.js";
10
10
  import { Link } from "@tanstack/react-router";
11
- import { u as usePrivacy, R as Route } from "./router-5hznwWqr.js";
12
- import { u as useSessionCost, E as ExportDropdown, d as downloadFile, a as dailyActivityToCSV, b as dailyTokensToCSV, m as modelUsageToCSV, s as statsToJSON } from "./useSessionCost-CYs5UOX-.js";
11
+ import { u as usePrivacy, R as Route } from "./router-BvYNknMb.js";
12
+ import { u as useSessionCost, E as ExportDropdown, d as downloadFile, a as dailyActivityToCSV, b as dailyTokensToCSV, m as modelUsageToCSV, s as statsToJSON } from "./useSessionCost-CyWBuljV.js";
13
13
  import "@tanstack/history";
14
14
  import "@tanstack/router-core/ssr/client";
15
15
  import "@tanstack/router-core";
@@ -20,16 +20,24 @@ import "tiny-invariant";
20
20
  import "seroval";
21
21
  import "@tanstack/react-router/ssr/server";
22
22
  import "zod";
23
- import "./settings.queries-DSQd324O.js";
23
+ import "./settings.queries-BVEZA-1G.js";
24
24
  import "./settings.types-DntadCHo.js";
25
25
  const getStats = createServerFn({
26
26
  method: "GET"
27
- }).handler(createSsrRpc("4b9a58c176f487b49800a372100037cdf33cf048f3592a449f115c7e3f5ea799"));
27
+ }).handler(createSsrRpc("44af69d3bfcf3ec46fffb3f297d2b12cd7fe4db36c654b8a322df34d549c6493"));
28
28
  const statsQuery = queryOptions({
29
29
  queryKey: ["stats"],
30
30
  queryFn: () => getStats(),
31
31
  refetchInterval: 6e4
32
32
  });
33
+ const getProjectAnalytics = createServerFn({
34
+ method: "GET"
35
+ }).handler(createSsrRpc("39e65590d2bc41f653f54a9b6a9e0a72f185da275304c0a4a595d811cf185572"));
36
+ const projectAnalyticsQuery = queryOptions({
37
+ queryKey: ["projects", "analytics"],
38
+ queryFn: () => getProjectAnalytics(),
39
+ refetchInterval: 6e4
40
+ });
33
41
  function ActivityChart({ data }) {
34
42
  const chartData = data.map((d) => ({
35
43
  ...d,
@@ -39,19 +47,19 @@ function ActivityChart({ data }) {
39
47
  /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-gray-300", children: "Daily Activity" }),
40
48
  /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-gray-500", children: "Messages, sessions, and tool calls per day" }),
41
49
  /* @__PURE__ */ jsx("div", { className: "mt-4 h-64", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(BarChart, { data: chartData, children: [
42
- /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", stroke: "#2a2926" }),
50
+ /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", stroke: "var(--color-gray-800)" }),
43
51
  /* @__PURE__ */ jsx(
44
52
  XAxis,
45
53
  {
46
54
  dataKey: "dateLabel",
47
- tick: { fill: "#7a7668", fontSize: 10 },
55
+ tick: { fill: "var(--color-gray-500)", fontSize: 10 },
48
56
  tickLine: false
49
57
  }
50
58
  ),
51
59
  /* @__PURE__ */ jsx(
52
60
  YAxis,
53
61
  {
54
- tick: { fill: "#7a7668", fontSize: 10 },
62
+ tick: { fill: "var(--color-gray-500)", fontSize: 10 },
55
63
  tickLine: false,
56
64
  axisLine: false
57
65
  }
@@ -60,8 +68,8 @@ function ActivityChart({ data }) {
60
68
  Tooltip,
61
69
  {
62
70
  contentStyle: {
63
- backgroundColor: "#1c1c1a",
64
- border: "1px solid #3d3b36",
71
+ backgroundColor: "var(--color-gray-900)",
72
+ border: "1px solid var(--color-gray-700)",
65
73
  borderRadius: "8px",
66
74
  fontSize: "12px"
67
75
  }
@@ -98,7 +106,7 @@ function ActivityChart({ data }) {
98
106
  ] });
99
107
  }
100
108
  const INTENSITY_COLORS = [
101
- "#2a2926",
109
+ "var(--color-gray-800)",
102
110
  // Level 0: warm gray-800 (no activity)
103
111
  "#3d2a1e",
104
112
  // Level 1: dark terracotta
@@ -422,7 +430,7 @@ function CustomTooltip({ active, payload, label }) {
422
430
  ] }, entry.name)),
423
431
  /* @__PURE__ */ jsxs("div", { className: "mt-1.5 border-t border-gray-700 pt-1.5 flex justify-between", children: [
424
432
  /* @__PURE__ */ jsx("span", { className: "text-gray-400", children: "Total" }),
425
- /* @__PURE__ */ jsx("span", { className: "font-mono font-medium text-white", children: formatTokenCount(total) })
433
+ /* @__PURE__ */ jsx("span", { className: "font-mono font-medium text-gray-100", children: formatTokenCount(total) })
426
434
  ] })
427
435
  ] });
428
436
  }
@@ -462,7 +470,7 @@ function TokenTrendChart({ data }) {
462
470
  {
463
471
  type: "button",
464
472
  onClick: () => setGranularity("daily"),
465
- className: `rounded-l-lg px-3 py-1 ${granularity === "daily" ? "bg-gray-700 text-white" : "text-gray-400 hover:text-gray-300"}`,
473
+ className: `rounded-l-lg px-3 py-1 ${granularity === "daily" ? "bg-gray-700 text-gray-100" : "text-gray-400 hover:text-gray-300"}`,
466
474
  children: "Daily"
467
475
  }
468
476
  ),
@@ -471,26 +479,26 @@ function TokenTrendChart({ data }) {
471
479
  {
472
480
  type: "button",
473
481
  onClick: () => setGranularity("weekly"),
474
- className: `rounded-r-lg px-3 py-1 ${granularity === "weekly" ? "bg-gray-700 text-white" : "text-gray-400 hover:text-gray-300"}`,
482
+ className: `rounded-r-lg px-3 py-1 ${granularity === "weekly" ? "bg-gray-700 text-gray-100" : "text-gray-400 hover:text-gray-300"}`,
475
483
  children: "Weekly"
476
484
  }
477
485
  )
478
486
  ] })
479
487
  ] }),
480
488
  /* @__PURE__ */ jsx("div", { className: "mt-4 h-72", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(AreaChart, { data: chartData, children: [
481
- /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", stroke: "#2a2926" }),
489
+ /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", stroke: "var(--color-gray-800)" }),
482
490
  /* @__PURE__ */ jsx(
483
491
  XAxis,
484
492
  {
485
493
  dataKey: "dateLabel",
486
- tick: { fill: "#7a7668", fontSize: 10 },
494
+ tick: { fill: "var(--color-gray-500)", fontSize: 10 },
487
495
  tickLine: false
488
496
  }
489
497
  ),
490
498
  /* @__PURE__ */ jsx(
491
499
  YAxis,
492
500
  {
493
- tick: { fill: "#7a7668", fontSize: 10 },
501
+ tick: { fill: "var(--color-gray-500)", fontSize: 10 },
494
502
  tickLine: false,
495
503
  axisLine: false,
496
504
  tickFormatter: (value) => formatTokenCount(value)
@@ -544,8 +552,8 @@ function ModelUsageChart({ data }) {
544
552
  {
545
553
  formatter: (value) => formatTokenCount(value),
546
554
  contentStyle: {
547
- backgroundColor: "#1c1c1a",
548
- border: "1px solid #3d3b36",
555
+ backgroundColor: "var(--color-gray-900)",
556
+ border: "1px solid var(--color-gray-700)",
549
557
  borderRadius: "8px",
550
558
  fontSize: "12px"
551
559
  }
@@ -610,14 +618,6 @@ function HourlyDistribution({
610
618
  ] })
611
619
  ] });
612
620
  }
613
- const getProjectAnalytics = createServerFn({
614
- method: "GET"
615
- }).handler(createSsrRpc("64052f224a1d6696436e5d3deeee2b798f0742e1292ffabd038c3a7bf75e6fcb"));
616
- const projectAnalyticsQuery = queryOptions({
617
- queryKey: ["projects", "analytics"],
618
- queryFn: () => getProjectAnalytics(),
619
- refetchInterval: 6e4
620
- });
621
621
  const COLUMNS = [
622
622
  { key: "projectName", label: "Project" },
623
623
  { key: "totalSessions", label: "Sessions", align: "right" },
@@ -690,7 +690,7 @@ function ProjectTable({ projects }) {
690
690
  {
691
691
  to: "/sessions",
692
692
  search: { project: project.projectName },
693
- className: "text-sm text-brand-300 hover:underline",
693
+ className: "text-sm text-brand-500 hover:underline",
694
694
  children: anonymizeProjectName(project.projectName)
695
695
  }
696
696
  ),
@@ -769,7 +769,7 @@ function SummaryCard({
769
769
  }) {
770
770
  return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-gray-800 bg-gray-900/50 p-4", children: [
771
771
  /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-400", children: label }),
772
- /* @__PURE__ */ jsx("p", { className: "mt-1 truncate text-xl font-bold text-white", children: value }),
772
+ /* @__PURE__ */ jsx("p", { className: "mt-1 truncate text-xl font-bold text-gray-100", children: value }),
773
773
  sub && /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-gray-500", children: sub })
774
774
  ] });
775
775
  }
@@ -802,7 +802,7 @@ function StatsPage() {
802
802
  return /* @__PURE__ */ jsxs("div", { children: [
803
803
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
804
804
  /* @__PURE__ */ jsxs("div", { children: [
805
- /* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold text-white", children: "Stats" }),
805
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold text-gray-100", children: "Stats" }),
806
806
  /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-gray-400", children: "Usage analytics and project insights" })
807
807
  ] }),
808
808
  tab === "overview" && stats && /* @__PURE__ */ jsx(ExportDropdown, { options: [{
@@ -824,12 +824,12 @@ function StatsPage() {
824
824
  search: {
825
825
  tab: "overview"
826
826
  }
827
- }), className: `px-4 py-2 text-sm border-b-2 transition-colors ${tab === "overview" ? "border-brand-500 text-white" : "border-transparent text-gray-400 hover:text-gray-200"}`, children: "Overview" }),
827
+ }), className: `px-4 py-2 text-sm border-b-2 transition-colors ${tab === "overview" ? "border-brand-500 text-gray-100" : "border-transparent text-gray-400 hover:text-gray-200"}`, children: "Overview" }),
828
828
  /* @__PURE__ */ jsx("button", { onClick: () => navigate({
829
829
  search: {
830
830
  tab: "projects"
831
831
  }
832
- }), className: `px-4 py-2 text-sm border-b-2 transition-colors ${tab === "projects" ? "border-brand-500 text-white" : "border-transparent text-gray-400 hover:text-gray-200"}`, children: "Projects" })
832
+ }), className: `px-4 py-2 text-sm border-b-2 transition-colors ${tab === "projects" ? "border-brand-500 text-gray-100" : "border-transparent text-gray-400 hover:text-gray-200"}`, children: "Projects" })
833
833
  ] }),
834
834
  tab === "overview" ? /* @__PURE__ */ jsx(StatsOverview, { stats, isLoading, cost }) : /* @__PURE__ */ jsx("div", { className: "mt-6", children: /* @__PURE__ */ jsx(ProjectAnalytics, {}) })
835
835
  ] });
@@ -839,10 +839,16 @@ function StatsOverview({
839
839
  isLoading,
840
840
  cost
841
841
  }) {
842
+ const {
843
+ data: projectData
844
+ } = useQuery(projectAnalyticsQuery);
842
845
  if (isLoading) {
843
846
  return /* @__PURE__ */ jsxs("div", { className: "mt-6 space-y-4", children: [
844
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-5", children: Array.from({
845
- length: 5
847
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-4", children: Array.from({
848
+ length: 4
849
+ }).map((_, i) => /* @__PURE__ */ jsx("div", { className: "h-20 animate-pulse rounded-xl bg-gray-900/50" }, i)) }),
850
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-4", children: Array.from({
851
+ length: 4
846
852
  }).map((_, i) => /* @__PURE__ */ jsx("div", { className: "h-20 animate-pulse rounded-xl bg-gray-900/50" }, i)) }),
847
853
  Array.from({
848
854
  length: 3
@@ -853,12 +859,20 @@ function StatsOverview({
853
859
  return /* @__PURE__ */ jsx("div", { className: "py-12 text-center text-sm text-gray-500", children: "No stats data found. Check ~/.claude/stats-cache.json" });
854
860
  }
855
861
  const totalTokens = Object.values(stats.modelUsage).reduce((sum, m) => sum + m.inputTokens + m.outputTokens, 0);
862
+ const totalToolCalls = stats.dailyActivity.reduce((sum, d) => sum + d.toolCallCount, 0);
863
+ const totalDurationMs = projectData?.projects.reduce((sum, p) => sum + p.totalDurationMs, 0) ?? 0;
864
+ const projectCount = projectData?.projects.length ?? 0;
856
865
  return /* @__PURE__ */ jsxs(Fragment, { children: [
857
- /* @__PURE__ */ jsxs("div", { className: "mt-6 grid grid-cols-2 gap-3 md:grid-cols-5", children: [
866
+ /* @__PURE__ */ jsxs("div", { className: "mt-6 grid grid-cols-2 gap-3 md:grid-cols-4", children: [
858
867
  /* @__PURE__ */ jsx(StatCard, { label: "Total Sessions", value: String(stats.totalSessions) }),
859
868
  /* @__PURE__ */ jsx(StatCard, { label: "Total Messages", value: stats.totalMessages.toLocaleString() }),
860
- /* @__PURE__ */ jsx(StatCard, { label: "Total Tokens", value: formatTokenCount(totalTokens), sub: cost ? `~${formatUSD(cost.totalUSD)}` : void 0 }),
861
- /* @__PURE__ */ jsx(StatCard, { label: "Total Estimated Cost", value: cost ? `~${formatUSD(cost.totalUSD)}` : "N/A" }),
869
+ /* @__PURE__ */ jsx(StatCard, { label: "Total Time", value: formatDuration(totalDurationMs) }),
870
+ /* @__PURE__ */ jsx(StatCard, { label: "Projects", value: String(projectCount) })
871
+ ] }),
872
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 grid grid-cols-2 gap-3 md:grid-cols-4", children: [
873
+ /* @__PURE__ */ jsx(StatCard, { label: "Total Tokens", value: formatTokenCount(totalTokens) }),
874
+ /* @__PURE__ */ jsx(StatCard, { label: "Estimated Cost", value: cost ? `~${formatUSD(cost.totalUSD)}` : "N/A" }),
875
+ /* @__PURE__ */ jsx(StatCard, { label: "Tool Calls", value: totalToolCalls.toLocaleString() }),
862
876
  /* @__PURE__ */ jsx(StatCard, { label: "Longest Session", value: formatDuration(stats.longestSession.duration), sub: `${stats.longestSession.messageCount} messages` })
863
877
  ] }),
864
878
  /* @__PURE__ */ jsx("div", { className: "mt-6", children: /* @__PURE__ */ jsx(ContributionHeatmap, { dailyActivity: stats.dailyActivity, dailyModelTokens: stats.dailyModelTokens }) }),
@@ -877,7 +891,7 @@ function StatCard({
877
891
  }) {
878
892
  return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-gray-800 bg-gray-900/50 p-4", children: [
879
893
  /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-400", children: label }),
880
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-xl font-bold text-white", children: value }),
894
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-xl font-bold text-gray-100", children: value }),
881
895
  sub && /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-gray-500", children: sub })
882
896
  ] });
883
897
  }
@@ -1,10 +1,10 @@
1
1
  import { c as createServerRpc } from "./createServerRpc-Bd3B-Ah9.js";
2
2
  import * as fs from "node:fs";
3
- import { a as getStatsPath, p as parseDetail } from "./session-parser-B0pdBvgT.js";
3
+ import { g as getStatsPath, p as parseDetail } from "./session-parser-DxLcS8VW.js";
4
4
  import * as path from "node:path";
5
5
  import * as os from "node:os";
6
6
  import { z } from "zod";
7
- import { s as scanAllSessionsWithPaths } from "./session-scanner-CpgOq5m1.js";
7
+ import { s as scanAllSessionsWithPaths } from "./session-scanner-DRGzVO2T.js";
8
8
  import { c as createServerFn } from "../server.js";
9
9
  import "node:readline";
10
10
  import "@tanstack/history";
@@ -384,9 +384,9 @@ async function computeStatsFromSessions() {
384
384
  }
385
385
  }
386
386
  const getStats_createServerFn_handler = createServerRpc({
387
- id: "4b9a58c176f487b49800a372100037cdf33cf048f3592a449f115c7e3f5ea799",
387
+ id: "44af69d3bfcf3ec46fffb3f297d2b12cd7fe4db36c654b8a322df34d549c6493",
388
388
  name: "getStats",
389
- filename: "src/features/stats/stats.server.ts"
389
+ filename: "src/features/stats/stats.api.ts"
390
390
  }, (opts) => getStats.__executeServer(opts));
391
391
  const getStats = createServerFn({
392
392
  method: "GET"
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useState, useRef, useEffect, useMemo } from "react";
3
3
  import { useQuery } from "@tanstack/react-query";
4
- import { s as settingsQuery } from "./settings.queries-DSQd324O.js";
4
+ import { s as settingsQuery } from "./settings.queries-BVEZA-1G.js";
5
5
  import { b as DEFAULT_PRICING, n as normalizeModelId } from "./settings.types-DntadCHo.js";
6
6
  function escapeCSVField(value) {
7
7
  if (value.includes(",") || value.includes('"') || value.includes("\n")) {
@@ -123,6 +123,7 @@ const createServerFn = (options, __opts) => {
123
123
  ...newOptions.middleware || [],
124
124
  serverFnBaseToMiddleware(newOptions)
125
125
  ];
126
+ extractedFn.method = resolvedOptions.method;
126
127
  return Object.assign(
127
128
  async (opts) => {
128
129
  const result = await executeMiddleware$1(resolvedMiddleware, "client", {
@@ -144,6 +145,9 @@ const createServerFn = (options, __opts) => {
144
145
  {
145
146
  // This copies over the URL, function ID
146
147
  ...extractedFn,
148
+ // Expose the declared HTTP method so the server handler
149
+ // can reject mismatched methods before parsing payloads
150
+ method: resolvedOptions.method,
147
151
  // The extracted function on the server-side calls
148
152
  // this function
149
153
  __executeServer: async (opts) => {
@@ -423,7 +427,7 @@ function getResponse() {
423
427
  return event.res;
424
428
  }
425
429
  async function getStartManifest(matchedRoutes) {
426
- const { tsrStartManifest } = await import("./assets/_tanstack-start-manifest_v-Dmhlhehg.js");
430
+ const { tsrStartManifest } = await import("./assets/_tanstack-start-manifest_v-Dva5sIpS.js");
427
431
  const startManifest = tsrStartManifest();
428
432
  const rootRoute = startManifest.routes[rootRouteId] = startManifest.routes[rootRouteId] || {};
429
433
  rootRoute.assets = rootRoute.assets || [];
@@ -577,33 +581,33 @@ function createMultiplexedStream(jsonStream, rawStreams) {
577
581
  }
578
582
  });
579
583
  }
580
- const manifest = { "ff8a3161afdfa175e9c519e4146a56ab5bce6e80745e99cfc2191ebbb7a859bb": {
581
- functionName: "getSessionDetail_createServerFn_handler",
582
- importer: () => import("./assets/session-detail.server-BIoOQwSE.js")
583
- }, "4b9a58c176f487b49800a372100037cdf33cf048f3592a449f115c7e3f5ea799": {
584
+ const manifest = { "44af69d3bfcf3ec46fffb3f297d2b12cd7fe4db36c654b8a322df34d549c6493": {
584
585
  functionName: "getStats_createServerFn_handler",
585
- importer: () => import("./assets/stats.server-DhzOihwM.js")
586
- }, "810657681a273df5b4e58f0d8fcc6a5451598b489431b9bcaa98eea0ad815da8": {
586
+ importer: () => import("./assets/stats.api-CH-wTCGE.js")
587
+ }, "71794080473579a94431392ab409ebd02772f6a9f6a08386cadbb8c0d3cf804a": {
588
+ functionName: "getSessionDetail_createServerFn_handler",
589
+ importer: () => import("./assets/session-detail.api-8plxSeB0.js")
590
+ }, "39e65590d2bc41f653f54a9b6a9e0a72f185da275304c0a4a595d811cf185572": {
591
+ functionName: "getProjectAnalytics_createServerFn_handler",
592
+ importer: () => import("./assets/project-analytics.api-QnhRRs7T.js")
593
+ }, "04ac41a7e3e644815167d098c2d6c3375d00a72a11e5af0d37033ba771081ba9": {
594
+ functionName: "getAppInfo_createServerFn_handler",
595
+ importer: () => import("./assets/app-info.api-CdaWsxHl.js")
596
+ }, "72f81ef9e8fa751bab60a8bdabd7e77816e2a6723a5e6e26e03712c01b3a249c": {
587
597
  functionName: "getSettings_createServerFn_handler",
588
- importer: () => import("./assets/settings.server-6B2PvLgf.js")
589
- }, "3050115d92ca91ab1fd8fd698e33076328aae80dc64ca27c088eee16cebccc1a": {
598
+ importer: () => import("./assets/settings.api-C9L2GoIE.js")
599
+ }, "7fe8c2b131c4fc81aa9a2570aec79640ff84603fe0060d13c24928b7329cb236": {
590
600
  functionName: "saveSettings_createServerFn_handler",
591
- importer: () => import("./assets/settings.server-6B2PvLgf.js")
592
- }, "bf8e4a7901f1843bdc9c46be1ad5ad59c615b8bbe611b73eb3ff28f20e43ee0d": {
601
+ importer: () => import("./assets/settings.api-C9L2GoIE.js")
602
+ }, "8fd6c4e5b4d5590acf1ec73da75f249978e8aced6dd2be23de06ade8431033be": {
593
603
  functionName: "getSessionList_createServerFn_handler",
594
- importer: () => import("./assets/sessions.server-Biq8gbAJ.js")
595
- }, "839d29fe93dfa2a6d506af7b48ca25197190a5ff4c796e970ddfdc6e8c98827f": {
604
+ importer: () => import("./assets/sessions.api-DRmOjipJ.js")
605
+ }, "946cc550946f64ee7985dc35913a690eb13183d7ba83cffe398e424e697b4265": {
596
606
  functionName: "getActiveSessionList_createServerFn_handler",
597
- importer: () => import("./assets/sessions.server-Biq8gbAJ.js")
598
- }, "a3f42f9012fd83586787da8f7cb90649da739dd947d867eb67572f68735ff495": {
607
+ importer: () => import("./assets/sessions.api-DRmOjipJ.js")
608
+ }, "e574977967ea9b3387e72d70704b6ca87230e72becaf69f0b98cbc91c9cd1339": {
599
609
  functionName: "getPaginatedSessions_createServerFn_handler",
600
- importer: () => import("./assets/sessions.server-Biq8gbAJ.js")
601
- }, "955327d72ca3168c4751159ca07b8fb0fe0d2381dd0b991f06b941480959fbe8": {
602
- functionName: "getAppInfo_createServerFn_handler",
603
- importer: () => import("./assets/app-info.server-CXcS0a5s.js")
604
- }, "64052f224a1d6696436e5d3deeee2b798f0742e1292ffabd038c3a7bf75e6fcb": {
605
- functionName: "getProjectAnalytics_createServerFn_handler",
606
- importer: () => import("./assets/project-analytics.server-Bxk8-NnT.js")
610
+ importer: () => import("./assets/sessions.api-DRmOjipJ.js")
607
611
  } };
608
612
  async function getServerFnById(id) {
609
613
  const serverFnInfo = manifest[id];
@@ -639,9 +643,19 @@ const handleServerAction = async ({
639
643
  }) => {
640
644
  const method = request.method;
641
645
  const methodUpper = method.toUpperCase();
642
- const methodLower = method.toLowerCase();
643
646
  const url = new URL(request.url);
644
647
  const action = await getServerFnById(serverFnId);
648
+ if (action.method && methodUpper !== action.method) {
649
+ return new Response(
650
+ `expected ${action.method} method. Got ${methodUpper}`,
651
+ {
652
+ status: 405,
653
+ headers: {
654
+ Allow: action.method
655
+ }
656
+ }
657
+ );
658
+ }
645
659
  const isServerFn = request.headers.get("x-tsr-serverFn") === "true";
646
660
  if (!serovalPlugins) {
647
661
  serovalPlugins = getDefaultSerovalPlugins();
@@ -770,7 +784,7 @@ const handleServerAction = async ({
770
784
  (type) => contentType && contentType.includes(type)
771
785
  )) {
772
786
  invariant(
773
- methodLower !== "get",
787
+ methodUpper !== "GET",
774
788
  "GET requests with FormData payloads are not supported"
775
789
  );
776
790
  const formData = await request.formData();
@@ -799,7 +813,7 @@ const handleServerAction = async ({
799
813
  }
800
814
  return await action(params);
801
815
  }
802
- if (methodLower === "get") {
816
+ if (methodUpper === "GET") {
803
817
  const payloadParam = url.searchParams.get("payload");
804
818
  if (payloadParam && payloadParam.length > MAX_PAYLOAD_SIZE) {
805
819
  throw new Error("Payload too large");
@@ -809,9 +823,6 @@ const handleServerAction = async ({
809
823
  payload2.method = methodUpper;
810
824
  return await action(payload2);
811
825
  }
812
- if (methodLower !== "post") {
813
- throw new Error("expected POST method");
814
- }
815
826
  let jsonPayload;
816
827
  if (contentType?.includes("application/json")) {
817
828
  jsonPayload = await request.json();
@@ -1019,7 +1030,7 @@ let entriesPromise;
1019
1030
  let baseManifestPromise;
1020
1031
  let cachedFinalManifestPromise;
1021
1032
  async function loadEntries() {
1022
- const routerEntry = await import("./assets/router-5hznwWqr.js").then((n) => n.r);
1033
+ const routerEntry = await import("./assets/router-BvYNknMb.js").then((n) => n.r);
1023
1034
  const startEntry = await import("./assets/start-HYkvq4Ni.js");
1024
1035
  return { startEntry, routerEntry };
1025
1036
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-session-dashboard",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Local observability dashboard for Claude Code sessions",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -55,6 +55,9 @@
55
55
  "recharts": "^3.7.0",
56
56
  "zod": "^4.3.6"
57
57
  },
58
+ "overrides": {
59
+ "picomatch": "^4.0.0"
60
+ },
58
61
  "devDependencies": {
59
62
  "@eslint/js": "^9.39.2",
60
63
  "@playwright/test": "^1.58.2",
@@ -1 +0,0 @@
1
- import{j as e,c,u as x,L as l,O as d}from"./main-BcKPK-4E.js";import{u as n,c as h,q as p}from"./createServerFn-BLR4iNR3.js";import{a as m}from"./sessions.queries-CHKiZnLm.js";function u(){const{data:r}=n(m),a=r?.length??0;return a===0?null:e.jsx("span",{className:"ml-auto rounded-full bg-emerald-500/20 px-1.5 py-0.5 text-[10px] font-medium text-emerald-400",children:a})}const f=h({method:"GET"}).handler(c("955327d72ca3168c4751159ca07b8fb0fe0d2381dd0b991f06b941480959fbe8")),g=p({queryKey:["app-info"],queryFn:()=>f(),staleTime:1/0,refetchOnWindowFocus:!1}),j=[{to:"/sessions",label:"Sessions",icon:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("line",{x1:"2",y1:"4",x2:"14",y2:"4"}),e.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"}),e.jsx("line",{x1:"2",y1:"12",x2:"14",y2:"12"})]})},{to:"/stats",label:"Stats",icon:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("rect",{x:"1",y:"8",width:"3",height:"7",rx:"0.5"}),e.jsx("rect",{x:"6.5",y:"4",width:"3",height:"11",rx:"0.5"}),e.jsx("rect",{x:"12",y:"1",width:"3",height:"14",rx:"0.5"})]})},{to:"/settings",label:"Settings",icon:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("path",{d:"M8 10a2 2 0 100-4 2 2 0 000 4z"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.5.8a1 1 0 011-.8h1a1 1 0 011 .8l.15.9a5.5 5.5 0 011.1.64l.86-.36a1 1 0 011.17.36l.5.86a1 1 0 01-.18 1.17l-.7.55a5.5 5.5 0 010 1.27l.7.55a1 1 0 01.18 1.17l-.5.86a1 1 0 01-1.17.36l-.86-.36a5.5 5.5 0 01-1.1.64l-.14.9a1 1 0 01-1 .8h-1a1 1 0 01-1-.8l-.14-.9a5.5 5.5 0 01-1.1-.64l-.87.36a1 1 0 01-1.17-.36l-.5-.86a1 1 0 01.18-1.17l.7-.55a5.5 5.5 0 010-1.27l-.7-.55a1 1 0 01-.18-1.17l.5-.86a1 1 0 011.17-.36l.87.36a5.5 5.5 0 011.1-.64L6.5.8zM8 11a3 3 0 100-6 3 3 0 000 6z"})]})}];function y({children:r}){const a=x(),o=a[a.length-1]?.pathname??"",{data:t}=n(g);return e.jsxs("div",{className:"flex min-h-screen",children:[e.jsxs("aside",{className:"flex w-56 shrink-0 flex-col border-r border-gray-800 bg-gray-950",children:[e.jsx("div",{className:"flex h-14 items-center border-b border-gray-800 px-4",children:e.jsxs(l,{to:"/sessions",className:"text-sm font-bold text-white",children:[e.jsx("span",{className:"text-brand-500",children:"Claude"})," Dashboard"]})}),e.jsx("nav",{className:"flex-1 p-3",children:j.map(s=>{const i=o.startsWith(s.to);return e.jsxs(l,{to:s.to,className:`flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm transition-colors ${i?"bg-gray-800 text-white":"text-gray-400 hover:bg-gray-800/50 hover:text-gray-200"}`,children:[e.jsx("span",{className:"text-gray-500",children:s.icon}),s.label,s.to==="/sessions"&&e.jsx(u,{})]},s.to)})}),e.jsxs("div",{className:"border-t border-gray-800 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:"https://github.com/dlupiak/claude-session-dashboard",target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 hover:text-gray-300 transition-colors",title:"GitHub Repository",children:e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"})})}),e.jsx("a",{href:"https://www.npmjs.com/package/claude-session-dashboard",target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 hover:text-gray-300 transition-colors",title:"npm Package",children:e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M0 0v16h16V0H0zm13 13H8V5H5v8H3V3h10v10z"})})})]}),e.jsx("p",{className:"text-xs text-gray-600",children:"Read-only"})]}),t&&e.jsxs("p",{className:"mt-1.5 truncate text-[10px] text-gray-600",title:`v${t.version} · ${t.appPath}`,children:["v",t.version," · ",t.appPath]})]})]}),e.jsx("main",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"mx-auto max-w-5xl px-6 py-6",children:r})})]})}function w(){return e.jsx(y,{children:e.jsx(d,{})})}export{w as component};
@@ -1,12 +0,0 @@
1
- import{r as v,c as ae,j as e,L as W,f as G,b as ne}from"./main-BcKPK-4E.js";import{c as re,q as le,u as _}from"./createServerFn-BLR4iNR3.js";import{f as C,d as X,b as M,i as V,g as E}from"./format-Bsprb3az.js";import{r as oe,a7 as ie,l as ce,bz as de,bA as xe,aw as me,bB as ue,d as P,bC as pe,bD as he,bE as Y,bF as ge,s as fe,aa as ye,Z as be,a as je,bG as ve,bH as Ne,at as O,bI as q,bJ as ke,bn as we,bq as Te,bo as Me,bp as Se,br as Ce,bK as Ie,bL as De,bs as J,bt as Ae,bu as $e,bM as Oe}from"./useSessionCost-BikgEmWy.js";import{s as Ee}from"./settings.types-DHC6rkil.js";import{a as Pe}from"./sessions.queries-CHKiZnLm.js";class Le{constructor(s){var{x:a,y:n}=s;this.xAxisScale=a,this.yAxisScale=n}map(s,a){var n,r,{position:o}=a;return{x:(n=this.xAxisScale.map(s.x,{position:o}))!==null&&n!==void 0?n:0,y:(r=this.yAxisScale.map(s.y,{position:o}))!==null&&r!==void 0?r:0}}mapWithFallback(s,a){var n,r,{position:o,fallback:l}=a,d,i;return l==="rangeMin"?d=this.yAxisScale.rangeMin():l==="rangeMax"?d=this.yAxisScale.rangeMax():d=0,l==="rangeMin"?i=this.xAxisScale.rangeMin():l==="rangeMax"?i=this.xAxisScale.rangeMax():i=0,{x:(n=this.xAxisScale.map(s.x,{position:o}))!==null&&n!==void 0?n:i,y:(r=this.yAxisScale.map(s.y,{position:o}))!==null&&r!==void 0?r:d}}isInRange(s){var{x:a,y:n}=s,r=a==null||this.xAxisScale.isInRange(a),o=n==null||this.yAxisScale.isInRange(n);return r&&o}}function K(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),a.push.apply(a,n)}return a}function Z(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?K(Object(a),!0).forEach(function(n){Re(t,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):K(Object(a)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(a,n))})}return t}function Re(t,s,a){return(s=Ue(s))in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function Ue(t){var s=We(t,"string");return typeof s=="symbol"?s:s+""}function We(t,s){if(typeof t!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var n=a.call(t,s);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function R(){return R=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var a=arguments[s];for(var n in a)({}).hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},R.apply(null,arguments)}var Fe=(t,s)=>{var a;if(v.isValidElement(t))a=v.cloneElement(t,s);else if(typeof t=="function")a=t(s);else{if(!O(s.x1)||!O(s.y1)||!O(s.x2)||!O(s.y2))return null;a=v.createElement("line",R({},s,{className:"recharts-reference-line-line"}))}return a},_e=(t,s,a,n,r,o)=>{var{x:l,width:d}=o,i=r.map(t,{position:a});if(!O(i)||s==="discard"&&!r.isInRange(i))return null;var h=[{x:l+d,y:i},{x:l,y:i}];return n==="left"?h.reverse():h},Xe=(t,s,a,n,r,o)=>{var{y:l,height:d}=o,i=r.map(t,{position:a});if(!O(i)||s==="discard"&&!r.isInRange(i))return null;var h=[{x:i,y:l+d},{x:i,y:l}];return n==="top"?h.reverse():h},Be=(t,s,a,n)=>{var r=[n.mapWithFallback(t[0],{position:a,fallback:"rangeMin"}),n.mapWithFallback(t[1],{position:a,fallback:"rangeMax"})];return s==="discard"&&r.some(o=>!n.isInRange(o))?null:r},ze=(t,s,a,n,r,o,l)=>{var{x:d,y:i,segment:h,ifOverflow:p}=l,f=q(d),g=q(i);return g?_e(i,p,n,o,s,a):f?Xe(d,p,n,r,t,a):h!=null&&h.length===2?Be(h,p,n,new Le({x:t,y:s})):null};function He(t){var s=ce();return v.useEffect(()=>(s(de(t)),()=>{s(xe(t))})),null}function Ge(t){var{xAxisId:s,yAxisId:a,shape:n,className:r,ifOverflow:o}=t,l=me(),d=ue(),i=P(S=>pe(S,s)),h=P(S=>he(S,a)),p=P(S=>Y(S,"xAxis",s,l)),f=P(S=>Y(S,"yAxis",a,l)),g=ge();if(!d||!g||i==null||h==null||p==null||f==null)return null;var N=ze(p,f,g,t.position,i.orientation,h.orientation,t);if(!N)return null;var k=N[0],c=N[1];if(k==null||c==null)return null;var{x:u,y:x}=k,{x:j,y:m}=c,b=o==="hidden"?"url(#".concat(d,")"):void 0,y=Z(Z({clipPath:b},fe(t)),{},{x1:u,y1:x,x2:j,y2:m}),w=ke({x1:u,y1:x,x2:j,y2:m});return v.createElement(ye,{zIndex:t.zIndex},v.createElement(be,{className:je("recharts-reference-line",r)},Fe(n,y),v.createElement(ve,R({},w,{lowerWidth:w.width,upperWidth:w.width}),v.createElement(Ne,{label:t.label}),t.children)))}var Ye={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",label:!1,stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:ie.line};function F(t){var s=oe(t,Ye);return v.createElement(v.Fragment,null,v.createElement(He,{yAxisId:s.yAxisId,xAxisId:s.xAxisId,ifOverflow:s.ifOverflow,x:s.x,y:s.y,segment:s.segment}),v.createElement(Ge,s))}F.displayName="ReferenceLine";const qe=re({method:"GET"}).handler(ae("ff8a3161afdfa175e9c519e4146a56ab5bce6e80745e99cfc2191ebbb7a859bb"));function Ke(t,s,a){return le({queryKey:["session","detail",t],queryFn:()=>qe({data:{sessionId:t,projectPath:s}}),staleTime:a?2e3:3e4,refetchInterval:a?5e3:void 0})}function Ze(t,s,a,n){const r=[];for(const c of t)if(c.timestamp){const u=new Date(c.timestamp).getTime();isNaN(u)||r.push(u)}for(const c of s)if(c.timestamp){const u=new Date(c.timestamp).getTime();isNaN(u)||r.push(u)}for(const c of a)if(c.timestamp){const u=new Date(c.timestamp).getTime();isNaN(u)||r.push(u)}if(r.length===0)return{startMs:0,endMs:0,durationMs:0,mainLane:[],agentLanes:[],skillMarkers:[],errorMarkers:[]};const o=Math.min(...r),l=Math.max(...r),d=Math.max(l-o,1);function i(c){return(c-o)/d}const h=new Set(s.map(c=>c.toolUseId)),p=new Set(a.map(c=>c.toolUseId)),f=[];for(const c of t){if(c.type!=="assistant"||c.toolCalls.length===0)continue;const u=new Date(c.timestamp).getTime();if(!isNaN(u))for(const x of c.toolCalls)h.has(x.toolUseId)||p.has(x.toolUseId)||f.push({timestampMs:u,toolName:x.toolName,toolUseId:x.toolUseId,relativeX:i(u)})}const g=s.map(c=>{const u=new Date(c.timestamp).getTime(),x=c.durationMs?u+c.durationMs:u+d*.02,j=[];if(c.toolCalls){const m=Object.entries(c.toolCalls).sort(([,w],[,S])=>S-w),b=m.reduce((w,[,S])=>w+S,0);let y=0;for(const[w,S]of m)for(let H=0;H<S;H++){const te=b>1?y/(b-1):.5,se=u+(x-u)*te;j.push({toolName:w,count:1,relativeX:i(se)}),y++}}return{subagentType:c.subagentType,description:c.description,startMs:u,endMs:x,startX:i(u),endX:i(x),durationMs:c.durationMs??null,totalTokens:c.totalTokens??null,totalToolUseCount:c.totalToolUseCount??null,toolDots:j,skills:c.skills?.map(m=>({skill:m.skill,args:m.args}))??[]}}),N=a.map(c=>{const u=new Date(c.timestamp).getTime();return isNaN(u)?null:{skill:c.skill,args:c.args,timestampMs:u,relativeX:i(u)}}).filter(c=>c!==null),k=n.map(c=>{const u=new Date(c.timestamp).getTime();return isNaN(u)?null:{message:c.message,type:c.type,timestampMs:u,relativeX:i(u)}}).filter(c=>c!==null);return{startMs:o,endMs:l,durationMs:d,mainLane:f,agentLanes:g,skillMarkers:N,errorMarkers:k}}function B(t){const s=t.match(/^mcp__[^_]+_[^_]+_[^_]+__(.+)$/);return s?s[1]:t}const Qe={Read:"#e09070",Grep:"#e09070",Glob:"#e09070",Write:"#34d399",Edit:"#34d399",NotebookEdit:"#34d399",Bash:"#fbbf24",Task:"#818cf8",TaskCreate:"#c084fc",TaskUpdate:"#c084fc",TaskList:"#c084fc",TaskGet:"#c084fc",Skill:"#fcd34d",WebSearch:"#22d3ee",WebFetch:"#22d3ee",EnterPlanMode:"#f472b6",ExitPlanMode:"#f472b6",AskUserQuestion:"#a78bfa"},Ve="#9ca3af";function z(t){return Qe[t]??Ve}const I=90,$=16,D=24,T=32,U=8,ee=4;function Je(t,s,a){const n=s-t;if(n<=0)return[];const r=Math.max(3,Math.round(a/120)),o=n/r,l=[5e3,1e4,15e3,3e4,6e4,2*6e4,5*6e4,10*6e4,15*6e4,30*6e4,60*6e4,120*6e4],d=l.find(g=>g>=o)??l[l.length-1],h=n<5*6e4?"HH:mm:ss":"HH:mm",p=Math.ceil(t/d)*d,f=[];for(let g=p;g<=s;g+=d){const N=(g-t)/n;f.push({ms:g,label:C(new Date(g),h),x:I+N*(a-I-$)})}return f}function et({data:t,width:s,onHover:a}){const n=v.useRef(null),r=s,o=r-I-$,l=t.skillMarkers.length>0,d=t.errorMarkers.length>0;let i=D;const h=i;i+=T;const p=[];for(let x=0;x<t.agentLanes.length;x++)i+=U,p.push(i),i+=T;let f=0;l&&(i+=U,f=i,i+=T);let g=0;d&&(i+=U,g=i,i+=T);const N=Math.max(i+8,80);function k(x){return I+x*o}const c=v.useCallback(x=>{if(!n.current)return{x:0,y:0};const j=n.current.getBoundingClientRect();return{x:x.clientX-j.left,y:x.clientY-j.top}},[]),u=Je(t.startMs,t.endMs,r);return e.jsxs("svg",{ref:n,width:r,height:N,className:"select-none",role:"img","aria-label":"Session timeline showing tool calls, agent runs, and skill invocations",onMouseLeave:()=>a(null,{x:0,y:0}),children:[e.jsx("line",{x1:I,y1:D-4,x2:r-$,y2:D-4,stroke:"#374151",strokeWidth:1}),u.map(x=>e.jsxs("g",{children:[e.jsx("line",{x1:x.x,y1:D-8,x2:x.x,y2:D-4,stroke:"#4b5563",strokeWidth:1}),e.jsx("text",{x:x.x,y:D-12,textAnchor:"middle",className:"fill-gray-500 text-[10px]",children:x.label})]},x.ms)),e.jsx("text",{x:4,y:h+T/2+4,className:"fill-gray-500 text-[11px] font-medium",children:"Main"}),e.jsx("line",{x1:I,y1:h+T/2,x2:r-$,y2:h+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.mainLane.map(x=>e.jsx("circle",{cx:k(x.relativeX),cy:h+T/2,r:ee,fill:z(x.toolName),opacity:.85,className:"cursor-pointer transition-transform hover:opacity-100",onMouseEnter:j=>a({kind:"tool",toolName:x.toolName,timestamp:new Date(x.timestampMs).toISOString(),toolUseId:x.toolUseId},c(j)),onMouseLeave:()=>a(null,{x:0,y:0}),children:e.jsx("title",{children:x.toolName})},x.toolUseId)),t.agentLanes.map((x,j)=>e.jsx(tt,{lane:x,y:p[j],toX:k,laneHeight:T,onHover:a,getPosition:c},`${x.subagentType}-${j}`)),l&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:4,y:f+T/2+4,className:"fill-amber-400/70 text-[11px] font-medium",children:"Skills"}),e.jsx("line",{x1:I,y1:f+T/2,x2:r-$,y2:f+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.skillMarkers.map((x,j)=>{const m=k(x.relativeX),b=f+T/2,y=5;return e.jsx("polygon",{points:`${m},${b-y} ${m+y},${b} ${m},${b+y} ${m-y},${b}`,fill:"#fbbf24",opacity:.85,className:"cursor-pointer hover:opacity-100",onMouseEnter:w=>a({kind:"skill",skill:x.skill,args:x.args,timestamp:new Date(x.timestampMs).toISOString()},c(w)),onMouseLeave:()=>a(null,{x:0,y:0}),children:e.jsxs("title",{children:["/",x.skill]})},`${x.skill}-${j}`)})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:4,y:g+T/2+4,className:"fill-red-400/70 text-[11px] font-medium",children:"Errors"}),e.jsx("line",{x1:I,y1:g+T/2,x2:r-$,y2:g+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.errorMarkers.map((x,j)=>{const m=k(x.relativeX),b=g+T/2,y=5;return e.jsxs("g",{className:"cursor-pointer hover:opacity-100",opacity:.85,onMouseEnter:w=>a({kind:"error",message:x.message,type:x.type,timestamp:new Date(x.timestampMs).toISOString()},c(w)),onMouseLeave:()=>a(null,{x:0,y:0}),children:[e.jsx("line",{x1:m-y,y1:b-y,x2:m+y,y2:b+y,stroke:"#f87171",strokeWidth:2,strokeLinecap:"round"}),e.jsx("line",{x1:m+y,y1:b-y,x2:m-y,y2:b+y,stroke:"#f87171",strokeWidth:2,strokeLinecap:"round"}),e.jsxs("title",{children:[x.type,": ",x.message]})]},`err-${j}`)})]})]})}function tt({lane:t,y:s,toX:a,laneHeight:n,onHover:r,getPosition:o}){const l=a(t.startX),d=Math.max(a(t.endX)-l,8),i=s+n/2,h=t.subagentType.length>10?t.subagentType.slice(0,10)+"...":t.subagentType;return e.jsxs("g",{children:[e.jsx("text",{x:4,y:i+4,className:"fill-indigo-400/70 text-[11px] font-medium",children:h}),e.jsx("rect",{x:l,y:s+2,width:d,height:n-4,rx:6,fill:"rgba(99, 102, 241, 0.08)",stroke:"rgba(99, 102, 241, 0.2)",strokeWidth:1,className:"cursor-pointer hover:fill-indigo-500/15",onMouseEnter:p=>r({kind:"agent",agent:t},o(p)),onMouseLeave:()=>r(null,{x:0,y:0}),children:e.jsxs("title",{children:[t.subagentType,": ",t.description]})}),e.jsx("line",{x1:l+4,y1:i,x2:l+d-4,y2:i,stroke:"rgba(99, 102, 241, 0.15)",strokeWidth:1}),t.toolDots.map((p,f)=>e.jsx("circle",{cx:a(p.relativeX),cy:i,r:ee-.5,fill:z(p.toolName),opacity:.75,className:"cursor-pointer hover:opacity-100",onMouseEnter:g=>r({kind:"tool",toolName:p.toolName,timestamp:new Date(t.startMs+(p.relativeX-t.startX)/(t.endX-t.startX)*(t.endMs-t.startMs)).toISOString(),toolUseId:`${t.subagentType}-${p.toolName}-${f}`},o(g)),onMouseLeave:()=>r(null,{x:0,y:0}),children:e.jsxs("title",{children:[p.toolName," (",t.subagentType,")"]})},`${p.toolName}-${f}`)),t.skills&&t.skills.length>0&&t.skills.map((p,f)=>{const g=t.startX+(t.endX-t.startX)/(t.skills.length+1)*(f+1),N=a(g),k=s+6,c=3;return e.jsx("polygon",{points:`${N},${k-c} ${N+c},${k} ${N},${k+c} ${N-c},${k}`,fill:"#fbbf24",opacity:.85,className:"cursor-pointer hover:opacity-100",onMouseEnter:u=>r({kind:"skill",skill:p.skill,args:p.args,timestamp:new Date(t.startMs).toISOString()},o(u)),onMouseLeave:()=>r(null,{x:0,y:0}),children:e.jsxs("title",{children:["/",p.skill," (",t.subagentType,")"]})},`skill-${p.skill}-${f}`)})]})}function st({item:t,position:s}){return e.jsxs("div",{className:"pointer-events-none absolute z-50 rounded-lg border border-gray-700 bg-gray-900 px-3 py-2 text-xs shadow-xl",style:{left:s.x,top:s.y,transform:"translate(-50%, -100%) translateY(-8px)"},children:[t.kind==="tool"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-gray-100",children:B(t.toolName)}),e.jsx("div",{className:"text-gray-400",children:C(new Date(t.timestamp),"HH:mm:ss")}),e.jsxs("div",{className:"font-mono text-[10px] text-gray-600",children:[t.toolUseId.slice(0,16),"..."]})]}),t.kind==="agent"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-indigo-300",children:t.agent.subagentType}),e.jsx("div",{className:"max-w-48 truncate text-gray-400",children:t.agent.description}),e.jsx("div",{className:"mt-1 flex items-center gap-2 text-gray-500",children:t.agent.durationMs!=null&&e.jsxs("span",{children:[C(new Date(t.agent.startMs),"HH:mm")," -"," ",C(new Date(t.agent.endMs),"HH:mm")," (",X(t.agent.durationMs),")"]})}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[t.agent.totalTokens!=null&&e.jsxs("span",{children:[M(t.agent.totalTokens)," tokens"]}),t.agent.totalToolUseCount!=null&&e.jsxs("span",{children:[t.agent.totalToolUseCount," tools"]})]})]}),t.kind==="skill"&&e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold text-amber-300",children:["/",t.skill]}),t.args&&e.jsx("div",{className:"text-gray-400",children:t.args}),e.jsx("div",{className:"text-gray-500",children:C(new Date(t.timestamp),"HH:mm:ss")})]}),t.kind==="error"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-red-400",children:t.type}),e.jsx("div",{className:"max-w-48 truncate text-gray-400",children:t.message}),e.jsx("div",{className:"text-gray-500",children:C(new Date(t.timestamp),"HH:mm:ss")})]})]})}function at({toolNames:t}){const s=[...new Set(t)].slice(0,12);return s.length===0?null:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-1 text-[10px] text-gray-500",children:[s.map(a=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:z(a)}}),e.jsx("span",{children:B(a)})]},a)),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rotate-45 bg-amber-400"}),e.jsx("span",{children:"Skill"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-red-400 font-bold leading-none",children:"×"}),e.jsx("span",{children:"Error"})]})]})}function nt({turns:t,agents:s,skills:a,errors:n}){const r=v.useRef(null),[o,l]=v.useState(0),[d,i]=v.useState(1),[h,p]=v.useState(null);v.useEffect(()=>{if(!r.current)return;const m=new ResizeObserver(b=>{const y=b[0];y&&l(y.contentRect.width)});return m.observe(r.current),()=>m.disconnect()},[]);const f=v.useMemo(()=>Ze(t,s,a,n),[t,s,a,n]),g=v.useMemo(()=>{const m=f.mainLane.map(y=>y.toolName);for(const y of f.agentLanes)for(const w of y.toolDots)m.push(w.toolName);const b={};for(const y of m)b[y]=(b[y]??0)+1;return Object.entries(b).sort(([,y],[,w])=>w-y).map(([y])=>y)},[f]),N=(m,b)=>{p(m?{item:m,position:b}:null)};if(t.length===0)return e.jsx("div",{className:"py-8 text-center text-sm text-gray-500",children:"No timeline data available"});const k=new Set(s.map(m=>m.toolUseId)),c=new Set(a.map(m=>m.toolUseId));let u=0,x=0,j=0;for(const m of t)if(m.type==="user"&&m.message?.trim()&&u++,m.type==="assistant"){x++;for(const b of m.toolCalls)!k.has(b.toolUseId)&&!c.has(b.toolUseId)&&j++}return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-4",children:[e.jsx(A,{label:"User commands",value:u,color:"blue"}),e.jsx(A,{label:"AI responses",value:x,color:"purple"}),j>0&&e.jsx(A,{label:"Tool calls",value:j,color:"gray"}),s.length>0&&e.jsx(A,{label:"Agents",value:s.length,color:"indigo"}),a.length>0&&e.jsx(A,{label:"Skills",value:a.length,color:"amber"}),n.length>0&&e.jsx(A,{label:"Errors",value:n.length,color:"red"})]}),e.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1",children:g.length>0&&e.jsx(at,{toolNames:g})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>i(m=>Math.max(1,m-.5)),disabled:d<=1,className:"rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-300 transition-colors hover:bg-gray-700 disabled:opacity-30",title:"Zoom out",children:"−"}),e.jsx("span",{className:"min-w-[3rem] text-center text-[10px] tabular-nums text-gray-500",children:d===1?"Fit":`${d.toFixed(1)}x`}),e.jsx("button",{type:"button",onClick:()=>i(m=>Math.min(8,m+.5)),disabled:d>=8,className:"rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-300 transition-colors hover:bg-gray-700 disabled:opacity-30",title:"Zoom in",children:"+"}),d>1&&e.jsx("button",{type:"button",onClick:()=>i(1),className:"ml-1 rounded bg-gray-800 px-2 py-0.5 text-[10px] text-gray-400 transition-colors hover:bg-gray-700",title:"Reset zoom",children:"Reset"})]})]}),e.jsx("div",{ref:r,className:"relative overflow-x-auto",children:o>0&&e.jsxs(e.Fragment,{children:[e.jsx(et,{data:f,width:Math.max(o*d,400),onHover:N}),h&&e.jsx(st,{item:h.item,position:h.position})]})})]})}function A({label:t,value:s,color:a}){const n={blue:"bg-brand-500/15 text-brand-400",purple:"bg-purple-500/15 text-purple-400",gray:"bg-gray-800 text-gray-300",indigo:"bg-indigo-500/15 text-indigo-400",amber:"bg-amber-500/15 text-amber-400",red:"bg-red-500/15 text-red-400"};return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`rounded-md px-2 py-1 text-sm font-bold tabular-nums ${n[a]}`,children:s}),e.jsx("span",{className:"text-[11px] text-gray-500",children:t})]})}function rt({contextWindow:t,tokens:s}){const[a,n]=v.useState(!1);if(!t)return e.jsx(ot,{tokens:s});const{contextLimit:r,modelName:o,systemOverhead:l,currentContextSize:d,messagesEstimate:i,freeSpace:h,autocompactBuffer:p,usagePercent:f,snapshots:g}=t,N=l/r*100,k=i/r*100,c=p/r*100,u=Math.max(0,100-N-k),x=o.replace(/^claude-/,"").split("-202")[0],j=g.map(m=>({turn:m.turnIndex,context:m.contextSize}));return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Context Window"}),e.jsx("span",{className:"rounded bg-gray-800 px-1.5 py-0.5 text-[10px] font-mono text-gray-400",children:x})]}),e.jsxs("div",{className:"mt-1 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-2xl font-bold text-white",children:M(d)}),e.jsxs("span",{className:"text-sm text-gray-500",children:["/ ",M(r)]}),e.jsxs("span",{className:"text-sm text-gray-400",children:["(",f,"%)"]})]}),e.jsx("p",{className:"text-[10px] text-gray-500",children:"~estimated from token usage"}),e.jsxs("div",{className:"mt-3 flex h-3 overflow-hidden rounded-full bg-gray-800",children:[e.jsx("div",{className:"bg-purple-500",style:{width:`${N}%`},title:`System: ~${M(l)}`}),e.jsx("div",{className:"bg-brand-500",style:{width:`${k}%`},title:`Messages: ~${M(i)}`}),u>0&&e.jsx(e.Fragment,{children:u>c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-gray-700",style:{width:`${u-c}%`}}),e.jsx("div",{className:"autocompact-stripe",style:{width:`${Math.min(c,u)}%`}})]}):e.jsx("div",{className:"autocompact-stripe",style:{width:`${u}%`}})})]}),e.jsxs("div",{className:"mt-1 flex gap-3 text-[10px] text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-purple-500"}),"system"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-brand-500"}),"messages"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-gray-700"}),"free"]})]}),e.jsxs("div",{className:"mt-3 space-y-1.5",children:[e.jsx(L,{label:"System overhead",value:l,total:r,color:"bg-purple-500",prefix:"~"}),e.jsx(L,{label:"Messages",value:i,total:r,color:"bg-brand-500",prefix:"~"}),e.jsx(L,{label:"Autocompact buffer",value:p,total:r,color:"bg-amber-500"}),e.jsx(L,{label:"Free space",value:h,total:r,color:"bg-gray-600"})]}),j.length>1&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1 text-[10px] text-gray-500",children:"Context growth"}),e.jsx(we,{width:"100%",height:96,children:e.jsxs(Te,{data:j,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"contextGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#d97757",stopOpacity:.3}),e.jsx("stop",{offset:"100%",stopColor:"#d97757",stopOpacity:.05})]})}),e.jsx(Me,{domain:[0,r],hide:!0}),e.jsx(Se,{contentStyle:{background:"#1c1c1a",border:"1px solid #3d3b36",borderRadius:"8px",fontSize:"11px"},labelFormatter:m=>`Turn ${m}`,formatter:m=>[M(m),"Context"]}),e.jsx(F,{y:r,stroke:"#ef4444",strokeDasharray:"4 4",strokeOpacity:.5}),e.jsx(F,{y:r-p,stroke:"#f59e0b",strokeDasharray:"2 4",strokeOpacity:.3}),e.jsx(Ce,{type:"stepAfter",dataKey:"context",stroke:"#d97757",fill:"url(#contextGrad)",strokeWidth:1.5,dot:!1})]})})]}),e.jsxs("button",{onClick:()=>n(!a),className:"mt-3 flex w-full items-center gap-1 text-xs text-gray-400 hover:text-gray-300 transition-colors",children:[e.jsx("span",{className:"text-[10px]",children:a?"▾":"▸"}),"Token Details"]}),a&&e.jsx(lt,{tokens:s}),e.jsx("style",{children:`
2
- .autocompact-stripe {
3
- background: repeating-linear-gradient(
4
- -45deg,
5
- #78716c,
6
- #78716c 2px,
7
- #f59e0b 2px,
8
- #f59e0b 4px
9
- );
10
- opacity: 0.4;
11
- }
12
- `})]})}function L({label:t,value:s,total:a,color:n,prefix:r=""}){const o=Math.max(0,Math.min(100,s/a*100));return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-32 text-xs text-gray-400 shrink-0",children:t}),e.jsxs("span",{className:"w-16 text-right text-xs font-mono text-gray-300 shrink-0",children:[r,M(s)]}),e.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-gray-800 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${n}`,style:{width:`${o}%`,opacity:.7}})})]})}function lt({tokens:t}){const s=t.inputTokens+t.outputTokens+t.cacheReadInputTokens+t.cacheCreationInputTokens,a=[{label:"Input",value:t.inputTokens,color:"bg-brand-400"},{label:"Output",value:t.outputTokens,color:"bg-emerald-400"},{label:"Cache Read",value:t.cacheReadInputTokens,color:"bg-amber-400"},{label:"Cache Create",value:t.cacheCreationInputTokens,color:"bg-purple-400"}];return e.jsxs("div",{className:"mt-2 space-y-1.5",children:[a.map(n=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-400",children:n.label}),e.jsx("span",{className:"text-xs font-mono text-gray-300",children:M(n.value)})]},n.label)),s>0&&e.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-gray-800",children:a.filter(n=>n.value>0).map(n=>e.jsx("div",{className:`${n.color} opacity-60`,style:{width:`${n.value/s*100}%`}},n.label))})]})}function ot({tokens:t}){const s=t.inputTokens+t.outputTokens,a=s+t.cacheReadInputTokens+t.cacheCreationInputTokens,n=[{label:"Input",value:t.inputTokens,color:"text-brand-400"},{label:"Output",value:t.outputTokens,color:"text-emerald-400"},{label:"Cache Read",value:t.cacheReadInputTokens,color:"text-amber-400"},{label:"Cache Create",value:t.cacheCreationInputTokens,color:"text-purple-400"}];return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Token Usage"}),e.jsx("p",{className:"mt-1 text-2xl font-bold text-white",children:M(s)}),e.jsxs("p",{className:"text-[10px] text-gray-500",children:["input + output (",M(a)," incl. cache)"]}),e.jsx("div",{className:"mt-3 space-y-2",children:n.map(r=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-400",children:r.label}),e.jsx("span",{className:`text-xs font-mono ${r.color}`,children:M(r.value)})]},r.label))}),a>0&&e.jsx("div",{className:"mt-3 flex h-2 overflow-hidden rounded-full bg-gray-800",children:n.filter(r=>r.value>0).map(r=>e.jsx("div",{className:`${r.color.replace("text-","bg-")} opacity-60`,style:{width:`${r.value/a*100}%`}},r.label))})]})}function it({toolFrequency:t}){const s=Object.entries(t).sort(([,n],[,r])=>r-n),a=s[0]?.[1]??1;return s.length===0?e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Tool Usage"}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"No tools used"})]}):e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Tool Usage"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:[s.length," tools, ",s.reduce((n,[,r])=>n+r,0)," calls"]}),e.jsx("div",{className:"mt-3 space-y-1.5",children:s.slice(0,15).map(([n,r])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-32 shrink-0 truncate text-xs font-mono text-gray-400",title:n,children:B(n)}),e.jsx("div",{className:"flex-1",children:e.jsx("div",{className:"h-4 rounded bg-brand-500/20",style:{width:`${r/a*100}%`},children:e.jsx("span",{className:"px-1.5 text-xs text-brand-300",children:r})})})]},n))})]})}function ct({errors:t}){return t.length===0?null:e.jsxs("div",{className:"rounded-xl border border-red-900/50 bg-red-950/20 p-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-red-400",children:["Errors (",t.length,")"]}),e.jsx("div",{className:"mt-3 max-h-64 space-y-2 overflow-y-auto",children:t.map((s,a)=>e.jsxs("div",{className:"rounded-lg bg-red-950/30 p-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-mono text-red-300",children:s.type}),s.timestamp&&e.jsx("span",{className:"text-xs text-gray-500",children:V(s.timestamp)})]}),e.jsx("p",{className:"mt-1 text-xs text-red-200/80",children:s.message})]},a))})]})}function Q(t){if(t.tokens)return t.tokens.inputTokens+t.tokens.outputTokens+t.tokens.cacheReadInputTokens+t.tokens.cacheCreationInputTokens}function dt({agents:t}){const{data:s}=_(Ee),{agentCosts:a,totalAgentCost:n}=v.useMemo(()=>{if(!s)return{agentCosts:new Map,totalAgentCost:0};const o=Ie(s),l=new Map;let d=0;for(let i=0;i<t.length;i++){const h=t[i];if(!h.tokens)continue;const f={[h.model??"claude-sonnet-4"]:h.tokens},g=De(f,o);l.set(i,g.totalUSD),d+=g.totalUSD}return{agentCosts:l,totalAgentCost:d}},[s,t]);if(t.length===0)return null;const r=t.reduce((o,l)=>o+(l.totalTokens??Q(l)??0),0);return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Agent Dispatches"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:[t.length," agent dispatch",t.length!==1?"es":"",r>0&&e.jsxs("span",{className:"ml-1 text-indigo-400",children:["(",M(r)," tokens",n>0&&` · ~${E(n)}`,")"]})]}),e.jsx("div",{className:"mt-3 space-y-1",children:t.map((o,l)=>{const d=o.totalTokens??Q(o),i=a.get(l);return e.jsxs("div",{className:"flex items-start gap-2 rounded bg-gray-950/40 px-2 py-1.5",children:[e.jsx("span",{className:"shrink-0 rounded bg-indigo-500/20 px-1.5 py-0.5 text-[10px] font-semibold text-indigo-300",children:o.subagentType}),o.model&&e.jsx("span",{className:"shrink-0 rounded bg-gray-800 px-1.5 py-0.5 text-[10px] font-mono text-gray-400",children:o.model.replace(/^claude-/,"").replace(/-\d{8}$/,"")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-gray-400",children:o.description}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[d!=null&&d>0&&e.jsx("span",{className:"text-[10px] font-mono text-indigo-400/80",children:M(d)}),i!=null&&i>0&&e.jsxs("span",{className:"text-[10px] font-mono text-emerald-400/80",children:["~",E(i)]}),o.totalToolUseCount!=null&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:[o.totalToolUseCount," tools"]}),o.durationMs!=null&&e.jsx("span",{className:"text-[10px] text-gray-600",children:X(o.durationMs)}),o.timestamp&&e.jsx("span",{className:"text-[10px] text-gray-600",children:C(new Date(o.timestamp),"HH:mm:ss")})]})]},`a-${l}`)})})]})}function xt({agents:t,skills:s}){const{groups:a,totalCount:n}=v.useMemo(()=>{const r=[...s.map(l=>({...l,agentSource:null})),...t.flatMap(l=>(l.skills??[]).map(d=>({...d,agentSource:l.subagentType})))].sort((l,d)=>l.timestamp.localeCompare(d.timestamp)),o=new Map;for(const l of r){let d=o.get(l.skill);d||(d={skill:l.skill,count:0,hasInjected:!1,invocations:[]},o.set(l.skill,d)),d.count++,l.source==="injected"&&(d.hasInjected=!0),d.invocations.push({agentSource:l.agentSource,timestamp:l.timestamp,source:l.source})}return{groups:Array.from(o.values()),totalCount:r.length}},[s,t]);return n===0?null:e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Skill Invocations"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:[a.length," unique skill",a.length!==1?"s":"",","," ",n," invocation",n!==1?"s":""]}),e.jsx("div",{className:"mt-3 space-y-1",children:a.map(r=>e.jsxs("div",{className:"rounded bg-gray-950/40 px-2 py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"shrink-0 rounded bg-amber-500/20 px-1.5 py-0.5 text-[10px] font-semibold text-amber-300",children:["/",r.skill]}),e.jsxs("span",{className:"text-[10px] text-gray-500",children:["×",r.count]}),r.hasInjected&&e.jsx("span",{className:"shrink-0 rounded bg-gray-800/40 px-1 py-0.5 text-[9px] text-gray-500",children:"context"})]}),e.jsx("div",{className:"mt-1 ml-2 flex flex-wrap gap-x-1 text-[10px] text-gray-500",children:r.invocations.map((o,l)=>e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:o.agentSource??"session"}),", ",e.jsx("span",{className:"text-gray-600",children:C(new Date(o.timestamp),"HH:mm:ss")}),l<r.invocations.length-1&&e.jsx("span",{className:"text-gray-700",children:"; "})]},l))})]},r.skill))})]})}const mt={pending:{label:"Pending",bg:"bg-gray-500/20",text:"text-gray-400"},in_progress:{label:"In Progress",bg:"bg-brand-500/20",text:"text-brand-400"},completed:{label:"Done",bg:"bg-emerald-500/20",text:"text-emerald-400"},deleted:{label:"Deleted",bg:"bg-red-500/20",text:"text-red-400"}};function ut({tasks:t}){if(t.length===0)return null;const s=t.filter(n=>n.status==="completed").length,a=t.filter(n=>n.status!=="deleted").length;return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Tasks"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:[s,"/",a," completed"]}),e.jsx("div",{className:"mt-3 space-y-1",children:t.map((n,r)=>{const o=mt[n.status];return e.jsxs("div",{className:"flex items-start gap-2 rounded bg-gray-950/40 px-2 py-1.5",children:[e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold ${o.bg} ${o.text}`,children:o.label}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-xs text-gray-300",children:n.subject}),n.description&&e.jsx("p",{className:"mt-0.5 truncate text-[10px] text-gray-500",children:n.description})]}),n.taskId&&e.jsxs("span",{className:"shrink-0 text-[10px] font-mono text-gray-600",children:["#",n.taskId]}),n.timestamp&&e.jsx("span",{className:"shrink-0 text-[10px] text-gray-600",children:C(new Date(n.timestamp),"HH:mm:ss")})]},n.taskId||r)})})]})}function pt({tokensByModel:t}){const{cost:s,isLoading:a}=J(t);return a?e.jsx("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:e.jsx("div",{className:"h-6 w-32 animate-pulse rounded bg-gray-800"})}):!s||s.totalUSD===0?e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Cost Estimation"}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"No token data available"})]}):e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Cost Estimation"}),e.jsxs("span",{className:"font-mono text-lg font-bold text-white",children:["~",E(s.totalUSD)]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-xs font-medium text-gray-400",children:"By Category"}),e.jsx(ht,{cost:s}),e.jsx(gt,{cost:s})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-xs font-medium text-gray-400",children:"By Model"}),e.jsx(ft,{cost:s})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between border-t border-gray-800 pt-3",children:[e.jsx("p",{className:"text-[10px] text-gray-600",children:"Estimated based on API pricing. Actual costs may vary."}),e.jsx(W,{to:"/settings",className:"text-[10px] text-gray-500 hover:text-gray-300",children:"Configure pricing"})]})]})}function ht({cost:t}){const s=[{label:"Input tokens",value:t.byCategory.input,color:"text-brand-400"},{label:"Output tokens",value:t.byCategory.output,color:"text-emerald-400"},{label:"Cache read",value:t.byCategory.cacheRead,color:"text-amber-400"},{label:"Cache write",value:t.byCategory.cacheWrite,color:"text-purple-400"}];return e.jsx("div",{className:"mt-2 space-y-1",children:s.map(a=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-400",children:a.label}),e.jsx("span",{className:`font-mono text-xs ${a.color}`,children:E(a.value)})]},a.label))})}function gt({cost:t}){if(t.totalUSD===0)return null;const s=[{key:"input",value:t.byCategory.input,color:"bg-brand-400"},{key:"output",value:t.byCategory.output,color:"bg-emerald-400"},{key:"cacheRead",value:t.byCategory.cacheRead,color:"bg-amber-400"},{key:"cacheWrite",value:t.byCategory.cacheWrite,color:"bg-purple-400"}];return e.jsx("div",{className:"mt-2 flex h-2 overflow-hidden rounded-full bg-gray-800",children:s.map(a=>{const n=a.value/t.totalUSD*100;return n<.5?null:e.jsx("div",{className:`${a.color} opacity-60`,style:{width:`${n}%`}},a.key)})})}function ft({cost:t}){const s=Object.values(t.byModel).sort((a,n)=>n.totalCost-a.totalCost);return s.length===0?null:e.jsx("div",{className:"mt-2 space-y-1",children:s.map(a=>{const n=t.totalUSD>0?Math.round(a.totalCost/t.totalUSD*100):0;return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-mono text-xs text-gray-300",children:a.displayName}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-gray-300",children:E(a.totalCost)}),e.jsxs("span",{className:"text-[10px] text-gray-500",children:["(",n,"%)"]}),e.jsxs("span",{className:"text-[10px] text-gray-600",children:[M(a.tokens.inputTokens+a.tokens.outputTokens+a.tokens.cacheReadInputTokens+a.tokens.cacheCreationInputTokens)," ","tok"]})]})]},a.modelId)})})}function yt({tokensByModel:t}){const{cost:s,isLoading:a}=J(t);return a||!s||s.totalUSD===0?null:e.jsxs("span",{className:"font-mono text-xs text-emerald-400",title:"Estimated cost based on API pricing",children:["~",E(s.totalUSD)]})}function bt(){return e.jsxs("div",{className:"mb-4 flex items-center gap-2 rounded-lg border border-emerald-800 bg-emerald-900/30 px-4 py-2 text-sm text-emerald-300",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-emerald-500"})]}),"This session is currently active. Data refreshes automatically."]})}function jt(t){const{data:s}=_(Pe);return s?.some(a=>a.sessionId===t)??!1}function St(){const{sessionId:t}=G.useParams(),{project:s=""}=G.useSearch(),{privacyMode:a,anonymizeProjectName:n,anonymizeBranch:r}=ne(),o=jt(t),{data:l,isLoading:d,error:i}=_(Ke(t,s,o));if(d)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-8 w-48 animate-pulse rounded bg-gray-800"}),e.jsx("div",{className:"h-64 animate-pulse rounded-xl bg-gray-900/50"})]});if(i||!l)return e.jsxs("div",{className:"py-12 text-center",children:[e.jsxs("p",{className:"text-sm text-red-400",children:["Failed to load session: ",i?.message??"Not found"]}),e.jsx(W,{to:"/sessions",className:"mt-2 inline-block text-sm text-brand-300 hover:underline",children:"Back to sessions"})]});const h=l.turns[0]?.timestamp,p=l.turns[l.turns.length-1]?.timestamp,f=h&&p?new Date(p).getTime()-new Date(h).getTime():0;return e.jsxs("div",{children:[o&&e.jsx(bt,{}),e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{to:"/sessions",className:"text-xs text-gray-500 hover:text-gray-300",children:"← Sessions"}),e.jsx("h1",{className:"mt-1 text-xl font-bold text-white",children:a?n(l.projectName):l.projectName}),e.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xs text-gray-400",children:[l.branch&&e.jsx("span",{className:"font-mono",children:r(l.branch)}),h&&e.jsx("span",{children:V(h)}),e.jsx("span",{children:X(f)}),e.jsxs("span",{children:[l.turns.length," turns"]}),e.jsx(yt,{tokensByModel:l.tokensByModel})]}),l.models.length>0&&e.jsx("div",{className:"mt-1 flex gap-1",children:l.models.map(g=>e.jsx("span",{className:"rounded bg-gray-800 px-1.5 py-0.5 text-[10px] font-mono text-gray-400",children:g.replace(/^claude-/,"").split("-202")[0]},g))})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ae,{options:[{label:"Export Session (JSON)",onClick:()=>$e(Oe(l),`session-${t.slice(0,8)}.json`,"application/json")}]}),e.jsx("span",{className:"font-mono text-xs text-gray-600",children:t.slice(0,8)})]})]}),e.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-4 md:grid-cols-2",children:[e.jsx(rt,{contextWindow:l.contextWindow,tokens:l.totalTokens}),e.jsx(it,{toolFrequency:l.toolFrequency})]}),e.jsx("div",{className:"mt-4",children:e.jsx(pt,{tokensByModel:l.tokensByModel})}),l.agents.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(dt,{agents:l.agents})}),l.tasks.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(ut,{tasks:l.tasks})}),e.jsx("div",{className:"mt-4",children:e.jsx(ct,{errors:l.errors})}),e.jsxs("div",{className:"mt-6",children:[e.jsx("h2",{className:"mb-3 text-sm font-semibold text-gray-300",children:"Timeline"}),e.jsx(nt,{turns:l.turns,agents:l.agents,skills:l.skills,errors:l.errors})]}),(l.skills.length>0||l.agents.some(g=>(g.skills?.length??0)>0))&&e.jsx("div",{className:"mt-6",children:e.jsx(xt,{agents:l.agents,skills:l.skills})})]})}export{St as component};