From 74033243c9f0cd26504105dfc5b4646b1407cdb0 Mon Sep 17 00:00:00 2001 From: Fusion Date: Sun, 24 May 2026 16:27:37 +0200 Subject: [PATCH] feat: send stty resize command on every resize, not just first Previously the stty command was only sent on the first resize. Now it is sent every time the terminal dimensions change, so resizing the browser window or rotating the device properly updates the container shell size. Added a check to skip when dimensions haven't changed. --- apps/api/src/services/terminal_session.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/api/src/services/terminal_session.py b/apps/api/src/services/terminal_session.py index 755722d..6b5d349 100644 --- a/apps/api/src/services/terminal_session.py +++ b/apps/api/src/services/terminal_session.py @@ -142,6 +142,11 @@ class TerminalSession: if self._closed: logger.warning("Cannot resize: session is closed") return + + # Only resize if dimensions actually changed + if self._cols == cols and self._rows == rows: + return + self._cols = cols self._rows = rows logger.info(f"resize() called for session {self.session_id}: {cols}x{rows}") @@ -149,12 +154,9 @@ class TerminalSession: # Docker exec doesn't forward PTY resize to the container process, # so we need to explicitly set the size inside the container shell. - # Only do this on the first resize to avoid interfering with user input. - if not getattr(self, '_stty_sent', False): - self._stty_sent = True - stty_cmd = f"stty cols {cols} rows {rows}\n".encode() - await self.write_input(stty_cmd) - logger.info(f"Sent stty command to container for session {self.session_id}: {cols}x{rows}") + stty_cmd = f"stty cols {cols} rows {rows}\n".encode() + await self.write_input(stty_cmd) + logger.info(f"Sent stty command to container for session {self.session_id}: {cols}x{rows}") async def reset(self) -> None: """Reset the session by killing the process and clearing state."""