Skip to content

feat(tui): render cramped markdown tables as key-value records [2 of 2]#24636

Merged
fcoury-oai merged 1 commit into
mainfrom
fcoury/table-key-value-fallback
May 27, 2026
Merged

feat(tui): render cramped markdown tables as key-value records [2 of 2]#24636
fcoury-oai merged 1 commit into
mainfrom
fcoury/table-key-value-fallback

Conversation

@fcoury-oai
Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai commented May 26, 2026

Stack

Review this PR against fcoury/app-style-markdown-tables; it contains only the fallback behavior for cramped tables.

Why

The row-separated markdown table rendering in #24489 remains readable while columns have usable room. Once long links or multiple prose-heavy columns are compressed into narrow allocations, however, the grid can turn words and paths into tall vertical strips that are difficult to scan. In those cases the content matters more than preserving the grid shape.

What Changed

Normal

CleanShot 2026-05-27 at 14 32 57

Narrow

CleanShot 2026-05-27 at 14 33 12

Very narrow

CleanShot 2026-05-27 at 14 33 47
  • Detect tables whose grid allocation causes systemic token fragmentation or starves multiple prose-heavy columns.
  • Render those tables as repeated key/value records instead of retaining an unreadable grid.
  • Use aligned label/value records when there is useful horizontal room, and switch to a stacked narrow-record layout where each label is followed by a full-width value when width is especially constrained.
  • Preserve the themed label color, rich inline formatting, links, and the existing grid presentation for tables that remain readable.
  • Add snapshot coverage for path-heavy narrow tables, prose-heavy issue tables, systemic compact fragmentation, and a control case that should continue to render as a grid.

How to Test

  1. Start Codex from this branch and render a normal multi-column markdown table at a comfortable terminal width. Confirm it still appears as the styled row-separated grid from feat(tui): render markdown tables in app style [1 of 2] #24489.
  2. Render a table containing a long linked record identifier or file-like value, then narrow the terminal until the grid would split the value into vertical fragments. Confirm it switches to key/value records, with labels above values at very narrow widths.
  3. Render a table with multiple prose-heavy columns, such as an issue summary table with Issue, Activity, Complexity, and Why start. Confirm a cramped width switches to records rather than wrapping several columns into hard-to-read strips.
  4. Render a compact table where only one value wraps mildly. Confirm it stays in grid form rather than switching prematurely.

Validation

  • Ran just test -p codex-tui while developing the fallback and reviewed/accepted the intended new markdown-render snapshots. The command still reports two unrelated existing guardian feature-flag test failures outside this diff.
  • Ran just fix -p codex-tui and just fmt after the Rust changes were complete.
  • just argument-comment-lint cannot reach source linting locally because Bazel fails while resolving LLVM sanitizer headers; touched positional literal callsites were inspected manually and annotated where needed.

@fcoury-oai fcoury-oai marked this pull request as ready for review May 27, 2026 13:28
@fcoury-oai fcoury-oai changed the title feat(tui): render cramped markdown tables as key-value records feat(tui): render cramped markdown tables as key-value records [2 of 2] May 27, 2026
fcoury-oai added a commit that referenced this pull request May 27, 2026
## Stack

- **Current: #24489 [1 of 2]** - render markdown tables in app style.
- **Stacked follow-up: #24636 [2 of 2]** - render cramped markdown
tables as key/value records.

## Why

Markdown tables currently render as boxed terminal grids, which gives
ordinary assistant output a heavier visual treatment than surrounding
rich text. This row-separated layout is the best match for how the App
renders tables, while accented headers remain distinguishable even when
a terminal font renders bold subtly.

<table>
<tr><td>
<p align="center">Codex CLI - Before</p>
<img width="1722" height="742" alt="CleanShot 2026-05-25 at 18 46 17"
src="https://github.com/user-attachments/assets/f673d92a-ebd8-46e2-b414-3d985e41b6a4"
/>
</td></tr>
<tr><td>
<p align="center">Codex CLI - After</p>
<img width="1720" height="957" alt="image"
src="https://github.com/user-attachments/assets/36a3d331-bea1-439b-b5be-e97b0731bd6f"
/>
</td></tr>
<tr><td>
<p align="center">Codex App</p>
<img width="979" height="1293" alt="CleanShot 2026-05-25 at 18 45 04"
src="https://github.com/user-attachments/assets/7d97cae0-9256-4f6e-a4b3-8b8f22b0d901"
/>
</td></tr>
</table>

## What Changed

- Render markdown tables as padded, aligned rows without an enclosing
box.
- Style table headers with the active syntax-theme accent plus bold
text, while keeping separators low contrast and theme-aware.
- Use a segmented heavy header rule and thin body-row rules, preserving
wrapping, narrow-width fallback, streaming parity, and rich-history
rendering.
- Update focused assertions and snapshots for the final table layout.

## How to Test

1. Render a markdown table in the TUI with several rows and columns.
2. Confirm the header uses the active theme accent, rows use
one-character interior padding, and the table has no enclosing box.
3. Confirm the header is followed by segmented `━` rules and multiple
body rows are separated by muted segmented `─` rules.
4. Render the same table while streaming and in history/raw-mode
toggles; the final rich layout should remain stable.
5. Render a narrow table with long content and verify wrapping or pipe
fallback does not overflow.

## Validation

- `just test -p codex-tui table`
- `just test -p codex-tui streaming::controller::tests`
- `just argument-comment-lint-from-source -p codex-tui -- --all-targets`
- `just fix -p codex-tui`
- `just fmt`

`just test -p codex-tui` was also run after accepting the snapshots; it
fails only in the unrelated existing guardian app tests
`update_feature_flags_disabling_guardian_clears_review_policy_and_restores_default`
and
`update_feature_flags_disabling_guardian_clears_manual_review_policy_without_history`.
Base automatically changed from fcoury/app-style-markdown-tables to main May 27, 2026 19:18
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature goes deep into nice-to-have territory. I'm not entirely convinced that it's worth the complexity it adds, but I'm sure that some users will appreciate it. It definitely adds some nice polish to the TUI.

Code looks good, and I verified manually

@fcoury-oai fcoury-oai enabled auto-merge (squash) May 27, 2026 20:09
@fcoury-oai fcoury-oai force-pushed the fcoury/table-key-value-fallback branch from 8cbc83b to 257530a Compare May 27, 2026 20:10
@fcoury-oai fcoury-oai merged commit 26c9502 into main May 27, 2026
31 checks passed
@fcoury-oai fcoury-oai deleted the fcoury/table-key-value-fallback branch May 27, 2026 20:27
@github-actions github-actions Bot locked and limited conversation to collaborators May 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants