pi-mega-compact 0.13.2 → 0.13.3
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.
- package/dist/extensions/dashboard-server/api-contracts/endpoints/registry.js +13 -0
- package/dist/extensions/dashboard-server/api-contracts/rag-settings.js +10 -0
- package/dist/extensions/dashboard-server/routes-rag-settings.js +169 -0
- package/dist/extensions/dashboard-server/routes.js +1 -0
- package/dist/extensions/dashboard-server/server.js +3 -1
- package/dist/src/config.js +14 -7
- package/dist/src/recall/sync.js +4 -3
- package/extensions/dashboard-client/dist/assets/{CacheTab-DPRHjYZ0.js → CacheTab-Cqnc7lMg.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-DPRHjYZ0.js.map → CacheTab-Cqnc7lMg.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-CgwYq-Qf.js → EventsTab-tYk3VFAp.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-CgwYq-Qf.js.map → EventsTab-tYk3VFAp.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-BgOCjVzR.js → HealthTab-D2_kjgxw.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-BgOCjVzR.js.map → HealthTab-D2_kjgxw.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Yw1yFpsy.js → MaintenanceTab-Bc-uPYrz.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Yw1yFpsy.js.map → MaintenanceTab-Bc-uPYrz.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-yHUX7Yzi.js → MemoryMapTab-D1V9g_NC.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-yHUX7Yzi.js.map → MemoryMapTab-D1V9g_NC.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-CcH9fP8P.js → MetricsTab-DT_XfL96.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-CcH9fP8P.js.map → MetricsTab-DT_XfL96.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-BOs8ZNev.js → OverviewTab-BY6KZCme.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-BOs8ZNev.js.map → OverviewTab-BY6KZCme.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-B-MfSPvg.js → ReposTab-CeS-tpDM.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-B-MfSPvg.js.map → ReposTab-CeS-tpDM.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-BmeN649Q.js → SessionsTab-C30AwyoF.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-BmeN649Q.js.map → SessionsTab-C30AwyoF.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/SetupTab-BJUHOVK2.js +2 -0
- package/extensions/dashboard-client/dist/assets/SetupTab-BJUHOVK2.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-DnPg0L0z.js → TimeSavedCard-p55K1tFP.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-DnPg0L0z.js.map → TimeSavedCard-p55K1tFP.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TopicsTab-BODHOg_b.js → TopicsTab-D8FqyAbK.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TopicsTab-BODHOg_b.js.map → TopicsTab-D8FqyAbK.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-BK0I7hKr.js → TurnsTab-ju-nXDys.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-BK0I7hKr.js.map → TurnsTab-ju-nXDys.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-mOlljTFI.js → index-BEj1Zahy.js} +8 -8
- package/extensions/dashboard-client/dist/assets/index-BEj1Zahy.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{useSSE-BYOtv1-3.js → useSSE-p1pOI_-P.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-BYOtv1-3.js.map → useSSE-p1pOI_-P.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-client/src/api/client.ts +17 -0
- package/extensions/dashboard-client/src/tabs/SetupTab/EmbedderSetup.tsx +2 -0
- package/extensions/dashboard-client/src/tabs/SetupTab/RagSettingsCard.tsx +160 -0
- package/extensions/dashboard-server/api-contracts/endpoints/registry.ts +23 -0
- package/extensions/dashboard-server/api-contracts/index.ts +8 -0
- package/extensions/dashboard-server/api-contracts/rag-settings.ts +42 -0
- package/extensions/dashboard-server/routes-rag-settings.ts +207 -0
- package/extensions/dashboard-server/routes.ts +1 -0
- package/extensions/dashboard-server/server.ts +2 -0
- package/package.json +1 -1
- package/src/config.ts +15 -7
- package/src/recall/sync.ts +4 -3
- package/extensions/dashboard-client/dist/assets/SetupTab-nOknoph5.js +0 -2
- package/extensions/dashboard-client/dist/assets/SetupTab-nOknoph5.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/index-mOlljTFI.js.map +0 -1
package/extensions/dashboard-client/dist/assets/{HealthTab-BgOCjVzR.js → HealthTab-D2_kjgxw.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as o,j as e}from"./index-
|
|
2
|
-
//# sourceMappingURL=HealthTab-
|
|
1
|
+
import{r as o,j as e}from"./index-BEj1Zahy.js";import{fetchContextHealth as u}from"./health-lSeDFTz7.js";function d(t){return t>.8?"#4ade80":t>=.5?"#facc15":"#f87171"}function f({score:t}){const a=2*Math.PI*70,h=a*(1-Math.max(0,Math.min(1,t))),n=d(t);return e.jsxs("div",{className:"health-gauge-wrap",children:[e.jsxs("svg",{width:"180",height:"180",viewBox:"0 0 180 180",children:[e.jsx("circle",{cx:"90",cy:"90",r:70,fill:"none",stroke:"#1e293b",strokeWidth:"14"}),e.jsx("circle",{cx:"90",cy:"90",r:70,fill:"none",stroke:n,strokeWidth:"14",strokeDasharray:a,strokeDashoffset:h,strokeLinecap:"round",transform:"rotate(-90 90 90)",style:{transition:"stroke-dashoffset 0.5s ease"}}),e.jsx("text",{x:"90",y:"85",textAnchor:"middle",fontSize:"32",fontWeight:"bold",fill:n,children:(t*100).toFixed(0)}),e.jsx("text",{x:"90",y:"108",textAnchor:"middle",fontSize:"14",fill:"#94a3b8",children:"/ 100"})]}),e.jsx("div",{className:"health-gauge-label",children:"Context Health"})]})}function p({trend:t}){if(t.length<2)return e.jsx("div",{className:"health-spark-empty",children:"No trend data yet"});const l=400,a=60,h=1,n=0,x=t.map((r,j)=>{const s=j/(t.length-1)*l,m=a-(r-n)/(h-n)*a;return`${s.toFixed(1)},${m.toFixed(1)}`}),c=t[t.length-1];return e.jsx("svg",{width:l,height:a,viewBox:`0 0 ${l} ${a}`,className:"health-spark",children:e.jsx("polyline",{points:x.join(" "),fill:"none",stroke:d(c),strokeWidth:"2"})})}function i({label:t,value:l}){return e.jsxs("div",{className:"health-subscore",children:[e.jsx("span",{className:"health-subscore-label",children:t}),e.jsx("div",{className:"health-subscore-bar",children:e.jsx("div",{className:"health-subscore-fill",style:{width:`${l*100}%`,background:d(l)}})}),e.jsxs("span",{className:"health-subscore-val",children:[(l*100).toFixed(0),"%"]})]})}function b(){const[t,l]=o.useState(null),[a,h]=o.useState(null),[n,x]=o.useState(!0),c=o.useCallback(()=>{u().then(l).catch(s=>h(s instanceof Error?s.message:String(s))).finally(()=>x(!1))},[]);if(o.useEffect(()=>{c();const s=setInterval(c,5e3);return()=>clearInterval(s)},[c]),n&&!t)return e.jsx("div",{className:"health-loading",children:"Loading health data…"});if(a&&!t)return e.jsxs("div",{className:"health-error",children:["Error: ",a]});if(!t)return e.jsx("div",{className:"health-empty",children:"No health data available."});const r=t.latest,j=r?.composite??0;return e.jsxs("div",{className:"health-tab",children:[e.jsxs("div",{className:"health-top-row",children:[e.jsx(f,{score:j}),e.jsxs("div",{className:"health-subscores",children:[e.jsx("h3",{children:"Sub-Scores"}),e.jsx(i,{label:"Drift",value:r?.driftScore??0}),e.jsx(i,{label:"Output Quality",value:r?.outputQuality??0}),e.jsx(i,{label:"Error Rate",value:r?.errorScore??0}),e.jsx(i,{label:"Cache Health",value:r?.cacheHealth??0}),e.jsx(i,{label:"Cache Poison",value:r?.cachePoison??0})]})]}),e.jsxs("div",{className:"health-trend-section",children:[e.jsxs("h3",{children:["Health Trend (last ",t.trend.length," turns)"]}),e.jsx(p,{trend:t.trend})]}),t.alerts.length>0&&e.jsxs("div",{className:"health-alerts",children:[e.jsxs("h3",{children:["Recent Alerts (",t.alerts.length,")"]}),e.jsx("div",{className:"health-alert-list",children:t.alerts.slice(-10).map(s=>e.jsxs("div",{className:"health-alert-row",children:[e.jsx("span",{className:"health-alert-time",children:new Date(s.ts).toLocaleTimeString()}),e.jsx("span",{className:"health-alert-model",children:s.modelId??"(unknown)"}),e.jsx("span",{className:"health-alert-score",style:{color:d(s.composite)},children:(s.composite*100).toFixed(0)}),s.cachePoison<.3&&e.jsx("span",{className:"health-alert-tag",children:"CACHE POISON"})]},`${s.ts}-${s.turnIndex}`))})]}),t.perModel.length>0&&e.jsxs("div",{className:"health-per-model",children:[e.jsx("h3",{children:"Health by Model"}),e.jsxs("table",{className:"health-model-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Model"}),e.jsx("th",{children:"Avg Health"}),e.jsx("th",{children:"Samples"})]})}),e.jsx("tbody",{children:t.perModel.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:s.modelId}),e.jsxs("td",{style:{color:d(s.avgComposite)},children:[(s.avgComposite*100).toFixed(0),"%"]}),e.jsx("td",{children:s.sampleCount})]},s.modelId))})]})]})]})}export{b as default};
|
|
2
|
+
//# sourceMappingURL=HealthTab-D2_kjgxw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HealthTab-BgOCjVzR.js","sources":["../../src/tabs/HealthTab.tsx"],"sourcesContent":["/**\n * HealthTab.tsx — Context Health dashboard tab.\n * Shows composite health gauge, sparkline trend, sub-score bars,\n * alerts, and per-model comparison. Polls /api/context-health every 5s.\n */\n\nimport { useState, useEffect, useCallback } from \"react\";\nimport { fetchContextHealth, type ContextHealthResponse } from \"../api/health\";\n\nfunction healthColor(score: number): string {\n\tif (score > 0.8) return \"#4ade80\";\n\tif (score >= 0.5) return \"#facc15\";\n\treturn \"#f87171\";\n}\n\nfunction HealthGauge({ score }: { score: number }): React.ReactElement {\n\tconst r = 70;\n\tconst circ = 2 * Math.PI * r;\n\tconst offset = circ * (1 - Math.max(0, Math.min(1, score)));\n\tconst color = healthColor(score);\n\treturn (\n\t\t<div className=\"health-gauge-wrap\">\n\t\t\t<svg width=\"180\" height=\"180\" viewBox=\"0 0 180 180\">\n\t\t\t\t<circle cx=\"90\" cy=\"90\" r={r} fill=\"none\" stroke=\"#1e293b\" strokeWidth=\"14\" />\n\t\t\t\t<circle\n\t\t\t\t\tcx=\"90\"\n\t\t\t\t\tcy=\"90\"\n\t\t\t\t\tr={r}\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke={color}\n\t\t\t\t\tstrokeWidth=\"14\"\n\t\t\t\t\tstrokeDasharray={circ}\n\t\t\t\t\tstrokeDashoffset={offset}\n\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\ttransform=\"rotate(-90 90 90)\"\n\t\t\t\t\tstyle={{ transition: \"stroke-dashoffset 0.5s ease\" }}\n\t\t\t\t/>\n\t\t\t\t<text x=\"90\" y=\"85\" textAnchor=\"middle\" fontSize=\"32\" fontWeight=\"bold\" fill={color}>\n\t\t\t\t\t{(score * 100).toFixed(0)}\n\t\t\t\t</text>\n\t\t\t\t<text x=\"90\" y=\"108\" textAnchor=\"middle\" fontSize=\"14\" fill=\"#94a3b8\">/ 100</text>\n\t\t\t</svg>\n\t\t\t<div className=\"health-gauge-label\">Context Health</div>\n\t\t</div>\n\t);\n}\n\nfunction HealthSparkline({ trend }: { trend: number[] }): React.ReactElement {\n\tif (trend.length < 2) return <div className=\"health-spark-empty\">No trend data yet</div>;\n\tconst w = 400;\n\tconst h = 60;\n\tconst max = 1;\n\tconst min = 0;\n\tconst pts = trend.map((v, i) => {\n\t\tconst x = (i / (trend.length - 1)) * w;\n\t\tconst y = h - ((v - min) / (max - min)) * h;\n\t\treturn `${x.toFixed(1)},${y.toFixed(1)}`;\n\t});\n\tconst last = trend[trend.length - 1];\n\treturn (\n\t\t<svg width={w} height={h} viewBox={`0 0 ${w} ${h}`} className=\"health-spark\">\n\t\t\t<polyline points={pts.join(\" \")} fill=\"none\" stroke={healthColor(last)} strokeWidth=\"2\" />\n\t\t</svg>\n\t);\n}\n\nfunction SubScoreBar({ label, value }: { label: string; value: number }): React.ReactElement {\n\treturn (\n\t\t<div className=\"health-subscore\">\n\t\t\t<span className=\"health-subscore-label\">{label}</span>\n\t\t\t<div className=\"health-subscore-bar\">\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"health-subscore-fill\"\n\t\t\t\t\tstyle={{ width: `${value * 100}%`, background: healthColor(value) }}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<span className=\"health-subscore-val\">{(value * 100).toFixed(0)}%</span>\n\t\t</div>\n\t);\n}\n\nexport default function HealthTab(): React.ReactElement {\n\tconst [data, setData] = useState<ContextHealthResponse | null>(null);\n\tconst [err, setError] = useState<string | null>(null);\n\tconst [loading, setLoading] = useState(true);\n\n\tconst poll = useCallback(() => {\n\t\tfetchContextHealth()\n\t\t\t.then(setData)\n\t\t\t.catch((e: unknown) => setError(e instanceof Error ? e.message : String(e)))\n\t\t\t.finally(() => setLoading(false));\n\t}, []);\n\n\tuseEffect(() => {\n\t\tpoll();\n\t\tconst id = setInterval(poll, 5000);\n\t\treturn () => clearInterval(id);\n\t}, [poll]);\n\n\tif (loading && !data) return <div className=\"health-loading\">Loading health data…</div>;\n\tif (err && !data) return <div className=\"health-error\">Error: {err}</div>;\n\tif (!data) return <div className=\"health-empty\">No health data available.</div>;\n\n\tconst latest = data.latest;\n\tconst composite = latest?.composite ?? 0;\n\n\treturn (\n\t\t<div className=\"health-tab\">\n\t\t\t<div className=\"health-top-row\">\n\t\t\t\t<HealthGauge score={composite} />\n\t\t\t\t<div className=\"health-subscores\">\n\t\t\t\t\t<h3>Sub-Scores</h3>\n\t\t\t\t\t<SubScoreBar label=\"Drift\" value={latest?.driftScore ?? 0} />\n\t\t\t\t\t<SubScoreBar label=\"Output Quality\" value={latest?.outputQuality ?? 0} />\n\t\t\t\t\t<SubScoreBar label=\"Error Rate\" value={latest?.errorScore ?? 0} />\n\t\t\t\t\t<SubScoreBar label=\"Cache Health\" value={latest?.cacheHealth ?? 0} />\n\t\t\t\t\t<SubScoreBar label=\"Cache Poison\" value={latest?.cachePoison ?? 0} />\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<div className=\"health-trend-section\">\n\t\t\t\t<h3>Health Trend (last {data.trend.length} turns)</h3>\n\t\t\t\t<HealthSparkline trend={data.trend} />\n\t\t\t</div>\n\n\t\t\t{data.alerts.length > 0 && (\n\t\t\t\t<div className=\"health-alerts\">\n\t\t\t\t\t<h3>Recent Alerts ({data.alerts.length})</h3>\n\t\t\t\t\t<div className=\"health-alert-list\">\n\t\t\t\t\t\t{data.alerts.slice(-10).map((a) => (\n\t\t\t\t\t\t\t<div key={`${a.ts}-${a.turnIndex}`} className=\"health-alert-row\">\n\t\t\t\t\t\t\t\t<span className=\"health-alert-time\">{new Date(a.ts).toLocaleTimeString()}</span>\n\t\t\t\t\t\t\t\t<span className=\"health-alert-model\">{a.modelId ?? \"(unknown)\"}</span>\n\t\t\t\t\t\t\t\t<span className=\"health-alert-score\" style={{ color: healthColor(a.composite) }}>\n\t\t\t\t\t\t\t\t\t{(a.composite * 100).toFixed(0)}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t{a.cachePoison < 0.3 && <span className=\"health-alert-tag\">CACHE POISON</span>}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\n\t\t\t{data.perModel.length > 0 && (\n\t\t\t\t<div className=\"health-per-model\">\n\t\t\t\t\t<h3>Health by Model</h3>\n\t\t\t\t\t<table className=\"health-model-table\">\n\t\t\t\t\t\t<thead><tr><th>Model</th><th>Avg Health</th><th>Samples</th></tr></thead>\n\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t{data.perModel.map((m) => (\n\t\t\t\t\t\t\t\t<tr key={m.modelId}>\n\t\t\t\t\t\t\t\t\t<td>{m.modelId}</td>\n\t\t\t\t\t\t\t\t\t<td style={{ color: healthColor(m.avgComposite) }}>\n\t\t\t\t\t\t\t\t\t\t{(m.avgComposite * 100).toFixed(0)}%\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td>{m.sampleCount}</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</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"names":["healthColor","score","HealthGauge","circ","offset","color","jsxs","jsx","HealthSparkline","trend","w","h","max","min","pts","v","i","x","y","last","SubScoreBar","label","value","HealthTab","data","setData","useState","err","setError","loading","setLoading","poll","useCallback","fetchContextHealth","e","useEffect","id","latest","composite","a","m"],"mappings":"yGASA,SAASA,EAAYC,EAAuB,CAC3C,OAAIA,EAAQ,GAAY,UACpBA,GAAS,GAAY,UAClB,SACR,CAEA,SAASC,EAAY,CAAE,MAAAD,GAAgD,CAEtE,MAAME,EAAO,EAAI,KAAK,GAAK,GACrBC,EAASD,GAAQ,EAAI,KAAK,IAAI,EAAG,KAAK,IAAI,EAAGF,CAAK,CAAC,GACnDI,EAAQL,EAAYC,CAAK,EAC/B,OACCK,EAAAA,KAAC,MAAA,CAAI,UAAU,oBACd,SAAA,CAAAA,OAAC,OAAI,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E,WAAA,CAAY,CAAA,GALXA,EAAE,OAMX,CACA,CAAA,CACF,CAAA,CAAA,CACD,CAAA,CAAA,CACD,CAAA,EAEF,CAEF"}
|
|
1
|
+
{"version":3,"file":"HealthTab-D2_kjgxw.js","sources":["../../src/tabs/HealthTab.tsx"],"sourcesContent":["/**\n * HealthTab.tsx — Context Health dashboard tab.\n * Shows composite health gauge, sparkline trend, sub-score bars,\n * alerts, and per-model comparison. Polls /api/context-health every 5s.\n */\n\nimport { useState, useEffect, useCallback } from \"react\";\nimport { fetchContextHealth, type ContextHealthResponse } from \"../api/health\";\n\nfunction healthColor(score: number): string {\n\tif (score > 0.8) return \"#4ade80\";\n\tif (score >= 0.5) return \"#facc15\";\n\treturn \"#f87171\";\n}\n\nfunction HealthGauge({ score }: { score: number }): React.ReactElement {\n\tconst r = 70;\n\tconst circ = 2 * Math.PI * r;\n\tconst offset = circ * (1 - Math.max(0, Math.min(1, score)));\n\tconst color = healthColor(score);\n\treturn (\n\t\t<div className=\"health-gauge-wrap\">\n\t\t\t<svg width=\"180\" height=\"180\" viewBox=\"0 0 180 180\">\n\t\t\t\t<circle cx=\"90\" cy=\"90\" r={r} fill=\"none\" stroke=\"#1e293b\" strokeWidth=\"14\" />\n\t\t\t\t<circle\n\t\t\t\t\tcx=\"90\"\n\t\t\t\t\tcy=\"90\"\n\t\t\t\t\tr={r}\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke={color}\n\t\t\t\t\tstrokeWidth=\"14\"\n\t\t\t\t\tstrokeDasharray={circ}\n\t\t\t\t\tstrokeDashoffset={offset}\n\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\ttransform=\"rotate(-90 90 90)\"\n\t\t\t\t\tstyle={{ transition: \"stroke-dashoffset 0.5s ease\" }}\n\t\t\t\t/>\n\t\t\t\t<text x=\"90\" y=\"85\" textAnchor=\"middle\" fontSize=\"32\" fontWeight=\"bold\" fill={color}>\n\t\t\t\t\t{(score * 100).toFixed(0)}\n\t\t\t\t</text>\n\t\t\t\t<text x=\"90\" y=\"108\" textAnchor=\"middle\" fontSize=\"14\" fill=\"#94a3b8\">/ 100</text>\n\t\t\t</svg>\n\t\t\t<div className=\"health-gauge-label\">Context Health</div>\n\t\t</div>\n\t);\n}\n\nfunction HealthSparkline({ trend }: { trend: number[] }): React.ReactElement {\n\tif (trend.length < 2) return <div className=\"health-spark-empty\">No trend data yet</div>;\n\tconst w = 400;\n\tconst h = 60;\n\tconst max = 1;\n\tconst min = 0;\n\tconst pts = trend.map((v, i) => {\n\t\tconst x = (i / (trend.length - 1)) * w;\n\t\tconst y = h - ((v - min) / (max - min)) * h;\n\t\treturn `${x.toFixed(1)},${y.toFixed(1)}`;\n\t});\n\tconst last = trend[trend.length - 1];\n\treturn (\n\t\t<svg width={w} height={h} viewBox={`0 0 ${w} ${h}`} className=\"health-spark\">\n\t\t\t<polyline points={pts.join(\" \")} fill=\"none\" stroke={healthColor(last)} strokeWidth=\"2\" />\n\t\t</svg>\n\t);\n}\n\nfunction SubScoreBar({ label, value }: { label: string; value: number }): React.ReactElement {\n\treturn (\n\t\t<div className=\"health-subscore\">\n\t\t\t<span className=\"health-subscore-label\">{label}</span>\n\t\t\t<div className=\"health-subscore-bar\">\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"health-subscore-fill\"\n\t\t\t\t\tstyle={{ width: `${value * 100}%`, background: healthColor(value) }}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<span className=\"health-subscore-val\">{(value * 100).toFixed(0)}%</span>\n\t\t</div>\n\t);\n}\n\nexport default function HealthTab(): React.ReactElement {\n\tconst [data, setData] = useState<ContextHealthResponse | null>(null);\n\tconst [err, setError] = useState<string | null>(null);\n\tconst [loading, setLoading] = useState(true);\n\n\tconst poll = useCallback(() => {\n\t\tfetchContextHealth()\n\t\t\t.then(setData)\n\t\t\t.catch((e: unknown) => setError(e instanceof Error ? e.message : String(e)))\n\t\t\t.finally(() => setLoading(false));\n\t}, []);\n\n\tuseEffect(() => {\n\t\tpoll();\n\t\tconst id = setInterval(poll, 5000);\n\t\treturn () => clearInterval(id);\n\t}, [poll]);\n\n\tif (loading && !data) return <div className=\"health-loading\">Loading health data…</div>;\n\tif (err && !data) return <div className=\"health-error\">Error: {err}</div>;\n\tif (!data) return <div className=\"health-empty\">No health data available.</div>;\n\n\tconst latest = data.latest;\n\tconst composite = latest?.composite ?? 0;\n\n\treturn (\n\t\t<div className=\"health-tab\">\n\t\t\t<div className=\"health-top-row\">\n\t\t\t\t<HealthGauge score={composite} />\n\t\t\t\t<div className=\"health-subscores\">\n\t\t\t\t\t<h3>Sub-Scores</h3>\n\t\t\t\t\t<SubScoreBar label=\"Drift\" value={latest?.driftScore ?? 0} />\n\t\t\t\t\t<SubScoreBar label=\"Output Quality\" value={latest?.outputQuality ?? 0} />\n\t\t\t\t\t<SubScoreBar label=\"Error Rate\" value={latest?.errorScore ?? 0} />\n\t\t\t\t\t<SubScoreBar label=\"Cache Health\" value={latest?.cacheHealth ?? 0} />\n\t\t\t\t\t<SubScoreBar label=\"Cache Poison\" value={latest?.cachePoison ?? 0} />\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<div className=\"health-trend-section\">\n\t\t\t\t<h3>Health Trend (last {data.trend.length} turns)</h3>\n\t\t\t\t<HealthSparkline trend={data.trend} />\n\t\t\t</div>\n\n\t\t\t{data.alerts.length > 0 && (\n\t\t\t\t<div className=\"health-alerts\">\n\t\t\t\t\t<h3>Recent Alerts ({data.alerts.length})</h3>\n\t\t\t\t\t<div className=\"health-alert-list\">\n\t\t\t\t\t\t{data.alerts.slice(-10).map((a) => (\n\t\t\t\t\t\t\t<div key={`${a.ts}-${a.turnIndex}`} className=\"health-alert-row\">\n\t\t\t\t\t\t\t\t<span className=\"health-alert-time\">{new Date(a.ts).toLocaleTimeString()}</span>\n\t\t\t\t\t\t\t\t<span className=\"health-alert-model\">{a.modelId ?? \"(unknown)\"}</span>\n\t\t\t\t\t\t\t\t<span className=\"health-alert-score\" style={{ color: healthColor(a.composite) }}>\n\t\t\t\t\t\t\t\t\t{(a.composite * 100).toFixed(0)}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t{a.cachePoison < 0.3 && <span className=\"health-alert-tag\">CACHE POISON</span>}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\n\t\t\t{data.perModel.length > 0 && (\n\t\t\t\t<div className=\"health-per-model\">\n\t\t\t\t\t<h3>Health by Model</h3>\n\t\t\t\t\t<table className=\"health-model-table\">\n\t\t\t\t\t\t<thead><tr><th>Model</th><th>Avg Health</th><th>Samples</th></tr></thead>\n\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t{data.perModel.map((m) => (\n\t\t\t\t\t\t\t\t<tr key={m.modelId}>\n\t\t\t\t\t\t\t\t\t<td>{m.modelId}</td>\n\t\t\t\t\t\t\t\t\t<td style={{ color: healthColor(m.avgComposite) }}>\n\t\t\t\t\t\t\t\t\t\t{(m.avgComposite * 100).toFixed(0)}%\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td>{m.sampleCount}</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</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"names":["healthColor","score","HealthGauge","circ","offset","color","jsxs","jsx","HealthSparkline","trend","w","h","max","min","pts","v","i","x","y","last","SubScoreBar","label","value","HealthTab","data","setData","useState","err","setError","loading","setLoading","poll","useCallback","fetchContextHealth","e","useEffect","id","latest","composite","a","m"],"mappings":"yGASA,SAASA,EAAYC,EAAuB,CAC3C,OAAIA,EAAQ,GAAY,UACpBA,GAAS,GAAY,UAClB,SACR,CAEA,SAASC,EAAY,CAAE,MAAAD,GAAgD,CAEtE,MAAME,EAAO,EAAI,KAAK,GAAK,GACrBC,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,OAAC,MAAG,MAAO,CAAE,MAAON,EAAYwC,EAAE,YAAY,CAAA,EAC3C,SAAA,EAAAA,EAAE,aAAe,KAAK,QAAQ,CAAC,EAAE,GAAA,EACpC,EACAjC,EAAAA,IAAC,KAAA,CAAI,SAAAiC,EAAE,WAAA,CAAY,CAAA,GALXA,EAAE,OAMX,CACA,CAAA,CACF,CAAA,CAAA,CACD,CAAA,CAAA,CACD,CAAA,EAEF,CAEF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,r,C as f,D as v,_ as p,u as N,E as C,F as w}from"./index-mOlljTFI.js";function k({columns:s}){const l=s.filter(t=>!t.present);return e.jsxs("div",{className:"stat-section",children:[e.jsxs("div",{className:"stat-label",children:["Column Audit (",s.length," columns, ",l.length," missing)"]}),e.jsxs("table",{className:"compact-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Table"}),e.jsx("th",{children:"Column"}),e.jsx("th",{children:"Decl"}),e.jsx("th",{children:"Status"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.table}),e.jsx("td",{children:t.column}),e.jsx("td",{className:"text-mono",children:t.expectedDecl}),e.jsx("td",{className:t.present?"text-ok":"text-error",children:t.present?"✓":"MISSING"})]},`${t.table}.${t.column}`))})]})]})}function S({data:s,loading:l,error:t}){return e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-header",children:["Schema Health",s&&e.jsx("span",{className:`badge ${s.healthy?"badge-ok":"badge-bad"}`,children:s.healthy?"HEALTHY":"DEGRADED"})]}),e.jsxs("div",{className:"card-body",children:[l&&!s&&e.jsx("span",{className:"text-muted",children:"Loading…"}),t&&!s&&e.jsx("span",{className:"text-error",children:t.message}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"stat-row",children:[e.jsx("span",{className:"stat-label",children:"Schema version"}),e.jsx("span",{className:"num",children:s.schemaVersion})]}),e.jsxs("div",{className:"stat-row",children:[e.jsx("span",{className:"stat-label",children:"Integrity"}),e.jsx("span",{className:s.integrity[0]==="ok"?"text-ok":"text-error",children:s.integrity.join("; ")})]}),e.jsx(k,{columns:s.columns}),s.fkCheck.length>0&&e.jsxs("div",{className:"stat-section",children:[e.jsxs("div",{className:"stat-label text-warn",children:["FK Check (",s.fkCheck.length,")"]}),s.fkCheck.map((i,o)=>e.jsx("div",{className:"text-warn text-mono",children:i},o))]})]})]})]})}function g(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function R({files:s,pageSize:l,pageCount:t,freelistPages:i}){const o=s.dbBytes+s.walBytes+s.shmBytes;return e.jsxs("div",{className:"stat-section",children:[e.jsx("div",{className:"stat-label",children:"File Sizes"}),e.jsx("table",{className:"compact-table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{children:"sqlite.db"}),e.jsx("td",{className:"num",children:g(s.dbBytes)})]}),s.walBytes>0&&e.jsxs("tr",{children:[e.jsx("td",{children:".wal"}),e.jsx("td",{className:"num",children:g(s.walBytes)})]}),s.shmBytes>0&&e.jsxs("tr",{children:[e.jsx("td",{children:".shm"}),e.jsx("td",{className:"num",children:g(s.shmBytes)})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Total"}),e.jsx("td",{className:"num",children:g(o)})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Page size"}),e.jsx("td",{className:"num",children:g(l)})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Pages"}),e.jsxs("td",{className:"num",children:[t.toLocaleString()," (",i.toLocaleString()," ","free)"]})]})]})})]})}function E({tables:s}){const l=s.reduce((t,i)=>t+Math.max(0,i.rowCount),0);return e.jsxs("div",{className:"stat-section",children:[e.jsxs("div",{className:"stat-label",children:["Table Row Counts (",l.toLocaleString()," total)"]}),e.jsxs("table",{className:"compact-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Table"}),e.jsx("th",{className:"num",children:"Rows"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.table}),e.jsx("td",{className:"num",children:t.rowCount>=0?t.rowCount.toLocaleString():"—"})]},t.table))})]})]})}function D({data:s,loading:l,error:t}){return e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"card-header",children:"DB Stats"}),e.jsxs("div",{className:"card-body",children:[l&&!s&&e.jsx("span",{className:"text-muted",children:"Loading…"}),t&&!s&&e.jsx("span",{className:"text-error",children:t.message}),s&&e.jsxs(e.Fragment,{children:[e.jsx(R,{files:s.storage.files,pageSize:s.storage.pageSize,pageCount:s.storage.pageCount,freelistPages:s.storage.freelistPages}),e.jsx(E,{tables:s.tables})]})]})]})}const A=[{key:"integrity-check",label:"Integrity Check",desc:"Run PRAGMA integrity_check",dangerous:!1},{key:"reconcile-dedup",label:"Reconcile Dedup Mirror",desc:"Fix orphan dedup rows + backfill refs",dangerous:!1,confirm:"Reconcile dedup_mirror (safe read/write)?"},{key:"checkpoint",label:"WAL Checkpoint",desc:"Merge WAL into main DB (read-only)",dangerous:!1},{key:"vacuum",label:"VACUUM",desc:"Rebuild DB reclaiming free pages",dangerous:!0,confirm:"VACUUM rewrites the entire DB. Continue?"},{key:"reindex",label:"REINDEX",desc:"Rebuild all indexes",dangerous:!0,confirm:"REINDEX rebuilds indexes. Continue?"},{key:"fts5-rebuild",label:"FTS5 Rebuild",desc:"Rebuild full-text search index",dangerous:!0,confirm:"Rebuild FTS5 trigram index. Continue?"},{key:"prune",label:"Prune Old Rows",desc:"Delete transcripts + epochs older than N days",dangerous:!0,daysOld:!0,confirm:"Delete old raw_transcript rows. Continue?"}];function B(){const[s,l]=r.useState([]),[t,i]=r.useState(null),[o,m]=r.useState("30"),x=r.useCallback(async a=>{const u=a.daysOld?{action:"prune",daysOld:Number(o)}:{action:a.key};i(a.key);try{const d=await f(u);l(n=>[{...d,timestamp:Date.now()},...n].slice(0,20))}catch(d){l(n=>[{operation:a.key,success:!1,affected:0,reclaimedBytes:0,summary:d instanceof Error?d.message:String(d),timestamp:Date.now()},...n].slice(0,20))}finally{i(null)}},[o]);return e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"card-header",children:"Actions"}),e.jsx("div",{className:"card-body",children:e.jsx("div",{className:"action-grid",children:A.map(a=>{const u=t===a.key,d=s.find(n=>n.operation===a.key);return e.jsxs("div",{className:"action-item",children:[e.jsxs("div",{className:"action-info",children:[e.jsxs("div",{className:"action-label",children:[a.label,a.dangerous&&e.jsx("span",{className:"badge badge-warn",children:"DESTRUCTIVE"})]}),e.jsx("div",{className:"action-desc",children:a.desc}),d&&e.jsx("div",{className:`action-result ${d.success?"text-ok":"text-error"}`,children:d.summary})]}),e.jsxs("div",{className:"action-controls",children:[a.daysOld&&e.jsx("input",{type:"number",min:1,max:365,value:o,onChange:n=>m(n.target.value),className:"days-input",disabled:u}),e.jsx("button",{className:`btn ${a.dangerous?"btn-danger":"btn-primary"}`,disabled:t!==null,onClick:()=>{a.confirm&&!window.confirm(a.confirm)||x(a)},children:u?"Running…":"Run"})]})]},a.key)})})})]})}function L(){const[s,l]=r.useState(null),[t,i]=r.useState(!1),[o,m]=r.useState(null),[x,a]=r.useState(!1),u=r.useCallback(async()=>{i(!0),m(null);try{const c=await v();l(c),a(!0)}catch(c){m(c instanceof Error?c.message:String(c))}finally{i(!1)}},[]),d=r.useCallback(()=>{if(!s)return;const c=JSON.stringify(s,null,2);navigator.clipboard.writeText(c).catch(()=>{})},[s]),n=r.useCallback(()=>{if(!s)return;const c=JSON.stringify(s,null,2),y=new Blob([c],{type:"application/json"}),b=URL.createObjectURL(y),j=document.createElement("a");j.href=b,j.download=`mega-compact-debug-bundle-${s.builtAt}.json`,j.click(),URL.revokeObjectURL(b)},[s]),h=s?.criticalEvents.length??0;return e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-header",children:["Debug Bundle",h>0&&e.jsxs("span",{className:"text-warn",style:{marginLeft:"1em"},children:[h," critical event",h!==1?"s":""," found"]})]}),e.jsxs("div",{className:"card-body",children:[e.jsx("p",{className:"text-muted",style:{marginBottom:"0.75em"},children:"Gather a diagnostic bundle (recent events, config flags, schema health, store stats) to attach to a bug report. Critical/compaction events are highlighted."}),e.jsx("button",{onClick:u,disabled:t,style:{marginRight:"0.5em"},children:t?"Gathering…":"Gather Debug Logs"}),o&&e.jsx("div",{className:"text-error",children:o}),s&&x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"0.75em",marginBottom:"0.5em"},children:[e.jsx("button",{onClick:d,style:{marginRight:"0.5em"},children:"Copy to clipboard"}),e.jsx("button",{onClick:n,children:"Download JSON"}),e.jsx("button",{onClick:()=>a(c=>!c),style:{marginLeft:"0.5em"},children:x?"Hide":"Show"})]}),h>0&&e.jsxs("div",{className:"stat-section",children:[e.jsxs("div",{className:"stat-label text-warn",children:["Critical events (",h,")"]}),e.jsx("pre",{className:"text-mono",style:{maxHeight:"12em",overflow:"auto"},children:JSON.stringify(s.criticalEvents,null,2)})]}),e.jsx("pre",{className:"text-mono",style:{maxHeight:"24em",overflow:"auto"},children:JSON.stringify(s,null,2)})]})]})]})}function T(){const[s,l]=r.useState(!1),[t,i]=r.useState(!0),[o,m]=r.useState(!1),[x,a]=r.useState(null),u=r.useCallback(async()=>{try{const{fetchHealthSettings:n}=await p(async()=>{const{fetchHealthSettings:c}=await import("./health-lSeDFTz7.js");return{fetchHealthSettings:c}},[],import.meta.url),h=await n();l(h.mitigate)}catch(n){a(n instanceof Error?n.message:String(n))}finally{i(!1)}},[]);r.useEffect(()=>{u()},[u]);const d=r.useCallback(async()=>{m(!0),a(null);try{const{setHealthMitigate:n}=await p(async()=>{const{setHealthMitigate:c}=await import("./health-lSeDFTz7.js");return{setHealthMitigate:c}},[],import.meta.url),h=!s;await n(h),l(h)}catch(n){a(n instanceof Error?n.message:String(n))}finally{m(!1)}},[s]);return e.jsxs("div",{className:"stat-section maintenance-card",children:[e.jsx("div",{className:"stat-label",children:"Context Health Mitigation"}),t?e.jsx("p",{className:"repo-none",children:"Loading…"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"health-mitigate-row",children:e.jsxs("label",{className:"health-mitigate-toggle",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:d,disabled:o}),e.jsxs("span",{children:["Auto-mitigation ",s?"ON":"OFF"]})]})}),e.jsxs("div",{className:"health-mitigate-info",children:[e.jsxs("p",{children:["When ",e.jsx("strong",{children:"ON"}),", the extension automatically intervenes when context health degrades:"]}),e.jsxs("ul",{children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Forced compaction"})," — when the composite health score drops below 0.4 (severe drift or garbled output), a compaction is triggered to flush the degraded context and rebuild from clean checkpoints, even if the context window isn't full."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Prefix break"})," — when KV cache poison is detected (score < 0.3), the cached prefix is invalidated to force a cache miss on the next turn, bypassing the corrupted KV state."]})]}),e.jsx("p",{className:"health-mitigate-warning",children:"WARNING: both interventions have costs — forced compaction discards live context, and prefix breaks kill cache savings. Only enable when you're seeing degraded output (garbled text, hallucinations, loss of coherence) and the Health tab confirms low scores."}),e.jsxs("p",{children:["Also settable via env var: ",e.jsx("code",{children:"MEGACOMPACT_CONTEXT_HEALTH_MITIGATE=1"}),". The dashboard toggle persists to the store and takes precedence."]}),x&&e.jsxs("p",{className:"health-mitigate-error",children:["Error: ",x]})]})]})]})}function _(){const{data:s,loading:l,error:t}=N(r.useCallback(()=>C(),[]),{pollInterval:15e3}),{data:i,loading:o,error:m}=N(r.useCallback(()=>w(),[]),{pollInterval:1e4});return e.jsxs("div",{className:"maintenance-tab",children:[e.jsxs("div",{className:"card-grid",children:[e.jsx(S,{data:i,loading:o,error:m}),e.jsx(D,{data:s,loading:l,error:t})]}),e.jsx(B,{}),e.jsx(L,{}),e.jsx(T,{})]})}export{_ as default};
|
|
2
|
-
//# sourceMappingURL=MaintenanceTab-
|
|
1
|
+
import{j as e,r,E as f,F as v,_ as p,u as N,G as w,H as C}from"./index-BEj1Zahy.js";function k({columns:s}){const l=s.filter(t=>!t.present);return e.jsxs("div",{className:"stat-section",children:[e.jsxs("div",{className:"stat-label",children:["Column Audit (",s.length," columns, ",l.length," missing)"]}),e.jsxs("table",{className:"compact-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Table"}),e.jsx("th",{children:"Column"}),e.jsx("th",{children:"Decl"}),e.jsx("th",{children:"Status"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.table}),e.jsx("td",{children:t.column}),e.jsx("td",{className:"text-mono",children:t.expectedDecl}),e.jsx("td",{className:t.present?"text-ok":"text-error",children:t.present?"✓":"MISSING"})]},`${t.table}.${t.column}`))})]})]})}function S({data:s,loading:l,error:t}){return e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-header",children:["Schema Health",s&&e.jsx("span",{className:`badge ${s.healthy?"badge-ok":"badge-bad"}`,children:s.healthy?"HEALTHY":"DEGRADED"})]}),e.jsxs("div",{className:"card-body",children:[l&&!s&&e.jsx("span",{className:"text-muted",children:"Loading…"}),t&&!s&&e.jsx("span",{className:"text-error",children:t.message}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"stat-row",children:[e.jsx("span",{className:"stat-label",children:"Schema version"}),e.jsx("span",{className:"num",children:s.schemaVersion})]}),e.jsxs("div",{className:"stat-row",children:[e.jsx("span",{className:"stat-label",children:"Integrity"}),e.jsx("span",{className:s.integrity[0]==="ok"?"text-ok":"text-error",children:s.integrity.join("; ")})]}),e.jsx(k,{columns:s.columns}),s.fkCheck.length>0&&e.jsxs("div",{className:"stat-section",children:[e.jsxs("div",{className:"stat-label text-warn",children:["FK Check (",s.fkCheck.length,")"]}),s.fkCheck.map((i,o)=>e.jsx("div",{className:"text-warn text-mono",children:i},o))]})]})]})]})}function g(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function R({files:s,pageSize:l,pageCount:t,freelistPages:i}){const o=s.dbBytes+s.walBytes+s.shmBytes;return e.jsxs("div",{className:"stat-section",children:[e.jsx("div",{className:"stat-label",children:"File Sizes"}),e.jsx("table",{className:"compact-table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{children:"sqlite.db"}),e.jsx("td",{className:"num",children:g(s.dbBytes)})]}),s.walBytes>0&&e.jsxs("tr",{children:[e.jsx("td",{children:".wal"}),e.jsx("td",{className:"num",children:g(s.walBytes)})]}),s.shmBytes>0&&e.jsxs("tr",{children:[e.jsx("td",{children:".shm"}),e.jsx("td",{className:"num",children:g(s.shmBytes)})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Total"}),e.jsx("td",{className:"num",children:g(o)})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Page size"}),e.jsx("td",{className:"num",children:g(l)})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Pages"}),e.jsxs("td",{className:"num",children:[t.toLocaleString()," (",i.toLocaleString()," ","free)"]})]})]})})]})}function E({tables:s}){const l=s.reduce((t,i)=>t+Math.max(0,i.rowCount),0);return e.jsxs("div",{className:"stat-section",children:[e.jsxs("div",{className:"stat-label",children:["Table Row Counts (",l.toLocaleString()," total)"]}),e.jsxs("table",{className:"compact-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Table"}),e.jsx("th",{className:"num",children:"Rows"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.table}),e.jsx("td",{className:"num",children:t.rowCount>=0?t.rowCount.toLocaleString():"—"})]},t.table))})]})]})}function D({data:s,loading:l,error:t}){return e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"card-header",children:"DB Stats"}),e.jsxs("div",{className:"card-body",children:[l&&!s&&e.jsx("span",{className:"text-muted",children:"Loading…"}),t&&!s&&e.jsx("span",{className:"text-error",children:t.message}),s&&e.jsxs(e.Fragment,{children:[e.jsx(R,{files:s.storage.files,pageSize:s.storage.pageSize,pageCount:s.storage.pageCount,freelistPages:s.storage.freelistPages}),e.jsx(E,{tables:s.tables})]})]})]})}const A=[{key:"integrity-check",label:"Integrity Check",desc:"Run PRAGMA integrity_check",dangerous:!1},{key:"reconcile-dedup",label:"Reconcile Dedup Mirror",desc:"Fix orphan dedup rows + backfill refs",dangerous:!1,confirm:"Reconcile dedup_mirror (safe read/write)?"},{key:"checkpoint",label:"WAL Checkpoint",desc:"Merge WAL into main DB (read-only)",dangerous:!1},{key:"vacuum",label:"VACUUM",desc:"Rebuild DB reclaiming free pages",dangerous:!0,confirm:"VACUUM rewrites the entire DB. Continue?"},{key:"reindex",label:"REINDEX",desc:"Rebuild all indexes",dangerous:!0,confirm:"REINDEX rebuilds indexes. Continue?"},{key:"fts5-rebuild",label:"FTS5 Rebuild",desc:"Rebuild full-text search index",dangerous:!0,confirm:"Rebuild FTS5 trigram index. Continue?"},{key:"prune",label:"Prune Old Rows",desc:"Delete transcripts + epochs older than N days",dangerous:!0,daysOld:!0,confirm:"Delete old raw_transcript rows. Continue?"}];function B(){const[s,l]=r.useState([]),[t,i]=r.useState(null),[o,m]=r.useState("30"),x=r.useCallback(async a=>{const u=a.daysOld?{action:"prune",daysOld:Number(o)}:{action:a.key};i(a.key);try{const d=await f(u);l(n=>[{...d,timestamp:Date.now()},...n].slice(0,20))}catch(d){l(n=>[{operation:a.key,success:!1,affected:0,reclaimedBytes:0,summary:d instanceof Error?d.message:String(d),timestamp:Date.now()},...n].slice(0,20))}finally{i(null)}},[o]);return e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"card-header",children:"Actions"}),e.jsx("div",{className:"card-body",children:e.jsx("div",{className:"action-grid",children:A.map(a=>{const u=t===a.key,d=s.find(n=>n.operation===a.key);return e.jsxs("div",{className:"action-item",children:[e.jsxs("div",{className:"action-info",children:[e.jsxs("div",{className:"action-label",children:[a.label,a.dangerous&&e.jsx("span",{className:"badge badge-warn",children:"DESTRUCTIVE"})]}),e.jsx("div",{className:"action-desc",children:a.desc}),d&&e.jsx("div",{className:`action-result ${d.success?"text-ok":"text-error"}`,children:d.summary})]}),e.jsxs("div",{className:"action-controls",children:[a.daysOld&&e.jsx("input",{type:"number",min:1,max:365,value:o,onChange:n=>m(n.target.value),className:"days-input",disabled:u}),e.jsx("button",{className:`btn ${a.dangerous?"btn-danger":"btn-primary"}`,disabled:t!==null,onClick:()=>{a.confirm&&!window.confirm(a.confirm)||x(a)},children:u?"Running…":"Run"})]})]},a.key)})})})]})}function L(){const[s,l]=r.useState(null),[t,i]=r.useState(!1),[o,m]=r.useState(null),[x,a]=r.useState(!1),u=r.useCallback(async()=>{i(!0),m(null);try{const c=await v();l(c),a(!0)}catch(c){m(c instanceof Error?c.message:String(c))}finally{i(!1)}},[]),d=r.useCallback(()=>{if(!s)return;const c=JSON.stringify(s,null,2);navigator.clipboard.writeText(c).catch(()=>{})},[s]),n=r.useCallback(()=>{if(!s)return;const c=JSON.stringify(s,null,2),y=new Blob([c],{type:"application/json"}),b=URL.createObjectURL(y),j=document.createElement("a");j.href=b,j.download=`mega-compact-debug-bundle-${s.builtAt}.json`,j.click(),URL.revokeObjectURL(b)},[s]),h=s?.criticalEvents.length??0;return e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-header",children:["Debug Bundle",h>0&&e.jsxs("span",{className:"text-warn",style:{marginLeft:"1em"},children:[h," critical event",h!==1?"s":""," found"]})]}),e.jsxs("div",{className:"card-body",children:[e.jsx("p",{className:"text-muted",style:{marginBottom:"0.75em"},children:"Gather a diagnostic bundle (recent events, config flags, schema health, store stats) to attach to a bug report. Critical/compaction events are highlighted."}),e.jsx("button",{onClick:u,disabled:t,style:{marginRight:"0.5em"},children:t?"Gathering…":"Gather Debug Logs"}),o&&e.jsx("div",{className:"text-error",children:o}),s&&x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"0.75em",marginBottom:"0.5em"},children:[e.jsx("button",{onClick:d,style:{marginRight:"0.5em"},children:"Copy to clipboard"}),e.jsx("button",{onClick:n,children:"Download JSON"}),e.jsx("button",{onClick:()=>a(c=>!c),style:{marginLeft:"0.5em"},children:x?"Hide":"Show"})]}),h>0&&e.jsxs("div",{className:"stat-section",children:[e.jsxs("div",{className:"stat-label text-warn",children:["Critical events (",h,")"]}),e.jsx("pre",{className:"text-mono",style:{maxHeight:"12em",overflow:"auto"},children:JSON.stringify(s.criticalEvents,null,2)})]}),e.jsx("pre",{className:"text-mono",style:{maxHeight:"24em",overflow:"auto"},children:JSON.stringify(s,null,2)})]})]})]})}function T(){const[s,l]=r.useState(!1),[t,i]=r.useState(!0),[o,m]=r.useState(!1),[x,a]=r.useState(null),u=r.useCallback(async()=>{try{const{fetchHealthSettings:n}=await p(async()=>{const{fetchHealthSettings:c}=await import("./health-lSeDFTz7.js");return{fetchHealthSettings:c}},[],import.meta.url),h=await n();l(h.mitigate)}catch(n){a(n instanceof Error?n.message:String(n))}finally{i(!1)}},[]);r.useEffect(()=>{u()},[u]);const d=r.useCallback(async()=>{m(!0),a(null);try{const{setHealthMitigate:n}=await p(async()=>{const{setHealthMitigate:c}=await import("./health-lSeDFTz7.js");return{setHealthMitigate:c}},[],import.meta.url),h=!s;await n(h),l(h)}catch(n){a(n instanceof Error?n.message:String(n))}finally{m(!1)}},[s]);return e.jsxs("div",{className:"stat-section maintenance-card",children:[e.jsx("div",{className:"stat-label",children:"Context Health Mitigation"}),t?e.jsx("p",{className:"repo-none",children:"Loading…"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"health-mitigate-row",children:e.jsxs("label",{className:"health-mitigate-toggle",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:d,disabled:o}),e.jsxs("span",{children:["Auto-mitigation ",s?"ON":"OFF"]})]})}),e.jsxs("div",{className:"health-mitigate-info",children:[e.jsxs("p",{children:["When ",e.jsx("strong",{children:"ON"}),", the extension automatically intervenes when context health degrades:"]}),e.jsxs("ul",{children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Forced compaction"})," — when the composite health score drops below 0.4 (severe drift or garbled output), a compaction is triggered to flush the degraded context and rebuild from clean checkpoints, even if the context window isn't full."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Prefix break"})," — when KV cache poison is detected (score < 0.3), the cached prefix is invalidated to force a cache miss on the next turn, bypassing the corrupted KV state."]})]}),e.jsx("p",{className:"health-mitigate-warning",children:"WARNING: both interventions have costs — forced compaction discards live context, and prefix breaks kill cache savings. Only enable when you're seeing degraded output (garbled text, hallucinations, loss of coherence) and the Health tab confirms low scores."}),e.jsxs("p",{children:["Also settable via env var: ",e.jsx("code",{children:"MEGACOMPACT_CONTEXT_HEALTH_MITIGATE=1"}),". The dashboard toggle persists to the store and takes precedence."]}),x&&e.jsxs("p",{className:"health-mitigate-error",children:["Error: ",x]})]})]})]})}function H(){const{data:s,loading:l,error:t}=N(r.useCallback(()=>w(),[]),{pollInterval:15e3}),{data:i,loading:o,error:m}=N(r.useCallback(()=>C(),[]),{pollInterval:1e4});return e.jsxs("div",{className:"maintenance-tab",children:[e.jsxs("div",{className:"card-grid",children:[e.jsx(S,{data:i,loading:o,error:m}),e.jsx(D,{data:s,loading:l,error:t})]}),e.jsx(B,{}),e.jsx(L,{}),e.jsx(T,{})]})}export{H as default};
|
|
2
|
+
//# sourceMappingURL=MaintenanceTab-Bc-uPYrz.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"oFAcA,SAASA,EAAgB,CACxB,QAAAC,CACD,EAEuB,CACtB,MAAMC,EAAUD,EAAQ,OAAQE,GAAM,CAACA,EAAE,OAAO,EAChD,OACCC,OAAC,OAAI,UAAU,eACd,UAAAA,OAAC,OAAI,UAAU,aAAa,2BACZH,EAAQ,OAAO,aAAWC,EAAQ,OAAO,aACzD,EACAE,OAAC,SAAM,UAAU,gBAChB,UAAAC,MAAC,SACA,gBAAC,MACA,UAAAA,MAAC,MAAG,iBAAK,EACTA,MAAC,MAAG,kBAAM,EACVA,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AAA,EAAgB,EAAE,EACpC,CAAE,aAAc,KAAM,EAGjB,CACL,KAAMC,EACN,QAASC,EACT,MAAOC,CAAA,EACJJ,EACH5C,cAAY,IAAMiD,EAAA,EAAqB,EAAE,EACzC,CAAE,aAAc,IAAM,EAGvB,OACClF,OAAC,OAAI,UAAU,kBACd,UAAAA,OAAC,OAAI,UAAU,YACd,UAAAC,MAACC,EAAA,CACA,KAAM6E,EACN,QAASC,EACT,MAAOC,CAAA,SAEP3D,EAAA,CAAY,KAAMoD,EAAS,QAASC,EAAc,MAAOC,CAAA,CAAY,GACvE,QACCpD,EAAA,EAAY,QACZoB,EAAA,EAAgB,QAChBiB,EAAA,EAAqB,GACvB,CAEF","names":["ColumnAuditCard","columns","missing","c","jsxs","jsx","SchemaHealthCard","data","loading","error","Fragment","line","i","fmtBytes","b","FileSizesCard","files","pageSize","pageCount","freelistPages","total","TableRowCountsCard","tables","totalRows","s","t","DbStatsCard","ACTIONS","ActionsCard","results","setResults","useState","running","setRunning","days","setDays","handleAction","useCallback","def","action","res","postMaintenanceAction","prev","err","isRunning","lastResult","r","e","DebugBundleCard","bundle","setBundle","setLoading","setError","showJson","setShowJson","gather","fetchDebugBundle","copyToClipboard","text","downloadJson","blob","url","a","criticalCount","v","HealthMitigationCard","mitigate","setMitigate","saving","setSaving","load","fetchHealthSettings","__vitePreload","useEffect","toggle","setHealthMitigate","next","MaintenanceTab","dbStats","statsLoading","statsError","useApi","fetchDbStats","schemaHealth","healthLoading","healthError","fetchSchemaHealth"],"ignoreList":[],"sources":["../../src/tabs/MaintenanceTab/SchemaHealthCard.tsx","../../src/tabs/MaintenanceTab/DbStatsCard.tsx","../../src/tabs/MaintenanceTab/ActionsCard.tsx","../../src/tabs/MaintenanceTab/DebugBundleCard.tsx","../../src/tabs/MaintenanceTab/HealthMitigationCard.tsx","../../src/tabs/MaintenanceTab.tsx"],"sourcesContent":["/**\n * dashboard-client/src/tabs/MaintenanceTab/SchemaHealthCard.tsx — Schema Health card.\n *\n * Extracted from MaintenanceTab.tsx (delegate-shell split). Renders schema\n * version, integrity check, column audit, and FK check from\n * GET /api/maintenance/schema-health.\n */\nimport type React from \"react\";\nimport type { SchemaHealthResponse } from \"@contracts\";\n\n// ---------------------------------------------------------------------------\n// Schema Health card\n// ---------------------------------------------------------------------------\n\nfunction ColumnAuditCard({\n\tcolumns,\n}: {\n\tcolumns: SchemaHealthResponse[\"columns\"];\n}): React.ReactElement {\n\tconst missing = columns.filter((c) => !c.present);\n\treturn (\n\t\t<div className=\"stat-section\">\n\t\t\t<div className=\"stat-label\">\n\t\t\t\tColumn Audit ({columns.length} columns, {missing.length} missing)\n\t\t\t</div>\n\t\t\t<table className=\"compact-table\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>Table</th>\n\t\t\t\t\t\t<th>Column</th>\n\t\t\t\t\t\t<th>Decl</th>\n\t\t\t\t\t\t<th>Status</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>\n\t\t\t\t\t{columns.map((c) => (\n\t\t\t\t\t\t<tr key={`${c.table}.${c.column}`}>\n\t\t\t\t\t\t\t<td>{c.table}</td>\n\t\t\t\t\t\t\t<td>{c.column}</td>\n\t\t\t\t\t\t\t<td className=\"text-mono\">{c.expectedDecl}</td>\n\t\t\t\t\t\t\t<td className={c.present ? \"text-ok\" : \"text-error\"}>\n\t\t\t\t\t\t\t\t{c.present ? \"✓\" : \"MISSING\"}\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t))}\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t);\n}\n\nexport function SchemaHealthCard({\n\tdata,\n\tloading,\n\terror,\n}: {\n\tdata: SchemaHealthResponse | null;\n\tloading: boolean;\n\terror: Error | null;\n}): React.ReactElement {\n\treturn (\n\t\t<div className=\"card\">\n\t\t\t<div className=\"card-header\">\n\t\t\t\tSchema Health\n\t\t\t\t{data && (\n\t\t\t\t\t<span className={`badge ${data.healthy ? \"badge-ok\" : \"badge-bad\"}`}>\n\t\t\t\t\t\t{data.healthy ? \"HEALTHY\" : \"DEGRADED\"}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t<div className=\"card-body\">\n\t\t\t\t{loading && !data && <span className=\"text-muted\">Loading…</span>}\n\t\t\t\t{error && !data && <span className=\"text-error\">{error.message}</span>}\n\t\t\t\t{data && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className=\"stat-row\">\n\t\t\t\t\t\t\t<span className=\"stat-label\">Schema version</span>\n\t\t\t\t\t\t\t<span className=\"num\">{data.schemaVersion}</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"stat-row\">\n\t\t\t\t\t\t\t<span className=\"stat-label\">Integrity</span>\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tdata.integrity[0] === \"ok\" ? \"text-ok\" : \"text-error\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{data.integrity.join(\"; \")}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<ColumnAuditCard columns={data.columns} />\n\t\t\t\t\t\t{data.fkCheck.length > 0 && (\n\t\t\t\t\t\t\t<div className=\"stat-section\">\n\t\t\t\t\t\t\t\t<div className=\"stat-label text-warn\">\n\t\t\t\t\t\t\t\t\tFK Check ({data.fkCheck.length})\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{data.fkCheck.map((line, i) => (\n\t\t\t\t\t\t\t\t\t<div key={i} className=\"text-warn text-mono\">\n\t\t\t\t\t\t\t\t\t\t{line}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n","/**\n * dashboard-client/src/tabs/MaintenanceTab/DbStatsCard.tsx — DB Stats card.\n *\n * Extracted from MaintenanceTab.tsx (delegate-shell split). Renders file sizes\n * and table row counts from GET /api/maintenance.\n */\nimport type React from \"react\";\nimport type { DbStatsResponse } from \"@contracts\";\n\n// ---------------------------------------------------------------------------\n// Format helpers (local — matches html.ts fmtBytes)\n// ---------------------------------------------------------------------------\n\nexport function fmtBytes(b: number): string {\n\tif (b < 1024) return `${b} B`;\n\tif (b < 1024 * 1024) return `${(b / 1024).toFixed(1)} KB`;\n\treturn `${(b / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n// ---------------------------------------------------------------------------\n// DB Stats card\n// ---------------------------------------------------------------------------\n\nfunction FileSizesCard({\n\tfiles,\n\tpageSize,\n\tpageCount,\n\tfreelistPages,\n}: {\n\tfiles: DbStatsResponse[\"storage\"][\"files\"];\n\tpageSize: number;\n\tpageCount: number;\n\tfreelistPages: number;\n}): React.ReactElement {\n\tconst total = files.dbBytes + files.walBytes + files.shmBytes;\n\treturn (\n\t\t<div className=\"stat-section\">\n\t\t\t<div className=\"stat-label\">File Sizes</div>\n\t\t\t<table className=\"compact-table\">\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>sqlite.db</td>\n\t\t\t\t\t\t<td className=\"num\">{fmtBytes(files.dbBytes)}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t{files.walBytes > 0 && (\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>.wal</td>\n\t\t\t\t\t\t\t<td className=\"num\">{fmtBytes(files.walBytes)}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t)}\n\t\t\t\t\t{files.shmBytes > 0 && (\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>.shm</td>\n\t\t\t\t\t\t\t<td className=\"num\">{fmtBytes(files.shmBytes)}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t)}\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Total</td>\n\t\t\t\t\t\t<td className=\"num\">{fmtBytes(total)}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Page size</td>\n\t\t\t\t\t\t<td className=\"num\">{fmtBytes(pageSize)}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Pages</td>\n\t\t\t\t\t\t<td className=\"num\">\n\t\t\t\t\t\t\t{pageCount.toLocaleString()} ({freelistPages.toLocaleString()}{\" \"}\n\t\t\t\t\t\t\tfree)\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t);\n}\n\nfunction TableRowCountsCard({\n\ttables,\n}: {\n\ttables: DbStatsResponse[\"tables\"];\n}): React.ReactElement {\n\tconst totalRows = tables.reduce((s, t) => s + Math.max(0, t.rowCount), 0);\n\treturn (\n\t\t<div className=\"stat-section\">\n\t\t\t<div className=\"stat-label\">\n\t\t\t\tTable Row Counts ({totalRows.toLocaleString()} total)\n\t\t\t</div>\n\t\t\t<table className=\"compact-table\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>Table</th>\n\t\t\t\t\t\t<th className=\"num\">Rows</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>\n\t\t\t\t\t{tables.map((t) => (\n\t\t\t\t\t\t<tr key={t.table}>\n\t\t\t\t\t\t\t<td>{t.table}</td>\n\t\t\t\t\t\t\t<td className=\"num\">\n\t\t\t\t\t\t\t\t{t.rowCount >= 0 ? t.rowCount.toLocaleString() : \"—\"}\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t))}\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t);\n}\n\nexport function DbStatsCard({\n\tdata,\n\tloading,\n\terror,\n}: {\n\tdata: DbStatsResponse | null;\n\tloading: boolean;\n\terror: Error | null;\n}): React.ReactElement {\n\treturn (\n\t\t<div className=\"card\">\n\t\t\t<div className=\"card-header\">DB Stats</div>\n\t\t\t<div className=\"card-body\">\n\t\t\t\t{loading && !data && <span className=\"text-muted\">Loading…</span>}\n\t\t\t\t{error && !data && <span className=\"text-error\">{error.message}</span>}\n\t\t\t\t{data && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<FileSizesCard\n\t\t\t\t\t\t\tfiles={data.storage.files}\n\t\t\t\t\t\t\tpageSize={data.storage.pageSize}\n\t\t\t\t\t\t\tpageCount={data.storage.pageCount}\n\t\t\t\t\t\t\tfreelistPages={data.storage.freelistPages}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<TableRowCountsCard tables={data.tables} />\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n","/**\n * dashboard-client/src/tabs/MaintenanceTab/ActionsCard.tsx — Actions card.\n *\n * Extracted from MaintenanceTab.tsx (delegate-shell split). One-time\n * maintenance operations (vacuum, checkpoint, reindex, prune, …) with a\n * results history.\n */\nimport type React from \"react\";\nimport { useState, useCallback } from \"react\";\nimport type {\n\tMaintenanceAction,\n\tMaintenanceActionResult,\n} from \"@contracts\";\nimport { postMaintenanceAction } from \"../../api/client\";\n\n// ---------------------------------------------------------------------------\n// Action config\n// ---------------------------------------------------------------------------\n\ninterface ActionDef {\n\tkey: string;\n\tlabel: string;\n\tdesc: string;\n\tdangerous: boolean;\n\tconfirm?: string;\n\tdaysOld?: boolean;\n}\n\nconst ACTIONS: ActionDef[] = [\n\t{\n\t\tkey: \"integrity-check\",\n\t\tlabel: \"Integrity Check\",\n\t\tdesc: \"Run PRAGMA integrity_check\",\n\t\tdangerous: false,\n\t},\n\t{\n\t\tkey: \"reconcile-dedup\",\n\t\tlabel: \"Reconcile Dedup Mirror\",\n\t\tdesc: \"Fix orphan dedup rows + backfill refs\",\n\t\tdangerous: false,\n\t\tconfirm: \"Reconcile dedup_mirror (safe read/write)?\",\n\t},\n\t{\n\t\tkey: \"checkpoint\",\n\t\tlabel: \"WAL Checkpoint\",\n\t\tdesc: \"Merge WAL into main DB (read-only)\",\n\t\tdangerous: false,\n\t},\n\t{\n\t\tkey: \"vacuum\",\n\t\tlabel: \"VACUUM\",\n\t\tdesc: \"Rebuild DB reclaiming free pages\",\n\t\tdangerous: true,\n\t\tconfirm: \"VACUUM rewrites the entire DB. Continue?\",\n\t},\n\t{\n\t\tkey: \"reindex\",\n\t\tlabel: \"REINDEX\",\n\t\tdesc: \"Rebuild all indexes\",\n\t\tdangerous: true,\n\t\tconfirm: \"REINDEX rebuilds indexes. Continue?\",\n\t},\n\t{\n\t\tkey: \"fts5-rebuild\",\n\t\tlabel: \"FTS5 Rebuild\",\n\t\tdesc: \"Rebuild full-text search index\",\n\t\tdangerous: true,\n\t\tconfirm: \"Rebuild FTS5 trigram index. Continue?\",\n\t},\n\t{\n\t\tkey: \"prune\",\n\t\tlabel: \"Prune Old Rows\",\n\t\tdesc: \"Delete transcripts + epochs older than N days\",\n\t\tdangerous: true,\n\t\tdaysOld: true,\n\t\tconfirm: \"Delete old raw_transcript rows. Continue?\",\n\t},\n];\n\n// ---------------------------------------------------------------------------\n// Actions card\n// ---------------------------------------------------------------------------\n\nexport function ActionsCard(): React.ReactElement {\n\tconst [results, setResults] = useState<MaintenanceActionResult[]>([]);\n\tconst [running, setRunning] = useState<string | null>(null);\n\tconst [days, setDays] = useState(\"30\");\n\n\tconst handleAction = useCallback(\n\t\tasync (def: ActionDef) => {\n\t\t\tconst action: MaintenanceAction = def.daysOld\n\t\t\t\t? { action: \"prune\", daysOld: Number(days) }\n\t\t\t\t: ({ action: def.key } as MaintenanceAction);\n\n\t\t\tsetRunning(def.key);\n\t\t\ttry {\n\t\t\t\tconst res = await postMaintenanceAction(action);\n\t\t\t\tsetResults((prev) =>\n\t\t\t\t\t[{ ...res, timestamp: Date.now() }, ...prev].slice(0, 20),\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tsetResults((prev) =>\n\t\t\t\t\t[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\toperation: def.key,\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\taffected: 0,\n\t\t\t\t\t\t\treclaimedBytes: 0,\n\t\t\t\t\t\t\tsummary: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...prev,\n\t\t\t\t\t].slice(0, 20),\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tsetRunning(null);\n\t\t\t}\n\t\t},\n\t\t[days],\n\t);\n\n\treturn (\n\t\t<div className=\"card\">\n\t\t\t<div className=\"card-header\">Actions</div>\n\t\t\t<div className=\"card-body\">\n\t\t\t\t<div className=\"action-grid\">\n\t\t\t\t\t{ACTIONS.map((def) => {\n\t\t\t\t\t\tconst isRunning = running === def.key;\n\t\t\t\t\t\tconst lastResult = results.find((r) => r.operation === def.key);\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div key={def.key} className=\"action-item\">\n\t\t\t\t\t\t\t\t<div className=\"action-info\">\n\t\t\t\t\t\t\t\t\t<div className=\"action-label\">\n\t\t\t\t\t\t\t\t\t\t{def.label}\n\t\t\t\t\t\t\t\t\t\t{def.dangerous && (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"badge badge-warn\">DESTRUCTIVE</span>\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<div className=\"action-desc\">{def.desc}</div>\n\t\t\t\t\t\t\t\t\t{lastResult && (\n\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\tclassName={`action-result ${lastResult.success ? \"text-ok\" : \"text-error\"}`}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{lastResult.summary}\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div className=\"action-controls\">\n\t\t\t\t\t\t\t\t\t{def.daysOld && (\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\t\t\t\tmin={1}\n\t\t\t\t\t\t\t\t\t\t\tmax={365}\n\t\t\t\t\t\t\t\t\t\t\tvalue={days}\n\t\t\t\t\t\t\t\t\t\t\tonChange={(e) => setDays(e.target.value)}\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"days-input\"\n\t\t\t\t\t\t\t\t\t\t\tdisabled={isRunning}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\tclassName={`btn ${def.dangerous ? \"btn-danger\" : \"btn-primary\"}`}\n\t\t\t\t\t\t\t\t\t\tdisabled={running !== null}\n\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\tif (def.confirm && !window.confirm(def.confirm)) return;\n\t\t\t\t\t\t\t\t\t\t\thandleAction(def);\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{isRunning ? \"Running…\" : \"Run\"}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n","/**\n * dashboard-client/src/tabs/MaintenanceTab/DebugBundleCard.tsx — Debug Bundle card.\n *\n * Extracted from MaintenanceTab.tsx (delegate-shell split). Gather a diagnostic\n * bundle (events, config, schema health, store stats) and let the user copy or\n * download it for bug reports.\n */\nimport type React from \"react\";\nimport { useState, useCallback } from \"react\";\nimport type { DebugBundleResponse } from \"@contracts\";\nimport { fetchDebugBundle } from \"../../api/client\";\n\n// ---------------------------------------------------------------------------\n// Debug bundle card — gather diagnostic info for bug reports\n// ---------------------------------------------------------------------------\n\nexport function DebugBundleCard(): React.ReactElement {\n\tconst [bundle, setBundle] = useState<DebugBundleResponse | null>(null);\n\tconst [loading, setLoading] = useState(false);\n\tconst [error, setError] = useState<string | null>(null);\n\tconst [showJson, setShowJson] = useState(false);\n\n\tconst gather = useCallback(async () => {\n\t\tsetLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst res = await fetchDebugBundle();\n\t\t\tsetBundle(res);\n\t\t\tsetShowJson(true);\n\t\t} catch (err) {\n\t\t\tsetError(err instanceof Error ? err.message : String(err));\n\t\t} finally {\n\t\t\tsetLoading(false);\n\t\t}\n\t}, []);\n\n\tconst copyToClipboard = useCallback(() => {\n\t\tif (!bundle) return;\n\t\tconst text = JSON.stringify(bundle, null, 2);\n\t\tvoid navigator.clipboard.writeText(text).catch(() => {});\n\t}, [bundle]);\n\n\tconst downloadJson = useCallback(() => {\n\t\tif (!bundle) return;\n\t\tconst text = JSON.stringify(bundle, null, 2);\n\t\tconst blob = new Blob([text], { type: \"application/json\" });\n\t\tconst url = URL.createObjectURL(blob);\n\t\tconst a = document.createElement(\"a\");\n\t\ta.href = url;\n\t\ta.download = `mega-compact-debug-bundle-${bundle.builtAt}.json`;\n\t\ta.click();\n\t\tURL.revokeObjectURL(url);\n\t}, [bundle]);\n\n\tconst criticalCount = bundle?.criticalEvents.length ?? 0;\n\n\treturn (\n\t\t<div className=\"card\">\n\t\t\t<div className=\"card-header\">\n\t\t\t\tDebug Bundle\n\t\t\t\t{criticalCount > 0 && (\n\t\t\t\t\t<span className=\"text-warn\" style={{ marginLeft: \"1em\" }}>\n\t\t\t\t\t\t{criticalCount} critical event{criticalCount !== 1 ? \"s\" : \"\"} found\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t<div className=\"card-body\">\n\t\t\t\t<p className=\"text-muted\" style={{ marginBottom: \"0.75em\" }}>\n\t\t\t\t\tGather a diagnostic bundle (recent events, config flags, schema health,\n\t\t\t\t\tstore stats) to attach to a bug report. Critical/compaction events are\n\t\t\t\t\thighlighted.\n\t\t\t\t</p>\n\t\t\t\t<button onClick={gather} disabled={loading} style={{ marginRight: \"0.5em\" }}>\n\t\t\t\t\t{loading ? \"Gathering…\" : \"Gather Debug Logs\"}\n\t\t\t\t</button>\n\t\t\t\t{error && <div className=\"text-error\">{error}</div>}\n\t\t\t\t{bundle && showJson && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div style={{ marginTop: \"0.75em\", marginBottom: \"0.5em\" }}>\n\t\t\t\t\t\t\t<button onClick={copyToClipboard} style={{ marginRight: \"0.5em\" }}>\n\t\t\t\t\t\t\t\tCopy to clipboard\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<button onClick={downloadJson}>Download JSON</button>\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\tonClick={() => setShowJson((v) => !v)}\n\t\t\t\t\t\t\t\tstyle={{ marginLeft: \"0.5em\" }}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{showJson ? \"Hide\" : \"Show\"}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{criticalCount > 0 && (\n\t\t\t\t\t\t\t<div className=\"stat-section\">\n\t\t\t\t\t\t\t\t<div className=\"stat-label text-warn\">\n\t\t\t\t\t\t\t\t\tCritical events ({criticalCount})\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<pre className=\"text-mono\" style={{ maxHeight: \"12em\", overflow: \"auto\" }}>\n\t\t\t\t\t\t\t\t\t{JSON.stringify(bundle.criticalEvents, null, 2)}\n\t\t\t\t\t\t\t\t</pre>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<pre className=\"text-mono\" style={{ maxHeight: \"24em\", overflow: \"auto\" }}>\n\t\t\t\t\t\t\t{JSON.stringify(bundle, null, 2)}\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n","/**\n * dashboard-client/src/tabs/MaintenanceTab/HealthMitigationCard.tsx — Health\n * Mitigation card.\n *\n * Extracted from MaintenanceTab.tsx (delegate-shell split). Toggles auto-\n * mitigation for degraded context (forced compaction / prefix break).\n */\nimport type React from \"react\";\nimport { useState, useCallback, useEffect } from \"react\";\n\n// ---------------------------------------------------------------------------\n// Health Mitigation card — toggle auto-mitigation for degraded context\n// ---------------------------------------------------------------------------\n\nexport function HealthMitigationCard(): React.ReactElement {\n\tconst [mitigate, setMitigate] = useState(false);\n\tconst [loading, setLoading] = useState(true);\n\tconst [saving, setSaving] = useState(false);\n\tconst [error, setError] = useState<string | null>(null);\n\n\tconst load = useCallback(async () => {\n\t\ttry {\n\t\t\tconst { fetchHealthSettings } = await import(\"../../api/health\");\n\t\t\tconst s = await fetchHealthSettings();\n\t\t\tsetMitigate(s.mitigate);\n\t\t} catch (e) {\n\t\t\tsetError(e instanceof Error ? e.message : String(e));\n\t\t} finally {\n\t\t\tsetLoading(false);\n\t\t}\n\t}, []);\n\n\tuseEffect(() => { void load(); }, [load]);\n\n\tconst toggle = useCallback(async () => {\n\t\tsetSaving(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { setHealthMitigate } = await import(\"../../api/health\");\n\t\t\tconst next = !mitigate;\n\t\t\tawait setHealthMitigate(next);\n\t\t\tsetMitigate(next);\n\t\t} catch (e) {\n\t\t\tsetError(e instanceof Error ? e.message : String(e));\n\t\t} finally {\n\t\t\tsetSaving(false);\n\t\t}\n\t}, [mitigate]);\n\n\treturn (\n\t\t<div className=\"stat-section maintenance-card\">\n\t\t\t<div className=\"stat-label\">Context Health Mitigation</div>\n\t\t\t{loading ? (\n\t\t\t\t<p className=\"repo-none\">Loading…</p>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"health-mitigate-row\">\n\t\t\t\t\t\t<label className=\"health-mitigate-toggle\">\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\tchecked={mitigate}\n\t\t\t\t\t\t\t\tonChange={toggle}\n\t\t\t\t\t\t\t\tdisabled={saving}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<span>Auto-mitigation {mitigate ? \"ON\" : \"OFF\"}</span>\n\t\t\t\t\t\t</label>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"health-mitigate-info\">\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tWhen <strong>ON</strong>, the extension automatically intervenes when\n\t\t\t\t\t\t\tcontext health degrades:\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li><strong>Forced compaction</strong> — when the composite health score\n\t\t\t\t\t\t\tdrops below 0.4 (severe drift or garbled output), a compaction is\n\t\t\t\t\t\t\ttriggered to flush the degraded context and rebuild from clean\n\t\t\t\t\t\t\tcheckpoints, even if the context window isn't full.</li>\n\t\t\t\t\t\t\t<li><strong>Prefix break</strong> — when KV cache poison is detected\n\t\t\t\t\t\t\t(score < 0.3), the cached prefix is invalidated to force a cache\n\t\t\t\t\t\t\tmiss on the next turn, bypassing the corrupted KV state.</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t<p className=\"health-mitigate-warning\">\n\t\t\t\t\t\t\tWARNING: both interventions have costs — forced compaction discards\n\t\t\t\t\t\t\tlive context, and prefix breaks kill cache savings. Only enable when\n\t\t\t\t\t\t\tyou're seeing degraded output (garbled text, hallucinations,\n\t\t\t\t\t\t\tloss of coherence) and the Health tab confirms low scores.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tAlso settable via env var: <code>MEGACOMPACT_CONTEXT_HEALTH_MITIGATE=1</code>.\n\t\t\t\t\t\t\tThe dashboard toggle persists to the store and takes precedence.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t{error && <p className=\"health-mitigate-error\">Error: {error}</p>}\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n","/**\n * dashboard-client/src/tabs/MaintenanceTab.tsx — Maintenance tab (v0.11.2 S49B).\n *\n * Delegate-shell (extensions split): three cards (Schema Health, DB Stats,\n * Actions) plus the Debug Bundle and Health Mitigation cards. The heavy card\n * components live in ./MaintenanceTab/* to keep every file under the extensions\n * line limit. All cards fetch independently; failures in one do not block the\n * others.\n */\n\nimport type React from \"react\";\nimport { useCallback } from \"react\";\nimport type {\n\tDbStatsResponse,\n\tSchemaHealthResponse,\n} from \"@contracts\";\nimport { useApi } from \"../hooks/useApi\";\nimport { fetchDbStats, fetchSchemaHealth } from \"../api/client\";\nimport { SchemaHealthCard } from \"./MaintenanceTab/SchemaHealthCard\";\nimport { DbStatsCard } from \"./MaintenanceTab/DbStatsCard\";\nimport { ActionsCard } from \"./MaintenanceTab/ActionsCard\";\nimport { DebugBundleCard } from \"./MaintenanceTab/DebugBundleCard\";\nimport { HealthMitigationCard } from \"./MaintenanceTab/HealthMitigationCard\";\n\n// ---------------------------------------------------------------------------\n// Main tab component\n// ---------------------------------------------------------------------------\n\nexport default function MaintenanceTab(): React.ReactElement {\n\tconst {\n\t\tdata: dbStats,\n\t\tloading: statsLoading,\n\t\terror: statsError,\n\t} = useApi<DbStatsResponse>(\n\t\tuseCallback(() => fetchDbStats(), []),\n\t\t{ pollInterval: 15000 },\n\t);\n\n\tconst {\n\t\tdata: schemaHealth,\n\t\tloading: healthLoading,\n\t\terror: healthError,\n\t} = useApi<SchemaHealthResponse>(\n\t\tuseCallback(() => fetchSchemaHealth(), []),\n\t\t{ pollInterval: 10000 },\n\t);\n\n\treturn (\n\t\t<div className=\"maintenance-tab\">\n\t\t\t<div className=\"card-grid\">\n\t\t\t\t<SchemaHealthCard\n\t\t\t\t\tdata={schemaHealth}\n\t\t\t\t\tloading={healthLoading}\n\t\t\t\t\terror={healthError}\n\t\t\t\t/>\n\t\t\t\t<DbStatsCard data={dbStats} loading={statsLoading} error={statsError} />\n\t\t\t</div>\n\t\t\t<ActionsCard />\n\t\t\t<DebugBundleCard />\n\t\t\t<HealthMitigationCard />\n\t\t</div>\n\t);\n}\n"],"file":"assets/MaintenanceTab-Yw1yFpsy.js"}
|
|
1
|
+
{"version":3,"mappings":"oFAcA,SAASA,EAAgB,CACxB,QAAAC,CACD,EAEuB,CACtB,MAAMC,EAAUD,EAAQ,OAAQE,GAAM,CAACA,EAAE,OAAO,EAChD,OACCC,OAAC,OAAI,UAAU,eACd,UAAAA,OAAC,OAAI,UAAU,aAAa,2BACZH,EAAQ,OAAO,aAAWC,EAAQ,OAAO,aACzD,EACAE,OAAC,SAAM,UAAU,gBAChB,UAAAC,MAAC,SACA,gBAAC,MACA,UAAAA,MAAC,MAAG,iBAAK,EACTA,MAAC,MAAG,kBAAM,EACVA,MAAC,MAAG,gBAAI,EACRA,MAAC,MAAG,kBAAM,GACX,EACD,QACC,SACC,SAAAJ,EAAQ,IAAKE,UACZ,MACA,UAAAE,MAAC,MAAI,WAAE,MAAM,EACbA,MAAC,MAAI,SAAAF,EAAE,OAAO,EACdE,MAAC,MAAG,UAAU,YAAa,WAAE,aAAa,EAC1CA,MAAC,MAAG,UAAWF,EAAE,QAAU,UAAY,aACrC,SAAAA,EAAE,QAAU,IAAM,UACpB,IANQ,GAAGA,EAAE,KAAK,IAAIA,EAAE,MAAM,EAO/B,CACA,EACF,GACD,GACD,CAEF,CAEO,SAASG,EAAiB,CAChC,KAAAC,EACA,QAAAC,EACA,MAAAC,CACD,EAIuB,CACtB,OACCL,OAAC,OAAI,UAAU,OACd,UAAAA,OAAC,OAAI,UAAU,cAAc,0BAE3BG,GACAF,MAAC,QAAK,UAAW,SAASE,EAAK,QAAU,WAAa,WAAW,GAC/D,SA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AAAD,OAAC,SAAM,UAAU,yBAChB,UAAAC,MAAC,SACA,KAAK,WACL,QAAS6D,EACT,SAAUQ,EACV,SAAUN,CAAA,UAEV,QAAK,6BAAiBF,EAAW,KAAO,OAAM,GAChD,EACD,EACA9D,OAAC,OAAI,UAAU,uBACd,UAAAA,OAAC,KAAE,kBACGC,MAAC,UAAO,cAAE,EAAS,0EAEzB,SACC,MACA,UAAAD,OAAC,MAAG,UAAAC,MAAC,UAAO,6BAAiB,EAAS,2NAGkB,SACvD,MAAG,UAAAA,MAAC,UAAO,wBAAY,EAAS,iKAEuB,GACzD,EACAA,MAAC,KAAE,UAAU,0BAA0B,4QAKvC,SACC,KAAE,wCACyBA,MAAC,QAAK,iDAAqC,EAAO,sEAE9E,EACCI,GAASL,OAAC,KAAE,UAAU,wBAAwB,oBAAQK,CAAA,EAAM,GAC9D,GACD,GAEF,CAEF,CCrEA,SAAwBoE,GAAqC,CAC5D,KAAM,CACL,KAAMC,EACN,QAASC,EACT,MAAOC,CAAA,EACJC,EACH5C,cAAY,IAAM6C,EAAA,EAAgB,EAAE,EACpC,CAAE,aAAc,KAAM,EAGjB,CACL,KAAMC,EACN,QAASC,EACT,MAAOC,CAAA,EACJJ,EACH5C,cAAY,IAAMiD,EAAA,EAAqB,EAAE,EACzC,CAAE,aAAc,IAAM,EAGvB,OACClF,OAAC,OAAI,UAAU,kBACd,UAAAA,OAAC,OAAI,UAAU,YACd,UAAAC,MAACC,EAAA,CACA,KAAM6E,EACN,QAASC,EACT,MAAOC,CAAA,SAEP3D,EAAA,CAAY,KAAMoD,EAAS,QAASC,EAAc,MAAOC,CAAA,CAAY,GACvE,QACCpD,EAAA,EAAY,QACZoB,EAAA,EAAgB,QAChBiB,EAAA,EAAqB,GACvB,CAEF","names":["ColumnAuditCard","columns","missing","c","jsxs","jsx","SchemaHealthCard","data","loading","error","Fragment","line","i","fmtBytes","b","FileSizesCard","files","pageSize","pageCount","freelistPages","total","TableRowCountsCard","tables","totalRows","s","t","DbStatsCard","ACTIONS","ActionsCard","results","setResults","useState","running","setRunning","days","setDays","handleAction","useCallback","def","action","res","postMaintenanceAction","prev","err","isRunning","lastResult","r","e","DebugBundleCard","bundle","setBundle","setLoading","setError","showJson","setShowJson","gather","fetchDebugBundle","copyToClipboard","text","downloadJson","blob","url","a","criticalCount","v","HealthMitigationCard","mitigate","setMitigate","saving","setSaving","load","fetchHealthSettings","__vitePreload","useEffect","toggle","setHealthMitigate","next","MaintenanceTab","dbStats","statsLoading","statsError","useApi","fetchDbStats","schemaHealth","healthLoading","healthError","fetchSchemaHealth"],"ignoreList":[],"sources":["../../src/tabs/MaintenanceTab/SchemaHealthCard.tsx","../../src/tabs/MaintenanceTab/DbStatsCard.tsx","../../src/tabs/MaintenanceTab/ActionsCard.tsx","../../src/tabs/MaintenanceTab/DebugBundleCard.tsx","../../src/tabs/MaintenanceTab/HealthMitigationCard.tsx","../../src/tabs/MaintenanceTab.tsx"],"sourcesContent":["/**\n * dashboard-client/src/tabs/MaintenanceTab/SchemaHealthCard.tsx — Schema Health card.\n *\n * Extracted from MaintenanceTab.tsx (delegate-shell split). Renders schema\n * version, integrity check, column audit, and FK check from\n * GET /api/maintenance/schema-health.\n */\nimport type React from \"react\";\nimport type { SchemaHealthResponse } from \"@contracts\";\n\n// ---------------------------------------------------------------------------\n// Schema Health card\n// ---------------------------------------------------------------------------\n\nfunction ColumnAuditCard({\n\tcolumns,\n}: {\n\tcolumns: SchemaHealthResponse[\"columns\"];\n}): React.ReactElement {\n\tconst missing = columns.filter((c) => !c.present);\n\treturn (\n\t\t<div className=\"stat-section\">\n\t\t\t<div className=\"stat-label\">\n\t\t\t\tColumn Audit ({columns.length} columns, {missing.length} missing)\n\t\t\t</div>\n\t\t\t<table className=\"compact-table\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>Table</th>\n\t\t\t\t\t\t<th>Column</th>\n\t\t\t\t\t\t<th>Decl</th>\n\t\t\t\t\t\t<th>Status</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>\n\t\t\t\t\t{columns.map((c) => (\n\t\t\t\t\t\t<tr key={`${c.table}.${c.column}`}>\n\t\t\t\t\t\t\t<td>{c.table}</td>\n\t\t\t\t\t\t\t<td>{c.column}</td>\n\t\t\t\t\t\t\t<td className=\"text-mono\">{c.expectedDecl}</td>\n\t\t\t\t\t\t\t<td className={c.present ? \"text-ok\" : \"text-error\"}>\n\t\t\t\t\t\t\t\t{c.present ? \"✓\" : \"MISSING\"}\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t))}\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t);\n}\n\nexport function SchemaHealthCard({\n\tdata,\n\tloading,\n\terror,\n}: {\n\tdata: SchemaHealthResponse | null;\n\tloading: boolean;\n\terror: Error | null;\n}): React.ReactElement {\n\treturn (\n\t\t<div className=\"card\">\n\t\t\t<div className=\"card-header\">\n\t\t\t\tSchema Health\n\t\t\t\t{data && (\n\t\t\t\t\t<span className={`badge ${data.healthy ? \"badge-ok\" : \"badge-bad\"}`}>\n\t\t\t\t\t\t{data.healthy ? \"HEALTHY\" : \"DEGRADED\"}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t<div className=\"card-body\">\n\t\t\t\t{loading && !data && <span className=\"text-muted\">Loading…</span>}\n\t\t\t\t{error && !data && <span className=\"text-error\">{error.message}</span>}\n\t\t\t\t{data && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className=\"stat-row\">\n\t\t\t\t\t\t\t<span className=\"stat-label\">Schema version</span>\n\t\t\t\t\t\t\t<span className=\"num\">{data.schemaVersion}</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"stat-row\">\n\t\t\t\t\t\t\t<span className=\"stat-label\">Integrity</span>\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tdata.integrity[0] === \"ok\" ? \"text-ok\" : \"text-error\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{data.integrity.join(\"; \")}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<ColumnAuditCard columns={data.columns} />\n\t\t\t\t\t\t{data.fkCheck.length > 0 && (\n\t\t\t\t\t\t\t<div className=\"stat-section\">\n\t\t\t\t\t\t\t\t<div className=\"stat-label text-warn\">\n\t\t\t\t\t\t\t\t\tFK Check ({data.fkCheck.length})\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{data.fkCheck.map((line, i) => (\n\t\t\t\t\t\t\t\t\t<div key={i} className=\"text-warn text-mono\">\n\t\t\t\t\t\t\t\t\t\t{line}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n","/**\n * dashboard-client/src/tabs/MaintenanceTab/DbStatsCard.tsx — DB Stats card.\n *\n * Extracted from MaintenanceTab.tsx (delegate-shell split). Renders file sizes\n * and table row counts from GET /api/maintenance.\n */\nimport type React from \"react\";\nimport type { DbStatsResponse } from \"@contracts\";\n\n// ---------------------------------------------------------------------------\n// Format helpers (local — matches html.ts fmtBytes)\n// ---------------------------------------------------------------------------\n\nexport function fmtBytes(b: number): string {\n\tif (b < 1024) return `${b} B`;\n\tif (b < 1024 * 1024) return `${(b / 1024).toFixed(1)} KB`;\n\treturn `${(b / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n// ---------------------------------------------------------------------------\n// DB Stats card\n// ---------------------------------------------------------------------------\n\nfunction FileSizesCard({\n\tfiles,\n\tpageSize,\n\tpageCount,\n\tfreelistPages,\n}: {\n\tfiles: DbStatsResponse[\"storage\"][\"files\"];\n\tpageSize: number;\n\tpageCount: number;\n\tfreelistPages: number;\n}): React.ReactElement {\n\tconst total = files.dbBytes + files.walBytes + files.shmBytes;\n\treturn (\n\t\t<div className=\"stat-section\">\n\t\t\t<div className=\"stat-label\">File Sizes</div>\n\t\t\t<table className=\"compact-table\">\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>sqlite.db</td>\n\t\t\t\t\t\t<td className=\"num\">{fmtBytes(files.dbBytes)}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t{files.walBytes > 0 && (\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>.wal</td>\n\t\t\t\t\t\t\t<td className=\"num\">{fmtBytes(files.walBytes)}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t)}\n\t\t\t\t\t{files.shmBytes > 0 && (\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>.shm</td>\n\t\t\t\t\t\t\t<td className=\"num\">{fmtBytes(files.shmBytes)}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t)}\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Total</td>\n\t\t\t\t\t\t<td className=\"num\">{fmtBytes(total)}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Page size</td>\n\t\t\t\t\t\t<td className=\"num\">{fmtBytes(pageSize)}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Pages</td>\n\t\t\t\t\t\t<td className=\"num\">\n\t\t\t\t\t\t\t{pageCount.toLocaleString()} ({freelistPages.toLocaleString()}{\" \"}\n\t\t\t\t\t\t\tfree)\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t);\n}\n\nfunction TableRowCountsCard({\n\ttables,\n}: {\n\ttables: DbStatsResponse[\"tables\"];\n}): React.ReactElement {\n\tconst totalRows = tables.reduce((s, t) => s + Math.max(0, t.rowCount), 0);\n\treturn (\n\t\t<div className=\"stat-section\">\n\t\t\t<div className=\"stat-label\">\n\t\t\t\tTable Row Counts ({totalRows.toLocaleString()} total)\n\t\t\t</div>\n\t\t\t<table className=\"compact-table\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>Table</th>\n\t\t\t\t\t\t<th className=\"num\">Rows</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>\n\t\t\t\t\t{tables.map((t) => (\n\t\t\t\t\t\t<tr key={t.table}>\n\t\t\t\t\t\t\t<td>{t.table}</td>\n\t\t\t\t\t\t\t<td className=\"num\">\n\t\t\t\t\t\t\t\t{t.rowCount >= 0 ? t.rowCount.toLocaleString() : \"—\"}\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t))}\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t);\n}\n\nexport function DbStatsCard({\n\tdata,\n\tloading,\n\terror,\n}: {\n\tdata: DbStatsResponse | null;\n\tloading: boolean;\n\terror: Error | null;\n}): React.ReactElement {\n\treturn (\n\t\t<div className=\"card\">\n\t\t\t<div className=\"card-header\">DB Stats</div>\n\t\t\t<div className=\"card-body\">\n\t\t\t\t{loading && !data && <span className=\"text-muted\">Loading…</span>}\n\t\t\t\t{error && !data && <span className=\"text-error\">{error.message}</span>}\n\t\t\t\t{data && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<FileSizesCard\n\t\t\t\t\t\t\tfiles={data.storage.files}\n\t\t\t\t\t\t\tpageSize={data.storage.pageSize}\n\t\t\t\t\t\t\tpageCount={data.storage.pageCount}\n\t\t\t\t\t\t\tfreelistPages={data.storage.freelistPages}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<TableRowCountsCard tables={data.tables} />\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n","/**\n * dashboard-client/src/tabs/MaintenanceTab/ActionsCard.tsx — Actions card.\n *\n * Extracted from MaintenanceTab.tsx (delegate-shell split). One-time\n * maintenance operations (vacuum, checkpoint, reindex, prune, …) with a\n * results history.\n */\nimport type React from \"react\";\nimport { useState, useCallback } from \"react\";\nimport type {\n\tMaintenanceAction,\n\tMaintenanceActionResult,\n} from \"@contracts\";\nimport { postMaintenanceAction } from \"../../api/client\";\n\n// ---------------------------------------------------------------------------\n// Action config\n// ---------------------------------------------------------------------------\n\ninterface ActionDef {\n\tkey: string;\n\tlabel: string;\n\tdesc: string;\n\tdangerous: boolean;\n\tconfirm?: string;\n\tdaysOld?: boolean;\n}\n\nconst ACTIONS: ActionDef[] = [\n\t{\n\t\tkey: \"integrity-check\",\n\t\tlabel: \"Integrity Check\",\n\t\tdesc: \"Run PRAGMA integrity_check\",\n\t\tdangerous: false,\n\t},\n\t{\n\t\tkey: \"reconcile-dedup\",\n\t\tlabel: \"Reconcile Dedup Mirror\",\n\t\tdesc: \"Fix orphan dedup rows + backfill refs\",\n\t\tdangerous: false,\n\t\tconfirm: \"Reconcile dedup_mirror (safe read/write)?\",\n\t},\n\t{\n\t\tkey: \"checkpoint\",\n\t\tlabel: \"WAL Checkpoint\",\n\t\tdesc: \"Merge WAL into main DB (read-only)\",\n\t\tdangerous: false,\n\t},\n\t{\n\t\tkey: \"vacuum\",\n\t\tlabel: \"VACUUM\",\n\t\tdesc: \"Rebuild DB reclaiming free pages\",\n\t\tdangerous: true,\n\t\tconfirm: \"VACUUM rewrites the entire DB. Continue?\",\n\t},\n\t{\n\t\tkey: \"reindex\",\n\t\tlabel: \"REINDEX\",\n\t\tdesc: \"Rebuild all indexes\",\n\t\tdangerous: true,\n\t\tconfirm: \"REINDEX rebuilds indexes. Continue?\",\n\t},\n\t{\n\t\tkey: \"fts5-rebuild\",\n\t\tlabel: \"FTS5 Rebuild\",\n\t\tdesc: \"Rebuild full-text search index\",\n\t\tdangerous: true,\n\t\tconfirm: \"Rebuild FTS5 trigram index. Continue?\",\n\t},\n\t{\n\t\tkey: \"prune\",\n\t\tlabel: \"Prune Old Rows\",\n\t\tdesc: \"Delete transcripts + epochs older than N days\",\n\t\tdangerous: true,\n\t\tdaysOld: true,\n\t\tconfirm: \"Delete old raw_transcript rows. Continue?\",\n\t},\n];\n\n// ---------------------------------------------------------------------------\n// Actions card\n// ---------------------------------------------------------------------------\n\nexport function ActionsCard(): React.ReactElement {\n\tconst [results, setResults] = useState<MaintenanceActionResult[]>([]);\n\tconst [running, setRunning] = useState<string | null>(null);\n\tconst [days, setDays] = useState(\"30\");\n\n\tconst handleAction = useCallback(\n\t\tasync (def: ActionDef) => {\n\t\t\tconst action: MaintenanceAction = def.daysOld\n\t\t\t\t? { action: \"prune\", daysOld: Number(days) }\n\t\t\t\t: ({ action: def.key } as MaintenanceAction);\n\n\t\t\tsetRunning(def.key);\n\t\t\ttry {\n\t\t\t\tconst res = await postMaintenanceAction(action);\n\t\t\t\tsetResults((prev) =>\n\t\t\t\t\t[{ ...res, timestamp: Date.now() }, ...prev].slice(0, 20),\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tsetResults((prev) =>\n\t\t\t\t\t[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\toperation: def.key,\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\taffected: 0,\n\t\t\t\t\t\t\treclaimedBytes: 0,\n\t\t\t\t\t\t\tsummary: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...prev,\n\t\t\t\t\t].slice(0, 20),\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tsetRunning(null);\n\t\t\t}\n\t\t},\n\t\t[days],\n\t);\n\n\treturn (\n\t\t<div className=\"card\">\n\t\t\t<div className=\"card-header\">Actions</div>\n\t\t\t<div className=\"card-body\">\n\t\t\t\t<div className=\"action-grid\">\n\t\t\t\t\t{ACTIONS.map((def) => {\n\t\t\t\t\t\tconst isRunning = running === def.key;\n\t\t\t\t\t\tconst lastResult = results.find((r) => r.operation === def.key);\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div key={def.key} className=\"action-item\">\n\t\t\t\t\t\t\t\t<div className=\"action-info\">\n\t\t\t\t\t\t\t\t\t<div className=\"action-label\">\n\t\t\t\t\t\t\t\t\t\t{def.label}\n\t\t\t\t\t\t\t\t\t\t{def.dangerous && (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"badge badge-warn\">DESTRUCTIVE</span>\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<div className=\"action-desc\">{def.desc}</div>\n\t\t\t\t\t\t\t\t\t{lastResult && (\n\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\tclassName={`action-result ${lastResult.success ? \"text-ok\" : \"text-error\"}`}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{lastResult.summary}\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div className=\"action-controls\">\n\t\t\t\t\t\t\t\t\t{def.daysOld && (\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\t\t\t\tmin={1}\n\t\t\t\t\t\t\t\t\t\t\tmax={365}\n\t\t\t\t\t\t\t\t\t\t\tvalue={days}\n\t\t\t\t\t\t\t\t\t\t\tonChange={(e) => setDays(e.target.value)}\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"days-input\"\n\t\t\t\t\t\t\t\t\t\t\tdisabled={isRunning}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\tclassName={`btn ${def.dangerous ? \"btn-danger\" : \"btn-primary\"}`}\n\t\t\t\t\t\t\t\t\t\tdisabled={running !== null}\n\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\tif (def.confirm && !window.confirm(def.confirm)) return;\n\t\t\t\t\t\t\t\t\t\t\thandleAction(def);\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{isRunning ? \"Running…\" : \"Run\"}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n","/**\n * dashboard-client/src/tabs/MaintenanceTab/DebugBundleCard.tsx — Debug Bundle card.\n *\n * Extracted from MaintenanceTab.tsx (delegate-shell split). Gather a diagnostic\n * bundle (events, config, schema health, store stats) and let the user copy or\n * download it for bug reports.\n */\nimport type React from \"react\";\nimport { useState, useCallback } from \"react\";\nimport type { DebugBundleResponse } from \"@contracts\";\nimport { fetchDebugBundle } from \"../../api/client\";\n\n// ---------------------------------------------------------------------------\n// Debug bundle card — gather diagnostic info for bug reports\n// ---------------------------------------------------------------------------\n\nexport function DebugBundleCard(): React.ReactElement {\n\tconst [bundle, setBundle] = useState<DebugBundleResponse | null>(null);\n\tconst [loading, setLoading] = useState(false);\n\tconst [error, setError] = useState<string | null>(null);\n\tconst [showJson, setShowJson] = useState(false);\n\n\tconst gather = useCallback(async () => {\n\t\tsetLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst res = await fetchDebugBundle();\n\t\t\tsetBundle(res);\n\t\t\tsetShowJson(true);\n\t\t} catch (err) {\n\t\t\tsetError(err instanceof Error ? err.message : String(err));\n\t\t} finally {\n\t\t\tsetLoading(false);\n\t\t}\n\t}, []);\n\n\tconst copyToClipboard = useCallback(() => {\n\t\tif (!bundle) return;\n\t\tconst text = JSON.stringify(bundle, null, 2);\n\t\tvoid navigator.clipboard.writeText(text).catch(() => {});\n\t}, [bundle]);\n\n\tconst downloadJson = useCallback(() => {\n\t\tif (!bundle) return;\n\t\tconst text = JSON.stringify(bundle, null, 2);\n\t\tconst blob = new Blob([text], { type: \"application/json\" });\n\t\tconst url = URL.createObjectURL(blob);\n\t\tconst a = document.createElement(\"a\");\n\t\ta.href = url;\n\t\ta.download = `mega-compact-debug-bundle-${bundle.builtAt}.json`;\n\t\ta.click();\n\t\tURL.revokeObjectURL(url);\n\t}, [bundle]);\n\n\tconst criticalCount = bundle?.criticalEvents.length ?? 0;\n\n\treturn (\n\t\t<div className=\"card\">\n\t\t\t<div className=\"card-header\">\n\t\t\t\tDebug Bundle\n\t\t\t\t{criticalCount > 0 && (\n\t\t\t\t\t<span className=\"text-warn\" style={{ marginLeft: \"1em\" }}>\n\t\t\t\t\t\t{criticalCount} critical event{criticalCount !== 1 ? \"s\" : \"\"} found\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t<div className=\"card-body\">\n\t\t\t\t<p className=\"text-muted\" style={{ marginBottom: \"0.75em\" }}>\n\t\t\t\t\tGather a diagnostic bundle (recent events, config flags, schema health,\n\t\t\t\t\tstore stats) to attach to a bug report. Critical/compaction events are\n\t\t\t\t\thighlighted.\n\t\t\t\t</p>\n\t\t\t\t<button onClick={gather} disabled={loading} style={{ marginRight: \"0.5em\" }}>\n\t\t\t\t\t{loading ? \"Gathering…\" : \"Gather Debug Logs\"}\n\t\t\t\t</button>\n\t\t\t\t{error && <div className=\"text-error\">{error}</div>}\n\t\t\t\t{bundle && showJson && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div style={{ marginTop: \"0.75em\", marginBottom: \"0.5em\" }}>\n\t\t\t\t\t\t\t<button onClick={copyToClipboard} style={{ marginRight: \"0.5em\" }}>\n\t\t\t\t\t\t\t\tCopy to clipboard\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<button onClick={downloadJson}>Download JSON</button>\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\tonClick={() => setShowJson((v) => !v)}\n\t\t\t\t\t\t\t\tstyle={{ marginLeft: \"0.5em\" }}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{showJson ? \"Hide\" : \"Show\"}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{criticalCount > 0 && (\n\t\t\t\t\t\t\t<div className=\"stat-section\">\n\t\t\t\t\t\t\t\t<div className=\"stat-label text-warn\">\n\t\t\t\t\t\t\t\t\tCritical events ({criticalCount})\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<pre className=\"text-mono\" style={{ maxHeight: \"12em\", overflow: \"auto\" }}>\n\t\t\t\t\t\t\t\t\t{JSON.stringify(bundle.criticalEvents, null, 2)}\n\t\t\t\t\t\t\t\t</pre>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<pre className=\"text-mono\" style={{ maxHeight: \"24em\", overflow: \"auto\" }}>\n\t\t\t\t\t\t\t{JSON.stringify(bundle, null, 2)}\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n","/**\n * dashboard-client/src/tabs/MaintenanceTab/HealthMitigationCard.tsx — Health\n * Mitigation card.\n *\n * Extracted from MaintenanceTab.tsx (delegate-shell split). Toggles auto-\n * mitigation for degraded context (forced compaction / prefix break).\n */\nimport type React from \"react\";\nimport { useState, useCallback, useEffect } from \"react\";\n\n// ---------------------------------------------------------------------------\n// Health Mitigation card — toggle auto-mitigation for degraded context\n// ---------------------------------------------------------------------------\n\nexport function HealthMitigationCard(): React.ReactElement {\n\tconst [mitigate, setMitigate] = useState(false);\n\tconst [loading, setLoading] = useState(true);\n\tconst [saving, setSaving] = useState(false);\n\tconst [error, setError] = useState<string | null>(null);\n\n\tconst load = useCallback(async () => {\n\t\ttry {\n\t\t\tconst { fetchHealthSettings } = await import(\"../../api/health\");\n\t\t\tconst s = await fetchHealthSettings();\n\t\t\tsetMitigate(s.mitigate);\n\t\t} catch (e) {\n\t\t\tsetError(e instanceof Error ? e.message : String(e));\n\t\t} finally {\n\t\t\tsetLoading(false);\n\t\t}\n\t}, []);\n\n\tuseEffect(() => { void load(); }, [load]);\n\n\tconst toggle = useCallback(async () => {\n\t\tsetSaving(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { setHealthMitigate } = await import(\"../../api/health\");\n\t\t\tconst next = !mitigate;\n\t\t\tawait setHealthMitigate(next);\n\t\t\tsetMitigate(next);\n\t\t} catch (e) {\n\t\t\tsetError(e instanceof Error ? e.message : String(e));\n\t\t} finally {\n\t\t\tsetSaving(false);\n\t\t}\n\t}, [mitigate]);\n\n\treturn (\n\t\t<div className=\"stat-section maintenance-card\">\n\t\t\t<div className=\"stat-label\">Context Health Mitigation</div>\n\t\t\t{loading ? (\n\t\t\t\t<p className=\"repo-none\">Loading…</p>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"health-mitigate-row\">\n\t\t\t\t\t\t<label className=\"health-mitigate-toggle\">\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\tchecked={mitigate}\n\t\t\t\t\t\t\t\tonChange={toggle}\n\t\t\t\t\t\t\t\tdisabled={saving}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<span>Auto-mitigation {mitigate ? \"ON\" : \"OFF\"}</span>\n\t\t\t\t\t\t</label>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"health-mitigate-info\">\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tWhen <strong>ON</strong>, the extension automatically intervenes when\n\t\t\t\t\t\t\tcontext health degrades:\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li><strong>Forced compaction</strong> — when the composite health score\n\t\t\t\t\t\t\tdrops below 0.4 (severe drift or garbled output), a compaction is\n\t\t\t\t\t\t\ttriggered to flush the degraded context and rebuild from clean\n\t\t\t\t\t\t\tcheckpoints, even if the context window isn't full.</li>\n\t\t\t\t\t\t\t<li><strong>Prefix break</strong> — when KV cache poison is detected\n\t\t\t\t\t\t\t(score < 0.3), the cached prefix is invalidated to force a cache\n\t\t\t\t\t\t\tmiss on the next turn, bypassing the corrupted KV state.</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t<p className=\"health-mitigate-warning\">\n\t\t\t\t\t\t\tWARNING: both interventions have costs — forced compaction discards\n\t\t\t\t\t\t\tlive context, and prefix breaks kill cache savings. Only enable when\n\t\t\t\t\t\t\tyou're seeing degraded output (garbled text, hallucinations,\n\t\t\t\t\t\t\tloss of coherence) and the Health tab confirms low scores.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tAlso settable via env var: <code>MEGACOMPACT_CONTEXT_HEALTH_MITIGATE=1</code>.\n\t\t\t\t\t\t\tThe dashboard toggle persists to the store and takes precedence.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t{error && <p className=\"health-mitigate-error\">Error: {error}</p>}\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n","/**\n * dashboard-client/src/tabs/MaintenanceTab.tsx — Maintenance tab (v0.11.2 S49B).\n *\n * Delegate-shell (extensions split): three cards (Schema Health, DB Stats,\n * Actions) plus the Debug Bundle and Health Mitigation cards. The heavy card\n * components live in ./MaintenanceTab/* to keep every file under the extensions\n * line limit. All cards fetch independently; failures in one do not block the\n * others.\n */\n\nimport type React from \"react\";\nimport { useCallback } from \"react\";\nimport type {\n\tDbStatsResponse,\n\tSchemaHealthResponse,\n} from \"@contracts\";\nimport { useApi } from \"../hooks/useApi\";\nimport { fetchDbStats, fetchSchemaHealth } from \"../api/client\";\nimport { SchemaHealthCard } from \"./MaintenanceTab/SchemaHealthCard\";\nimport { DbStatsCard } from \"./MaintenanceTab/DbStatsCard\";\nimport { ActionsCard } from \"./MaintenanceTab/ActionsCard\";\nimport { DebugBundleCard } from \"./MaintenanceTab/DebugBundleCard\";\nimport { HealthMitigationCard } from \"./MaintenanceTab/HealthMitigationCard\";\n\n// ---------------------------------------------------------------------------\n// Main tab component\n// ---------------------------------------------------------------------------\n\nexport default function MaintenanceTab(): React.ReactElement {\n\tconst {\n\t\tdata: dbStats,\n\t\tloading: statsLoading,\n\t\terror: statsError,\n\t} = useApi<DbStatsResponse>(\n\t\tuseCallback(() => fetchDbStats(), []),\n\t\t{ pollInterval: 15000 },\n\t);\n\n\tconst {\n\t\tdata: schemaHealth,\n\t\tloading: healthLoading,\n\t\terror: healthError,\n\t} = useApi<SchemaHealthResponse>(\n\t\tuseCallback(() => fetchSchemaHealth(), []),\n\t\t{ pollInterval: 10000 },\n\t);\n\n\treturn (\n\t\t<div className=\"maintenance-tab\">\n\t\t\t<div className=\"card-grid\">\n\t\t\t\t<SchemaHealthCard\n\t\t\t\t\tdata={schemaHealth}\n\t\t\t\t\tloading={healthLoading}\n\t\t\t\t\terror={healthError}\n\t\t\t\t/>\n\t\t\t\t<DbStatsCard data={dbStats} loading={statsLoading} error={statsError} />\n\t\t\t</div>\n\t\t\t<ActionsCard />\n\t\t\t<DebugBundleCard />\n\t\t\t<HealthMitigationCard />\n\t\t</div>\n\t);\n}\n"],"file":"assets/MaintenanceTab-Bc-uPYrz.js"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,r as c,G as V}from"./index-mOlljTFI.js";const w={checkpoint:"#6366f1",turn:"#58a6ff","turn-content":"#22c55e",memory:"#f59e0b"},U={checkpoint:"Checkpoint",turn:"Turn","turn-content":"Turn Content",memory:"Memory"};function Y(t,r){return`M 0,-${r} L ${t},0 L 0,${r} L -${t},0 Z`}function Q(t){return!t||t==="active"?1:.5}function X(t,r,i,d,n,m,a){const p=m?w[d]??"#6366f1":"#d1d5db",u=n?"#ef4444":"none",h=Q(a);switch(d){case"checkpoint":return e.jsx("circle",{cx:t,cy:r,r:n?i+3:i,fill:p,opacity:h,stroke:u,strokeWidth:n?2:0});case"turn":return e.jsx("circle",{cx:t,cy:r,r:n?i+3:i,fill:"none",stroke:p,strokeWidth:2.5,opacity:h});case"turn-content":return e.jsxs("g",{children:[e.jsx("circle",{cx:t,cy:r,r:n?i+3:i,fill:"none",stroke:p,strokeWidth:2.5,opacity:h}),e.jsx("circle",{cx:t,cy:r,r:Math.max(3,i*.3),fill:p,opacity:h})]});case"memory":const x=i*.85,j=i*.85;return e.jsx("path",{d:Y(x,j),transform:`translate(${t}, ${r})`,fill:p,opacity:h,stroke:u,strokeWidth:n?2:0})}}const Z=5e3,I=.005,P=.01,W=.9,J=.1,L=50;function K(t){const r=t.nodes.map((n,m)=>{const a=2*Math.PI*m/Math.max(t.nodes.length,1),p=200;return{...n,pos:{x:Math.cos(a)*p+300,y:Math.sin(a)*p+200},vx:0,vy:0,pinned:!1}}),i=new Map;r.forEach((n,m)=>i.set(n.id,m));const d=t.edges.map(n=>{const m=i.get(n.source),a=i.get(n.target);return m===void 0||a===void 0||m===a?null:{source:m,target:a,weight:n.weight,type:n.type}}).filter(n=>n!==null);return{nodes:r,edges:d}}function ee(t){const{nodes:r,edges:i}=t,d=r.length;if(d!==0)for(let n=0;n<d;n++){if(r[n].pinned)continue;let m=0,a=0;for(let u=0;u<d;u++){if(n===u)continue;const h=r[n].pos.x-r[u].pos.x,x=r[n].pos.y-r[u].pos.y,j=h*h+x*x||1,v=Z/j,g=Math.sqrt(j);m+=h/g*v,a+=x/g*v}for(const u of i){let h;if(u.source===n)h=u.target;else if(u.target===n)h=u.source;else continue;const x=r[h].pos.x-r[n].pos.x,j=r[h].pos.y-r[n].pos.y;m+=x*I*u.weight,a+=j*I*u.weight}m-=r[n].pos.x*P,a-=r[n].pos.y*P,r[n].vx=(r[n].vx+m)*W,r[n].vy=(r[n].vy+a)*W;const p=Math.sqrt(r[n].vx*r[n].vx+r[n].vy*r[n].vy);p>L&&(r[n].vx=r[n].vx/p*L,r[n].vy=r[n].vy/p*L),p>J&&(r[n].pos.x+=r[n].vx,r[n].pos.y+=r[n].vy)}}const te=300,se=.3,N=900,S=600,y=40;function E(t){switch(t){case"temporal":return"#6366f1";case"semantic":return"#22c55e";case"raptor_parent":return"#f59e0b"}}const k=({color:t,shape:r,label:i})=>{const d={display:"inline-block",width:"10px",height:"10px",verticalAlign:"middle",marginRight:"3px",borderRadius:r.startsWith("hollow")||r==="filled-circle"?"50%":void 0};let n;return r==="line"?e.jsx("span",{style:{color:t,marginRight:"6px"},children:i}):(r==="filled-circle"?n=e.jsx("span",{style:{...d,backgroundColor:t}}):r==="hollow-circle"?n=e.jsx("span",{style:{...d,border:`2px solid ${t}`,backgroundColor:"transparent"}}):r==="hollow-ring"?n=e.jsx("span",{style:{...d,border:`2px solid ${t}`,backgroundColor:"transparent",position:"relative"},children:e.jsx("span",{style:{display:"block",width:"4px",height:"4px",borderRadius:"50%",backgroundColor:t,margin:"2px auto"}})}):n=e.jsx("span",{style:{...d,clipPath:"polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)",backgroundColor:t}}),e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"memory-map-legend-item",children:[n,i]})," "]}))},ne=()=>{const[t,r]=c.useState(null),[i,d]=c.useState(!0),[n,m]=c.useState(null),[a,p]=c.useState(null),[u,h]=c.useState(""),[x]=c.useState(""),[j,v]=c.useState(0),g=c.useRef(null),T=c.useRef(0);c.useEffect(()=>{let s=!1;const o=new URLSearchParams;return x&&o.set("sessionId",x),o.set("threshold","0.7"),o.set("maxEdgesPerNode","4"),d(!0),m(null),fetch(`/api/memory-map?${o.toString()}`).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);return l.json()}).then(l=>{s||(r(l),g.current=K(l),v(1),d(!1))}).catch(l=>{s||(m(l instanceof Error?l.message:"Unknown error"),d(!1))}),()=>{s=!0,cancelAnimationFrame(T.current)}},[x]),c.useEffect(()=>{if(!g.current||j===0)return;const s=g.current;let o=0;const l=()=>{o>=te||(ee(s),o++,v(o),T.current=requestAnimationFrame(l))};return T.current=requestAnimationFrame(l),()=>cancelAnimationFrame(T.current)},[j]);const z=c.useCallback((s,o)=>{const l=g.current;l&&(l.nodes[o].pinned=!l.nodes[o].pinned,l.nodes[o].pinned||(l.nodes[o].vx=0,l.nodes[o].vy=0),p(f=>f?.id===s.id?null:s),v(f=>f+1))},[]),$=c.useMemo(()=>{const s=g.current;if(!s||!u)return null;const o=u.toLowerCase();return new Set(s.nodes.map((l,f)=>l.summaryTruncated.toLowerCase().includes(o)||l.label.toLowerCase().includes(o)?f:-1).filter(l=>l>=0))},[u]),R=c.useMemo(()=>{const s=t?.validation;return s?s.gatesPassed<s.gatesRun?{level:"red",label:"Gate failure"}:s.warnings.length>0?{level:"yellow",label:`${s.warnings.length} warning(s)`}:{level:"green",label:"Healthy"}:{level:"yellow",label:"No validation"}},[t?.validation]),B={green:"#22c55e",yellow:"#eab308",red:"#ef4444"},F=c.useMemo(()=>{const s=t?.validation;if(!s)return`${t?.metadata.totalNodes??0} nodes`;const o=[];return s.sources.checkpoint>0&&o.push(`${s.sources.checkpoint} checkpoints`),s.sources.turn>0&&o.push(`${s.sources.turn} turns`),s.sources.turnContent>0&&o.push(`${s.sources.turnContent} turn-content`),s.sources.memory>0&&o.push(`${s.sources.memory} memories`),o.length===0&&o.push(`${t?.metadata.totalNodes??0} nodes`),o.join(" · ")},[t?.validation,t?.metadata.totalNodes]),A=c.useMemo(()=>{const s=t?.validation;if(!s)return"";const o=[];return o.push(s.sources.checkpoint>0?"✓ checkpoints":"✗ checkpoints"),o.push(s.sources.turn>0?"✓ turns":"✗ turns"),o.push(s.sources.turnContent>0?"✓ turn-content":"✗ turn-content"),o.push(s.sources.memory>0?"✓ memories":"✗ memories"),o.join(" | ")},[t?.validation]),G=c.useMemo(()=>{const s=t?.validation;return s?s.sources.checkpoint===0&&s.sources.turn===0&&s.sources.turnContent===0&&s.sources.memory===0:t?.metadata.totalNodes===0},[t?.validation,t?.metadata.totalNodes]);if(i)return e.jsx("div",{className:"memory-map-loading",children:"Loading memory graph..."});if(n)return e.jsxs("div",{className:"memory-map-error",children:[e.jsxs("p",{children:["Failed to load memory map: ",n]}),e.jsx("button",{className:"memory-map-retry-btn",onClick:()=>v(s=>s+1),children:"Retry"})]});if(!t||!g.current||G)return e.jsx("div",{className:"memory-map-empty",children:e.jsx("p",{children:"Memories appear after your first compaction. The graph shows checkpoints (compaction summaries) linked by semantic similarity and time. Run a longer session or lower the compaction tier to see it sooner."})});const b=g.current;return e.jsxs("div",{className:"memory-map-container",children:[e.jsxs("div",{className:"memory-map-toolbar",children:[e.jsx("input",{type:"text",placeholder:"Search memories...",value:u,onInput:s=>h(s.target.value),className:"memory-map-search"}),e.jsxs("span",{className:"memory-map-stats",children:[e.jsx("span",{className:"memory-map-count-badge",children:F}),e.jsx("br",{}),e.jsxs("span",{className:"memory-map-edges",children:[t.edges.length," edges"]})]}),e.jsx("span",{className:"memory-map-health-badge",style:{backgroundColor:B[R.level]??"#6b7280",color:"#fff",padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,marginLeft:"8px"},title:`Validation: ${R.label}`,children:R.level==="green"?"Healthy":R.level==="yellow"?"Warnings":"Critical"})]}),A?e.jsx("div",{className:"memory-map-source-avail",style:{fontSize:"11px",padding:"2px 12px",color:"#6b7280"},children:A}):null,e.jsxs("div",{className:"memory-map-legend",children:[e.jsx("span",{className:"memory-map-legend-section",children:"Nodes:"}),e.jsx(k,{type:"node",color:w.checkpoint,shape:"filled-circle",label:"Checkpoint"}),e.jsx(k,{type:"node",color:w.turn,shape:"hollow-circle",label:"Turn"}),e.jsx(k,{type:"node",color:w["turn-content"],shape:"hollow-ring",label:"Turn Content"}),e.jsx(k,{type:"node",color:w.memory,shape:"diamond",label:"Memory"}),e.jsx("span",{className:"memory-map-legend-sep",children:"|"}),e.jsx("span",{className:"memory-map-legend-section",children:"Edges:"}),e.jsx(k,{type:"edge",color:E("semantic"),shape:"line",label:"Semantic"}),e.jsx(k,{type:"edge",color:E("temporal"),shape:"line",label:"Temporal"}),e.jsx(k,{type:"edge",color:E("raptor_parent"),shape:"line",label:"Raptor"})]}),e.jsxs("svg",{width:N,height:S,viewBox:`0 0 ${N} ${S}`,className:"memory-map-svg",children:[b.edges.map((s,o)=>{const l=b.nodes[s.source],f=b.nodes[s.target],C=E(s.type),M=Math.max(1,s.weight*2.5);return e.jsx("line",{x1:y+l.pos.x/(b.nodes.length||1)*(N-2*y),y1:y+l.pos.y/(b.nodes.length||1)*(S-2*y),x2:y+f.pos.x/(b.nodes.length||1)*(N-2*y),y2:y+f.pos.y/(b.nodes.length||1)*(S-2*y),stroke:C,strokeWidth:M,opacity:se},`edge-${o}`)}),b.nodes.map((s,o)=>{const l=y+s.pos.x/(b.nodes.length||1)*(N-2*y),f=y+s.pos.y/(b.nodes.length||1)*(S-2*y),C=Math.min(20,8+s.tokenEstimate/500),M=$?$.has(o):!0,H=a?.id===s.id,q=s.label.length>20?s.label.slice(0,18)+"...":s.label;return e.jsxs("g",{className:"memory-map-node-group",onClick:()=>z(s,o),style:{cursor:"pointer"},children:[X(l,f,C,s.nodeType,H,M,s.dedupStatus),e.jsx("text",{x:l,y:f+C+12,textAnchor:"middle",fontSize:"9px",fill:"#374151",className:"memory-map-label",children:q})]},`node-${o}`)})]}),a?e.jsxs("div",{className:"memory-map-detail",children:[e.jsxs("h3",{children:[e.jsx("span",{className:"memory-map-detail-type",style:{display:"inline-block",fontSize:"12px",fontWeight:400,color:"#6b7280",marginRight:"6px"},children:U[a.nodeType]}),a.label]}),e.jsx("p",{children:a.summaryTruncated}),a.topicSummary?e.jsxs("p",{className:"memory-map-topic",children:["Topic: ",a.topicSummary]}):null,e.jsxs("p",{children:["Tokens: ",a.tokenEstimate," | Decisions: ",a.decisionCount]}),e.jsxs("p",{children:["Session: ",a.sessionId]}),e.jsxs("p",{children:["Raptor Level: ",a.raptorLevel]}),e.jsx("p",{className:"memory-map-snippet",children:a.textSnippet})]}):null]})};function re(t){return t===0?"#d4a017":t===1?"#3b82f6":"#14b8a6"}function _(t){return t?new Date(t).toLocaleString():"—"}const oe={padding:"1rem",width:"100%",boxSizing:"border-box"},ae={display:"flex",gap:"1.5rem",alignItems:"center",marginBottom:"1rem",color:"#a0a0c0",fontSize:"0.9rem"},D={padding:"2rem",border:"1px dashed #2a2a4e",borderRadius:"8px",color:"#a0a0c0",textAlign:"center"},le={padding:"1rem",color:"#a0a0c0"};function ie({node:t}){const r=re(t.level),i=t.children.length>0?`${t.children.length} child${t.children.length===1?"":"ren"}`:"leaf";return e.jsxs("div",{style:{background:"#14142b",border:`1px solid ${r}`,borderRadius:"8px",padding:"0.75rem 1rem",marginBottom:"0.6rem",marginLeft:t.level*24,maxWidth:"90%"},children:[e.jsxs("div",{style:{display:"flex",gap:"0.75rem",alignItems:"center",marginBottom:"0.35rem"},children:[e.jsxs("span",{style:{display:"inline-block",background:r,color:"#fff",borderRadius:"10px",padding:"1px 8px",fontSize:"11px",fontWeight:600},children:["L",t.level]}),e.jsxs("span",{style:{fontSize:"12px",color:"#6b7280"},children:[i," · ",t.tokenEstimate," tok · ",t.qualityMarker]}),e.jsx("span",{style:{fontSize:"12px",color:"#6b7280",marginLeft:"auto"},children:_(t.builtAt)})]}),e.jsx("div",{style:{fontSize:"0.92rem",color:"#e5e7eb"},children:t.summary})]})}function ce(){const[t,r]=c.useState(null),[i,d]=c.useState(!0),[n,m]=c.useState(null);return c.useEffect(()=>{let a=!1;return d(!0),m(null),V().then(p=>{a||(r(p),d(!1))}).catch(p=>{a||(m(p instanceof Error?p.message:"Unknown error"),d(!1))}),()=>{a=!0}},[]),i?e.jsx("div",{style:le,children:"Loading RAPTOR tree..."}):n?e.jsx("div",{style:D,children:e.jsxs("p",{children:["Failed to load RAPTOR tree: ",n]})}):!t||t.empty||t.nodes.length===0?e.jsx("div",{style:D,children:e.jsx("p",{children:"No RAPTOR tree built yet — run a compaction (the tree builds during compaction)."})}):e.jsxs("div",{style:oe,children:[e.jsxs("div",{style:ae,children:[e.jsxs("span",{children:[e.jsx("strong",{children:t.nodes.length})," nodes"]}),e.jsxs("span",{children:[e.jsx("strong",{children:t.levels+1})," levels"]}),e.jsxs("span",{children:["Built ",_(t.builtAt??0)]})]}),t.nodes.map(a=>e.jsx(ie,{node:a},a.id))]})}const de={display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid #2a2a4e",paddingBottom:"0.5rem",paddingTop:"0.5rem",width:"100%"};function O(t){return{background:t?"#3a5a9f":"transparent",color:t?"#fff":"#a0a0c0",border:"1px solid",borderColor:t?"#3a5a9f":"#2a2a4e",borderRadius:"6px",padding:"0.4rem 0.8rem",cursor:"pointer",fontSize:"0.9rem",fontWeight:t?600:400}}const pe=()=>{const[t,r]=c.useState("map");return e.jsxs("div",{className:"memory-map-tab",children:[e.jsxs("nav",{style:de,"aria-label":"Memory map sections",children:[e.jsx("button",{type:"button",style:O(t==="map"),onClick:()=>r("map"),children:"Memory Map"}),e.jsx("button",{type:"button",style:O(t==="raptor"),onClick:()=>r("raptor"),children:"RAPTOR Tree"})]}),t==="map"&&e.jsx(ne,{}),t==="raptor"&&e.jsx(ce,{})]})};export{pe as default};
|
|
2
|
-
//# sourceMappingURL=MemoryMapTab-
|
|
1
|
+
import{j as e,r as c,I as V}from"./index-BEj1Zahy.js";const w={checkpoint:"#6366f1",turn:"#58a6ff","turn-content":"#22c55e",memory:"#f59e0b"},U={checkpoint:"Checkpoint",turn:"Turn","turn-content":"Turn Content",memory:"Memory"};function Y(t,r){return`M 0,-${r} L ${t},0 L 0,${r} L -${t},0 Z`}function Q(t){return!t||t==="active"?1:.5}function X(t,r,i,d,n,m,a){const p=m?w[d]??"#6366f1":"#d1d5db",u=n?"#ef4444":"none",h=Q(a);switch(d){case"checkpoint":return e.jsx("circle",{cx:t,cy:r,r:n?i+3:i,fill:p,opacity:h,stroke:u,strokeWidth:n?2:0});case"turn":return e.jsx("circle",{cx:t,cy:r,r:n?i+3:i,fill:"none",stroke:p,strokeWidth:2.5,opacity:h});case"turn-content":return e.jsxs("g",{children:[e.jsx("circle",{cx:t,cy:r,r:n?i+3:i,fill:"none",stroke:p,strokeWidth:2.5,opacity:h}),e.jsx("circle",{cx:t,cy:r,r:Math.max(3,i*.3),fill:p,opacity:h})]});case"memory":const x=i*.85,j=i*.85;return e.jsx("path",{d:Y(x,j),transform:`translate(${t}, ${r})`,fill:p,opacity:h,stroke:u,strokeWidth:n?2:0})}}const Z=5e3,I=.005,P=.01,W=.9,J=.1,L=50;function K(t){const r=t.nodes.map((n,m)=>{const a=2*Math.PI*m/Math.max(t.nodes.length,1),p=200;return{...n,pos:{x:Math.cos(a)*p+300,y:Math.sin(a)*p+200},vx:0,vy:0,pinned:!1}}),i=new Map;r.forEach((n,m)=>i.set(n.id,m));const d=t.edges.map(n=>{const m=i.get(n.source),a=i.get(n.target);return m===void 0||a===void 0||m===a?null:{source:m,target:a,weight:n.weight,type:n.type}}).filter(n=>n!==null);return{nodes:r,edges:d}}function ee(t){const{nodes:r,edges:i}=t,d=r.length;if(d!==0)for(let n=0;n<d;n++){if(r[n].pinned)continue;let m=0,a=0;for(let u=0;u<d;u++){if(n===u)continue;const h=r[n].pos.x-r[u].pos.x,x=r[n].pos.y-r[u].pos.y,j=h*h+x*x||1,v=Z/j,g=Math.sqrt(j);m+=h/g*v,a+=x/g*v}for(const u of i){let h;if(u.source===n)h=u.target;else if(u.target===n)h=u.source;else continue;const x=r[h].pos.x-r[n].pos.x,j=r[h].pos.y-r[n].pos.y;m+=x*I*u.weight,a+=j*I*u.weight}m-=r[n].pos.x*P,a-=r[n].pos.y*P,r[n].vx=(r[n].vx+m)*W,r[n].vy=(r[n].vy+a)*W;const p=Math.sqrt(r[n].vx*r[n].vx+r[n].vy*r[n].vy);p>L&&(r[n].vx=r[n].vx/p*L,r[n].vy=r[n].vy/p*L),p>J&&(r[n].pos.x+=r[n].vx,r[n].pos.y+=r[n].vy)}}const te=300,se=.3,N=900,S=600,y=40;function E(t){switch(t){case"temporal":return"#6366f1";case"semantic":return"#22c55e";case"raptor_parent":return"#f59e0b"}}const k=({color:t,shape:r,label:i})=>{const d={display:"inline-block",width:"10px",height:"10px",verticalAlign:"middle",marginRight:"3px",borderRadius:r.startsWith("hollow")||r==="filled-circle"?"50%":void 0};let n;return r==="line"?e.jsx("span",{style:{color:t,marginRight:"6px"},children:i}):(r==="filled-circle"?n=e.jsx("span",{style:{...d,backgroundColor:t}}):r==="hollow-circle"?n=e.jsx("span",{style:{...d,border:`2px solid ${t}`,backgroundColor:"transparent"}}):r==="hollow-ring"?n=e.jsx("span",{style:{...d,border:`2px solid ${t}`,backgroundColor:"transparent",position:"relative"},children:e.jsx("span",{style:{display:"block",width:"4px",height:"4px",borderRadius:"50%",backgroundColor:t,margin:"2px auto"}})}):n=e.jsx("span",{style:{...d,clipPath:"polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)",backgroundColor:t}}),e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"memory-map-legend-item",children:[n,i]})," "]}))},ne=()=>{const[t,r]=c.useState(null),[i,d]=c.useState(!0),[n,m]=c.useState(null),[a,p]=c.useState(null),[u,h]=c.useState(""),[x]=c.useState(""),[j,v]=c.useState(0),g=c.useRef(null),T=c.useRef(0);c.useEffect(()=>{let s=!1;const o=new URLSearchParams;return x&&o.set("sessionId",x),o.set("threshold","0.7"),o.set("maxEdgesPerNode","4"),d(!0),m(null),fetch(`/api/memory-map?${o.toString()}`).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);return l.json()}).then(l=>{s||(r(l),g.current=K(l),v(1),d(!1))}).catch(l=>{s||(m(l instanceof Error?l.message:"Unknown error"),d(!1))}),()=>{s=!0,cancelAnimationFrame(T.current)}},[x]),c.useEffect(()=>{if(!g.current||j===0)return;const s=g.current;let o=0;const l=()=>{o>=te||(ee(s),o++,v(o),T.current=requestAnimationFrame(l))};return T.current=requestAnimationFrame(l),()=>cancelAnimationFrame(T.current)},[j]);const z=c.useCallback((s,o)=>{const l=g.current;l&&(l.nodes[o].pinned=!l.nodes[o].pinned,l.nodes[o].pinned||(l.nodes[o].vx=0,l.nodes[o].vy=0),p(f=>f?.id===s.id?null:s),v(f=>f+1))},[]),$=c.useMemo(()=>{const s=g.current;if(!s||!u)return null;const o=u.toLowerCase();return new Set(s.nodes.map((l,f)=>l.summaryTruncated.toLowerCase().includes(o)||l.label.toLowerCase().includes(o)?f:-1).filter(l=>l>=0))},[u]),R=c.useMemo(()=>{const s=t?.validation;return s?s.gatesPassed<s.gatesRun?{level:"red",label:"Gate failure"}:s.warnings.length>0?{level:"yellow",label:`${s.warnings.length} warning(s)`}:{level:"green",label:"Healthy"}:{level:"yellow",label:"No validation"}},[t?.validation]),B={green:"#22c55e",yellow:"#eab308",red:"#ef4444"},F=c.useMemo(()=>{const s=t?.validation;if(!s)return`${t?.metadata.totalNodes??0} nodes`;const o=[];return s.sources.checkpoint>0&&o.push(`${s.sources.checkpoint} checkpoints`),s.sources.turn>0&&o.push(`${s.sources.turn} turns`),s.sources.turnContent>0&&o.push(`${s.sources.turnContent} turn-content`),s.sources.memory>0&&o.push(`${s.sources.memory} memories`),o.length===0&&o.push(`${t?.metadata.totalNodes??0} nodes`),o.join(" · ")},[t?.validation,t?.metadata.totalNodes]),A=c.useMemo(()=>{const s=t?.validation;if(!s)return"";const o=[];return o.push(s.sources.checkpoint>0?"✓ checkpoints":"✗ checkpoints"),o.push(s.sources.turn>0?"✓ turns":"✗ turns"),o.push(s.sources.turnContent>0?"✓ turn-content":"✗ turn-content"),o.push(s.sources.memory>0?"✓ memories":"✗ memories"),o.join(" | ")},[t?.validation]),G=c.useMemo(()=>{const s=t?.validation;return s?s.sources.checkpoint===0&&s.sources.turn===0&&s.sources.turnContent===0&&s.sources.memory===0:t?.metadata.totalNodes===0},[t?.validation,t?.metadata.totalNodes]);if(i)return e.jsx("div",{className:"memory-map-loading",children:"Loading memory graph..."});if(n)return e.jsxs("div",{className:"memory-map-error",children:[e.jsxs("p",{children:["Failed to load memory map: ",n]}),e.jsx("button",{className:"memory-map-retry-btn",onClick:()=>v(s=>s+1),children:"Retry"})]});if(!t||!g.current||G)return e.jsx("div",{className:"memory-map-empty",children:e.jsx("p",{children:"Memories appear after your first compaction. The graph shows checkpoints (compaction summaries) linked by semantic similarity and time. Run a longer session or lower the compaction tier to see it sooner."})});const b=g.current;return e.jsxs("div",{className:"memory-map-container",children:[e.jsxs("div",{className:"memory-map-toolbar",children:[e.jsx("input",{type:"text",placeholder:"Search memories...",value:u,onInput:s=>h(s.target.value),className:"memory-map-search"}),e.jsxs("span",{className:"memory-map-stats",children:[e.jsx("span",{className:"memory-map-count-badge",children:F}),e.jsx("br",{}),e.jsxs("span",{className:"memory-map-edges",children:[t.edges.length," edges"]})]}),e.jsx("span",{className:"memory-map-health-badge",style:{backgroundColor:B[R.level]??"#6b7280",color:"#fff",padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,marginLeft:"8px"},title:`Validation: ${R.label}`,children:R.level==="green"?"Healthy":R.level==="yellow"?"Warnings":"Critical"})]}),A?e.jsx("div",{className:"memory-map-source-avail",style:{fontSize:"11px",padding:"2px 12px",color:"#6b7280"},children:A}):null,e.jsxs("div",{className:"memory-map-legend",children:[e.jsx("span",{className:"memory-map-legend-section",children:"Nodes:"}),e.jsx(k,{type:"node",color:w.checkpoint,shape:"filled-circle",label:"Checkpoint"}),e.jsx(k,{type:"node",color:w.turn,shape:"hollow-circle",label:"Turn"}),e.jsx(k,{type:"node",color:w["turn-content"],shape:"hollow-ring",label:"Turn Content"}),e.jsx(k,{type:"node",color:w.memory,shape:"diamond",label:"Memory"}),e.jsx("span",{className:"memory-map-legend-sep",children:"|"}),e.jsx("span",{className:"memory-map-legend-section",children:"Edges:"}),e.jsx(k,{type:"edge",color:E("semantic"),shape:"line",label:"Semantic"}),e.jsx(k,{type:"edge",color:E("temporal"),shape:"line",label:"Temporal"}),e.jsx(k,{type:"edge",color:E("raptor_parent"),shape:"line",label:"Raptor"})]}),e.jsxs("svg",{width:N,height:S,viewBox:`0 0 ${N} ${S}`,className:"memory-map-svg",children:[b.edges.map((s,o)=>{const l=b.nodes[s.source],f=b.nodes[s.target],C=E(s.type),M=Math.max(1,s.weight*2.5);return e.jsx("line",{x1:y+l.pos.x/(b.nodes.length||1)*(N-2*y),y1:y+l.pos.y/(b.nodes.length||1)*(S-2*y),x2:y+f.pos.x/(b.nodes.length||1)*(N-2*y),y2:y+f.pos.y/(b.nodes.length||1)*(S-2*y),stroke:C,strokeWidth:M,opacity:se},`edge-${o}`)}),b.nodes.map((s,o)=>{const l=y+s.pos.x/(b.nodes.length||1)*(N-2*y),f=y+s.pos.y/(b.nodes.length||1)*(S-2*y),C=Math.min(20,8+s.tokenEstimate/500),M=$?$.has(o):!0,H=a?.id===s.id,q=s.label.length>20?s.label.slice(0,18)+"...":s.label;return e.jsxs("g",{className:"memory-map-node-group",onClick:()=>z(s,o),style:{cursor:"pointer"},children:[X(l,f,C,s.nodeType,H,M,s.dedupStatus),e.jsx("text",{x:l,y:f+C+12,textAnchor:"middle",fontSize:"9px",fill:"#374151",className:"memory-map-label",children:q})]},`node-${o}`)})]}),a?e.jsxs("div",{className:"memory-map-detail",children:[e.jsxs("h3",{children:[e.jsx("span",{className:"memory-map-detail-type",style:{display:"inline-block",fontSize:"12px",fontWeight:400,color:"#6b7280",marginRight:"6px"},children:U[a.nodeType]}),a.label]}),e.jsx("p",{children:a.summaryTruncated}),a.topicSummary?e.jsxs("p",{className:"memory-map-topic",children:["Topic: ",a.topicSummary]}):null,e.jsxs("p",{children:["Tokens: ",a.tokenEstimate," | Decisions: ",a.decisionCount]}),e.jsxs("p",{children:["Session: ",a.sessionId]}),e.jsxs("p",{children:["Raptor Level: ",a.raptorLevel]}),e.jsx("p",{className:"memory-map-snippet",children:a.textSnippet})]}):null]})};function re(t){return t===0?"#d4a017":t===1?"#3b82f6":"#14b8a6"}function _(t){return t?new Date(t).toLocaleString():"—"}const oe={padding:"1rem",width:"100%",boxSizing:"border-box"},ae={display:"flex",gap:"1.5rem",alignItems:"center",marginBottom:"1rem",color:"#a0a0c0",fontSize:"0.9rem"},D={padding:"2rem",border:"1px dashed #2a2a4e",borderRadius:"8px",color:"#a0a0c0",textAlign:"center"},le={padding:"1rem",color:"#a0a0c0"};function ie({node:t}){const r=re(t.level),i=t.children.length>0?`${t.children.length} child${t.children.length===1?"":"ren"}`:"leaf";return e.jsxs("div",{style:{background:"#14142b",border:`1px solid ${r}`,borderRadius:"8px",padding:"0.75rem 1rem",marginBottom:"0.6rem",marginLeft:t.level*24,maxWidth:"90%"},children:[e.jsxs("div",{style:{display:"flex",gap:"0.75rem",alignItems:"center",marginBottom:"0.35rem"},children:[e.jsxs("span",{style:{display:"inline-block",background:r,color:"#fff",borderRadius:"10px",padding:"1px 8px",fontSize:"11px",fontWeight:600},children:["L",t.level]}),e.jsxs("span",{style:{fontSize:"12px",color:"#6b7280"},children:[i," · ",t.tokenEstimate," tok · ",t.qualityMarker]}),e.jsx("span",{style:{fontSize:"12px",color:"#6b7280",marginLeft:"auto"},children:_(t.builtAt)})]}),e.jsx("div",{style:{fontSize:"0.92rem",color:"#e5e7eb"},children:t.summary})]})}function ce(){const[t,r]=c.useState(null),[i,d]=c.useState(!0),[n,m]=c.useState(null);return c.useEffect(()=>{let a=!1;return d(!0),m(null),V().then(p=>{a||(r(p),d(!1))}).catch(p=>{a||(m(p instanceof Error?p.message:"Unknown error"),d(!1))}),()=>{a=!0}},[]),i?e.jsx("div",{style:le,children:"Loading RAPTOR tree..."}):n?e.jsx("div",{style:D,children:e.jsxs("p",{children:["Failed to load RAPTOR tree: ",n]})}):!t||t.empty||t.nodes.length===0?e.jsx("div",{style:D,children:e.jsx("p",{children:"No RAPTOR tree built yet — run a compaction (the tree builds during compaction)."})}):e.jsxs("div",{style:oe,children:[e.jsxs("div",{style:ae,children:[e.jsxs("span",{children:[e.jsx("strong",{children:t.nodes.length})," nodes"]}),e.jsxs("span",{children:[e.jsx("strong",{children:t.levels+1})," levels"]}),e.jsxs("span",{children:["Built ",_(t.builtAt??0)]})]}),t.nodes.map(a=>e.jsx(ie,{node:a},a.id))]})}const de={display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid #2a2a4e",paddingBottom:"0.5rem",paddingTop:"0.5rem",width:"100%"};function O(t){return{background:t?"#3a5a9f":"transparent",color:t?"#fff":"#a0a0c0",border:"1px solid",borderColor:t?"#3a5a9f":"#2a2a4e",borderRadius:"6px",padding:"0.4rem 0.8rem",cursor:"pointer",fontSize:"0.9rem",fontWeight:t?600:400}}const pe=()=>{const[t,r]=c.useState("map");return e.jsxs("div",{className:"memory-map-tab",children:[e.jsxs("nav",{style:de,"aria-label":"Memory map sections",children:[e.jsx("button",{type:"button",style:O(t==="map"),onClick:()=>r("map"),children:"Memory Map"}),e.jsx("button",{type:"button",style:O(t==="raptor"),onClick:()=>r("raptor"),children:"RAPTOR Tree"})]}),t==="map"&&e.jsx(ne,{}),t==="raptor"&&e.jsx(ce,{})]})};export{pe as default};
|
|
2
|
+
//# sourceMappingURL=MemoryMapTab-D1V9g_NC.js.map
|