tui2: stop baking streaming wraps; reflow agent markdown #8761
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Streaming assistant prose in tui2 was being rendered with viewport-width wrapping during streaming, then stored in history cells as already split
Lines. Those width-derived breaks became indistinguishable from hard newlines, so the transcript could not "un-split" on resize. This also degraded copy/paste, since soft wraps looked like hard breaks.What changed
MarkdownLogicalLineoutput intui2/src/markdown_render.rs, preserving markdown wrap semantics: initial/subsequent indents, per-line style, and a preformatted flag.tui2/src/markdown_stream.rs) to emit logical lines (newline-gated) and remove any captured viewport width.tui2/src/streaming/*) to queue and emit logical lines, producingAgentMessageCell::new_logical(...).AgentMessageCellstore logical lines and wrap at render time inHistoryCell::transcript_lines_with_joiners(width), emitting joiners so copy/paste can join soft-wrap continuations correctly.Overlay deferral
When an overlay is active, defer cells (not rendered
Vec<Line>) and render them at overlay close time. This avoids baking width-derived wraps based on a stale width.Tests + docs
More details
See
codex-rs/tui2/docs/streaming_wrapping_design.mdfor the full problem statement and solution approach, andcodex-rs/tui2/docs/tui_viewport_and_history.mdfor viewport vs printed output behavior.