Metadata
| Status | done |
|---|---|
| Assigned | agent-1107 |
| Agent identity | f51439356729d112a6c404803d88015d5b44832c6c584c62b96732b63c2b0c7e |
| Created | 2026-04-29T14:12:41.914516208+00:00 |
| Started | 2026-04-29T14:13:03.137901541+00:00 |
| Completed | 2026-04-29T14:38:17.434054987+00:00 |
| Tags | priority-high,fix,tui,pty, eval-scheduled |
| Eval score | 0.72 |
| └ blocking impact | 0.70 |
| └ completeness | 0.65 |
| └ constraint fidelity | 0.85 |
| └ coordination overhead | 0.75 |
| └ correctness | 0.70 |
| └ downstream usability | 0.80 |
| └ efficiency | 0.75 |
| └ intent fidelity | 0.88 |
| └ style adherence | 0.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)
- 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
- Drop the existing
scrollback_hiddencounter workaround — obsoleted by proper reflow - 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
- (none)
Log
- 2026-04-29T14:12:41.904792628+00:00 Task paused
- 2026-04-29T14:12:43.005405007+00:00 Task published
- 2026-04-29T14:13:01.569810074+00:00 Lightweight assignment: agent=Careful Programmer (f5143935), exec_mode=full, context_scope=task, reason=Careful Programmer (0.77/296 tasks) matches implementation role; Careful tradeoff aligns with this priority-high PTY correctness-critical fix requiring complex validation and escape-hatch awareness.
- 2026-04-29T14:13:03.137904847+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-29T14:13:47.604858417+00:00 Starting work. Read diagnostic from agent-1104. Plan: implement re-feed reflow in PtyPane::resize, drop scrollback_hidden+pending_dedup machinery, add TDD test + smoke scenario.
- 2026-04-29T14:36:48.039110592+00:00 Implementation complete: - Added free fns reflow_parser + snapshot_logical_lines + read_row_for_reflow in src/tui/pty_pane.rs (~100 LOC) - PtyPane::resize now snapshots scrollback+visible into logical lines (joining wrapped rows), builds a fresh vt100::Parser at new dims, re-feeds, and atomically swaps. Then calls master.resize so child sees SIGWINCH. - Dropped pending_dedup, scrollback_hidden, RESIZE_DEDUP_WINDOW, maybe_resolve_dedup, and Self::scrollback_count. scroll_up/scroll_down simplified to plain offset arithmetic. - Replaced obsolete tests sigwinch_reflow_duplicates_scrollback_and_dedup_hides_them + scroll_up_skips_sigwinch_hidden_rows. Dropped helper collect_scrollback_only_deduped. - Added 7 new tests: naive_set_size_then_child_reprint_creates_scrollback_duplicates (bug-shape pre-condition), refeed_reflow_eliminates_scrollback_duplicates (primary fix), refeed_reflow_rewraps_at_narrower_width, refeed_reflow_unwraps_at_wider_width, refeed_reflow_handles_burst_of_resizes_without_compounding_duplicates, refeed_reflow_then_child_repaint_keeps_scrollback_almost_clean, pty_pane_resize_does_not_create_scrollback_duplicates (real PtyPane spawn + resize burst integration). - Updated tests/smoke/scenarios/pty_resize_dedup_no_scrollback_echo.sh to run all six unit tests + the integration test. Added fix-scrollback-reflow + diagnose-scrollback-corruption to manifest owners. - All 713 TUI tests pass. Pre-existing config::tests::test_global_config_path failure is unrelated (failed before my changes too).
- 2026-04-29T14:37:35.218971869+00:00 Committed: c733406c7 — pushed to remote
- 2026-04-29T14:38:05.567121747+00:00 Validated: cargo build + 713 cargo test --bin wg --lib tui:: pass with no regressions. 6 new unit tests + 1 end-to-end PtyPane integration test in src/tui/pty_pane.rs all pass. Smoke scenario tests/smoke/scenarios/pty_resize_dedup_no_scrollback_echo.sh passes standalone. cargo install --path . was rerun. Pre-existing config::tests::test_global_config_path failure is unrelated (failed before changes too — confirmed via git stash + retry; restored).
- 2026-04-29T14:38:10.456624909+00:00 Live smoke caveat: human-eye TUI resize stress (open wg tui, resize host terminal both directions, scroll back) was NOT performed — agent has no interactive terminal. Equivalent automated coverage: pty_pane_resize_does_not_create_scrollback_duplicates spawns a real /bin/sh PTY, fills scrollback (30 markers + sleep), drives 4 back-to-back resizes through PtyPane::resize (which routes through the new reflow helper + master.resize → SIGWINCH to child), and asserts each marker appears at most once across scrollback + visible. Codex / claude TUI repaint scenarios are simulated programmatically in refeed_reflow_then_child_repaint_keeps_scrollback_almost_clean (clear+repaint after reflow → bounded ≤ 2 occurrences per marker). Real codex / claude integration would require a TTY harness; flagging as a follow-up gap if user wants it.
- 2026-04-29T14:38:17.434058734+00:00 Task pending eval (agent reported done; awaiting `.evaluate-*` to score)
- 2026-04-29T14:40:18.229085278+00:00 PendingEval → Done (evaluator passed; downstream unblocks)