From 538d11165c71790bfa8e52862789002041e7ba9b Mon Sep 17 00:00:00 2001 From: Brian Krabach Date: Sat, 2 May 2026 07:08:18 -0700 Subject: [PATCH] fix: refit terminal after sidebar toggle animation completes toggleSidebar() flipped the sidebar--collapsed CSS class but never told xterm.js to recalculate its dimensions. The terminal canvas kept its old column/row count until a new session was opened (which creates a fresh terminal that measures correctly on first fit()). Fix: expose window._refitTerminal() from terminal.js, then call it via a transitionend listener in toggleSidebar() so the terminal refits once the 250ms CSS width/transform transition finishes. Bumps version to 0.4.5. --- muxplex/frontend/app.js | 7 +++++++ muxplex/frontend/terminal.js | 7 +++++++ pyproject.toml | 2 +- uv.lock | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/muxplex/frontend/app.js b/muxplex/frontend/app.js index 262e09a..3bf8a70 100644 --- a/muxplex/frontend/app.js +++ b/muxplex/frontend/app.js @@ -804,6 +804,13 @@ function toggleSidebar() { var collapseBtn = $('sidebar-collapse-btn'); if (collapseBtn) collapseBtn.textContent = isOpen ? '\u2039' : '\u203a'; + + // Refit xterm.js after the sidebar CSS transition completes (0.25s ease). + // 'width' fires on desktop (flex layout); 'transform' fires on mobile (overlay). + sidebar.addEventListener('transitionend', function(e) { + if (e.propertyName !== 'width' && e.propertyName !== 'transform') return; + if (window._refitTerminal) window._refitTerminal(); + }, { once: true }); } /** diff --git a/muxplex/frontend/terminal.js b/muxplex/frontend/terminal.js index b73bfd7..fb4a812 100644 --- a/muxplex/frontend/terminal.js +++ b/muxplex/frontend/terminal.js @@ -542,6 +542,13 @@ function setTerminalFontSize(size) { window._setTerminalFontSize = setTerminalFontSize; +// Refit the terminal to its container dimensions. +// Call after layout changes (e.g. sidebar toggle) that alter available space. +window._refitTerminal = function() { + if (!_fitAddon) return; + try { _fitAddon.fit(); } catch (_) {} +}; + // --------------------------------------------------------------------------- // Mobile touch scroll — rAF-batched WheelEvent dispatch // Mobile devices batch touchmove events irregularly; dispatching one WheelEvent diff --git a/pyproject.toml b/pyproject.toml index ee61367..53bb426 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "muxplex" -version = "0.4.4" +version = "0.4.5" description = "Web-based tmux session dashboard — access all your tmux sessions from any browser" readme = "README.md" license = { text = "MIT" } diff --git a/uv.lock b/uv.lock index 59e2a8e..a6fc4fd 100644 --- a/uv.lock +++ b/uv.lock @@ -332,7 +332,7 @@ wheels = [ [[package]] name = "muxplex" -version = "0.4.4" +version = "0.4.5" source = { editable = "." } dependencies = [ { name = "aiofiles" },