Skip to content

vscode/terminal: terminal pane fails to refit when sibling editor group is closed (residual #1052 family) #1065

@amrmelsayed

Description

@amrmelsayed

Symptom

When a Codev terminal (architect or builder) shares the editor area with a second editor group and that group is then closed, the terminal pane does not re-render to fill the now-wider pane. Content stays wrapped at the old (~half) column width, the right ~half of the pane is blank, and the visible reflowed text is garbled.

Manual resize (dragging the window edge) or clear-and-reopen recovers. The PTY's COLUMNS is also stuck at the old narrow value, so a running TUI (Claude Code etc.) continues to redraw at the wrong width until the recovery action.

Repro

  1. Open a Codev terminal (e.g. architect) in editor group 1
  2. Open any other editor in group 2 (right side)
  3. Close editor group 2
  4. Observe: the terminal pane is now ~2× wider but content stays at old narrow width; right half blank; visible content garbled

Hypothesis

Same family as the recently-shipped #1052 (terminal rendering corrupted on open: replay painted at not-yet-final width), but a different trigger surface. The on-open path now correctly debounces and flushes at the settled width. Editor-group removal resizes the pane without firing that refit path: the terminal-adapter is not listening on the layout-change event that signals "your sibling group just disappeared, your width just doubled."

Proposed fix (plan-gate)

Wire the right VS Code layout-change signal into the terminal-adapter (exact event API to confirm at plan time, candidates include onDidChangeWindowState and onDidChangeActiveTextEditor plus any group-specific layout event) so editor-group changes trigger:

  1. An xterm fit at the new pane dimensions (or the same buffer-and-flush settled-width approach used in vscode: terminal renders corrupted and cursor lands at top after window reactivation #1052)
  2. A SIGWINCH / COLUMNS update propagated to the PTY so the TUI redraws at the right width

Same settled-width discipline as #1052 to avoid an intermediate-size repaint during the layout transition. Symmetric: opening a sibling group (terminal narrows) should hit the same path.

Acceptance criteria

  • Closing a sibling editor group while a Codev terminal is open triggers a refit; content fills the new pane width
  • PTY's COLUMNS matches the new pane width so the TUI redraws correctly
  • Opening a sibling editor group (terminal narrows) also triggers refit, symmetric path
  • No regression to vscode: terminal renders corrupted and cursor lands at top after window reactivation #1052's on-open buffer-and-flush behavior (settled-width discipline preserved)
  • Manual dev-approval verification: open terminal next to a second group, close the second group, verify clean refill; reverse it, verify clean reflow
  • Both architect and builder terminals exhibit the fixed behavior

Protocol selection

Surfaced by builder pir-1060 while parked at dev-approval; the builder explicitly stayed out of scope on its branch. Recommendation at spawn time:

Out of scope

Related

Surfaced by

PIR #1060 builder during dev-approval; flagged via inter-agent messaging, kept out of scope on the builder-pir-1060 branch.

Metadata

Metadata

Assignees

Labels

area/terminalArea: Terminal-specific (PTY, vscode terminal pane)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions