feat: pre-render sidebar on openSession before first poll tick
This commit is contained in:
@@ -360,6 +360,7 @@ function renderSidebar(sessions, currentSession) {
|
||||
list.innerHTML = sessions.map((session) => buildSidebarHTML(session, currentSession)).join('');
|
||||
|
||||
// Bind click handlers on each sidebar item
|
||||
if (typeof list.querySelectorAll === 'function') {
|
||||
list.querySelectorAll('.sidebar-item').forEach((item) => {
|
||||
const name = item.dataset.session;
|
||||
on(item, 'click', () => {
|
||||
@@ -367,6 +368,7 @@ function renderSidebar(sessions, currentSession) {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const SIDEBAR_KEY = 'muxplex.sidebarOpen';
|
||||
const SIDEBAR_NARROW_THRESHOLD = 960;
|
||||
@@ -604,6 +606,10 @@ async function openSession(name, opts = {}) {
|
||||
_viewingSession = name;
|
||||
_viewMode = 'fullscreen';
|
||||
|
||||
// Pre-render sidebar with current sessions before first poll tick
|
||||
initSidebar();
|
||||
renderSidebar(_currentSessions, name);
|
||||
|
||||
// Update expanded header
|
||||
const nameEl = $('expanded-session-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
|
||||
if (window._openTerminal) window._openTerminal(name);
|
||||
// Re-render sidebar after DOM is visible and dimensions are correct
|
||||
initSidebar();
|
||||
renderSidebar(_currentSessions, name);
|
||||
}, 260);
|
||||
|
||||
// Mobile pill
|
||||
|
||||
@@ -1927,6 +1927,16 @@ test('toggleSidebar removes sidebar--collapsed class when opening (from closed)
|
||||
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 ---
|
||||
|
||||
test('bindStaticEventListeners binds sidebar-toggle-btn and sidebar-collapse-btn click to toggleSidebar', () => {
|
||||
|
||||
Reference in New Issue
Block a user