From 56d13c71efd419777b38aaeb27261722e5bd2c9e Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Fri, 1 May 2026 13:17:56 +0200 Subject: [PATCH] use tmux resize-window for explicit window size control tmux determines window size from its client, not the PTY winsize. TIOCSWINSZ + SIGWINCH on the master fd has no effect on tmux's internal dimensions. Use tmux resize-window -t -x -y to explicitly set the window size on resize. Co-Authored-By: Claude Opus 4.6 (1M context) --- .pql/pql-plan.json | 2 +- lib/builtin/claude/src/claude_pane.dart | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.pql/pql-plan.json b/.pql/pql-plan.json index b1d18ad8..dac02f0f 100644 --- a/.pql/pql-plan.json +++ b/.pql/pql-plan.json @@ -1,5 +1,5 @@ { - "exported_at": "2026-05-01T11:11:26Z", + "exported_at": "2026-05-01T11:17:56Z", "decisions": [ { "id": "D-1", diff --git a/lib/builtin/claude/src/claude_pane.dart b/lib/builtin/claude/src/claude_pane.dart index 2f34d0b7..0bd84edc 100644 --- a/lib/builtin/claude/src/claude_pane.dart +++ b/lib/builtin/claude/src/claude_pane.dart @@ -48,6 +48,7 @@ class _ClaudePaneState extends State { late final Terminal _terminal; StreamSubscription? _eventSub; String? _paneId; + String? _sessionName; String? _error; String _statusLine = 'attaching…'; @@ -119,7 +120,7 @@ class _ClaudePaneState extends State { repoRoot = (rootResp.data['path'] as String?) ?? repoRoot; } - final sessionName = widget.isPrimary + _sessionName = widget.isPrimary ? primarySessionName(repoRoot) : secondarySessionName(repoRoot, widget.secondaryIndex!); @@ -133,7 +134,7 @@ class _ClaudePaneState extends State { 'new-session', '-A', '-s', - sessionName, + _sessionName!, '-x', '$cols', '-y', '$rows', ]; @@ -144,7 +145,7 @@ class _ClaudePaneState extends State { 'cwd': repoRoot, 'cols': _terminal.viewWidth, 'rows': _terminal.viewHeight, - 'title': sessionName, + 'title': _sessionName, }); if (!resp.ok) { @@ -157,7 +158,7 @@ class _ClaudePaneState extends State { 'cwd': repoRoot, 'cols': _terminal.viewWidth, 'rows': _terminal.viewHeight, - 'title': sessionName, + 'title': _sessionName, }); if (!resp.ok) { setState(() { @@ -167,7 +168,7 @@ class _ClaudePaneState extends State { } setState(() => _statusLine = 'no-tmux · fresh every launch'); } else { - setState(() => _statusLine = 'tmux · $sessionName'); + setState(() => _statusLine = 'tmux · $_sessionName'); } if (!mounted) return; @@ -243,9 +244,11 @@ class _ClaudePaneState extends State { final id = _paneId; if (id == null) return; _ipc()?.request('pane.resize', args: {'id': id, 'cols': cols, 'rows': rows}); - // tmux doesn't re-read PTY winsize on SIGWINCH — it needs an - // explicit refresh-client to update its internal window size. - Process.run('tmux', ['refresh-client', '-C', '$cols,$rows']); + // tmux sizes windows by client, not PTY winsize. Explicitly + // resize the tmux window to match the TerminalView dimensions. + if (_sessionName != null) { + Process.run('tmux', ['resize-window', '-t', _sessionName!, '-x', '$cols', '-y', '$rows']); + } }); }