Skip to content

feat(tui): render markdown tables responsively#18576

Draft
fcoury-oai wants to merge 6 commits intomainfrom
fcoury/markdown-table-support
Draft

feat(tui): render markdown tables responsively#18576
fcoury-oai wants to merge 6 commits intomainfrom
fcoury/markdown-table-support

Conversation

@fcoury-oai
Copy link
Copy Markdown
Contributor

Summary

Add responsive markdown pipe-table rendering for the TUI, including markdown-fence unwrapping for agent output and terminal-width-aware boxed table layout.

Streaming agent output now holds mutable table tails until finalization, so column widths can settle without committing malformed partial rows to scrollback. The live-tail path is gated behind stream_table_live_tail_reflow for speculative uncommitted table preview behavior.

Validation

  • just fmt
  • just write-config-schema
  • cargo test -p codex-tui
  • just fix -p codex-tui

@fcoury-oai fcoury-oai force-pushed the fcoury/markdown-table-support branch from d8a5069 to c868d3d Compare April 19, 2026 20:52
@fcoury-oai fcoury-oai force-pushed the fcoury/resize-backlog-reflow-interrupt branch from 9e8dc88 to 9e3dfdd Compare April 20, 2026 15:47
@fcoury-oai fcoury-oai force-pushed the fcoury/markdown-table-support branch 3 times, most recently from 4c6b99b to e0d20c3 Compare April 20, 2026 16:12
Store streamed markdown source so queued output and finalized transcript
cells can be re-rendered when the terminal width changes. Clear stale
pending history lines before rebuilding scrollback from transcript cells.

Handle terminal resize as a distinct TUI event so resize-driven renders
can force a full repaint and avoid stale terminal contents after resize.
Add a disabled-by-default `terminal_resize_reflow` feature around the transcript scrollback rebuild path so old resize behavior stays intact unless explicitly enabled.

Keep live terminal resize updates flowing to active streams while preserving the coalesced reflow path for opt-in testing.
Add explicit argument comments for resize reflow test and stream-width
callsites so CI's argument comment lint accepts the new positional
literals.

This keeps the resize behavior unchanged while documenting the literal
arguments introduced by the PR.
Set `background_task_id` on the dummy ChatGPT auth test record so
Bazel clippy can compile the login unit test target after the auth
record gained the optional field.
@fcoury-oai fcoury-oai force-pushed the fcoury/resize-backlog-reflow-interrupt branch from aa0e6b5 to d0b08cf Compare April 20, 2026 16:23
@fcoury-oai fcoury-oai force-pushed the fcoury/markdown-table-support branch from e0d20c3 to a8a9b0f Compare April 20, 2026 16:25
Move resize reflow and thread event buffering helpers out of `app.rs` so the PR stays below the blob-size policy limit.

This keeps the behavior intact while preserving the resize reflow split and making the module boundaries more explicit.
Render pipe-table markdown into responsive box-drawing tables and keep
streamed table tails mutable until finalization so column widths can
settle.

Add table detection, live-tail holdback, markdown-fence unwrapping,
and regression coverage for resize, emoji width, and interrupt cleanup
paths.
@fcoury-oai fcoury-oai force-pushed the fcoury/markdown-table-support branch from a8a9b0f to d2f1e04 Compare April 20, 2026 16:35
@fcoury-oai fcoury-oai force-pushed the fcoury/resize-backlog-reflow-interrupt branch 15 times, most recently from 036d15f to 5ae5512 Compare April 24, 2026 18:07
@fcoury-oai fcoury-oai force-pushed the fcoury/resize-backlog-reflow-interrupt branch from e4366f4 to bcb9067 Compare April 24, 2026 19:18
@vincent-globalorange
Copy link
Copy Markdown

Thanks for pushing #18575/#18576. We reached the “try glow for tables” stage over here, so these fixes will surely be appreciated.

Generated by GPT-5.5. Approved by user.

@fcoury-oai fcoury-oai force-pushed the fcoury/resize-backlog-reflow-interrupt branch from e3e32d1 to 0103043 Compare April 26, 2026 00:38
fcoury-oai added a commit that referenced this pull request Apr 26, 2026
Fixes multiple scrollback and terminal resize issues: #5538, #5576,
#8352, #12223, #16165, and #15380.

## Why

Codex writes finalized transcript output into terminal scrollback after
wrapping it for the current viewport width. A later terminal resize
could leave that scrollback shaped for the old width, so wider windows
kept narrow output and narrower windows could show stale wrapping
artifacts until enough new output replaced the visible area.

This is also the foundation PR for responsive markdown tables. Table
rendering needs finalized transcript content to be width-sensitive after
insertion, not only while content is first streaming. Markdown table
rendering itself stays in #18576.

## Stack

- PR1: resize backlog reflow and interrupt cleanup
- #18576: markdown table support

## What Changed

