tui: history grouping fully renders cells only to test visibility

Open 💬 0 comments Opened Aug 3, 2026 by MikeeI

What variant of Codex are you using?

CLI

What feature would you like to see?

I found a potential performance concern in the current TUI source, rather than a confirmed user-visible bug. Please consider a behavior-preserving way for history grouping to determine whether an inserted cell is visible without fully rendering that cell.

Additional information

Evidence

  • ChatWidget::add_to_history and ChatWidget::add_boxed_history route each supplied HistoryCell through add_boxed_history. When keep_placeholder_header_active is false, add_boxed_history evaluates cell.display_lines(u16::MAX).is_empty(); after that conditional branch, it sends the same cell in AppEvent::InsertHistoryCell.
  • HistoryCell::display_lines returns Vec<Line<'static>>. The function retains only the empty/non-empty result to decide whether to break exec grouping.
  • This is source-proven eager work, not an observed UI symptom: the visibility decision cannot short-circuit after the first line because is_empty() is applied only after the complete result has been returned.

Impact

Not measured. The unknown is allocation volume and UI-thread latency per history insertion. For a content-rich cell on this path, the complete rendered-line collection is created and discarded before insertion even though the grouping decision needs only a boolean. This report does not claim observed user-visible latency.

Question

Would it make sense to provide a cheap visibility predicate or first-visible-line probe for HistoryCell so exec grouping can keep its current behavior without invoking full display rendering?

I checked all relevant issues, comments, pull requests, discussions, and release notes; this report is not a duplicate.

I am reporting this finding only and am not proposing a pull request unless a maintainer invites one.

Disclosure

Investigated thoroughly with GPT-5.6 Sol (runtime-default reasoning effort), using Oh My Pi as the agent framework.

This report is not generic or unreviewed AI-generated output. Its claims were checked against the cited evidence, and it includes the relevant detail intended to help maintainers resolve the issue.

If reports like this are not useful to the project, please let me know and I will refrain from submitting similar ones. My intent is to help without wasting maintainer time or energy or discouraging their work.

Thank you for your work.

View original on GitHub ↗