From 9910fd4445471c1bfab5a3f0a976f29780c7525f Mon Sep 17 00:00:00 2001 From: Fusion Date: Sun, 24 May 2026 16:25:14 +0200 Subject: [PATCH] fix: send stty command to resize container shell on first resize Docker exec doesn't forward PTY resize to the container process, so the container bash stays at 80x24 regardless of frontend resize. Work around this by sending a stty command through the terminal on first resize to set the correct dimensions inside the container. --- apps/api/src/services/terminal_session.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/api/src/services/terminal_session.py b/apps/api/src/services/terminal_session.py index d4e504e..755722d 100644 --- a/apps/api/src/services/terminal_session.py +++ b/apps/api/src/services/terminal_session.py @@ -146,6 +146,15 @@ class TerminalSession: self._rows = rows logger.info(f"resize() called for session {self.session_id}: {cols}x{rows}") self._set_terminal_size(cols, rows) + + # 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}") async def reset(self) -> None: """Reset the session by killing the process and clearing state."""