pi-mega-compact 0.20.57 → 0.20.59

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 (82) hide show
  1. package/dist/config/vector-cortex-dash-0a.js +22 -0
  2. package/dist/config/vector-cortex-dash-0b.js +21 -0
  3. package/dist/config/vector-cortex.js +4 -0
  4. package/dist/config.js +1 -1
  5. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +2 -0
  6. package/dist/src/config/vector-cortex-dash-0a.js +22 -0
  7. package/dist/src/config/vector-cortex-dash-0b.js +21 -0
  8. package/dist/src/config/vector-cortex.js +4 -0
  9. package/dist/src/config.js +1 -1
  10. package/extensions/dashboard-client/dist/assets/{AreaChart-CtJ6dSMT.js → AreaChart-GTwQxOAm.js} +2 -2
  11. package/extensions/dashboard-client/dist/assets/{AreaChart-CtJ6dSMT.js.map → AreaChart-GTwQxOAm.js.map} +1 -1
  12. package/extensions/dashboard-client/dist/assets/{BarChart-DJ3j3xDz.js → BarChart-BFqUD5L4.js} +2 -2
  13. package/extensions/dashboard-client/dist/assets/{BarChart-DJ3j3xDz.js.map → BarChart-BFqUD5L4.js.map} +1 -1
  14. package/extensions/dashboard-client/dist/assets/{CacheTab-CXU1_9lR.js → CacheTab-BLM6_PQQ.js} +2 -2
  15. package/extensions/dashboard-client/dist/assets/{CacheTab-CXU1_9lR.js.map → CacheTab-BLM6_PQQ.js.map} +1 -1
  16. package/extensions/dashboard-client/dist/assets/{EventsTab-DF-Q3o7x.js → EventsTab-BYLh6cud.js} +2 -2
  17. package/extensions/dashboard-client/dist/assets/{EventsTab-DF-Q3o7x.js.map → EventsTab-BYLh6cud.js.map} +1 -1
  18. package/extensions/dashboard-client/dist/assets/{HealthTab-Dr1HGOkl.js → HealthTab-CkJXEbjn.js} +2 -2
  19. package/extensions/dashboard-client/dist/assets/{HealthTab-Dr1HGOkl.js.map → HealthTab-CkJXEbjn.js.map} +1 -1
  20. package/extensions/dashboard-client/dist/assets/HydeDetailPanel-Dt9T7kc5.js +5 -0
  21. package/extensions/dashboard-client/dist/assets/HydeDetailPanel-Dt9T7kc5.js.map +1 -0
  22. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-zKhR18_s.js → MaintenanceTab-Lm3v0nJO.js} +2 -2
  23. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-zKhR18_s.js.map → MaintenanceTab-Lm3v0nJO.js.map} +1 -1
  24. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DekIzfn2.js → MemoryMapTab-C8AeBIQi.js} +2 -2
  25. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DekIzfn2.js.map → MemoryMapTab-C8AeBIQi.js.map} +1 -1
  26. package/extensions/dashboard-client/dist/assets/{MetricsTab-CEKajY38.js → MetricsTab-m410T4vk.js} +2 -2
  27. package/extensions/dashboard-client/dist/assets/{MetricsTab-CEKajY38.js.map → MetricsTab-m410T4vk.js.map} +1 -1
  28. package/extensions/dashboard-client/dist/assets/{OverviewTab-24sG8xiE.js → OverviewTab-BfDfMFXx.js} +2 -2
  29. package/extensions/dashboard-client/dist/assets/{OverviewTab-24sG8xiE.js.map → OverviewTab-BfDfMFXx.js.map} +1 -1
  30. package/extensions/dashboard-client/dist/assets/{ReposTab-70gkV8l9.js → ReposTab-CsFxxqJ6.js} +2 -2
  31. package/extensions/dashboard-client/dist/assets/{ReposTab-70gkV8l9.js.map → ReposTab-CsFxxqJ6.js.map} +1 -1
  32. package/extensions/dashboard-client/dist/assets/SessionsTab-DstDOzwu.js +2 -0
  33. package/extensions/dashboard-client/dist/assets/SessionsTab-DstDOzwu.js.map +1 -0
  34. package/extensions/dashboard-client/dist/assets/{SetupTab-tbPrrfYx.js → SetupTab-DVT4PrH0.js} +2 -2
  35. package/extensions/dashboard-client/dist/assets/{SetupTab-tbPrrfYx.js.map → SetupTab-DVT4PrH0.js.map} +1 -1
  36. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-B6mdtCWE.js → TimeSavedCard-BkRzjyRm.js} +2 -2
  37. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-B6mdtCWE.js.map → TimeSavedCard-BkRzjyRm.js.map} +1 -1
  38. package/extensions/dashboard-client/dist/assets/TurnsTab-D5QTnv52.js +2 -0
  39. package/extensions/dashboard-client/dist/assets/TurnsTab-D5QTnv52.js.map +1 -0
  40. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-SDThp0R0.js → VcStatusBadge-B8B8RStV.js} +2 -2
  41. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-SDThp0R0.js.map → VcStatusBadge-B8B8RStV.js.map} +1 -1
  42. package/extensions/dashboard-client/dist/assets/VectorCortexTab-CrGANNd_.js +2 -0
  43. package/extensions/dashboard-client/dist/assets/VectorCortexTab-CrGANNd_.js.map +1 -0
  44. package/extensions/dashboard-client/dist/assets/{WikiTab-Cki48_8N.js → WikiTab-DyD0yGzI.js} +2 -2
  45. package/extensions/dashboard-client/dist/assets/{WikiTab-Cki48_8N.js.map → WikiTab-DyD0yGzI.js.map} +1 -1
  46. package/extensions/dashboard-client/dist/assets/{button-CojFYd7q.js → button-Bynl3ONj.js} +2 -2
  47. package/extensions/dashboard-client/dist/assets/{button-CojFYd7q.js.map → button-Bynl3ONj.js.map} +1 -1
  48. package/extensions/dashboard-client/dist/assets/{card-Cxeeje9o.js → card-Daf3pQIu.js} +2 -2
  49. package/extensions/dashboard-client/dist/assets/{card-Cxeeje9o.js.map → card-Daf3pQIu.js.map} +1 -1
  50. package/extensions/dashboard-client/dist/assets/{client-extra-DLxyGxW8.js → client-extra-DqAYZBW1.js} +2 -2
  51. package/extensions/dashboard-client/dist/assets/{client-extra-DLxyGxW8.js.map → client-extra-DqAYZBW1.js.map} +1 -1
  52. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DRlqBks2.js → generateCategoricalChart-B-fe5jjr.js} +2 -2
  53. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DRlqBks2.js.map → generateCategoricalChart-B-fe5jjr.js.map} +1 -1
  54. package/extensions/dashboard-client/dist/assets/{index-CkbdlPBm.js → index-Bjvv23bp.js} +3 -3
  55. package/extensions/dashboard-client/dist/assets/{index-CkbdlPBm.js.map → index-Bjvv23bp.js.map} +1 -1
  56. package/extensions/dashboard-client/dist/assets/{switch-Cx_nl-Ba.js → switch-CivyERPS.js} +2 -2
  57. package/extensions/dashboard-client/dist/assets/{switch-Cx_nl-Ba.js.map → switch-CivyERPS.js.map} +1 -1
  58. package/extensions/dashboard-client/dist/assets/{toggle-CfIFzp6P.js → toggle-qmdkrAgF.js} +2 -2
  59. package/extensions/dashboard-client/dist/assets/{toggle-CfIFzp6P.js.map → toggle-qmdkrAgF.js.map} +1 -1
  60. package/extensions/dashboard-client/dist/assets/{useSSE-B9_N7ccG.js → useSSE-uNuduyGe.js} +2 -2
  61. package/extensions/dashboard-client/dist/assets/{useSSE-B9_N7ccG.js.map → useSSE-uNuduyGe.js.map} +1 -1
  62. package/extensions/dashboard-client/dist/index.html +1 -1
  63. package/extensions/dashboard-client/src/dash-consolidation/plan.ts +200 -0
  64. package/extensions/dashboard-client/src/tabs/SessionsTab/TurnMemoryView.tsx +383 -0
  65. package/extensions/dashboard-client/src/tabs/SessionsTab.tsx +77 -6
  66. package/extensions/dashboard-client/src/tabs/VectorCortexTab/sections.tsx +201 -0
  67. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +168 -122
  68. package/extensions/dashboard-client/src/tabs/index.ts +30 -0
  69. package/extensions/dashboard-client/src/tabs/registry.ts +17 -0
  70. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +12 -0
  71. package/extensions/mega-runtime/widget-types.ts +2 -1
  72. package/package.json +1 -1
  73. package/src/config/vector-cortex-dash-0a.ts +24 -0
  74. package/src/config/vector-cortex-dash-0b.ts +23 -0
  75. package/src/config/vector-cortex.ts +4 -0
  76. package/src/config.ts +2 -0
  77. package/extensions/dashboard-client/dist/assets/SessionsTab-B3quvYPZ.js +0 -2
  78. package/extensions/dashboard-client/dist/assets/SessionsTab-B3quvYPZ.js.map +0 -1
  79. package/extensions/dashboard-client/dist/assets/TurnsTab-CmhRJJqr.js +0 -5
  80. package/extensions/dashboard-client/dist/assets/TurnsTab-CmhRJJqr.js.map +0 -1
  81. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DDjCkTjk.js +0 -2
  82. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DDjCkTjk.js.map +0 -1
@@ -0,0 +1,30 @@
1
+ /**
2
+ * dashboard-client/src/tabs/index.ts — additive tab barrel (DASH-0b).
3
+ *
4
+ * Re-exports the 7 fixed navigational SURFACE host components defined by the
5
+ * DASH-0a merge plan (plan.ts `DASHSurface`). These map the consolidated
6
+ * surfaces to their host components; DASH-0d rewires App.tsx's lazy list to
7
+ * this barrel. THIS SPRINT App.tsx does NOT switch to it — the barrel is purely
8
+ * additive and the break-native 13-tab surface keeps rendering as today.
9
+ *
10
+ * Host mapping (surface → component):
11
+ * - overview → OverviewTab
12
+ * - sessions → SessionsTab (TurnsTab folded in via TurnMemoryView)
13
+ * - cache-perf → CacheTab
14
+ * - memory-graph → MemoryMapTab
15
+ * - diagnostics → VectorCortexTab
16
+ * - setup → SetupTab
17
+ * - admin → AdminTab (RESERVED alias — maps to the existent
18
+ * MaintenanceTab; no standalone AdminTab.tsx yet)
19
+ *
20
+ * PREVENT-PI-004: imports only — no network. PREVENT-011: no `any`.
21
+ */
22
+
23
+ export { default as OverviewTab } from "./OverviewTab";
24
+ export { default as SessionsTab } from "./SessionsTab";
25
+ export { default as CacheTab } from "./CacheTab";
26
+ export { default as MemoryMapTab } from "./MemoryMapTab";
27
+ export { default as VectorCortexTab } from "./VectorCortexTab";
28
+ export { default as SetupTab } from "./SetupTab";
29
+ /** Reserved admin-surface alias: maps to the existent MaintenanceTab host. */
30
+ export { default as AdminTab } from "./MaintenanceTab";
@@ -58,3 +58,20 @@ export const ADVANCED_TABS: TabDef[] = [
58
58
  export const ADVANCED_TAB_IDS: ReadonlySet<TabId> = new Set(
59
59
  ADVANCED_TABS.map((t) => t.id),
60
60
  );
61
+
62
+ /**
63
+ * The fixed 7 dashboard navigation SURFACE ids from the DASH-0a merge plan
64
+ * (plan.ts `DASHSurface`). These are the consolidated surfaces consumed by the
65
+ * additive `tabs/index.ts` barrel. The existent 13-tab `TabId` union above is
66
+ * LEFT UNCHANGED (rollback-safe) — this constant documents the 7 surfaces the
67
+ * DASH-0d rewire will navigate, and deliberately does NOT replace TabId.
68
+ */
69
+ export const DASH_SURFACE_IDS: readonly string[] = [
70
+ "overview",
71
+ "sessions",
72
+ "cache-perf",
73
+ "memory-graph",
74
+ "diagnostics",
75
+ "setup",
76
+ "admin",
77
+ ] as const;
@@ -330,5 +330,17 @@ export const VECTOR_CORTEX_SETTINGS: SettingGroup = {
330
330
  "Cross-repo corpus preparation (REPO-A): the governed, consent-gated reader-only path that builds a pseudonymous corpus manifest from per-repo events.log slices and serves GET /api/repo-corpus answering which pseudonymous repos/sessions are in the corpus, what cross-repo overlap exists, and whether consent is active for each — counts + IDs + status only, never payload content. Consent is append-only (consent.mjs, CLI/ops-only); revocation freezes the builder + route. OFF = builder refuses to run, reader route 404s, single-repo recall untouched (byte-identical predecessor).",
331
331
  true,
332
332
  ),
333
+ boolDirect(
334
+ "MEGACOMPACT_DASH_0A",
335
+ "Dashboard Consolidation — Tab Plan",
336
+ "DASH-0a dashboard tab-audit + consolidation merge plan: records (as typed constants) the collapse of the 13 current TabIds onto the fixed 7 navigational surfaces (Overview, Sessions, Cache+Performance, Memory Graph, Diagnostics, Setup, Admin), plus the deep-link map, a11y nav-map, and responsive plan. Contract-planning only — no component moves, no route change. OFF = the plan module is inert (never imported by the shell); all 13 tab/section top-level files render exactly as today (byte-identical predecessor).",
337
+ true,
338
+ ),
339
+ boolDirect(
340
+ "MEGACOMPACT_DASH_0B",
341
+ "Dashboard Consolidation — Sessions/Cortex sections",
342
+ "DASH-0b dashboard consolidation execution: (1) the Sessions surface absorbs TurnsTab as a drill-down — a SessionsViews toggle renders the existent session summary/chart/table or the turns view (TurnMemoryView); (2) VectorCortexTab re-groups its flat 14-card layout under 4 <section aria-labelledby> headers (Cortex status / repair / cache / adaptive). OFF = SessionsTab renders only its own body (no toggle, no TurnMemoryView) and VectorCortexTab keeps its flat card layout (byte-identical predecessor).",
343
+ true,
344
+ ),
333
345
  ],
334
346
  };
