From 6f12c884cd4c18b74d4d6f3928be38080d19ce05 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Fri, 1 May 2026 09:24:10 +0200 Subject: [PATCH] defer PTY spawn until first TerminalView resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PTY was spawning at 80x24 defaults before TerminalView had laid out, then the real resize caused visual artifacts (ghost lines, broken reflow). Now spawn triggers on the first onResize callback when real dimensions are known — matching the pty-spike's proven pattern. Co-Authored-By: Claude Opus 4.6 (1M context) --- .pql/pql-plan.json | 2 +- lib/builtin/claude/src/claude_pane.dart | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.pql/pql-plan.json b/.pql/pql-plan.json index 0e39e917..dfc998bc 100644 --- a/.pql/pql-plan.json +++ b/.pql/pql-plan.json @@ -1,5 +1,5 @@ { - "exported_at": "2026-04-30T20:42:24Z", + "exported_at": "2026-05-01T07:24:10Z", "decisions": [ { "id": "D-1", diff --git a/lib/builtin/claude/src/claude_pane.dart b/lib/builtin/claude/src/claude_pane.dart index c3fe870b..3bf7d8ae 100644 --- a/lib/builtin/claude/src/claude_pane.dart +++ b/lib/builtin/claude/src/claude_pane.dart @@ -52,12 +52,15 @@ class _ClaudePaneState extends State { String _statusLine = 'attaching…'; @override + bool _spawned = false; + void initState() { super.initState(); _terminal = Terminal(maxLines: _maxLines); _terminal.onOutput = _onOutput; _terminal.onResize = _onResize; - WidgetsBinding.instance.addPostFrameCallback((_) => _spawnWhenReady()); + // Don't spawn here — wait for the first onResize from TerminalView + // so the PTY gets real dimensions, not 80x24 defaults. } @override @@ -201,6 +204,12 @@ class _ClaudePaneState extends State { } void _onResize(int cols, int rows, int _, int __) { + if (!_spawned) { + // First resize — TerminalView has real dimensions now. + _spawned = true; + _spawnWhenReady(); + return; + } final id = _paneId; if (id == null) return; _ipc()?.request('pane.resize', args: {'id': id, 'cols': cols, 'rows': rows});