diff --git a/AppImage/components/terminal-panel.tsx b/AppImage/components/terminal-panel.tsx index 5c7c075..e1896e4 100644 --- a/AppImage/components/terminal-panel.tsx +++ b/AppImage/components/terminal-panel.tsx @@ -325,6 +325,12 @@ export const TerminalPanel: React.FC = ({ websocketUrl, onCl if (xtermViewport) xtermViewport.style.padding = "0" if (xtermScreen) xtermScreen.style.padding = "0" fitAddon.fit() + + const cols = term.cols + const rows = term.rows + if (ws.readyState === WebSocket.OPEN) { + ws.send(`\x1b[8;${rows};${cols}t`) + } }, 10) const wsUrl = websocketUrl || getWebSocketUrl() @@ -359,6 +365,11 @@ export const TerminalPanel: React.FC = ({ websocketUrl, onCl const handleResize = () => { try { fitAddon.fit() + const cols = term.cols + const rows = term.rows + if (ws.readyState === WebSocket.OPEN) { + ws.send(`\x1b[8;${rows};${cols}t`) + } } catch { // Ignore resize errors } diff --git a/AppImage/scripts/flask_terminal_routes.py b/AppImage/scripts/flask_terminal_routes.py index f76c59a..8a5cd81 100644 --- a/AppImage/scripts/flask_terminal_routes.py +++ b/AppImage/scripts/flask_terminal_routes.py @@ -169,16 +169,19 @@ def terminal_websocket(ws): # Client closed connection break - # Handle terminal resize (optional) if data.startswith('\x1b[8;'): try: + # Parse: \x1b[8;{rows};{cols}t parts = data[4:-1].split(';') - rows, cols = int(parts[0]), int(parts[1]) - set_winsize(master_fd, rows, cols) + if len(parts) >= 2: + rows, cols = int(parts[0]), int(parts[1]) + set_winsize(master_fd, rows, cols) + print(f"[Terminal] Resized to {rows}x{cols}") continue - except: + except Exception as e: + print(f"Error parsing resize: {e}") pass - + # Send input to bash try: os.write(master_fd, data.encode('utf-8'))