From 76abce349b5758b9afa7ad419754ec2db144e945 Mon Sep 17 00:00:00 2001 From: Yu-Wei Chang Date: Sat, 24 Oct 2026 22:53:45 -0700 Subject: [PATCH] fix(sidebar): measure the auto-collapse restore with the sidebar at full width When the window widens after an auto-collapse, the restore check removes .hidden and measures the chat width to decide whether the sidebar fits. html.ody-sidebar-mini also forces the sidebar to width 0 and was only cleared by syncRailSide() after the measurement, so the check always saw a 0-width sidebar and restored it even when the chat ended up narrower than MIN_CHAT_WIDTH. Sync the mode classes before measuring. --- static/js/sidebar-layout.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/js/sidebar-layout.js b/static/js/sidebar-layout.js index 58fcb363a..92f371070 100644 --- a/static/js/sidebar-layout.js +++ b/static/js/sidebar-layout.js @@ -322,9 +322,11 @@ export function initSidebarLayout(Storage, opts) { syncRailSide(); } else if (window.innerWidth >= AUTO_COLLAPSE_WIDTH && isHidden && _wasAutoCollapsed) { // Only restore if chat won't be too narrow. Suppress the width - // transition so the reflow measures the sidebar at its full width. + // transition and sync the mode classes (ody-sidebar-mini also forces + // width 0) so the reflow measures the sidebar at its full width. sidebar.style.transition = 'none'; sidebar.classList.remove('hidden'); + syncRailSide(); void document.body.offsetWidth; // reflow if (chatContainer && chatContainer.offsetWidth < MIN_CHAT_WIDTH) { sidebar.classList.add('hidden');