- Rebuild source-backed transcript history when the terminal width
changes. `terminal_resize_reflow` is introduced through the experimental
feature system, but is enabled by default for this rollout so we can
validate behavior across real terminals.
- Preserve assistant and plan stream source so finalized streaming
output can participate in resize reflow after consolidation.
- Debounce resize work, but force a final source-backed reflow when a
resize happened during active or unconsolidated streaming output.
- Clear stale pending history lines on resize so old-width wrapped
output is not emitted just before rebuilt scrollback.
- Bound replay work with `[tui.terminal_resize_reflow].max_rows`:
omitted uses terminal-specific defaults, `0` keeps all rendered rows,
and a positive value sets an explicit cap. The cap applies both while
initially replaying a resumed transcript into scrollback and when
rebuilding scrollback after terminal resize.
- Consolidate interrupted assistant streams before cleanup, then clear
pending stream output and active-tail state consistently.
- Move resize reflow and thread event buffering helpers out of `app.rs`
into dedicated TUI modules.
- Add focused coverage for resize reflow, feature-gated behavior,
streaming source preservation, interrupted output cleanup,
unicode-neutral text, terminal-specific row caps, and composer/layout
stability.

## Runtime Bounds

Resize reflow keeps only the most recent rendered rows when a row cap is
active. The default is `auto`, which maps to the detected terminal's
default scrollback size where Codex can identify it: VS Code `1000`,
Windows Terminal `9001`, WezTerm `3500`, and Alacritty `10000`.
Terminals without a dedicated mapping use the conservative fallback of
`1000` rows. Users can override this with `[tui.terminal_resize_reflow]
max_rows = N`, or set `max_rows = 0` to disable row limiting.

## Validation

- `just fmt`
- `git diff --check`
- `cargo test --manifest-path codex-rs/Cargo.toml -p codex-tui reflow`
- `cargo test --manifest-path codex-rs/Cargo.toml -p codex-tui
transcript_reflow`
- `just fix -p codex-tui`
- PR CI in progress on the squashed branch
Base automatically changed from fcoury/resize-backlog-reflow-interrupt to main April 26, 2026 01:00
canvrno-oai pushed a commit that referenced this pull request Apr 28, 2026
Fixes multiple scrollback and terminal resize issues: #5538, #5576,
#8352, #12223, #16165, and #15380.

## Why

Codex writes finalized transcript output into terminal scrollback after
wrapping it for the current viewport width. A later terminal resize
could leave that scrollback shaped for the old width, so wider windows
kept narrow output and narrower windows could show stale wrapping
artifacts until enough new output replaced the visible area.

This is also the foundation PR for responsive markdown tables. Table
rendering needs finalized transcript content to be width-sensitive after
insertion, not only while content is first streaming. Markdown table
rendering itself stays in #18576.

## Stack

- PR1: resize backlog reflow and interrupt cleanup
- #18576: markdown table support

## What Changed

- Rebuild source-backed transcript history when the terminal width
changes. `terminal_resize_reflow` is introduced through the experimental
feature system, but is enabled by default for this rollout so we can
validate behavior across real terminals.
- Preserve assistant and plan stream source so finalized streaming
output can participate in resize reflow after consolidation.
- Debounce resize work, but force a final source-backed reflow when a
resize happened during active or unconsolidated streaming output.
- Clear stale pending history lines on resize so old-width wrapped
output is not emitted just before rebuilt scrollback.
- Bound replay work with `[tui.terminal_resize_reflow].max_rows`:
omitted uses terminal-specific defaults, `0` keeps all rendered rows,
and a positive value sets an explicit cap. The cap applies both while
initially replaying a resumed transcript into scrollback and when
rebuilding scrollback after terminal resize.
- Consolidate interrupted assistant streams before cleanup, then clear
pending stream output and active-tail state consistently.
- Move resize reflow and thread event buffering helpers out of `app.rs`
into dedicated TUI modules.
- Add focused coverage for resize reflow, feature-gated behavior,
streaming source preservation, interrupted output cleanup,
unicode-neutral text, terminal-specific row caps, and composer/layout
stability.

## Runtime Bounds

Resize reflow keeps only the most recent rendered rows when a row cap is
active. The default is `auto`, which maps to the detected terminal's
default scrollback size where Codex can identify it: VS Code `1000`,
Windows Terminal `9001`, WezTerm `3500`, and Alacritty `10000`.
Terminals without a dedicated mapping use the conservative fallback of
`1000` rows. Users can override this with `[tui.terminal_resize_reflow]
max_rows = N`, or set `max_rows = 0` to disable row limiting.

## Validation

- `just fmt`
- `git diff --check`
- `cargo test --manifest-path codex-rs/Cargo.toml -p codex-tui reflow`
- `cargo test --manifest-path codex-rs/Cargo.toml -p codex-tui
transcript_reflow`
- `just fix -p codex-tui`
- PR CI in progress on the squashed branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants