fix(hub): restore monitor host status panel after missing pref helpers
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -73,6 +73,21 @@
|
||||
const HOST_RESOURCE_ALERT_THRESHOLD = 85;
|
||||
const hostResourceAlertLatch = { cpu: false, mem: false };
|
||||
|
||||
function loadBoolPref(key, defaultValue) {
|
||||
try {
|
||||
const raw = localStorage.getItem(key);
|
||||
if (raw === "1" || raw === "true") return true;
|
||||
if (raw === "0" || raw === "false") return false;
|
||||
} catch (_) {}
|
||||
return !!defaultValue;
|
||||
}
|
||||
|
||||
function saveBoolPref(key, on) {
|
||||
try {
|
||||
localStorage.setItem(key, on ? "1" : "0");
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
function fmtHostBytes(n) {
|
||||
const v = Number(n);
|
||||
if (!Number.isFinite(v)) return "—";
|
||||
@@ -153,13 +168,19 @@
|
||||
return parts.join(" · ") || "—";
|
||||
}
|
||||
|
||||
let hostStatusPanelInited = false;
|
||||
|
||||
function initHostStatusPanel() {
|
||||
const panel = document.getElementById("host-status-panel");
|
||||
if (!panel) return;
|
||||
panel.open = loadBoolPref(HOST_STATUS_OPEN_KEY, false);
|
||||
panel.addEventListener("toggle", function () {
|
||||
saveBoolPref(HOST_STATUS_OPEN_KEY, !!panel.open);
|
||||
});
|
||||
panel.classList.remove("hidden");
|
||||
if (!hostStatusPanelInited) {
|
||||
panel.open = loadBoolPref(HOST_STATUS_OPEN_KEY, false);
|
||||
panel.addEventListener("toggle", function () {
|
||||
saveBoolPref(HOST_STATUS_OPEN_KEY, !!panel.open);
|
||||
});
|
||||
hostStatusPanelInited = true;
|
||||
}
|
||||
}
|
||||
|
||||
function renderHostStatusBar(data) {
|
||||
|
||||
Reference in New Issue
Block a user