fix-scrollback-reflow

Fix: scrollback reflow on resize — re-feed approach (per diagnose-scrollback-corruption)

Metadata

Statusdone
Assignedagent-1107
Agent identityf51439356729d112a6c404803d88015d5b44832c6c584c62b96732b63c2b0c7e
Created2026-04-29T14:12:41.914516208+00:00
Started2026-04-29T14:13:03.137901541+00:00
Completed2026-04-29T14:38:17.434054987+00:00
Tagspriority-high,fix,tui,pty, eval-scheduled
Eval score0.72
└ blocking impact0.70
└ completeness0.65
└ constraint fidelity0.85
└ coordination overhead0.75
└ correctness0.70
└ downstream usability0.80
└ efficiency0.75
└ intent fidelity0.88
└ style adherence0.75

Description

Description

Implement the re-feed reflow approach identified by diagnose-scrollback-corruption (agent-1104). Read that task's log via wg show diagnose-scrollback-corruption for the full diagnostic + file:line citations + cited fix proposal.

Root cause (already proven)

vt100::Parser doesn't reflow scrollback on resize. vt100/src/grid.rs:66-100 only resizes self.rows (visible region); existing scrollback lines retain old wrap. After a width change, the visual artifact is duplication of what was a wrapped row.

Fix scope (per diagnose)

  1. On resize event, re-feed the scrollback into a freshly-sized parser:
    • Snapshot scrollback bytes before set_size
    • Call set_size to resize the visible grid
    • Replay scrollback bytes into the parser at the new width
    • Result: scrollback lines re-wrap correctly to the new column count
  2. Drop the existing scrollback_hidden counter workaround — obsoleted by proper reflow
  3. Drop the 'spawn at correct size' workaround in consume_pending_chat_pty_spawn (still nice-to-have for first-resize UX, but no longer load-bearing for correctness)

Validation

  • Failing test written first (TDD): deterministic in-process repro from /tmp/sigwinch-repro/ (cited in diagnose log) — must show duplication PRE-fix and absence POST-fix
  • Live smoke: open the TUI, fill scrollback (multi-screen), resize the terminal in BOTH directions multiple times, scroll back through history. NO duplicated lines. Record observation in task log.
  • Live smoke: run a codex chat (uses DEC mode 2026 batched rendering), repeat the resize stress test. No duplicates.
  • No regression of fix-tui-pty / fix-pty-scrollback original repros — verify those repros still produce clean output
  • cargo build + cargo test pass with no regressions
  • Permanent smoke scenario added under tests/smoke/scenarios/ — exercises the resize-reflow path with deterministic SIGWINCH events. This task id in owners.
  • cargo install --path . was run before claiming done

Escape hatch

If re-feed proves too lossy (SGR formatting / Unicode width / OSC 8 hyperlinks lost across reflow), do NOT ship a half-fix. Instead, FAIL this task back with concrete evidence of which content was lost, and reopen the deeper fix as the queued replace-custom-pty path (alacritty_terminal or wezterm-term) which has true reflow with formatting preservation. ~1-2 days vs the current ~50-100 LOC estimate.

Depends on

Required by

Log