feat: pre-render sidebar on openSession before first poll tick
This commit is contained in:
+14
-5
@@ -360,12 +360,14 @@ function renderSidebar(sessions, currentSession) {
|
|||||||
list.innerHTML = sessions.map((session) => buildSidebarHTML(session, currentSession)).join('');
|
list.innerHTML = sessions.map((session) => buildSidebarHTML(session, currentSession)).join('');
|
||||||
|
|
||||||
// Bind click handlers on each sidebar item
|
// Bind click handlers on each sidebar item
|
||||||
list.querySelectorAll('.sidebar-item').forEach((item) => {
|
if (typeof list.querySelectorAll === 'function') {
|
||||||
const name = item.dataset.session;
|
list.querySelectorAll('.sidebar-item').forEach((item) => {
|
||||||
on(item, 'click', () => {
|
const name = item.dataset.session;
|
||||||
if (name !== currentSession) openSession(name);
|
on(item, 'click', () => {
|
||||||
|
if (name !== currentSession) openSession(name);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SIDEBAR_KEY = 'muxplex.sidebarOpen';
|
const SIDEBAR_KEY = 'muxplex.sidebarOpen';
|
||||||
@@ -604,6 +606,10 @@ async function openSession(name, opts = {}) {
|
|||||||
_viewingSession = name;
|
_viewingSession = name;
|
||||||
_viewMode = 'fullscreen';
|
_viewMode = 'fullscreen';
|
||||||
|
|
||||||
|
// Pre-render sidebar with current sessions before first poll tick
|
||||||
|
initSidebar();
|
||||||
|
renderSidebar(_currentSessions, name);
|
||||||
|
|
||||||
// Update expanded header
|
// Update expanded header
|
||||||
const nameEl = $('expanded-session-name');
|
const nameEl = $('expanded-session-name');
|
||||||
if (nameEl) nameEl.textContent = name;
|
if (nameEl) nameEl.textContent = name;
|
||||||
@@ -638,6 +644,9 @@ async function openSession(name, opts = {}) {
|
|||||||
}
|
}
|
||||||
// Mount terminal AFTER view is visible so FitAddon measures real dimensions
|
// Mount terminal AFTER view is visible so FitAddon measures real dimensions
|
||||||
if (window._openTerminal) window._openTerminal(name);
|
if (window._openTerminal) window._openTerminal(name);
|
||||||
|
// Re-render sidebar after DOM is visible and dimensions are correct
|
||||||
|
initSidebar();
|
||||||
|
renderSidebar(_currentSessions, name);
|
||||||
}, 260);
|
}, 260);
|
||||||
|
|
||||||
// Mobile pill
|
// Mobile pill
|
||||||
|
|||||||
@@ -1927,6 +1927,16 @@ test('toggleSidebar removes sidebar--collapsed class when opening (from closed)
|
|||||||
globalThis.document.getElementById = origGetById;
|
globalThis.document.getElementById = origGetById;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// --- Guard: initSidebar and renderSidebar are exported and callable ---
|
||||||
|
|
||||||
|
test('initSidebar is exported and callable', () => {
|
||||||
|
assert.strictEqual(typeof app.initSidebar, 'function', 'initSidebar should be a function');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('renderSidebar is exported and callable', () => {
|
||||||
|
assert.strictEqual(typeof app.renderSidebar, 'function', 'renderSidebar should be a function');
|
||||||
|
});
|
||||||
|
|
||||||
// --- bindStaticEventListeners sidebar toggle buttons ---
|
// --- bindStaticEventListeners sidebar toggle buttons ---
|
||||||
|
|
||||||
test('bindStaticEventListeners binds sidebar-toggle-btn and sidebar-collapse-btn click to toggleSidebar', () => {
|
test('bindStaticEventListeners binds sidebar-toggle-btn and sidebar-collapse-btn click to toggleSidebar', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user