auto-save 2026-05-09 18:36 (~3)
This commit is contained in:
12
src/app.js
12
src/app.js
@@ -9,6 +9,7 @@ const LS_THEME = "hermes-ui-theme-v1";
|
||||
const LS_AGENTS = "hermes-ui-agents-v1";
|
||||
const LS_CUSTOM_SKILLS = "hermes-ui-custom-skills-v1";
|
||||
const LS_FLOWS = "hermes-ui-flows-v1";
|
||||
const LS_TAB = "hermes-ui-active-tab-v1";
|
||||
|
||||
const state = {
|
||||
apiBase: "/api/v1",
|
||||
@@ -61,6 +62,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
renderSidebar();
|
||||
renderChat();
|
||||
renderAgents();
|
||||
restoreActiveTab();
|
||||
pingBackend();
|
||||
fetchIP();
|
||||
setInterval(pingBackend, 30000);
|
||||
@@ -329,10 +331,18 @@ function bindTabs() {
|
||||
btn.addEventListener("click", () => switchTab(btn.dataset.tab));
|
||||
});
|
||||
}
|
||||
function restoreActiveTab() {
|
||||
const saved = localStorage.getItem(LS_TAB);
|
||||
if (!saved) return;
|
||||
if (!document.querySelector(`.side-item[data-tab="${CSS.escape(saved)}"]`)) return;
|
||||
if (!document.getElementById("tab-" + saved)) return;
|
||||
switchTab(saved, { persist: false });
|
||||
}
|
||||
let _dashboardDirty = true;
|
||||
function markDashboardDirty() { _dashboardDirty = true; }
|
||||
|
||||
function switchTab(name) {
|
||||
function switchTab(name, options = {}) {
|
||||
if (options.persist !== false) localStorage.setItem(LS_TAB, name);
|
||||
document.querySelectorAll(".side-item").forEach(t => t.classList.toggle("active", t.dataset.tab === name));
|
||||
document.querySelectorAll(".tab-panel").forEach(p => p.classList.toggle("active", p.id === "tab-" + name));
|
||||
if (name === "chat") setTimeout(() => document.getElementById("chatInput")?.focus(), 50);
|
||||
|
||||
Reference in New Issue
Block a user