This commit is contained in:
vee
2026-08-14 15:01:29 +08:00
parent 6d768aaef4
commit f77dda70fe
20 changed files with 1125 additions and 122 deletions
+26 -3
View File
@@ -89,10 +89,10 @@
let activeView = sessionStorage.getItem(VIEW_KEY) === "hardware"
? "hardware"
: "software";
let executionMode = sessionStorage.getItem(MODE_KEY) === "bench"
? "bench"
: "shadow";
sessionStorage.removeItem(MODE_KEY);
let executionMode = "shadow";
let polling = false;
let bootstrapRuntimeReset = false;
let toastTimer = 0;
let confirmationResolve = null;
let eventFilter = "all";
@@ -642,6 +642,29 @@
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
latest = await response.json();
if (!bootstrapRuntimeReset) {
bootstrapRuntimeReset = true;
const backendMode = latest.runtime?.execution_mode === "bench" ? "bench" : "shadow";
if (backendMode === "bench") {
// A physical session is authoritative: retain it and render bench feedback.
executionMode = "bench";
sessionStorage.setItem(MODE_KEY, executionMode);
if ($("#repairExecutionMode")) $("#repairExecutionMode").value = executionMode;
} else {
// Shadow state is one-run-only. A full web runtime restart always returns
// counters, injected faults, and the twin to the initial safe state.
if (latest.runtime?.active) {
await apiPost("/runtime", { active: false, execution_mode: "shadow" });
}
await apiPost("/runtime/reset-statistics");
const resetResponse = await fetch(`${API_ROOT}/state`, {
cache: "no-store",
credentials: "same-origin",
headers: { Accept: "application/json", "X-Cognitive-Agent-Role": "admin" },
});
if (resetResponse.ok) latest = await resetResponse.json();
}
}
if (!["IDLE"].includes(latest.healing?.phase)) selectedCaseId = latest.healing.case_id;
renderAll();
} catch (error) {