fix(#1015,#1016): declare overflow vars before syncTabFromHash() call

overflowBtn/overflowDrop/overflowWrap were declared after syncTabFromHash()
was invoked. activateTab() calls updateTabbarOverflow() which closes over
these consts — hitting them in the TDZ threw ReferenceError on every page
load, also preventing fetchAndRenderToolGroups() from running (tool-groups
section stuck at loading).
This commit is contained in:
iris 2026-06-01 20:42:42 +02:00
commit 6c75030420

View file

@ -3487,16 +3487,6 @@ window.marked = marked;
// so it stays fresh without an SSE channel.
if (target === 'system') fetchAndRenderToolGroups();
}
function syncTabFromHash() {
const h = (window.location.hash || '#swarm').replace(/^#/, '');
activateTab(h);
}
window.addEventListener('hashchange', () => {
syncTabFromHash();
updateTabbarOverflow();
});
syncTabFromHash();
// ─── tabbar overflow menu ────────────────────────────────────────────────
// Tabs with `data-overflow="default"` (LOGS, SETTINGS) always live in
// the ⋮ dropdown. When the bar is too narrow to show all remaining tabs,
@ -3506,12 +3496,27 @@ window.marked = marked;
// flex end. `tab-overflowed` hides a tab from the bar (display:none).
// The dropdown is rebuilt from scratch on every call — it holds cloned
// <a>/<button> items, not the originals.
//
// IMPORTANT: these must be declared before syncTabFromHash() is called
// below — activateTab() calls updateTabbarOverflow() which closes over
// these variables, and const/let are not accessible before their
// declaration (TDZ).
const overflowWrap = $('tabbar-overflow');
const overflowBtn = $('tabbar-overflow-btn');
const overflowDrop = $('tabbar-overflow-dropdown');
let overflowOpen = false;
function syncTabFromHash() {
const h = (window.location.hash || '#swarm').replace(/^#/, '');
activateTab(h);
}
window.addEventListener('hashchange', () => {
syncTabFromHash();
updateTabbarOverflow();
});
syncTabFromHash();
function closeOverflowMenu() {
if (!overflowOpen) return;
overflowOpen = false;