From a028eb7ad3d4a9bd7c54423c710ab522cfce335b Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Fri, 1 May 2026 13:03:51 +0200 Subject: [PATCH] pass -x/-y to tmux new-session for correct initial size tmux running inside a PTY without a traditional terminal client defaults to a huge window size (2000+ cols, 10000 rows). Pass explicit -x and -y flags matching the TerminalView dimensions. Co-Authored-By: Claude Opus 4.6 (1M context) --- .pql/pql-plan.json | 2 +- lib/builtin/claude/src/claude_pane.dart | 9 +++++++++ lib/src/pty/native_pty.dart | 5 ++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.pql/pql-plan.json b/.pql/pql-plan.json index 56246474..c114e76e 100644 --- a/.pql/pql-plan.json +++ b/.pql/pql-plan.json @@ -1,5 +1,5 @@ { - "exported_at": "2026-05-01T10:20:03Z", + "exported_at": "2026-05-01T11:03:51Z", "decisions": [ { "id": "D-1", diff --git a/lib/builtin/claude/src/claude_pane.dart b/lib/builtin/claude/src/claude_pane.dart index 88d0bcd1..723f1a03 100644 --- a/lib/builtin/claude/src/claude_pane.dart +++ b/lib/builtin/claude/src/claude_pane.dart @@ -124,13 +124,20 @@ class _ClaudePaneState extends State { : secondarySessionName(repoRoot, widget.secondaryIndex!); // tmux-wrapped session for persistence (D-041). + // -x/-y set the initial window size; without them tmux defaults + // to a huge size when running inside a PTY without a real terminal. + final cols = _terminal.viewWidth; + final rows = _terminal.viewHeight; var argv = [ 'tmux', 'new-session', '-A', '-s', sessionName, + '-x', '$cols', + '-y', '$rows', ]; + print('[spawn] cols=${_terminal.viewWidth} rows=${_terminal.viewHeight}'); var resp = await ipc.request('pane.spawn', args: { 'argv': argv, 'kind': PaneKind.claude.wire, @@ -222,6 +229,7 @@ class _ClaudePaneState extends State { Timer? _resizeTimer; void _onResize(int cols, int rows, int _, int __) { + print('[onResize] cols=$cols rows=$rows spawned=$_spawned paneId=$_paneId'); if (!_spawned) { // First resize — TerminalView has real dimensions now. _spawned = true; @@ -234,6 +242,7 @@ class _ClaudePaneState extends State { _resizeTimer = Timer(const Duration(milliseconds: 150), () { final id = _paneId; if (id == null) return; + print('[resize] cols=$cols rows=$rows'); _ipc()?.request('pane.resize', args: {'id': id, 'cols': cols, 'rows': rows}); }); } diff --git a/lib/src/pty/native_pty.dart b/lib/src/pty/native_pty.dart index 216f4cd9..d113ebb9 100644 --- a/lib/src/pty/native_pty.dart +++ b/lib/src/pty/native_pty.dart @@ -276,11 +276,10 @@ class NativePty { final ws = calloc<_Winsize>() ..ref.wsRow = rows ..ref.wsCol = cols; - _ioctl(_fd, _kTiocsWinsz, ws); + final rc = _ioctl(_fd, _kTiocsWinsz, ws); calloc.free(ws); + print('[pty-resize] fd=$_fd cols=$cols rows=$rows ioctl=$rc pid=$pid'); // Explicitly signal the child to re-query its terminal size. - // macOS should auto-send SIGWINCH on TIOCSWINSZ, but the legacy - // Python implementation sent it explicitly for reliability. _nativeKill(pid, 28); // SIGWINCH = 28 on macOS/Linux }