Mount Cortex OS Runtime Health as WebUI panel

This commit is contained in:
Svrnty 2026-05-29 03:13:56 -04:00
parent 1707a7b09d
commit 3685710fe8
5 changed files with 54 additions and 4 deletions

View File

@ -9,6 +9,10 @@
font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
} }
main.main:not(.svrnty-showing-cortex-os) .cortex-os-runtime-health {
display: none;
}
.cortex-os-runtime-health h2 { .cortex-os-runtime-health h2 {
margin: 0 0 8px; margin: 0 0 8px;
font-size: 15px; font-size: 15px;

View File

@ -42,7 +42,10 @@
panel.appendChild(summary); panel.appendChild(summary);
panel.appendChild(list); panel.appendChild(list);
var target = document.querySelector("main") || document.body; var target = document.querySelector("main.main");
if (!target) {
return panel;
}
target.appendChild(panel); target.appendChild(panel);
return panel; return panel;
} }
@ -99,9 +102,17 @@
}); });
} }
if (document.readyState === "loading") { function handlePanelSwitch(event) {
document.addEventListener("DOMContentLoaded", loadRuntimeHealth, { once: true }); var detail = (event && event.detail) || {};
} else { if (detail.name === "cortex-os") {
loadRuntimeHealth();
}
}
window.addEventListener("svrnty:panel-switch", handlePanelSwitch);
var main = document.querySelector("main.main");
if (main && main.classList.contains("svrnty-showing-cortex-os")) {
loadRuntimeHealth(); loadRuntimeHealth();
} }
})(); })();

View File

@ -24,11 +24,14 @@
'<path d="M12 2l1.8 5.6L19.4 9.4l-4.5 3.3 1.7 5.7L12 15l-4.6 3.4 1.7-5.7L4.6 9.4l5.6-1.8L12 2z"/>', '<path d="M12 2l1.8 5.6L19.4 9.4l-4.5 3.3 1.7 5.7L12 15l-4.6 3.4 1.7-5.7L4.6 9.4l5.6-1.8L12 2z"/>',
canvas: canvas:
'<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M8 3v18M16 3v18M3 8h18M3 16h18"/>', '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M8 3v18M16 3v18M3 8h18M3 16h18"/>',
"cortex-os":
'<path d="M4 7h16M4 12h16M4 17h10"/><circle cx="17" cy="17" r="3"/>',
}; };
const TABS = [ const TABS = [
{ id: "adwright", label: "Adwright", tooltip: "Adwright — marketing intelligence" }, { id: "adwright", label: "Adwright", tooltip: "Adwright — marketing intelligence" },
{ id: "bte", label: "BTE", tooltip: "BTE — brand creative studio" }, { id: "bte", label: "BTE", tooltip: "BTE — brand creative studio" },
{ id: "canvas", label: "Canvas", tooltip: "Canvas — sovereign UI design" }, { id: "canvas", label: "Canvas", tooltip: "Canvas — sovereign UI design" },
{ id: "cortex-os", label: "Cortex OS", tooltip: "Cortex OS — Runtime Health" },
]; ];
function _svg(iconPath, size, stroke) { function _svg(iconPath, size, stroke) {

View File

@ -22,6 +22,18 @@ def test_runtime_health_display_has_no_hidden_write_surface():
"localStorage", "localStorage",
"sessionStorage", "sessionStorage",
"document.cookie", "document.cookie",
"indexedDB",
"caches",
"navigator.sendBeacon",
"WebSocket",
"EventSource",
"BroadcastChannel",
"SharedWorker",
"ServiceWorker",
"window.open",
"eval(",
"new Function",
"innerHTML",
"<form", "<form",
".submit(", ".submit(",
"POST", "POST",
@ -43,3 +55,15 @@ def test_runtime_health_css_is_scoped_to_panel():
assert ".cortex-os-runtime-health" in css assert ".cortex-os-runtime-health" in css
assert "body {" not in css assert "body {" not in css
assert "#app" not in css assert "#app" not in css
def test_runtime_health_mounts_only_in_cortex_os_panel_context():
js = JS.read_text(encoding="utf-8")
assert 'window.addEventListener("svrnty:panel-switch", handlePanelSwitch)' in js
assert 'detail.name === "cortex-os"' in js
assert 'document.querySelector("main.main")' in js
assert "document.body" not in js
assert 'document.addEventListener("DOMContentLoaded", loadRuntimeHealth' not in js
assert "loadRuntimeHealth();" in js
assert js.count("/api/cortex-os/runtime-health") == 1

View File

@ -23,3 +23,11 @@ def test_canvas_tab_is_registered():
src = NAV_JS.read_text() src = NAV_JS.read_text()
assert '{ id: "canvas"' in src assert '{ id: "canvas"' in src
assert "svrnty-showing-\" + id" in src assert "svrnty-showing-\" + id" in src
def test_cortex_os_tab_is_registered_once():
src = NAV_JS.read_text()
assert src.count('id: "cortex-os"') == 1
assert '"cortex-os":' in src
for tab_id in ['id: "adwright"', 'id: "bte"', 'id: "canvas"']:
assert tab_id in src