@@ -55,7 +55,8 @@ export interface WidgetData {
55
55
  /** TUI display mode: 'full' (default) = the full stats panel; 'minimal' = a
56
56
  * one-line `LVL n | cache NN%` view flanked by panel bars. */
57
57
  tuiMode?: "full" | "minimal";
58
- /** Player level (game-mode). Stub = 1 until S33 wires the real scoring. */
58
+ /** Player level (game-mode). S33 wired the real scoring: getTurnLevelImpl
59
+ * (runtime-helpers.ts) computes floor(log2(turns+1))+1 via turnLevel. */
59
60
  level?: number;
60
61
  /** Cache hit rate as a percent (0..100+, may exceed 100 → MEGA CACHE). */
61
62
  cachePct?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mega-compact",
3
- "version": "0.20.57",
3
+ "version": "0.20.59",
4
4
  "description": "Layered, local, vector-backed context compressor for pi — supersede/collapse/cluster compaction with deduped inline recall.",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",
@@ -0,0 +1,24 @@
1
+ /**
2
+ * config/vector-cortex-dash-0a.ts — DASH-0a dashboard consolidation tab-plan flag.
3
+ *
4
+ * Extracted to this sibling (per the vector-cortex-cosfp.ts precedent) so
5
+ * src/config/vector-cortex.ts stays under the 300-line soft limit. The flag is
6
+ * positive, defaults ON, and `MEGACOMPACT_DASH_0A=0` is byte-identical to the
7
+ * predecessor: the merge plan module is never imported by the shell, so all 13
8
+ * current tab/section top-level components render exactly as today. Registered
9
+ * as a visible VECTOR_CORTEX_SETTINGS boolDirect toggle, never EXCLUDED.
10
+ *
11
+ * Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
12
+ */
13
+
14
+ import { sprintFlag } from "./vector-cortex-flag.js";
15
+
16
+ /**
17
+ * DASH-0a — dashboard tab-audit + merge plan. Default ON.
18
+ * `MEGACOMPACT_DASH_0A=0` disables and is byte-identical to the predecessor:
19
+ * the plan module (DASH_TAB_PLAN / DEEP_LINK_TARGETS / nav-map) is a static
20
+ * constant module that nothing imports at runtime, so the shell and all 13
21
+ * tab/section top-level files render exactly as today. This sprint records the
22
+ * plan only; DASH-0b/0c/0d consume it.
23
+ */
24
+ export const DASH_0A_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_DASH_0A");
@@ -0,0 +1,23 @@
1
+ /**
2
+ * config/vector-cortex-dash-0b.ts — DASH-0b dashboard consolidation execution flag.
3
+ *
4
+ * Extracted to this sibling (per the vector-cortex-dash-0a.ts precedent) so
5
+ * src/config/vector-cortex.ts stays under the 300-line soft limit. The flag is
6
+ * positive, defaults ON, and `MEGACOMPACT_DASH_0B=0` is byte-identical to the
7
+ * predecessor: SessionsTab and TurnsTab render as two independent top-level
8
+ * surfaces and VectorCortexTab keeps its flat card layout. Registered as a
9
+ * visible VECTOR_CORTEX_SETTINGS boolDirect toggle, never EXCLUDED.
10
+ *
11
+ * Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
12
+ */
13
+
14
+ import { sprintFlag } from "./vector-cortex-flag.js";
15
+
16
+ /**
17
+ * DASH-0b — first execution sprint of the DASH consolidation plan:
18
+ * (1) Sessions surface absorbs TurnsTab as a drill-down via TurnMemoryView,
19
+ * (2) VectorCortexTab re-groups its flat cards under 4 `<section>` headers.
20
+ * `MEGACOMPACT_DASH_0B=0` renders the pre-DASH surfaces independently and the
21
+ * flat 14-card VectorCortexTab layout — byte-identical predecessor.
22
+ */
23
+ export const DASH_0B_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_DASH_0B");
@@ -69,6 +69,10 @@ export { COSINE_FP_REAL_ENABLED } from "./vector-cortex-cosfp-real.js";
69
69
  // REPO-A cross-repo corpus prep flag extracted to repo-corpus.ts (no vector-cortex
70
70
  // prefix per spec); re-exported so root src/config.ts barrel resolves unchanged.
71
71
  export { REPO_CORPUS_ENABLED } from "./repo-corpus.js";
72
+ // DASH-0a dashboard consolidation tab-plan flag extracted to vector-cortex-dash-0a.ts.
73
+ export { DASH_0A_ENABLED } from "./vector-cortex-dash-0a.js";
74
+ // DASH-0b dashboard consolidation execution flag extracted to vector-cortex-dash-0b.ts.
75
+ export { DASH_0B_ENABLED } from "./vector-cortex-dash-0b.js";
72
76
  export { ENC_1A_ENABLED } from "./vector-cortex-enc1a.js";
73
77
  export {
74
78
  ENC_1B_ENABLED,
package/src/config.ts CHANGED
@@ -205,6 +205,8 @@ export {
205
205
  COSINE_FP_BENCH_ENABLED,
206
206
  COSINE_FP_REAL_ENABLED,
207
207
  REPO_CORPUS_ENABLED,
208
+ DASH_0A_ENABLED,
209
+ DASH_0B_ENABLED,
208
210
  BREAKER_WINDOW_MS,
209
211
  BREAKER_MIN_ATTEMPTS,
210
212
  BREAKER_PERF_FAILURES,
@@ -1,2 +0,0 @@
1
- import{r as d,j as e,u as b,b as M,D as A}from"./index-CkbdlPBm.js";import{u as C}from"./useSSE-B9_N7ccG.js";import{C as c,c as m}from"./card-Cxeeje9o.js";import{R as I,C as T,X as D,Y as L,T as E,a as F,L as W}from"./generateCategoricalChart-DRlqBks2.js";import{A as R,a as z}from"./AreaChart-CtJ6dSMT.js";import{T as P}from"./toggle-CfIFzp6P.js";function O(s,i){const n=new Map,o=s.map(t=>t.sessionId);for(const t of s)for(const r of t.data){let a=n.get(r.ts);if(!a){a={ts:r.ts,total:0};for(const l of o)a[l]=0;n.set(r.ts,a)}a[t.sessionId]=r.tokens}for(const t of i){let r=n.get(t.ts);if(!r){r={ts:t.ts,total:0};for(const a of o)r[a]=0;n.set(t.ts,r)}r.total=t.tokens}return[...n.values()].sort((t,r)=>t.ts-r.ts)}function v(s){return new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function k(s){const i=Number(s);return Number.isFinite(i)?i.toLocaleString():String(s)}function N(s){return`grad-${s.replace(/[^a-zA-Z0-9_-]/g,"_")}`}function G({series:s,totals:i}){const n=d.useMemo(()=>O(s,i),[s,i]);return s.length===0?e.jsx(c,{children:e.jsx(m,{children:"No token samples in this window yet."})}):e.jsx(c,{children:e.jsx(m,{children:e.jsx(I,{width:"100%",height:360,children:e.jsxs(R,{data:n,margin:{top:8,right:16,left:0,bottom:0},children:[e.jsx("defs",{children:s.map(o=>e.jsxs("linearGradient",{id:N(o.sessionId),x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:o.color,stopOpacity:.7}),e.jsx("stop",{offset:"95%",stopColor:o.color,stopOpacity:.25})]},`${o.sessionId}-grad`))}),e.jsx(T,{strokeDasharray:"3 3",stroke:"#30363d"}),e.jsx(D,{dataKey:"ts",type:"number",domain:["dataMin","dataMax"],tickFormatter:o=>v(o),stroke:"#8b949e",tick:{fontSize:11},scale:"time"}),e.jsx(L,{stroke:"#8b949e",tick:{fontSize:11},width:56,tickFormatter:o=>k(o)}),e.jsx(E,{labelFormatter:o=>v(o),formatter:o=>[k(o),"tokens"],contentStyle:{background:"#161b22",border:"1px solid #30363d",borderRadius:"6px",color:"#e6edf3"},labelStyle:{color:"#8b949e",fontSize:12}}),e.jsx(F,{wrapperStyle:{fontSize:12}}),s.map(o=>e.jsx(z,{type:"monotone",dataKey:o.sessionId,name:o.label,stackId:"1",stroke:o.color,fill:`url(#${N(o.sessionId)})`,fillOpacity:1,isAnimationActive:!1,dot:!1},o.sessionId)),e.jsx(W,{type:"monotone",dataKey:"total",name:"Total",stroke:"#e6edf3",strokeWidth:1.5,strokeDasharray:"4 2",dot:!1,isAnimationActive:!1})]})})})})}const y=["PID","Repo","Model","Context %","Tokens / Window","Last Heartbeat","State Dir","Trend"];function K(s){const i=Math.max(0,Math.round(s/1e3));if(i<60)return`${i}s ago`;const n=Math.floor(i/60);return n<60?`${n}m ${i%60}s ago`:`${Math.floor(n/60)}h ${n%60}m ago`}function S(s){return s==null?"—":s>=1e5?`${(s/1e3).toFixed(0)}k`:s>=1e3?`${(s/1e3).toFixed(1)}k`:s.toLocaleString()}function X(s){return s==null?"sessions-pct-ok":s>=85?"sessions-pct-err":s>=60?"sessions-pct-warn":"sessions-pct-ok"}function _(s){return s==null?"—":`${Math.round(s)}%`}function B(s,i){return s==null?"—":`${S(s)} / ${S(i)}`}function H({points:s,color:i}){if(s.length<2)return e.jsx("span",{className:"sessions-sparkline-empty",children:"—"});const n=Math.min(...s),t=Math.max(...s)-n||1,r=64,a=18,l=r/(s.length-1),x=s.map((u,h)=>{const j=h*l,p=a-(u-n)/t*a;return`${h===0?"M":"L"} ${j.toFixed(1)} ${p.toFixed(1)}`});return e.jsx("svg",{className:"sessions-sparkline",width:r,height:a,viewBox:`0 0 ${r} ${a}`,role:"img","aria-label":"token trend",children:e.jsx("path",{d:x.join(" "),fill:"none",stroke:i,strokeWidth:"1.5",strokeLinejoin:"round",strokeLinecap:"round"})})}function Y(s){const i=new Map;for(const n of s)i.set(n.sessionId,n);return i}function Z({sessions:s,series:i}){const n=Y(i),o=Date.now();return e.jsx(c,{children:e.jsx(m,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{children:y.map((t,r)=>e.jsx("th",{className:`border-b border-border px-3 py-2 text-left font-medium text-muted-foreground${r>=3&&r!==6?" text-right":""}`,children:t},t))})}),e.jsxs("tbody",{children:[s.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:y.length,className:"px-3 py-4 text-muted-foreground",children:"No active sessions."})}),s.map(t=>{const r=n.get(t.sessionId),a=r?.data.map(x=>x.tokens)??[],l=r?.color??"#58a6ff";return e.jsxs("tr",{className:"border-b border-border/50 hover:bg-bg-elevated/40",children:[e.jsx("td",{className:"px-3 py-2 text-right font-mono",children:t.pid}),e.jsx("td",{className:"px-3 py-2",title:t.repoRoot??void 0,children:t.displayName||t.repoRoot||"—"}),e.jsx("td",{className:"px-3 py-2",children:t.model??"—"}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("span",{className:`sessions-pct-pill ${X(t.percent)}`,children:_(t.percent)})}),e.jsx("td",{className:"px-3 py-2 text-right",children:B(t.tokens,t.ctxWindow)}),e.jsx("td",{className:"px-3 py-2 text-right",children:K(o-t.lastSeen)}),e.jsx("td",{title:t.stateDir??void 0,className:"px-3 py-2 font-mono text-muted-foreground",children:t.stateDir?t.stateDir.split("/").pop()||t.stateDir:"—"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(H,{points:a,color:l})})]},`${t.pid}:${t.sessionId}`)})]})]})})})})}function q(s){return s.type==="session_sample"}const w=[{value:5,label:"5m"},{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"60m"}];function J({sessions:s}){const i=s.sessions.length,n=s.sessions.reduce((r,a)=>r+(a.tokens??0),0),o=s.sessions.reduce((r,a)=>Math.max(r,a.ctxWindow),0),t=o>0?n/o*100:0;return e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(c,{children:e.jsxs(m,{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Active sessions"}),e.jsx("div",{className:"text-xl font-semibold",children:i})]})}),e.jsx(c,{children:e.jsxs(m,{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Combined tokens"}),e.jsx("div",{className:"text-xl font-semibold",children:n>=1e5?`${(n/1e3).toFixed(0)}k`:n.toLocaleString()})]})}),e.jsx(c,{children:e.jsxs(m,{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Combined % of max window"}),e.jsxs("div",{className:"text-xl font-semibold",children:[Math.round(t),"%"]})]})}),e.jsx(c,{children:e.jsxs(m,{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Pruned (stale)"}),e.jsx("div",{className:"text-xl font-semibold",children:s.pruned})]})})]})}function ne(){const[s,i]=d.useState(30),{data:n,error:o,refetch:t}=b(d.useCallback(()=>M(),[]),{pollInterval:2e3}),{data:r,error:a,refetch:l}=b(d.useCallback(()=>A(s),[s]),{pollInterval:2e3}),{events:x}=C(),u=d.useMemo(()=>x.filter(q),[x]),h=d.useMemo(()=>u.length===0?null:u[u.length-1].ts,[u]);if(d.useEffect(()=>{h!=null&&(t(),l())},[h,t,l]),o&&!n)return e.jsxs("div",{className:"tab-stub",children:["Error loading sessions: ",o.message]});if(a&&!r)return e.jsxs("div",{className:"tab-stub",children:["Error loading timeseries: ",a.message]});if(!n)return e.jsx("div",{className:"tab-stub",children:"Loading sessions…"});const j=n.sessions,p=r?.series??[],g=r?.totals??[],$=w.find(f=>f.value===s)?.label??`${s}m`;return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-heading text-lg font-semibold",children:"Session Memory Graph"}),e.jsx("div",{className:"flex gap-2",children:w.map(f=>e.jsx(P,{pressed:s===f.value,onClick:()=>i(f.value),children:f.label},f.value))})]}),j.length===0?e.jsx("div",{className:"text-sm text-muted-foreground",children:"No active sessions."}):e.jsxs(e.Fragment,{children:[e.jsx(J,{sessions:n}),e.jsx(G,{series:p,totals:g}),e.jsx("h2",{className:"font-heading text-lg font-semibold",children:"Active Sessions"}),e.jsx(Z,{sessions:j,series:p}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.length," series · ",g.length," timestamps ·"," ",$," window · updated"," ",r?.updatedAt??n.updatedAt]})]})]})}export{ne as default};
2
- //# sourceMappingURL=SessionsTab-B3quvYPZ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SessionsTab-B3quvYPZ.js","sources":["../../src/components/SessionsMemoryChart.tsx","../../src/components/ActiveSessionsTable.tsx","../../src/tabs/SessionsTab.tsx"],"sourcesContent":["/**\n * dashboard-client/src/components/SessionsMemoryChart.tsx — Stacked memory graph (S39).\n *\n * Recharts stacked `<Area>` per session + total `<Line>` + `<Tooltip>` +\n * `<Legend>` + `<ResponsiveContainer>`. Data comes from `/api/sessions/timeseries`\n * which returns `SessionSeries[]` (per-session data points + stable hex color)\n * and a `totals[]` array (sum across all sessions per timestamp).\n *\n * PREVENT-PI-004: recharts is bundled into this localhost-served static\n * dashboard bundle; it makes no runtime network calls. Chart data arrives via\n * same-origin fetch to the dashboard server (loopback, ports 9320–9329).\n */\n\nimport type React from \"react\";\nimport { useMemo } from \"react\";\nimport {\n\tResponsiveContainer,\n\tAreaChart,\n\tArea,\n\tLine,\n\tXAxis,\n\tYAxis,\n\tCartesianGrid,\n\tTooltip,\n\tLegend,\n} from \"recharts\";\nimport type { SessionSeries } from \"@contracts\";\nimport { Card, CardContent } from \"../components/ui/card\";\n\nexport interface SessionsMemoryChartProps {\n\t/** Per-session series with stable colors (from /api/sessions/timeseries). */\n\tseries: SessionSeries[];\n\t/** Totals (sum across all sessions) per timestamp. */\n\ttotals: ReadonlyArray<{ ts: number; tokens: number }>;\n}\n\n/** A row in the pivoted data table passed to recharts `<AreaChart>`. */\ninterface PivotedRow {\n\t/** Unix timestamp (ms). */\n\tts: number;\n\t/** Total tokens across all sessions at this timestamp. */\n\ttotal: number;\n\t/** Per-session token count keyed by sessionId. */\n\t[sessionId: string]: number;\n}\n\n/**\n * Pivot the per-session series + totals into recharts' expected flat shape:\n * one row per unique timestamp, with each session's token count as a column\n * keyed by sessionId. Missing values for a session at a given timestamp are\n * filled with zero so the stack renders continuously.\n */\nfunction pivot(\n\tseries: SessionSeries[],\n\ttotals: ReadonlyArray<{ ts: number; tokens: number }>,\n): PivotedRow[] {\n\tconst map = new Map<number, PivotedRow>();\n\tconst sessionIds = series.map((s) => s.sessionId);\n\n\tfor (const s of series) {\n\t\tfor (const pt of s.data) {\n\t\t\tlet row = map.get(pt.ts);\n\t\t\tif (!row) {\n\t\t\t\trow = { ts: pt.ts, total: 0 } as PivotedRow;\n\t\t\t\tfor (const sid of sessionIds) row[sid] = 0;\n\t\t\t\tmap.set(pt.ts, row);\n\t\t\t}\n\t\t\trow[s.sessionId] = pt.tokens;\n\t\t}\n\t}\n\tfor (const t of totals) {\n\t\tlet row = map.get(t.ts);\n\t\tif (!row) {\n\t\t\trow = { ts: t.ts, total: 0 } as PivotedRow;\n\t\t\tfor (const sid of sessionIds) row[sid] = 0;\n\t\t\tmap.set(t.ts, row);\n\t\t}\n\t\trow.total = t.tokens;\n\t}\n\n\treturn [...map.values()].sort((a, b) => a.ts - b.ts);\n}\n\nfunction fmtTs(ts: number): string {\n\treturn new Date(ts).toLocaleTimeString([], {\n\t\thour: \"2-digit\",\n\t\tminute: \"2-digit\",\n\t\tsecond: \"2-digit\",\n\t});\n}\n\nfunction fmtTokens(value: number | string): string {\n\tconst n = Number(value);\n\treturn Number.isFinite(n) ? n.toLocaleString() : String(value);\n}\n\n/** Sanitize an arbitrary sessionId for use in an SVG gradient id. */\nfunction gradId(sessionId: string): string {\n\tconst safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, \"_\");\n\treturn `grad-${safe}`;\n}\n\nexport function SessionsMemoryChart({\n\tseries,\n\ttotals,\n}: SessionsMemoryChartProps): React.ReactElement {\n\tconst data = useMemo(\n\t\t() => pivot(series, totals),\n\t\t[series, totals],\n\t);\n\n\tif (series.length === 0) {\n\t\treturn (\n\t\t\t<Card>\n\t\t\t\t<CardContent>No token samples in this window yet.</CardContent>\n\t\t\t</Card>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Card>\n\t\t\t<CardContent>\n\t\t\t<ResponsiveContainer width=\"100%\" height={360}>\n\t\t\t\t<AreaChart\n\t\t\t\t\tdata={data}\n\t\t\t\t\tmargin={{ top: 8, right: 16, left: 0, bottom: 0 }}\n\t\t\t\t>\n\t\t\t\t\t<defs>\n\t\t\t\t\t\t{series.map((s) => (\n\t\t\t\t\t\t\t<linearGradient\n\t\t\t\t\t\t\t\tkey={`${s.sessionId}-grad`}\n\t\t\t\t\t\t\t\tid={gradId(s.sessionId)}\n\t\t\t\t\t\t\t\tx1=\"0\"\n\t\t\t\t\t\t\t\ty1=\"0\"\n\t\t\t\t\t\t\t\tx2=\"0\"\n\t\t\t\t\t\t\t\ty2=\"1\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<stop offset=\"5%\" stopColor={s.color} stopOpacity={0.7} />\n\t\t\t\t\t\t\t\t<stop offset=\"95%\" stopColor={s.color} stopOpacity={0.25} />\n\t\t\t\t\t\t\t</linearGradient>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</defs>\n\t\t\t\t\t<CartesianGrid strokeDasharray=\"3 3\" stroke=\"#30363d\" />\n\t\t\t\t\t<XAxis\n\t\t\t\t\t\tdataKey=\"ts\"\n\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\tdomain={[\"dataMin\", \"dataMax\"]}\n\t\t\t\t\t\ttickFormatter={(ts: number) => fmtTs(ts)}\n\t\t\t\t\t\tstroke=\"#8b949e\"\n\t\t\t\t\t\ttick={{ fontSize: 11 }}\n\t\t\t\t\t\tscale=\"time\"\n\t\t\t\t\t/>\n\t\t\t\t\t<YAxis\n\t\t\t\t\t\tstroke=\"#8b949e\"\n\t\t\t\t\t\ttick={{ fontSize: 11 }}\n\t\t\t\t\t\twidth={56}\n\t\t\t\t\t\ttickFormatter={(v: number) => fmtTokens(v)}\n\t\t\t\t\t/>\n\t\t\t\t\t<Tooltip\n\t\t\t\t\t\tlabelFormatter={(ts: number) => fmtTs(ts)}\n\t\t\t\t\t\tformatter={(value) =>\n\t\t\t\t\t\t\t[fmtTokens(value as number), \"tokens\"] as [string, string]\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontentStyle={{\n\t\t\t\t\t\t\tbackground: \"#161b22\",\n\t\t\t\t\t\t\tborder: \"1px solid #30363d\",\n\t\t\t\t\t\t\tborderRadius: \"6px\",\n\t\t\t\t\t\t\tcolor: \"#e6edf3\",\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tlabelStyle={{ color: \"#8b949e\", fontSize: 12 }}\n\t\t\t\t\t/>\n\t\t\t\t\t<Legend wrapperStyle={{ fontSize: 12 }} />\n\t\t\t\t\t{series.map((s) => (\n\t\t\t\t\t\t<Area\n\t\t\t\t\t\t\tkey={s.sessionId}\n\t\t\t\t\t\t\ttype=\"monotone\"\n\t\t\t\t\t\t\tdataKey={s.sessionId}\n\t\t\t\t\t\t\tname={s.label}\n\t\t\t\t\t\t\tstackId=\"1\"\n\t\t\t\t\t\t\tstroke={s.color}\n\t\t\t\t\t\t\tfill={`url(#${gradId(s.sessionId)})`}\n\t\t\t\t\t\t\tfillOpacity={1}\n\t\t\t\t\t\t\tisAnimationActive={false}\n\t\t\t\t\t\t\tdot={false}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t\t<Line\n\t\t\t\t\t\ttype=\"monotone\"\n\t\t\t\t\t\tdataKey=\"total\"\n\t\t\t\t\t\tname=\"Total\"\n\t\t\t\t\t\tstroke=\"#e6edf3\"\n\t\t\t\t\t\tstrokeWidth={1.5}\n\t\t\t\t\t\tstrokeDasharray=\"4 2\"\n\t\t\t\t\t\tdot={false}\n\t\t\t\t\t\tisAnimationActive={false}\n\t\t\t\t\t/>\n\t\t\t\t</AreaChart>\n\t\t\t</ResponsiveContainer>\n\t\t\t</CardContent>\n\t\t</Card>\n\t);\n}\n","/**\n * dashboard-client/src/components/ActiveSessionsTable.tsx — Active sessions table (S39).\n *\n * Per-session rows: PID, Repo, Model, Context %, Tokens/Window,\n * Heartbeat age, State dir, Sparkline.\n *\n * Data from /api/sessions (active sessions list) and /api/sessions/timeseries\n * (per-session data points used to render inline sparklines).\n */\n\nimport type React from \"react\";\nimport type { ActiveSession, SessionSeries } from \"@contracts\";\nimport { Card, CardContent } from \"../components/ui/card\";\n\nexport interface ActiveSessionsTableProps {\n\t/** Active sessions, sorted by lastSeen descending (from /api/sessions). */\n\tsessions: ActiveSession[];\n\t/** Per-session timeseries used to render the inline sparkline column. */\n\tseries: SessionSeries[];\n}\n\nconst HEADERS = [\n\t\"PID\",\n\t\"Repo\",\n\t\"Model\",\n\t\"Context %\",\n\t\"Tokens / Window\",\n\t\"Last Heartbeat\",\n\t\"State Dir\",\n\t\"Trend\",\n] as const;\n\n/** Format a duration in milliseconds → human-readable age string. */\nfunction fmtAge(ms: number): string {\n\tconst s = Math.max(0, Math.round(ms / 1000));\n\tif (s < 60) return `${s}s ago`;\n\tconst m = Math.floor(s / 60);\n\tif (m < 60) return `${m}m ${s % 60}s ago`;\n\tconst h = Math.floor(m / 60);\n\treturn `${h}h ${m % 60}m ago`;\n}\n\nfunction fmtTokens(n: number | null): string {\n\tif (n == null) return \"\\u2014\";\n\tif (n >= 100_000) return `${(n / 1000).toFixed(0)}k`;\n\tif (n >= 1000) return `${(n / 1000).toFixed(1)}k`;\n\treturn n.toLocaleString();\n}\n\nfunction pctClass(pct: number | null): string {\n\tif (pct == null) return \"sessions-pct-ok\";\n\tif (pct >= 85) return \"sessions-pct-err\";\n\tif (pct >= 60) return \"sessions-pct-warn\";\n\treturn \"sessions-pct-ok\";\n}\n\nfunction fmtPct(pct: number | null): string {\n\tif (pct == null) return \"\\u2014\";\n\treturn `${Math.round(pct)}%`;\n}\n\nfunction fmtWindow(tokens: number | null, window: number): string {\n\tif (tokens == null) return \"\\u2014\";\n\treturn `${fmtTokens(tokens)} / ${fmtTokens(window)}`;\n}\n\ninterface SparklineProps {\n\t/** Token counts over time (oldest → newest). */\n\tpoints: number[];\n\t/** Stable hex color for the stroke. */\n\tcolor: string;\n}\n\nfunction Sparkline({ points, color }: SparklineProps): React.ReactElement {\n\tif (points.length < 2) {\n\t\treturn <span className=\"sessions-sparkline-empty\">{\"\\u2014\"}</span>;\n\t}\n\tconst min = Math.min(...points);\n\tconst max = Math.max(...points);\n\tconst range = max - min || 1;\n\tconst w = 64;\n\tconst h = 18;\n\tconst stepX = w / (points.length - 1);\n\tconst segments = points.map((p, i) => {\n\t\tconst x = i * stepX;\n\t\tconst y = h - ((p - min) / range) * h;\n\t\treturn `${i === 0 ? \"M\" : \"L\"} ${x.toFixed(1)} ${y.toFixed(1)}`;\n\t});\n\treturn (\n\t\t<svg\n\t\t\tclassName=\"sessions-sparkline\"\n\t\t\twidth={w}\n\t\t\theight={h}\n\t\t\tviewBox={`0 0 ${w} ${h}`}\n\t\t\trole=\"img\"\n\t\t\taria-label=\"token trend\"\n\t\t>\n\t\t\t<path\n\t\t\t\td={segments.join(\" \")}\n\t\t\t\tfill=\"none\"\n\t\t\t\tstroke={color}\n\t\t\t\tstrokeWidth=\"1.5\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\n/** Map sessionId → series for the sparkline column lookup. */\nfunction indexSeries(\n\tseries: SessionSeries[],\n): Map<string, SessionSeries> {\n\tconst m = new Map<string, SessionSeries>();\n\tfor (const s of series) m.set(s.sessionId, s);\n\treturn m;\n}\n\nexport function ActiveSessionsTable({\n\tsessions,\n\tseries,\n}: ActiveSessionsTableProps): React.ReactElement {\n\tconst seriesById = indexSeries(series);\n\tconst now = Date.now();\n\n\treturn (\n\t\t<Card>\n\t\t\t<CardContent>\n\t\t\t<div className=\"overflow-x-auto\">\n\t\t\t\t<table className=\"w-full border-collapse text-sm\">\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t{HEADERS.map((h, i) => (\n\t\t\t\t\t\t\t\t<th\n\t\t\t\t\t\t\t\t\tkey={h}\n\t\t\t\t\t\t\t\t\tclassName={`border-b border-border px-3 py-2 text-left font-medium text-muted-foreground${\n\t\t\t\t\t\t\t\t\t\ti >= 3 && i !== 6 ? \" text-right\" : \"\"\n\t\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{h}\n\t\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t{sessions.length === 0 && (\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td colSpan={HEADERS.length} className=\"px-3 py-4 text-muted-foreground\">\n\t\t\t\t\t\t\t\t\tNo active sessions.\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{sessions.map((s) => {\n\t\t\t\t\t\t\tconst srs = seriesById.get(s.sessionId);\n\t\t\t\t\t\t\tconst sparkPts =\n\t\t\t\t\t\t\t\tsrs?.data.map((d) => d.tokens) ?? [];\n\t\t\t\t\t\t\tconst color = srs?.color ?? \"#58a6ff\";\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<tr\n\t\t\t\t\t\t\t\t\tkey={`${s.pid}:${s.sessionId}`}\n\t\t\t\t\t\t\t\t\tclassName=\"border-b border-border/50 hover:bg-bg-elevated/40\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<td className=\"px-3 py-2 text-right font-mono\">{s.pid}</td>\n\t\t\t\t\t\t\t\t\t<td className=\"px-3 py-2\" title={s.repoRoot ?? undefined}>\n\t\t\t\t\t\t\t\t\t\t{s.displayName || s.repoRoot || \"\\u2014\"}\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td className=\"px-3 py-2\">{s.model ?? \"\\u2014\"}</td>\n\t\t\t\t\t\t\t\t\t<td className=\"px-3 py-2 text-right\">\n\t\t\t\t\t\t\t\t\t\t<span className={`sessions-pct-pill ${pctClass(s.percent)}`}>\n\t\t\t\t\t\t\t\t\t\t\t{fmtPct(s.percent)}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td className=\"px-3 py-2 text-right\">\n\t\t\t\t\t\t\t\t\t\t{fmtWindow(s.tokens, s.ctxWindow)}\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td className=\"px-3 py-2 text-right\">{fmtAge(now - s.lastSeen)}</td>\n\t\t\t\t\t\t\t\t\t<td\n\t\t\t\t\t\t\t\t\t\ttitle={s.stateDir ?? undefined}\n\t\t\t\t\t\t\t\t\t\tclassName=\"px-3 py-2 font-mono text-muted-foreground\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{s.stateDir\n\t\t\t\t\t\t\t\t\t\t\t? s.stateDir.split(\"/\").pop() || s.stateDir\n\t\t\t\t\t\t\t\t\t\t\t: \"\\u2014\"}\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td className=\"px-3 py-2\">\n\t\t\t\t\t\t\t\t\t\t<Sparkline points={sparkPts} color={color} />\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t})}\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t\t</CardContent>\n\t\t</Card>\n\t);\n}\n","/**\n * dashboard-client/src/tabs/SessionsTab.tsx — Sessions tab (S39).\n *\n * Renders: window selector (5/15/30/60 min), sessions summary tiles,\n * the stacked-memory graph (SessionsMemoryChart), and the active sessions\n * table (ActiveSessionsTable).\n *\n * Data sources: fetchSessions() + fetchSessionTimeseries(minutes). Both poll\n * every 2s for near-real-time updates. useSSE() listens for session_sample\n * events emitted by appendTokenSample (Step 5) so the chart refetches\n * instantly between polls when a new token sample is appended to events.log.\n *\n * Empty state: shows \"No active sessions.\" when the /api/sessions response\n * returns an empty array (e.g. no pi processes are running yet).\n */\n\nimport type React from \"react\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { useApi } from \"../hooks/useApi\";\nimport { useSSE } from \"../hooks/useSSE\";\nimport { fetchSessions, fetchSessionTimeseries } from \"../api/client\";\nimport type { SseEvent, SseSessionSample, SessionsResponse, SessionTimeseriesResponse } from \"@contracts\";\nimport { SessionsMemoryChart } from \"../components/SessionsMemoryChart\";\nimport { ActiveSessionsTable } from \"../components/ActiveSessionsTable\";\nimport { Toggle } from \"../components/ui/toggle\";\nimport { Card, CardContent } from \"../components/ui/card\";\n\n/**\n * Shape of the {@link SseSessionSample} SSE event appended to events.log by\n * `appendTokenSample` (src/store/sqlite/global-index.ts). The contract now\n * defines this variant as part of the {@link SseEvent} union (Step 5); the\n * local alias keeps the surface terser in this file.\n */\ntype SessionSampleEvent = SseSessionSample;\n\n/** Type guard: narrows an SSE event to a session_sample event. */\nfunction isSessionSample(\n\te: SseEvent,\n): e is SessionSampleEvent {\n\treturn e.type === \"session_sample\";\n}\n\nconst WINDOWS: ReadonlyArray<{ value: number; label: string }> = [\n\t{ value: 5, label: \"5m\" },\n\t{ value: 15, label: \"15m\" },\n\t{ value: 30, label: \"30m\" },\n\t{ value: 60, label: \"60m\" },\n] as const;\n\ninterface SummaryTilesProps {\n\tsessions: SessionsResponse;\n}\n\nfunction SummaryTiles({ sessions }: SummaryTilesProps): React.ReactElement {\n\tconst active = sessions.sessions.length;\n\tconst combinedTokens = sessions.sessions.reduce(\n\t\t(sum, s) => sum + (s.tokens ?? 0),\n\t\t0,\n\t);\n\tconst maxWindow = sessions.sessions.reduce(\n\t\t(max, s) => Math.max(max, s.ctxWindow),\n\t\t0,\n\t);\n\tconst combinedPct = maxWindow > 0 ? (combinedTokens / maxWindow) * 100 : 0;\n\treturn (\n\t\t<div className=\"grid grid-cols-2 gap-4 md:grid-cols-4\">\n\t\t\t<Card>\n\t\t\t\t<CardContent>\n\t\t\t\t\t<span className=\"text-xs text-muted-foreground\">Active sessions</span>\n\t\t\t\t\t<div className=\"text-xl font-semibold\">{active}</div>\n\t\t\t\t</CardContent>\n\t\t\t</Card>\n\t\t\t<Card>\n\t\t\t\t<CardContent>\n\t\t\t\t\t<span className=\"text-xs text-muted-foreground\">Combined tokens</span>\n\t\t\t\t\t<div className=\"text-xl font-semibold\">\n\t\t\t\t\t\t{combinedTokens >= 100_000\n\t\t\t\t\t\t\t? `${(combinedTokens / 1000).toFixed(0)}k`\n\t\t\t\t\t\t\t: combinedTokens.toLocaleString()}\n\t\t\t\t\t</div>\n\t\t\t\t</CardContent>\n\t\t\t</Card>\n\t\t\t<Card>\n\t\t\t\t<CardContent>\n\t\t\t\t\t<span className=\"text-xs text-muted-foreground\">\n\t\t\t\t\t\tCombined % of max window\n\t\t\t\t\t</span>\n\t\t\t\t\t<div className=\"text-xl font-semibold\">{Math.round(combinedPct)}%</div>\n\t\t\t\t</CardContent>\n\t\t\t</Card>\n\t\t\t<Card>\n\t\t\t\t<CardContent>\n\t\t\t\t\t<span className=\"text-xs text-muted-foreground\">Pruned (stale)</span>\n\t\t\t\t\t<div className=\"text-xl font-semibold\">{sessions.pruned}</div>\n\t\t\t\t</CardContent>\n\t\t\t</Card>\n\t\t</div>\n\t);\n}\n\nexport default function SessionsTab(): React.ReactElement {\n\tconst [minutes, setMinutes] = useState(30);\n\n\tconst {\n\t\tdata: sessionsData,\n\t\terror: sessionsErr,\n\t\trefetch: refetchSessions,\n\t} = useApi<SessionsResponse>(\n\t\tuseCallback(() => fetchSessions(), []),\n\t\t{ pollInterval: 2_000 },\n\t);\n\n\tconst {\n\t\tdata: timeseriesData,\n\t\terror: timeseriesErr,\n\t\trefetch: refetchTimeseries,\n\t} = useApi<SessionTimeseriesResponse>(\n\t\tuseCallback(() => fetchSessionTimeseries(minutes), [minutes]),\n\t\t{ pollInterval: 2_000 },\n\t);\n\n\tconst { events } = useSSE();\n\n\t// Filter SSE events for session_sample pushes (Step 5) and trigger an\n\t// immediate refetch when a new sample arrives, so the chart updates\n\t// between the 2s polls. The events array grows as new samples arrive; the\n\t// length-based dependency means the effect re-runs when a new sample event\n\t// lands (not on every poll). We debounce via a microtask guard.\n\tconst sampleEvents = useMemo(\n\t\t() => events.filter(isSessionSample),\n\t\t[events],\n\t);\n\n\tconst lastSampleTs = useMemo(() => {\n\t\tif (sampleEvents.length === 0) return null;\n\t\treturn sampleEvents[sampleEvents.length - 1].ts;\n\t}, [sampleEvents]);\n\n\tuseEffect(() => {\n\t\tif (lastSampleTs == null) return;\n\t\trefetchSessions();\n\t\trefetchTimeseries();\n\t}, [lastSampleTs, refetchSessions, refetchTimeseries]);\n\n\tif (sessionsErr && !sessionsData) {\n\t\treturn (\n\t\t\t<div className=\"tab-stub\">\n\t\t\t\tError loading sessions: {sessionsErr.message}\n\t\t\t</div>\n\t\t);\n\t}\n\tif (timeseriesErr && !timeseriesData) {\n\t\treturn (\n\t\t\t<div className=\"tab-stub\">\n\t\t\t\tError loading timeseries: {timeseriesErr.message}\n\t\t\t</div>\n\t\t);\n\t}\n\tif (!sessionsData) {\n\t\treturn <div className=\"tab-stub\">Loading sessions…</div>;\n\t}\n\n\tconst sessions = sessionsData.sessions;\n\tconst series = timeseriesData?.series ?? [];\n\tconst totals = timeseriesData?.totals ?? [];\n\tconst windowLabel =\n\t\tWINDOWS.find((w) => w.value === minutes)?.label ?? `${minutes}m`;\n\n\treturn (\n\t\t<div className=\"flex flex-col gap-4\">\n\t\t\t<div className=\"flex items-center justify-between\">\n\t\t\t\t<h2 className=\"font-heading text-lg font-semibold\">\n\t\t\t\t\tSession Memory Graph\n\t\t\t\t</h2>\n\t\t\t\t<div className=\"flex gap-2\">\n\t\t\t\t\t{WINDOWS.map((w) => (\n\t\t\t\t\t\t<Toggle\n\t\t\t\t\t\t\tkey={w.value}\n\t\t\t\t\t\t\tpressed={minutes === w.value}\n\t\t\t\t\t\t\tonClick={() => setMinutes(w.value)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{w.label}\n\t\t\t\t\t\t</Toggle>\n\t\t\t\t\t))}\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t{sessions.length === 0 ? (\n\t\t\t\t<div className=\"text-sm text-muted-foreground\">No active sessions.</div>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<SummaryTiles sessions={sessionsData} />\n\t\t\t\t\t<SessionsMemoryChart series={series} totals={totals} />\n\t\t\t\t\t<h2 className=\"font-heading text-lg font-semibold\">\n\t\t\t\t\t\tActive Sessions\n\t\t\t\t\t</h2>\n\t\t\t\t\t<ActiveSessionsTable sessions={sessions} series={series} />\n\t\t\t\t\t<div className=\"text-xs text-muted-foreground\">\n\t\t\t\t\t\t{series.length} series · {totals.length} timestamps ·{\" \"}\n\t\t\t\t\t\t{windowLabel} window · updated{\" \"}\n\t\t\t\t\t\t{timeseriesData?.updatedAt ?? sessionsData.updatedAt}\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"names":["pivot","series","totals","map","sessionIds","s","pt","row","sid","a","b","fmtTs","ts","fmtTokens","value","n","gradId","sessionId","SessionsMemoryChart","data","useMemo","jsx","Card","CardContent","ResponsiveContainer","jsxs","AreaChart","CartesianGrid","XAxis","YAxis","v","Tooltip","Legend","Area","Line","HEADERS","fmtAge","ms","m","pctClass","pct","fmtPct","fmtWindow","tokens","window","Sparkline","points","color","min","range","w","h","stepX","segments","p","i","x","y","indexSeries","ActiveSessionsTable","sessions","seriesById","now","srs","sparkPts","d","isSessionSample","e","WINDOWS","SummaryTiles","active","combinedTokens","sum","maxWindow","max","combinedPct","SessionsTab","minutes","setMinutes","useState","sessionsData","sessionsErr","refetchSessions","useApi","useCallback","fetchSessions","timeseriesData","timeseriesErr","refetchTimeseries","fetchSessionTimeseries","events","useSSE","sampleEvents","lastSampleTs","useEffect","windowLabel","Toggle","Fragment"],"mappings":"4VAoDA,SAASA,EACRC,EACAC,EACe,CACf,MAAMC,MAAU,IACVC,EAAaH,EAAO,IAAKI,GAAMA,EAAE,SAAS,EAEhD,UAAWA,KAAKJ,EACf,UAAWK,KAAMD,EAAE,KAAM,CACxB,IAAIE,EAAMJ,EAAI,IAAIG,EAAG,EAAE,EACvB,GAAI,CAACC,EAAK,CACTA,EAAM,CAAE,GAAID,EAAG,GAAI,MAAO,CAAA,EAC1B,UAAWE,KAAOJ,EAAYG,EAAIC,CAAG,EAAI,EACzCL,EAAI,IA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AAA,IAAC,KAAA,CAAG,UAAU,qCAAqC,SAAA,kBAEnD,EACAA,EAAAA,IAACsC,EAAA,CAAoB,SAAAC,EAAoB,OAAA3D,CAAA,CAAgB,EACzDwB,EAAAA,KAAC,MAAA,CAAI,UAAU,gCACb,SAAA,CAAAxB,EAAO,OAAO,aAAWC,EAAO,OAAO,gBAAc,IACrD6F,EAAY,oBAAkB,IAC9BT,GAAgB,WAAaN,EAAa,SAAA,CAAA,CAC5C,CAAA,CAAA,CACD,CAAA,EAEF,CAEF"}
@@ -1,5 +0,0 @@
1
- import{u as C,r as l,f as L,j as e,B as m,P as R,Q as $,S as H,T as P,U as A}from"./index-CkbdlPBm.js";import{C as g,a as y,b as N,c as v}from"./card-Cxeeje9o.js";import{B as D}from"./button-CojFYd7q.js";function I(r,d){return`${r}:${d}`}function B(r,d){const a=r.split(`
2
- `);return a.length>d?a.slice(0,d).join(`
3
- `):r}function M({row:r}){return r.recallScore>0||r.recallPass===1?e.jsxs("div",{className:"mt-2 rounded-md border border-border/60 bg-bg-elevated/40 p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Recall quality"}),e.jsx(m,{variant:r.recallPass===1?"success":"warning",children:r.recallPass===1?"pass":"fail"}),e.jsxs("span",{children:["score ",e.jsx("strong",{className:"text-foreground",children:r.recallScore.toFixed(2)})]})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-4 gap-y-0.5 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["relevance ",r.recallRelevance.toFixed(2)]}),e.jsxs("span",{children:["coverage ",r.recallCoverage.toFixed(2)]}),e.jsxs("span",{children:["diversity ",r.recallDiversity.toFixed(2)]}),e.jsxs("span",{children:["specificity ",r.recallSpecificity.toFixed(2)]})]})]}):e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"No recall-quality metrics for this turn."})}const _=({conversationId:r,turnIndex:d})=>{const{data:a}=C(l.useMemo(()=>()=>L(),[]),{pollInterval:3e4}),[o,t]=l.useState(!1),s=l.useMemo(()=>a?.recent.find(x=>I(x.conversationId,x.turnIndex)===I(r,d))??null,[a,r,d]);if(!a)return e.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading HyDE stats…"});if(!s)return e.jsx("div",{className:"text-xs text-muted-foreground",children:"No HyDE/recall telemetry recorded for this turn."});const i=s.hydeDoc??"",f=i.split(`
4
- `).length>3,b=o||!f?i:B(i,3);return e.jsxs(g,{className:"border border-border/60 bg-bg-elevated/20 p-3",children:[s.hydeRan===1?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs",children:[e.jsx(m,{variant:"accent",children:"HyDE ran"}),e.jsxs("span",{className:"text-muted-foreground",children:["gen ",e.jsxs("strong",{className:"text-foreground",children:[s.hydeGenerationMs,"ms"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:["raw ",e.jsx("strong",{className:"text-foreground",children:s.hydeRawCount}),e.jsx(T,{}),"hyde ",e.jsx("strong",{className:"text-foreground",children:s.hydeHydeCount}),e.jsx(T,{}),"fused ",e.jsx("strong",{className:"text-foreground",children:s.hydeFusedCount})]}),e.jsxs("span",{className:"text-muted-foreground",children:["lift"," ",e.jsxs("strong",{className:"text-neon",children:[s.hydeLift.toFixed(2),"×"]})]})]}),i&&e.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-border/50 bg-bg-elevated/40 p-2 font-mono text-xs text-muted-foreground",children:b}),f&&e.jsx("button",{type:"button",className:"mt-1 text-xs text-accent underline",onClick:()=>t(x=>!x),children:o?"Show less":"Show full hypothetical doc"})]}):e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx(m,{variant:"warning",children:"HyDE skipped"}),e.jsx("span",{className:"text-muted-foreground",children:q(s)})]}),e.jsx(M,{row:s})]})};function T(){return e.jsx("span",{className:"text-muted-foreground/60",children:" → "})}function q(r){switch(r.hydeReason){case"no-llm":return"No LLM embedder available (requires Ollama/HTTP embedder).";case"generation-failed":return"Hypothetical doc generation failed this turn.";case"disabled":return"HyDE is disabled (MEGACOMPACT_HYDE_DISABLED).";default:return"HyDE was not invoked for this turn."}}function w(r){return r?new Date(r).toLocaleString():"—"}function G(r){return r==="green"?"success":r==="yellow"?"warning":r==="red"?"danger":"default"}function O(r){return r==="checkpoint"?"ckpt":r==="cluster_summary"?"raptor":"mem"}function Y(){const{data:r,loading:d,error:a}=C(l.useCallback(()=>R(),[]),{pollInterval:1e4}),{data:o}=C(l.useCallback(()=>$(),[]),{pollInterval:5e3}),[t,s]=l.useState(null),[i,p]=l.useState(null),[f,b]=l.useState(!1),[x,j]=l.useState(null),[k,u]=l.useState(null),E=l.useCallback(async n=>{if(t===n){s(null),p(null);return}s(n),b(!0),p(null);try{const c=await H(n);p(c)}finally{b(!1)}},[t]),S=l.useCallback(async(n,c)=>{j(`fork:${n}:${c}`),u(null);try{const h=await P(n,c);u(`Forked → ${h.childConversationId} (${h.recalledCount} recalled)`)}catch(h){u(`Fork failed: ${h.message}`)}finally{j(null)}},[]),F=l.useCallback(async(n,c)=>{j(`rewind:${n}:${c}`),u(null);try{await A(n,c),u(`Rewind intent queued for turn ${c}`)}catch(h){u(`Rewind failed: ${h.message}`)}finally{j(null)}},[]);return a&&!r?e.jsxs("div",{className:"tab-stub",children:["Error loading turns: ",a.message]}):d&&!r?e.jsx("div",{className:"tab-stub",children:"Loading turns…"}):!r||r.conversations.length===0?e.jsxs("div",{className:"tab-stub",children:[e.jsx("h3",{children:"Turn-by-turn memory"}),e.jsxs("p",{children:["No turns recorded yet. Per-turn tracking starts when"," ",e.jsx("code",{children:"MEGACOMPACT_TURNS_DB=1"})," and the session runs through a compaction. Each turn records its context metrics + the checkpoints recalled into it."]})]}):e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h3",{className:"font-heading text-lg font-semibold",children:"Turn-by-turn memory tracking + recall"}),k&&e.jsx(m,{variant:"warning",children:k}),o&&o.intents.length>0&&e.jsxs(g,{children:[e.jsx(y,{children:e.jsxs(N,{children:["Pending rewind intents (",o.intents.length,")"]})}),e.jsx(v,{children:e.jsx("ul",{className:"list-disc space-y-1 pl-5",children:o.intents.map(n=>e.jsxs("li",{children:[w(n.createdAt)," — rewind"," ",e.jsx("code",{children:n.conversationId})," to turn ",n.targetTurnIndex]},n.id))})})]}),e.jsxs(g,{children:[e.jsx(y,{children:e.jsxs(N,{children:["Conversations (",r.conversations.length,")"]})}),e.jsx(v,{children:e.jsxs("table",{className:"w-full border-collapse text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Conversation"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Turns"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Recall"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Epochs"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Avg ctx%"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Last turn"}),e.jsx("th",{className:"border-b border-border px-3 py-2"})]})}),e.jsx("tbody",{children:r.conversations.map(n=>e.jsx(z,{c:n,active:r.activeConversationId===n.conversationId,expanded:t===n.conversationId,onExpand:()=>E(n.conversationId)},n.conversationId))})]})})]}),t&&e.jsxs(g,{children:[e.jsx(y,{children:e.jsxs(N,{children:["Turns in ",e.jsx("code",{children:t})]})}),e.jsx(v,{children:f?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading turns…"}):i?e.jsx(U,{detail:i,busy:x,onFork:S,onRewind:F}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"No detail."})})]})]})}function z({c:r,active:d,expanded:a,onExpand:o}){return e.jsx(e.Fragment,{children:e.jsxs("tr",{className:`border-b border-border/50 hover:bg-bg-elevated/40 ${d?"bg-primary/10":""}`,onClick:o,style:{cursor:"pointer"},children:[e.jsxs("td",{className:"px-3 py-2",children:[a?"▾":"▸"," ",e.jsx("code",{children:r.conversationId}),d&&e.jsx(m,{variant:"accent",className:"ml-2",children:"active"})]}),e.jsx("td",{className:"px-3 py-2 text-right",children:r.turnCount}),e.jsx("td",{className:"px-3 py-2 text-right",children:r.totalRecall}),e.jsx("td",{className:"px-3 py-2 text-right",children:r.epochCount}),e.jsxs("td",{className:"px-3 py-2 text-right",children:[r.avgCtxPercent.toFixed(0),"%"]}),e.jsx("td",{className:"px-3 py-2",children:w(r.lastTurnAt)}),e.jsx("td",{className:"px-3 py-2"})]})})}function U({detail:r,busy:d,onFork:a,onRewind:o}){return e.jsxs("table",{className:"w-full border-collapse text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"#"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Role"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Ctx"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Band"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Epoch"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Recalled checkpoints (memory recall)"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"HyDE"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Ended"}),e.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:r.turns.map(t=>e.jsxs("tr",{className:"border-b border-border/50 hover:bg-bg-elevated/40",children:[e.jsx("td",{className:"px-3 py-2 text-right",children:t.turnIndex}),e.jsx("td",{className:"px-3 py-2",children:t.role}),e.jsxs("td",{className:"px-3 py-2",children:[t.ctxTokens??"—",t.ctxPercent!=null&&e.jsxs("span",{className:"text-muted-foreground",children:[" ","· ",t.ctxPercent.toFixed(0),"%"]})]}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(m,{variant:G(t.pressureBand),children:t.pressureBand??"—"})}),e.jsx("td",{className:"px-3 py-2",children:t.epochId?e.jsx("code",{children:t.epochId.slice(0,8)}):"—"}),e.jsx("td",{className:"px-3 py-2",children:t.recall.length===0?e.jsx("span",{className:"text-muted-foreground",children:"—"}):e.jsx("ul",{className:"space-y-1",children:t.recall.map(s=>e.jsxs("li",{children:[e.jsx("code",{children:s.checkpointId.slice(0,12)})," ",e.jsxs("span",{className:"text-muted-foreground",children:[O(s.source)," · ",s.score.toFixed(2),s.raptorLevel!=null?` · L${s.raptorLevel}`:""]})]},s.checkpointId))})}),e.jsx("td",{className:"px-3 py-2 align-top",children:e.jsx(_,{conversationId:t.conversationId,turnIndex:t.turnIndex})}),e.jsx("td",{className:"px-3 py-2",children:w(t.endedAt)}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{type:"button",variant:"outline",size:"sm",disabled:d!==null,onClick:()=>a(t.conversationId,t.turnIndex),children:"fork"}),e.jsx(D,{type:"button",variant:"outline",size:"sm",disabled:d!==null,onClick:()=>o(t.conversationId,t.turnIndex),children:"rewind"})]})})]},`${t.conversationId}:${t.turnIndex}`))})]})}export{Y as default};
5
- //# sourceMappingURL=TurnsTab-CmhRJJqr.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TurnsTab-CmhRJJqr.js","sources":["../../src/components/HydeDetailPanel.tsx","../../src/tabs/TurnsTab.tsx"],"sourcesContent":["/**\n * dashboard-client/src/components/HydeDetailPanel.tsx — per-turn HyDE + recall\n * quality detail (H3.1).\n *\n * Fetches /api/rag-metrics once and indexes telemetry rows by the composite\n * `conversationId:turnIndex` key (the dashboard TurnRow has no DB id, so the\n * pair is the stable identifier). Renders one of three HyDE states:\n * - HyDE ran: hypothetical doc (collapsible), raw/hyde/fused hit counts,\n * lift multiplier, generation latency.\n * - HyDE skipped: reason (disabled / no-llm / generation-failed).\n * - No telemetry: nothing (the parent only renders us when flagged).\n * Plus a CRAG-style mini score line when recall metrics exist.\n *\n * PREVENT-PI-004: relative-path fetch to the same-origin dashboard server.\n */\n\nimport type React from \"react\";\nimport { useMemo, useState } from \"react\";\nimport { useApi } from \"../hooks/useApi\";\nimport { fetchRagMetrics } from \"../api/client\";\nimport type { RagMetricsResponse } from \"@contracts\";\nimport { Card } from \"./ui/card\";\nimport { Badge } from \"./ui/badge\";\n\n/** Per-turn telemetry row shape derived from the rag-metrics contract. */\ntype TelemetryRow = RagMetricsResponse[\"recent\"][number];\n\nexport interface HydeDetailPanelProps {\n\tconversationId: string;\n\tturnIndex: number;\n}\n\n/** Composite key matching a telemetry row to a rendered turn. */\nfunction rowKey(conversationId: string, turnIndex: number): string {\n\treturn `${conversationId}:${turnIndex}`;\n}\n\n/** First N lines of the hypothetical doc (or full when expanded). */\nfunction truncateDoc(doc: string, maxLines: number): string {\n\tconst lines = doc.split(\"\\n\");\n\treturn lines.length > maxLines ? lines.slice(0, maxLines).join(\"\\n\") : doc;\n}\n\n/** CRAG-style mini score line when recall metrics were captured. */\nfunction ScoreLine({ row }: { row: TelemetryRow }): React.ReactElement {\n\tconst hasScore = row.recallScore > 0 || row.recallPass === 1;\n\tif (!hasScore) {\n\t\treturn (\n\t\t\t<div className=\"mt-2 text-xs text-muted-foreground\">\n\t\t\t\tNo recall-quality metrics for this turn.\n\t\t\t</div>\n\t\t);\n\t}\n\treturn (\n\t\t<div className=\"mt-2 rounded-md border border-border/60 bg-bg-elevated/40 p-2\">\n\t\t\t<div className=\"flex items-center gap-2 text-xs\">\n\t\t\t\t<span className=\"font-medium text-muted-foreground\">Recall quality</span>\n\t\t\t\t<Badge variant={row.recallPass === 1 ? \"success\" : \"warning\"}>\n\t\t\t\t\t{row.recallPass === 1 ? \"pass\" : \"fail\"}\n\t\t\t\t</Badge>\n\t\t\t\t<span>\n\t\t\t\t\tscore <strong className=\"text-foreground\">{row.recallScore.toFixed(2)}</strong>\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t\t<div className=\"mt-1 flex flex-wrap gap-x-4 gap-y-0.5 text-xs text-muted-foreground\">\n\t\t\t\t<span>relevance {row.recallRelevance.toFixed(2)}</span>\n\t\t\t\t<span>coverage {row.recallCoverage.toFixed(2)}</span>\n\t\t\t\t<span>diversity {row.recallDiversity.toFixed(2)}</span>\n\t\t\t\t<span>specificity {row.recallSpecificity.toFixed(2)}</span>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport const HydeDetailPanel: React.FC<HydeDetailPanelProps> = ({\n\tconversationId,\n\tturnIndex,\n}) => {\n\tconst { data: metrics } = useApi<RagMetricsResponse>(\n\t\tuseMemo(() => () => fetchRagMetrics(), []),\n\t\t{ pollInterval: 30_000 },\n\t);\n\tconst [showFullDoc, setShowFullDoc] = useState(false);\n\n\t// Rebuild the index whenever metrics arrive; rare enough that a full\n\t// rebuild on each render is cheaper than memoizing with a mutable dep.\n\tconst row = useMemo(\n\t\t() =>\n\t\t\tmetrics?.recent.find(\n\t\t\t\t(t) => rowKey(t.conversationId, t.turnIndex) === rowKey(conversationId, turnIndex),\n\t\t\t) ?? null,\n\t\t[metrics, conversationId, turnIndex],\n\t);\n\n\tif (!metrics) {\n\t\treturn <div className=\"text-xs text-muted-foreground\">Loading HyDE stats…</div>;\n\t}\n\tif (!row) {\n\t\treturn (\n\t\t\t<div className=\"text-xs text-muted-foreground\">\n\t\t\t\tNo HyDE/recall telemetry recorded for this turn.\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst doc = row.hydeDoc ?? \"\";\n\tconst docLines = doc.split(\"\\n\").length;\n\tconst showDoc = docLines > 3;\n\tconst visibleDoc = showFullDoc || !showDoc ? doc : truncateDoc(doc, 3);\n\n\treturn (\n\t\t<Card className=\"border border-border/60 bg-bg-elevated/20 p-3\">\n\t\t\t{row.hydeRan === 1 ? (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"mb-2 flex flex-wrap items-center gap-2 text-xs\">\n\t\t\t\t\t\t<Badge variant=\"accent\">HyDE ran</Badge>\n\t\t\t\t\t\t<span className=\"text-muted-foreground\">\n\t\t\t\t\t\t\tgen <strong className=\"text-foreground\">{row.hydeGenerationMs}ms</strong>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"text-muted-foreground\">\n\t\t\t\t\t\t\traw <strong className=\"text-foreground\">{row.hydeRawCount}</strong>\n\t\t\t\t\t\t\t<Arrow />\n\t\t\t\t\t\t\thyde <strong className=\"text-foreground\">{row.hydeHydeCount}</strong>\n\t\t\t\t\t\t\t<Arrow />\n\t\t\t\t\t\t\tfused <strong className=\"text-foreground\">{row.hydeFusedCount}</strong>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"text-muted-foreground\">\n\t\t\t\t\t\t\tlift{\" \"}\n\t\t\t\t\t\t\t<strong className=\"text-neon\">{row.hydeLift.toFixed(2)}×</strong>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t{doc && (\n\t\t\t\t\t\t<pre className=\"max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-border/50 bg-bg-elevated/40 p-2 font-mono text-xs text-muted-foreground\">\n\t\t\t\t\t\t\t{visibleDoc}\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t)}\n\t\t\t\t\t{showDoc && (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tclassName=\"mt-1 text-xs text-accent underline\"\n\t\t\t\t\t\t\tonClick={() => setShowFullDoc((v) => !v)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{showFullDoc ? \"Show less\" : \"Show full hypothetical doc\"}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<div className=\"flex items-center gap-2 text-xs\">\n\t\t\t\t\t<Badge variant=\"warning\">HyDE skipped</Badge>\n\t\t\t\t\t<span className=\"text-muted-foreground\">{skipReason(row)}</span>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t\t<ScoreLine row={row} />\n\t\t</Card>\n\t);\n};\n\nfunction Arrow(): React.ReactElement {\n\treturn <span className=\"text-muted-foreground/60\"> → </span>;\n}\n\nfunction skipReason(row: TelemetryRow): string {\n\tswitch (row.hydeReason) {\n\t\tcase \"no-llm\":\n\t\t\treturn \"No LLM embedder available (requires Ollama/HTTP embedder).\";\n\t\tcase \"generation-failed\":\n\t\t\treturn \"Hypothetical doc generation failed this turn.\";\n\t\tcase \"disabled\":\n\t\t\treturn \"HyDE is disabled (MEGACOMPACT_HYDE_DISABLED).\";\n\t\tdefault:\n\t\t\treturn \"HyDE was not invoked for this turn.\";\n\t}\n}\n","/**\n * dashboard-client/src/tabs/TurnsTab.tsx — Turn-by-turn memory tracking + recall (S52).\n *\n * Fetches /api/turns (conversation list), expands the active conversation into\n * per-turn detail (/api/turns/conversation/:id), and renders:\n * - Conversation summary list (turn count, recall total, epochs, last turn).\n * - Per-turn rows: turn index, role, ctx tokens/percent + pressure band,\n * epoch id, and the injected-checkpoint recall set (the memory recalled\n * at each turn, with score + source).\n * - Pending rewind intents (S52A) + Fork action (S50C primitive).\n *\n * Read-mostly via /api/turns; fork/intent/prune via POST. No absolute URLs\n * (PREVENT-PI-004: loopback-only, same-origin static bundle).\n */\n\nimport type React from \"react\";\nimport { useCallback, useState } from \"react\";\nimport { useApi } from \"../hooks/useApi\";\nimport {\n\tfetchTurns,\n\tfetchConversationTurns,\n\tfetchTurnIntents,\n\tpostFork,\n\tpostTurnIntent,\n} from \"../api/client\";\nimport type {\n\tTurnsResponse,\n\tConversationTurnsResponse,\n\tRewindIntentsResponse,\n\tTurnRow,\n\tConversationSummary,\n} from \"@contracts\";\nimport { Card, CardContent, CardHeader, CardTitle } from \"../components/ui/card\";\nimport { Badge } from \"../components/ui/badge\";\nimport { Button } from \"../components/ui/button\";\nimport { HydeDetailPanel } from \"../components/HydeDetailPanel\";\n\nfunction fmtTs(ms: number): string {\n\tif (!ms) return \"—\";\n\treturn new Date(ms).toLocaleString();\n}\n\nfunction bandVariant(band: TurnRow[\"pressureBand\"]): \"success\" | \"warning\" | \"danger\" | \"default\" {\n\tif (band === \"green\") return \"success\";\n\tif (band === \"yellow\") return \"warning\";\n\tif (band === \"red\") return \"danger\";\n\treturn \"default\";\n}\n\nfunction sourceLabel(s: TurnRow[\"recall\"][number][\"source\"]): string {\n\tif (s === \"checkpoint\") return \"ckpt\";\n\tif (s === \"cluster_summary\") return \"raptor\";\n\treturn \"mem\";\n}\n\nexport default function TurnsTab(): React.ReactElement {\n\tconst {\n\t\tdata: turns,\n\t\tloading,\n\t\terror,\n\t} = useApi<TurnsResponse>(\n\t\tuseCallback(() => fetchTurns(), []),\n\t\t{\n\t\t\tpollInterval: 10_000,\n\t\t},\n\t);\n\tconst { data: intents } = useApi<RewindIntentsResponse>(\n\t\tuseCallback(() => fetchTurnIntents(), []),\n\t\t{ pollInterval: 5_000 },\n\t);\n\tconst [expanded, setExpanded] = useState<string | null>(null);\n\tconst [detail, setDetail] = useState<ConversationTurnsResponse | null>(null);\n\tconst [detailLoading, setDetailLoading] = useState(false);\n\tconst [busy, setBusy] = useState<string | null>(null);\n\tconst [notice, setNotice] = useState<string | null>(null);\n\n\tconst expand = useCallback(\n\t\tasync (conversationId: string) => {\n\t\t\tif (expanded === conversationId) {\n\t\t\t\tsetExpanded(null);\n\t\t\t\tsetDetail(null);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpanded(conversationId);\n\t\t\tsetDetailLoading(true);\n\t\t\tsetDetail(null);\n\t\t\ttry {\n\t\t\t\tconst d = await fetchConversationTurns(conversationId);\n\t\t\t\tsetDetail(d);\n\t\t\t} finally {\n\t\t\t\tsetDetailLoading(false);\n\t\t\t}\n\t\t},\n\t\t[expanded],\n\t);\n\n\tconst onFork = useCallback(\n\t\tasync (conversationId: string, turnIndex: number) => {\n\t\t\tsetBusy(`fork:${conversationId}:${turnIndex}`);\n\t\t\tsetNotice(null);\n\t\t\ttry {\n\t\t\t\tconst out = await postFork(conversationId, turnIndex);\n\t\t\t\tsetNotice(\n\t\t\t\t\t`Forked → ${out.childConversationId} (${out.recalledCount} recalled)`,\n\t\t\t\t);\n\t\t\t} catch (e) {\n\t\t\t\tsetNotice(`Fork failed: ${(e as Error).message}`);\n\t\t\t} finally {\n\t\t\t\tsetBusy(null);\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\n\tconst onRewind = useCallback(\n\t\tasync (conversationId: string, turnIndex: number) => {\n\t\t\tsetBusy(`rewind:${conversationId}:${turnIndex}`);\n\t\t\tsetNotice(null);\n\t\t\ttry {\n\t\t\t\tawait postTurnIntent(conversationId, turnIndex);\n\t\t\t\tsetNotice(`Rewind intent queued for turn ${turnIndex}`);\n\t\t\t} catch (e) {\n\t\t\t\tsetNotice(`Rewind failed: ${(e as Error).message}`);\n\t\t\t} finally {\n\t\t\t\tsetBusy(null);\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\n\tif (error && !turns) {\n\t\treturn <div className=\"tab-stub\">Error loading turns: {error.message}</div>;\n\t}\n\tif (loading && !turns) {\n\t\treturn <div className=\"tab-stub\">Loading turns…</div>;\n\t}\n\tif (!turns || turns.conversations.length === 0) {\n\t\treturn (\n\t\t\t<div className=\"tab-stub\">\n\t\t\t\t<h3>Turn-by-turn memory</h3>\n\t\t\t\t<p>\n\t\t\t\t\tNo turns recorded yet. Per-turn tracking starts when{\" \"}\n\t\t\t\t\t<code>MEGACOMPACT_TURNS_DB=1</code> and the session runs through a\n\t\t\t\t\tcompaction. Each turn records its context metrics + the checkpoints\n\t\t\t\t\trecalled into it.\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"flex flex-col gap-4\">\n\t\t\t<h3 className=\"font-heading text-lg font-semibold\">\n\t\t\t\tTurn-by-turn memory tracking + recall\n\t\t\t</h3>\n\t\t\t{notice && <Badge variant=\"warning\">{notice}</Badge>}\n\n\t\t\t{intents && intents.intents.length > 0 && (\n\t\t\t\t<Card>\n\t\t\t\t\t<CardHeader>\n\t\t\t\t\t\t<CardTitle>\n\t\t\t\t\t\t\tPending rewind intents ({intents.intents.length})\n\t\t\t\t\t\t</CardTitle>\n\t\t\t\t\t</CardHeader>\n\t\t\t\t\t<CardContent>\n\t\t\t\t\t\t<ul className=\"list-disc space-y-1 pl-5\">\n\t\t\t\t\t\t\t{intents.intents.map((i) => (\n\t\t\t\t\t\t\t\t<li key={i.id}>\n\t\t\t\t\t\t\t\t\t{fmtTs(i.createdAt)} — rewind{\" \"}\n\t\t\t\t\t\t\t\t\t<code>{i.conversationId}</code> to turn {i.targetTurnIndex}\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</CardContent>\n\t\t\t\t</Card>\n\t\t\t)}\n\n\t\t\t<Card>\n\t\t\t\t<CardHeader>\n\t\t\t\t\t<CardTitle>\n\t\t\t\t\t\tConversations ({turns.conversations.length})\n\t\t\t\t\t</CardTitle>\n\t\t\t\t</CardHeader>\n\t\t\t\t<CardContent>\n\t\t\t\t\t<table className=\"w-full border-collapse text-sm\">\n\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Conversation</th>\n\t\t\t\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Turns</th>\n\t\t\t\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Recall</th>\n\t\t\t\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Epochs</th>\n\t\t\t\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Avg ctx%</th>\n\t\t\t\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Last turn</th>\n\t\t\t\t\t\t\t\t<th className=\"border-b border-border px-3 py-2\"></th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</thead>\n\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t{turns.conversations.map((c: ConversationSummary) => (\n\t\t\t\t\t\t\t\t<ConversationRow\n\t\t\t\t\t\t\t\t\tkey={c.conversationId}\n\t\t\t\t\t\t\t\t\tc={c}\n\t\t\t\t\t\t\t\t\tactive={turns.activeConversationId === c.conversationId}\n\t\t\t\t\t\t\t\t\texpanded={expanded === c.conversationId}\n\t\t\t\t\t\t\t\t\tonExpand={() => expand(c.conversationId)}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t</CardContent>\n\t\t\t</Card>\n\n\t\t\t{expanded && (\n\t\t\t\t<Card>\n\t\t\t\t\t<CardHeader>\n\t\t\t\t\t\t<CardTitle>\n\t\t\t\t\t\t\tTurns in <code>{expanded}</code>\n\t\t\t\t\t\t</CardTitle>\n\t\t\t\t\t</CardHeader>\n\t\t\t\t\t<CardContent>\n\t\t\t\t\t\t{detailLoading ? (\n\t\t\t\t\t\t\t<div className=\"text-sm text-muted-foreground\">Loading turns…</div>\n\t\t\t\t\t\t) : detail ? (\n\t\t\t\t\t\t\t<TurnDetail\n\t\t\t\t\t\t\t\tdetail={detail}\n\t\t\t\t\t\t\t\tbusy={busy}\n\t\t\t\t\t\t\t\tonFork={onFork}\n\t\t\t\t\t\t\t\tonRewind={onRewind}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<div className=\"text-sm text-muted-foreground\">No detail.</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</CardContent>\n\t\t\t\t</Card>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n\nfunction ConversationRow({\n\tc,\n\tactive,\n\texpanded,\n\tonExpand,\n}: {\n\tc: ConversationSummary;\n\tactive: boolean;\n\texpanded: boolean;\n\tonExpand: () => void;\n}): React.ReactElement {\n\treturn (\n\t\t<>\n\t\t\t<tr\n\t\t\t\tclassName={`border-b border-border/50 hover:bg-bg-elevated/40 ${\n\t\t\t\t\tactive ? \"bg-primary/10\" : \"\"\n\t\t\t\t}`}\n\t\t\t\tonClick={onExpand}\n\t\t\t\tstyle={{ cursor: \"pointer\" }}\n\t\t\t>\n\t\t\t\t<td className=\"px-3 py-2\">\n\t\t\t\t\t{expanded ? \"▾\" : \"▸\"} <code>{c.conversationId}</code>\n\t\t\t\t\t{active && <Badge variant=\"accent\" className=\"ml-2\">active</Badge>}\n\t\t\t\t</td>\n\t\t\t\t<td className=\"px-3 py-2 text-right\">{c.turnCount}</td>\n\t\t\t\t<td className=\"px-3 py-2 text-right\">{c.totalRecall}</td>\n\t\t\t\t<td className=\"px-3 py-2 text-right\">{c.epochCount}</td>\n\t\t\t\t<td className=\"px-3 py-2 text-right\">{c.avgCtxPercent.toFixed(0)}%</td>\n\t\t\t\t<td className=\"px-3 py-2\">{fmtTs(c.lastTurnAt)}</td>\n\t\t\t\t<td className=\"px-3 py-2\" />\n\t\t\t</tr>\n\t\t</>\n\t);\n}\n\nfunction TurnDetail({\n\tdetail,\n\tbusy,\n\tonFork,\n\tonRewind,\n}: {\n\tdetail: ConversationTurnsResponse;\n\tbusy: string | null;\n\tonFork: (conversationId: string, turnIndex: number) => void;\n\tonRewind: (conversationId: string, turnIndex: number) => void;\n}): React.ReactElement {\n\treturn (\n\t\t<table className=\"w-full border-collapse text-sm\">\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">#</th>\n\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Role</th>\n\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Ctx</th>\n\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Band</th>\n\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Epoch</th>\n\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Recalled checkpoints (memory recall)</th>\n\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">HyDE</th>\n\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Ended</th>\n\t\t\t\t\t<th className=\"border-b border-border px-3 py-2 text-left font-medium text-muted-foreground\">Actions</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>\n\t\t\t\t{detail.turns.map((t) => (\n\t\t\t\t\t<tr\n\t\t\t\t\t\tkey={`${t.conversationId}:${t.turnIndex}`}\n\t\t\t\t\t\tclassName=\"border-b border-border/50 hover:bg-bg-elevated/40\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<td className=\"px-3 py-2 text-right\">{t.turnIndex}</td>\n\t\t\t\t\t\t<td className=\"px-3 py-2\">{t.role}</td>\n\t\t\t\t\t\t<td className=\"px-3 py-2\">\n\t\t\t\t\t\t\t{t.ctxTokens ?? \"—\"}\n\t\t\t\t\t\t\t{t.ctxPercent != null && (\n\t\t\t\t\t\t\t\t<span className=\"text-muted-foreground\">\n\t\t\t\t\t\t\t\t\t{\" \"}\n\t\t\t\t\t\t\t\t\t· {t.ctxPercent.toFixed(0)}%\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td className=\"px-3 py-2\">\n\t\t\t\t\t\t\t<Badge variant={bandVariant(t.pressureBand)}>\n\t\t\t\t\t\t\t\t{t.pressureBand ?? \"—\"}\n\t\t\t\t\t\t\t</Badge>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td className=\"px-3 py-2\">{t.epochId ? <code>{t.epochId.slice(0, 8)}</code> : \"—\"}</td>\n\t\t\t\t\t\t<td className=\"px-3 py-2\">\n\t\t\t\t\t\t\t{t.recall.length === 0 ? (\n\t\t\t\t\t\t\t\t<span className=\"text-muted-foreground\">—</span>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<ul className=\"space-y-1\">\n\t\t\t\t\t\t\t\t\t{t.recall.map((r) => (\n\t\t\t\t\t\t\t\t\t\t<li key={r.checkpointId}>\n\t\t\t\t\t\t\t\t\t\t\t<code>{r.checkpointId.slice(0, 12)}</code>{\" \"}\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"text-muted-foreground\">\n\t\t\t\t\t\t\t\t\t\t\t\t{sourceLabel(r.source)} · {r.score.toFixed(2)}\n\t\t\t\t\t\t\t\t\t\t\t\t{r.raptorLevel != null ? ` · L${r.raptorLevel}` : \"\"}\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td className=\"px-3 py-2 align-top\">\n\t\t\t\t\t\t\t<HydeDetailPanel\n\t\t\t\t\t\t\t\tconversationId={t.conversationId}\n\t\t\t\t\t\t\t\tturnIndex={t.turnIndex}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td className=\"px-3 py-2\">{fmtTs(t.endedAt)}</td>\n\t\t\t\t\t\t<td className=\"px-3 py-2\">\n\t\t\t\t\t\t\t<div className=\"flex gap-2\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\t\t\t\t\tdisabled={busy !== null}\n\t\t\t\t\t\t\t\t\tonClick={() => onFork(t.conversationId, t.turnIndex)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tfork\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\t\t\t\t\tdisabled={busy !== null}\n\t\t\t\t\t\t\t\t\tonClick={() => onRewind(t.conversationId, t.turnIndex)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\trewind\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t))}\n\t\t\t</tbody>\n\t\t</table>\n\t);\n}\n"],"names":["rowKey","conversationId","turnIndex","truncateDoc","doc","maxLines","lines","ScoreLine","row","jsxs","jsx","Badge","HydeDetailPanel","metrics","useApi","useMemo","fetchRagMetrics","showFullDoc","setShowFullDoc","useState","t","showDoc","visibleDoc","Card","Fragment","Arrow","v","skipReason","fmtTs","ms","bandVariant","band","sourceLabel","s","TurnsTab","turns","loading","error","useCallback","fetchTurns","intents","fetchTurnIntents","expanded","setExpanded","detail","setDetail","detailLoading","setDetailLoading","busy","setBusy","notice","setNotice","expand","d","fetchConversationTurns","onFork","out","postFork","e","onRewind","postTurnIntent","CardHeader","CardTitle","CardContent","i","c","ConversationRow","TurnDetail","active","onExpand","r","Button"],"mappings":"4MAiCA,SAASA,EAAOC,EAAwBC,EAA2B,CAClE,MAAO,GAAGD,CAAc,IAAIC,CAAS,EACtC,CAGA,SAASC,EAAYC,EAAaC,EAA0B,CAC3D,MAAMC,EAAQF,EAAI,MAAM;AAAA,CAAI,EAC5B,OAAOE,EAAM,OAASD,EAAWC,EAAM,MAAM,EAAGD,CAAQ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,IAAC6D,EAAA,CACA,KAAK,SACL,QAAQ,UACR,KAAK,KACL,SAAUvB,IAAS,KACnB,QAAS,IAAMW,EAAS,EAAE,eAAgB,EAAE,SAAS,EACrD,SAAA,QAAA,CAAA,CAED,CAAA,CACD,CAAA,CACD,CAAA,CAAA,EAjEK,GAAG,EAAE,cAAc,IAAI,EAAE,SAAS,EAAA,CAmExC,CAAA,CACF,CAAA,EACD,CAEF"}
@@ -1,2 +0,0 @@
1
- import{j as e,r as g,B as y}from"./index-CkbdlPBm.js";import{C as d,a as i,b as c,c as x}from"./card-Cxeeje9o.js";import{V as m}from"./VcStatusBadge-SDThp0R0.js";import{i as R,b as V}from"./client-extra-DLxyGxW8.js";async function E(){const s=await fetch("/api/vector-cortex/evaluation");if(!s.ok)throw new Error(`vector-cortex evaluation: ${s.status}`);return s.json()}async function S(){const s=await fetch("/api/vector-cortex/health");if(!s.ok)throw new Error(`vector-cortex health: ${s.status}`);return s.json()}async function k(){const s=await fetch("/api/vector-cortex/topology");if(!s.ok)throw new Error(`vector-cortex topology: ${s.status}`);return s.json()}async function A(){const s=await fetch("/api/vector-cortex/query");if(!s.ok)throw new Error(`vector-cortex query: ${s.status}`);return s.json()}async function D(){const s=await fetch("/api/vector-cortex/shards");if(!s.ok)throw new Error(`vector-cortex shards: ${s.status}`);return s.json()}async function _(){const s=await fetch("/api/vector-cortex/reconstruct");if(!s.ok)throw new Error(`vector-cortex reconstruct: ${s.status}`);return s.json()}async function M(){const s=await fetch("/api/vector-cortex/plans");if(!s.ok)throw new Error(`vector-cortex plans: ${s.status}`);return s.json()}async function P(){const s=await fetch("/api/vector-cortex/render");if(!s.ok)throw new Error(`vector-cortex render: ${s.status}`);return s.json()}async function T(){const s=await fetch("/api/vector-cortex/rollout");if(!s.ok)throw new Error(`vector-cortex rollout: ${s.status}`);return s.json()}async function B(){const s=await fetch("/api/vector-cortex/closure-proof");if(!s.ok)throw new Error(`vector-cortex closure-proof: ${s.status}`);return s.json()}async function $(){const s=await fetch("/api/vector-cortex/restore");if(!s.ok)throw new Error(`vector-cortex restore: ${s.status}`);return s.json()}async function F(){const s=await fetch("/api/vector-cortex/repair");if(!s.ok)throw new Error(`vector-cortex repair: ${s.status}`);return s.json()}async function w(s="default"){const a=await fetch(`/api/vector-cortex/ledger?session=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`vector-cortex ledger: ${a.status}`);return a.json()}async function I(s){const a=await fetch("/api/vector-cortex/breakers/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({subsystem:s})});if(!a.ok)throw new Error(`vector-cortex reset: ${a.status}`);return a.json()}async function L(){const s=await fetch("/api/vector-cortex/cache-crystals");if(!s.ok)throw new Error(`vector-cortex cache-crystals: ${s.status}`);return s.json()}async function U(){const s=await fetch("/api/vector-cortex/cache-economics");if(!s.ok)throw new Error(`vector-cortex cache-economics: ${s.status}`);return s.json()}async function O(){const s=await fetch("/api/vector-cortex/cache-diagnostics");if(!s.ok)throw new Error(`vector-cortex cache-diagnostics: ${s.status}`);return s.json()}async function H(){const s=await fetch("/api/vector-cortex/outcomes");if(!s.ok)throw new Error(`vector-cortex outcomes: ${s.status}`);return s.json()}async function q(){const s=await fetch("/api/vector-cortex/policy");if(!s.ok)throw new Error(`vector-cortex policy: ${s.status}`);return s.json()}async function z(){const s=await fetch("/api/vector-cortex/platform");if(!s.ok)throw new Error(`vector-cortex platform: ${s.status}`);return s.json()}function t({label:s,value:a}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:s}),e.jsx("div",{className:"font-mono text-sm",children:a})]})}function Y(){const[s,a]=g.useState({loading:!0,error:null,data:null,health:null,ledger:null,topology:null,query:null,shards:null,reconstruct:null,plans:null,render:null,rollout:null,closureProof:null,restore:null,repair:null,crystals:null,economics:null,diagnostics:null,outcomes:null,policy:null,platform:null}),u=g.useCallback(()=>{a(r=>({...r,loading:!0})),E().then(r=>a(n=>({...n,data:r,loading:!1,error:null}))).catch(r=>a(n=>({...n,loading:!1,error:r instanceof Error?r.message:String(r)}))),S().then(r=>a(n=>({...n,health:r}))).catch(()=>{}),w().then(r=>a(n=>({...n,ledger:r}))).catch(()=>{}),k().then(r=>a(n=>({...n,topology:r}))).catch(()=>{}),A().then(r=>a(n=>({...n,query:r}))).catch(()=>{}),D().then(r=>a(n=>({...n,shards:r}))).catch(()=>{}),_().then(r=>a(n=>({...n,reconstruct:r}))).catch(()=>{}),M().then(r=>a(n=>({...n,plans:r}))).catch(()=>{}),P().then(r=>a(n=>({...n,render:r}))).catch(()=>{}),T().then(r=>a(n=>({...n,rollout:r}))).catch(()=>{}),B().then(r=>a(n=>({...n,closureProof:r}))).catch(()=>{}),$().then(r=>a(n=>({...n,restore:r}))).catch(()=>{}),F().then(r=>a(n=>({...n,repair:r}))).catch(()=>{}),L().then(r=>a(n=>({...n,crystals:r}))).catch(()=>{}),U().then(r=>a(n=>({...n,economics:r}))).catch(()=>{}),O().then(r=>a(n=>({...n,diagnostics:r}))).catch(()=>{}),H().then(r=>a(n=>({...n,outcomes:r}))).catch(()=>{}),q().then(r=>a(n=>({...n,policy:r}))).catch(()=>{}),z().then(r=>a(n=>({...n,platform:r}))).catch(()=>{})},[]);return g.useEffect(()=>{u();const r=setInterval(u,5e3);return()=>clearInterval(r)},[u]),[s,u]}function W({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Validated Prompt Renderer (VC5B)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Render fixtures",value:String(s.renderCount)}),e.jsx(t,{label:"Provider profiles",value:String(s.providerCount)}),e.jsx(t,{label:"Known profiles",value:String(s.knownProfiles.length)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only render conformance route — no prompt text or session payloads exposed."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Renderer disabled (VC5B off)."})})]})}function G({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Live Graduated Rollout (VC5C)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Gate",value:`${s.gatePct}%`}),e.jsx(t,{label:"Exposed buckets",value:String(s.bucketCount)}),e.jsx(t,{label:"Total buckets",value:String(s.buckets)}),e.jsx(t,{label:"Promotion",value:s.promotionBlocked?"FROZEN":"OPEN"}),e.jsx(t,{label:"Events",value:String(s.events)}),e.jsx(t,{label:"Sessions",value:String(s.sessions)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only rollout route — no session payloads or bucket→session mappings exposed."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Rollout disabled (VC5C off)."})})]})}function K({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Closure Optimization (VC6A)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Optimizations",value:String(s.optimizations)}),e.jsx(t,{label:"Proof rejections",value:String(s.proofRejections)}),e.jsx(t,{label:"Last rejection",value:s.lastRejection??"none"}),e.jsx(t,{label:"Retained edges",value:String(s.retainedEdgeTotal)}),e.jsx(t,{label:"Removed edges",value:String(s.removedEdgeTotal)}),e.jsx(t,{label:"Conservative walks",value:String(s.conservativeTraversalTotal)}),e.jsx(t,{label:"Optimized walks",value:String(s.optimizedTraversalTotal)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only closure diagnostics — aggregate counts only; per-edge proof rows, node ids, and source payloads are never exposed (SECURITY_PRIVACY)."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Closure optimization disabled (VC6A off) — conservative VC4C closure used directly (mode B)."})})]})}function Q({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Exact Source Restoration (VC6B)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Restore attempts",value:String(s.restoreAttempts)}),e.jsx(t,{label:"Restored",value:String(s.restoredCount)}),e.jsx(t,{label:"Missing source",value:String(s.missingCount)}),e.jsx(t,{label:"Digest rejections",value:String(s.digestRejections)}),e.jsx(t,{label:"Last rejection",value:s.lastRejection??"none"}),e.jsx(t,{label:"Updated",value:s.updatedAt})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only restore diagnostics — counts and HEAL_RESTORE_* codes only. There is no payload endpoint: restored bytes, span ids, node ids, and ledger text are never exposed (SECURITY_PRIVACY)."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Exact source restoration disabled (VC6B off) — no exact source is restored; omitted context is disclosed as loss (mode C)."})})]})}function J({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Self-Healing Derived State (VC6C)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Repair attempts",value:String(s.repairAttempts)}),e.jsx(t,{label:"Repairs planned",value:String(s.repairsPlanned)}),e.jsx(t,{label:"Pointers switched",value:String(s.pointersSwitched)}),e.jsx(t,{label:"Backoffs",value:String(s.backoffs)}),e.jsx(t,{label:"Last backoff",value:s.lastBackoffMs===null?"none":`${s.lastBackoffMs}ms`}),e.jsx(t,{label:"Last failure",value:s.lastFailure??"none"}),e.jsx(t,{label:"Updated",value:s.updatedAt})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only repair diagnostics — counts and HEAL_REPAIR_* codes only. There is no payload endpoint: subsystem source bytes, gap ranges, high-water marks, root digests, and ledger text are never exposed (SECURITY_PRIVACY)."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Self-healing derived state disabled (VC6C off) — no controller detects gaps or rebuilds derived state; derived state is reported disabled rather than healed (mode C)."})})]})}function Z({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Frozen Range Crystals (VC7A)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Crystals",value:String(s.crystalCount)}),e.jsx(t,{label:"Frozen bytes",value:String(s.totalBytes)}),e.jsx(t,{label:"Hits",value:String(s.hits)}),e.jsx(t,{label:"Misses",value:String(s.misses)}),e.jsx(t,{label:"Hit bytes",value:String(s.hitBytes)}),e.jsx(t,{label:"Writes",value:String(s.writes)}),e.jsx(t,{label:"Duplicate writes",value:String(s.duplicateWrites)}),e.jsx(t,{label:"Collisions",value:String(s.collisions)}),e.jsx(t,{label:"Last failure",value:s.lastFailure??"none"}),e.jsx(t,{label:"Updated",value:s.updatedAt})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only crystal diagnostics — counts, byte volumes, and CRY_* codes only. A crystal is a frozen rendered prompt, so frozen bytes, covered ranges, span/covered digests, request digests, and session ids are never exposed (SECURITY_PRIVACY). Keys exclude the global ledger frontier, so an unrelated append does not invalidate a crystal; a covered-byte, dependency, renderer, or profile change does. Collisions mean two renders of one identity disagreed — the stored crystal is never overwritten."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Frozen range crystals disabled (VC7A off) — nothing is served from the crystal cache and every render is produced fresh; the cache is reported bypassed rather than hit (mode C)."})})]})}function X({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Cache Economics (VC7B)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Profiles",value:String(s.profileCount)}),e.jsx(t,{label:"Proven exclusions",value:String(s.provenExclusions)}),e.jsx(t,{label:"Unproven exclusions",value:String(s.unprovenExclusions)}),e.jsx(t,{label:"Last failure",value:s.lastFailure??"none"}),e.jsx(t,{label:"Updated",value:s.updatedAt})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only cache-economics diagnostics — counts and ECON_* codes only. Cache economics price a frozen rendered prompt's reuse, so provider prices, covered ranges, span/covered digests, request digests, and session ids are never exposed (SECURITY_PRIVACY). An unproven exclusion (declared without a proving fixture id) is rejected by the exclusion-proof rule and is reported here only as a count."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Cache economics disabled (VC7B off) — no cache reuse is priced; the cache-economics surface is reported bypassed rather than priced (mode C)."})})]})}function ee({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Cache Diagnostics & Breakers (VC7C)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Profile misses",value:String(s.profileMisses)}),e.jsx(t,{label:"Range misses",value:String(s.rangeMisses)}),e.jsx(t,{label:"Dependency misses",value:String(s.dependencyMisses)}),e.jsx(t,{label:"Request misses",value:String(s.requestMisses)}),e.jsx(t,{label:"Generation misses",value:String(s.generationMisses)}),e.jsx(t,{label:"Unknown misses",value:String(s.unknownMisses)}),e.jsx(t,{label:"Serves blocked",value:String(s.serveBlocked)}),e.jsx(t,{label:"Breaker",value:s.breakerState}),e.jsx(t,{label:"Last failure",value:s.lastFailure??"none"}),e.jsx(t,{label:"Updated",value:s.updatedAt})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only cache miss diagnostics — per-class counts and CACHE_*/M5_* codes only. Classification is exclusive and ordered (profile, range, dependency, request, generation, then unknown), so each miss increments exactly one counter. A miss diagnostic would otherwise carry the missed request itself, so request payloads, RequestHashV2 digests, covered ranges, span/covered digests, profile digests, and session ids are never exposed (SECURITY_PRIVACY). Blocked serves are demotions taken BEFORE a cache serve — on key collision, stale generation, digest failure, or profile mismatch — and are reported here only as a count; the breaker cannot be reset from this reader-only surface."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Cache diagnostics disabled (VC7C off) — no miss is classified and no cache serve is attested here, so all caches are reported bypassed rather than hit (mode C). The classification and breaker arithmetic still runs; only this reporting seam is suppressed."})})]})}function se({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Consent-Bound Outcomes (VC8A)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Outcomes",value:String(s.outcomeCount)}),e.jsx(t,{label:"Consented sessions",value:String(s.consentedSessions)}),e.jsx(t,{label:"Revoked sessions",value:String(s.revokedSessions)}),e.jsx(t,{label:"Manifests",value:String(s.manifestCount)}),e.jsx(t,{label:"Excluded records",value:String(s.excludedCount)}),e.jsx(t,{label:"Last failure",value:s.lastFailure??"none"}),e.jsx(t,{label:"Updated",value:s.updatedAt})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only consent-bound outcome ledger — aggregate counts and OUT_ codes only. The outcome ledger carries metrics without payload, so no prompt bytes, response text, free-text, or session content ever reaches the client. Dataset inclusion requires active explicit consent at export time; revocations disappear from future manifests."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Outcome ledger disabled (VC8A off) — no outcomes are appended and no dataset manifests are built, so all learning is bypassed (mode C). The ledger validation, consent evaluation, and manifest builder arithmetic still run; only this reporting seam is suppressed."})})]})}function te({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Shadow Adaptive Policy (VC8B)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Shadow decisions",value:String(s.shadowDecisions)}),e.jsx(t,{label:"Clamped",value:String(s.clampedDecisions)}),e.jsx(t,{label:"Rejected inputs",value:String(s.rejectedInputs)}),e.jsx(t,{label:"Live mutations",value:String(s.liveMutations)}),e.jsx(t,{label:"Pressure version",value:String(s.pressureVersion)}),e.jsx(t,{label:"Last failure",value:s.lastFailure??"none"}),e.jsx(t,{label:"Updated",value:s.updatedAt})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only shadow adaptive policy — aggregate counts and POL_/M7_ codes only. Policy actions are from a finite set chosen deterministically by the canonical pressure level; budgets are clamped into a configured window after the pressure factor. Unknown pressure labels are rejected as POL_PRESSURE_UNKNOWN, never coerced. The shadow engine is structurally incapable of affecting the live path — inputs are deep-copied and the prompt digest is pinned before and after — so liveMutations is always zero. M7 migrates legacy pressure labels to the v2 canonical five by copy/validate/switch; an unknown label blocks the switch (M7_PRESSURE_UNKNOWN). No prompt bytes, session content, or free-text ever reaches the client."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Shadow adaptive policy disabled (VC8B off) — no shadow decisions are reported, so the live path uses the predecessor thresholds (mode C). The policy, shadow, and M7 migration arithmetic still run; only this reporting seam is suppressed."})})]})}function re({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Canary Platform + Rust Parity (VC8C)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Fixtures",value:String(s.fixtureCount)}),e.jsx(t,{label:"Passed",value:String(s.passed)}),e.jsx(t,{label:"Failed",value:String(s.failed)}),e.jsx(t,{label:"External runner",value:s.externalRunnerConfigured?"configured":"none"}),e.jsx(t,{label:"Last failure",value:s.lastFailure??"none"}),e.jsx(t,{label:"Updated",value:s.updatedAt})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only canary selection and external Rust parity — aggregate counts and RUST_ codes only. The selector admits a qualified external Rust artifact only when ABI version, URL metadata, commit, Cargo.lock digest, and platform all match evidence; otherwise it demotes to TS reference (mode B) or legacy (mode C). The cross-conformance runner exchanges length-framed neutral records over a local stdin/stdout channel (no network). No artifact bytes, output bytes, or free-text ever reaches the client."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Canary platform disabled (VC8C off) — no engine parity checks are reported, so the selection stays at the predecessor (mode C). The selector and cross-conformance runner arithmetic still run; only this reporting seam is suppressed."})})]})}function ae({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Dual-Tier Shards (VC4A)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Semantic shards",value:String(s.semanticCount)}),e.jsx(t,{label:"Exact shards",value:String(s.exactCount)}),e.jsx(t,{label:"Byte total",value:String(s.byteTotal)}),e.jsx(t,{label:"Protected bytes",value:String(s.protectedByteTotal)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only count/byte aggregate; staged in-memory this sprint."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Dual-tier shards disabled (VC4A off)."})})]})}function ne({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Reconstruction Fidelity (VC4C)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Closure attempts",value:String(s.closureAttempts)}),e.jsx(t,{label:"Closure rejections",value:String(s.closureRejections)}),e.jsx(t,{label:"Validated",value:String(s.validatedCount)}),e.jsx(t,{label:"Invalidated",value:String(s.invalidatedCount)}),e.jsx(t,{label:"Span total",value:String(s.spanTotal)}),e.jsx(t,{label:"Byte total",value:String(s.byteTotal)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only closure/validation aggregate; staged in-memory this sprint."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Reconstruction fidelity disabled (VC4C off)."})})]})}function le({view:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Plan Manifests (VC5A)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"DAG fixtures",value:String(s.dagCount)}),e.jsx(t,{label:"Plan fixtures",value:String(s.plannerCount)}),e.jsx(t,{label:"Plans exposed",value:String(s.plans.length)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only plan manifests only — no session payloads or prompt text. Per-run plan outputs are staged in-memory this sprint."}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"PromptDagV1 + budgeted planner disabled (VC5A off)."})})]})}function oe({topology:s,query:a}){return e.jsxs(e.Fragment,{children:[e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Derived Cortex Store (VC3A)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3",children:[e.jsx(t,{label:"Generation",value:s.generationId??"—"}),e.jsx(t,{label:"Ordinal",value:s.ordinal??"—"}),e.jsx(t,{label:"Records",value:String(s.recordCount)}),e.jsx(t,{label:"Frontier (HW)",value:s.sourceHighWater}),e.jsx(t,{label:"Root digest",value:s.rootDigest?s.rootDigest.slice(0,16):"—"}),s.nodes!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx(t,{label:"Nodes",value:String(s.nodes?.length??0)}),e.jsx(t,{label:"Edges",value:String(s.edges?.length??0)}),e.jsx(t,{label:"Graph digest",value:s.generationDigest?s.generationDigest.slice(0,16):"—"})]})]}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]}),s.nodes!==void 0&&(s.edges?.length??0)>0&&e.jsxs("div",{className:"mt-4 max-h-56 overflow-y-auto",children:[e.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"Topology edges (VC3B)"}),e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50 text-muted-foreground",children:[e.jsx("th",{className:"py-1 pr-2",children:"source"}),e.jsx("th",{className:"py-1 pr-2",children:"target"}),e.jsx("th",{className:"py-1 pr-2",children:"head"}),e.jsx("th",{className:"py-1 pr-2",children:"dir"}),e.jsx("th",{className:"py-1",children:"score"})]})}),e.jsx("tbody",{children:s.edges?.map((u,r)=>e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"py-1 pr-2 font-mono",children:u.source}),e.jsx("td",{className:"py-1 pr-2 font-mono",children:u.target}),e.jsx("td",{className:"py-1 pr-2 font-mono",children:u.head}),e.jsx("td",{className:"py-1 pr-2",children:u.direction}),e.jsx("td",{className:"py-1 font-mono",children:u.score})]},`${u.source}-${u.target}-${u.head}-${r}`))})]})]})]}):e.jsx("div",{className:"vc-empty",children:"Cortex store disabled (VC3A off)."})})]}),e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Topology Query Diagnostics (VC3C)"}),e.jsx(m,{status:a?.status})]})}),e.jsx(x,{children:a?.enabled?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3",children:e.jsx(t,{label:"Router version",value:String(a.routerVersion)})}),a?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),a?.status==="deferred"&&a?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",a.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Query diagnostics unavailable (VC3C off)."})})]})]})}function de({ledger:s}){return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Occurrence Ledger (VC1B)"}),e.jsx(m,{status:s?.status})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-3 grid grid-cols-2 gap-4 md:grid-cols-3",children:[e.jsx(t,{label:"Session",value:s.session}),e.jsx(t,{label:"High-water",value:s.highWater}),e.jsx(t,{label:"Occurrences",value:String(s.count)})]}),s.occurrences.length===0?e.jsx("div",{className:"vc-empty",children:"No occurrences recorded."}):e.jsx("div",{className:"max-h-64 overflow-y-auto",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50 text-muted-foreground",children:[e.jsx("th",{className:"py-1 pr-2",children:"seq"}),e.jsx("th",{className:"py-1 pr-2",children:"eventId"}),e.jsx("th",{className:"py-1 pr-2",children:"kind"}),e.jsx("th",{className:"py-1 pr-2",children:"toolCall"}),e.jsx("th",{className:"py-1",children:"digest"})]})}),e.jsx("tbody",{children:s.occurrences.map(a=>e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"py-1 pr-2 font-mono",children:a.seq}),e.jsx("td",{className:"py-1 pr-2 font-mono",children:a.eventId}),e.jsx("td",{className:"py-1 pr-2",children:a.kind}),e.jsx("td",{className:"py-1 pr-2 font-mono",children:a.toolCallId??"—"}),e.jsx("td",{className:"max-w-[180px] truncate font-mono text-muted-foreground",children:a.digest})]},`${a.seq}-${a.eventId}`))})]})}),s?.status==="awaiting_data"&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Awaiting first event. Data will appear after the next pipeline run."}),s?.status==="deferred"&&s?.deferredReason&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Deferred: ",s.deferredReason.replace(/_/g," ")]})]}):e.jsx("div",{className:"vc-empty",children:"Ledger disabled (VC1B off)."})})]})}function ie({encoderMode:s,encoderAssetDigest:a,status:u}){const[r,n]=g.useState({state:"idle"}),[p,l]=g.useState(!1),[o,v]=g.useState(null),b=f=>{V(f).then(j=>{j.status==="improving"?(n({state:"improving",progress:j.progress,jobId:f}),window.setTimeout(()=>b(f),2e3)):j.status==="qualified"?n({state:"promoted",digest:j.assetDigest,verdictText:j.verdict.verdict}):n({state:"rejected",reason:j.reason}),l(!1)}).catch(j=>{v(j instanceof Error?j.message:String(j)),n({state:"idle"}),l(!1)})},h=()=>{window.confirm("Run local ML5-A training and re-qualify the encoder heads? The Improve job is local-only.")&&(l(!0),v(null),R().then(f=>{n({state:"improving",progress:0,jobId:f.jobId}),b(f.jobId)}).catch(f=>{v(f instanceof Error?f.message:String(f)),l(!1)}))},C=r.state==="promoted"?e.jsx(y,{variant:"success",children:"Promoted"}):r.state==="rejected"?e.jsx(y,{variant:"danger",children:"Rejected"}):s==="A"?e.jsx(y,{variant:"success",children:"Promoted"}):e.jsx(y,{variant:"outline",children:"Idle"});return e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Model Improvement (ML5-D)"}),C]})}),e.jsxs(x,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Encoder mode",value:s}),e.jsx(t,{label:"Asset digest",value:a?a.slice(0,12):"none"}),e.jsx(t,{label:"Status",value:u??"off"}),e.jsx(t,{label:"Job",value:r.state==="improving"?`${Math.round(r.progress*100)}%`:r.state==="promoted"?"promoted":r.state==="rejected"?"rejected":"idle"})]}),(r.state==="promoted"||r.state==="rejected")&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:r.state==="promoted"?`Qualified verdict: ${r.verdictText} · asset ${r.digest.slice(0,12)}`:`Demoted to mode B: ${r.reason}`}),o&&e.jsx("div",{className:"vc-error mt-2 text-xs",children:o}),e.jsx("div",{className:"mt-3",children:e.jsx("button",{onClick:h,disabled:p||u==="off",className:"rounded border border-border px-3 py-1 text-xs disabled:opacity-50",children:p?"Improving…":"Improve"})})]})]})}function N({mode:s,count:a}){return e.jsxs("div",{className:"flex items-center justify-between border-b border-border/50 py-1 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Mode ",s]}),e.jsx("span",{className:"font-mono",children:a})]})}function he(){const[s,a]=Y(),[u,r]=g.useState(null),{loading:n,error:p,data:l,health:o}=s,v=()=>{I("provider").then(h=>(r(`Breaker "${h.subsystem}" ${h.state}; evidence retained: ${h.failures} failures / ${h.attempts} attempts`),S())).then(h=>{a()}).catch(h=>r(h instanceof Error?h.message:String(h)))};if(n&&!l)return e.jsx("div",{className:"vc-loading",children:"Loading vector-cortex evaluation…"});if(p&&!l)return e.jsxs("div",{className:"vc-error",children:["Error: ",p]});if(!l)return e.jsx("div",{className:"vc-empty",children:"No evaluation data available."});const b=Math.max(1,...l.histogram.cells,l.histogram.overflow);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Vector Cortex Evaluation"}),e.jsx(m,{status:l.status}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[l.samples," samples · mode ",l.mode]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[e.jsxs(d,{children:[e.jsx(i,{children:e.jsx(c,{children:"Samples"})}),e.jsxs(x,{children:[e.jsx("div",{className:"text-3xl font-bold",children:l.samples}),e.jsxs("div",{className:"mt-2 flex flex-col",children:[e.jsx(N,{mode:"A",count:l.byMode.A}),e.jsx(N,{mode:"B",count:l.byMode.B}),e.jsx(N,{mode:"C",count:l.byMode.C})]})]})]}),e.jsxs(d,{className:"md:col-span-2",children:[e.jsx(i,{children:e.jsx(c,{children:"Latency Histogram (ms, inclusive edges)"})}),e.jsxs(x,{children:[e.jsxs("div",{className:"flex items-end gap-2",style:{height:160},children:[l.histogram.edges.map((h,C)=>{const f=l.histogram.cells[C]/b*140;return e.jsxs("div",{className:"flex flex-1 flex-col items-center gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:l.histogram.cells[C]}),e.jsx("div",{className:"w-full rounded-t",style:{height:Math.max(2,f),background:"#6366f1"}}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["≤",h]})]},h)}),e.jsxs("div",{className:"flex flex-1 flex-col items-center gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:l.histogram.overflow}),e.jsx("div",{className:"w-full rounded-t",style:{height:Math.max(2,l.histogram.overflow/b*140),background:"#f87171"}}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:">250"})]})]}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:["Total: ",l.histogram.total," · Rejects: ",l.rejects.length]})]})]})]}),e.jsxs(d,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{children:"Live Safety Envelope (VC0C)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[o?.stateSource==="ephemeral"&&e.jsx(y,{variant:"outline",children:"EPHEMERAL (non-live)"}),e.jsx("button",{onClick:v,disabled:!o?.enabled,className:"rounded border border-border px-2 py-1 text-xs disabled:opacity-50",children:"Reset Cooldown"})]})]})}),e.jsxs(x,{children:[u&&e.jsx("div",{className:"mb-2 text-xs text-muted-foreground",children:u}),o?e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"State",value:o.state}),e.jsx(t,{label:"Mode",value:o.mode}),e.jsx(t,{label:"Window",value:`${o.windowMs}ms`}),e.jsx(t,{label:"Probes",value:String(o.probeCount)}),e.jsx(t,{label:"Backoff",value:`${o.backoffDelayMs}ms`}),e.jsx(t,{label:"Failures",value:`${o.failures}/${o.attempts}`}),e.jsx(t,{label:"Frontier",value:o.stateSource==="ephemeral"?"non-live":o.frontierFrozen?"FROZEN":"LIVE"}),e.jsx(t,{label:"Spool lag",value:String(o.spoolLag)}),e.jsx(t,{label:"Encoder mode",value:o.encoderMode}),e.jsx(t,{label:"Encoder asset",value:o.encoderAssetDigest?o.encoderAssetDigest.slice(0,12):"none"})]}):e.jsx("div",{className:"vc-empty",children:"Health unavailable (VC0C off)."})]})]}),l.ml5dEnabled&&e.jsx(ie,{encoderMode:o?.encoderMode??"B",encoderAssetDigest:o?.encoderAssetDigest??null,status:l.status}),e.jsx(oe,{topology:s.topology,query:s.query}),e.jsx(ae,{view:s.shards}),e.jsx(ne,{view:s.reconstruct}),e.jsx(le,{view:s.plans}),e.jsx(W,{view:s.render}),e.jsx(G,{view:s.rollout}),e.jsx(K,{view:s.closureProof}),e.jsx(Q,{view:s.restore}),e.jsx(J,{view:s.repair}),e.jsx(Z,{view:s.crystals}),e.jsx(X,{view:s.economics}),e.jsx(ee,{view:s.diagnostics}),e.jsx(se,{view:s.outcomes}),e.jsx(te,{view:s.policy}),e.jsx(re,{view:s.platform}),e.jsx(de,{ledger:s.ledger})]})}export{he as default};
2
- //# sourceMappingURL=VectorCortexTab-DDjCkTjk.js.map