Skip to content

[CTX-0266] fix(term-state): reflow rewraps line tails on narrow - #441

Merged
Xuepoo merged 2 commits into
mainfrom
ctx-0266/fix-reflow-rewrap
Sep 9, 2026
Merged

Xuepoo merged 2 commits into
mainfrom
ctx-0266/fix-reflow-rewrap

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Priority: P1 | Area: render | Labels: fix,area:render,P1 | Milestone: v0.1.0 | RFC: OQ-007 | Task: CTX-0266

Closes #440

Root cause: Grid and Scrollback resize truncated/padded only; no rewrapping.

Reflow semantics: primary unwraps via soft-wrap flags and rewraps width-aware (wide atomic, combining safe); overflow to scrollback capped, underflow pads grid; fresh monotonic scrollback ids; cursor follows logical offset; alt truncates (documented xterm).

Tests: reflow_rewrap_repro 4/4, resize_scrollback 8/8, term-state/rich/runtime/ui libs green, clippy/fmt clean, windows-gnu check ok. Workspace lib green except bitty-compat-lab umbrella baselines pinned v3 (v4 regen cross-repo follow-up). Live verification OWED (headless only). Recording captures: recording/ctx-0266/ uncommitted.

STOP at in_review: requesting independent review; not merging.

@Xuepoo Xuepoo added this to the v0.1.0 milestone Sep 9, 2026
@Xuepoo Xuepoo added fix Bug fix P1 Priority: high area:render Area: rendering labels Sep 9, 2026
@Xuepoo

Xuepoo commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Windows CI failure triaged by core-fix-0266: REAL reflow regression in test expectations, not a platform flake (reproduced deterministically on Linux: 28 vs 25).

Root cause: the test feeds "needle one\n" via handle_pty_bytes, where LF (no CR) packs multiple needles per physical row with wrap-seam splits, so pre-resize search finds 25 of 28 needles. The old assert_eq!(count, cnt) after a width-changing resize assumed truncate/pad semantics. Under CTX-0266 reflow, widening 80->104 cols re-unwraps/rewraps logical lines, rejoining 3 seam-split matches (sb 8->5, total rows 32->29, count 25->28). The new count is the CORRECT behavior.

Fix (commit ff4bd71, test-only): split the resize assertion in search_ui_refresh_preserves_current_clamped_and_auto_refresh_headless into (a) a height-only resize (736x586 -> 80x30, widths preserved) that keeps exact count equality, and (b) the width-changing resize asserting refresh correctness instead (active, bounded, current clamped, highlights bounded).

Verification: target suite 9/9 x5 iterations + --test-threads=1, bitty-term-state all green, bitty-ui search green, full bitty-runtime suite green, fmt clean, clippy -D warnings clean. No product-code changes.

@Xuepoo
Xuepoo merged commit 1330c31 into main Sep 9, 2026
16 of 17 checks passed
@Xuepoo
Xuepoo deleted the ctx-0266/fix-reflow-rewrap branch September 9, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:render Area: rendering fix Bug fix P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split/resize drops line tails instead of reflowing

1 participant