From 3da68eaaf878816ff2618fad802ccb9d76f1d144 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Sat, 24 Jan 2026 16:32:49 +0000 Subject: [PATCH] Improve tmux redraw by toggling terminal size Toggle width -1 then back to force tmux to fully redraw all panes --- src/textual_webterm/terminal_session.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/textual_webterm/terminal_session.py b/src/textual_webterm/terminal_session.py index 7ba7dd9..abc231e 100644 --- a/src/textual_webterm/terminal_session.py +++ b/src/textual_webterm/terminal_session.py @@ -117,12 +117,16 @@ class TerminalSession(Session): self._screen.resize(height, width) async def force_redraw(self) -> None: - """Force a terminal redraw by re-sending the current size. + """Force a terminal redraw by toggling the size. - This triggers a SIGWINCH to the child process, causing applications - like tmux to redraw their display. + Briefly changes the terminal size then restores it, which forces + applications like tmux to fully redraw all panes. """ loop = asyncio.get_running_loop() + # Briefly shrink by 1 column then restore - this forces a full redraw + await loop.run_in_executor( + None, self._set_terminal_size, self._last_width - 1, self._last_height + ) await loop.run_in_executor( None, self._set_terminal_size, self._last_width, self._last_height )