Skip to content

[3/4] TUI: reuse retained text measurements - #14585

Merged
kevinyang372 merged 1 commit into
masterfrom
oz/tui-retained-frame-overhead
Jul 31, 2026
Merged

[3/4] TUI: reuse retained text measurements#14585
kevinyang372 merged 1 commit into
masterfrom
oz/tui-retained-frame-overhead

Conversation

@kevinyang372

Copy link
Copy Markdown
Member

Description

Stack 3 of 4. Reuses TuiText natural measurements when retained content is laid out again at the same width, and avoids copying a viewport selection snapshot when there is no active selection and line-end trimming is disabled.

This layer targets steady-state frame overhead after stack PR 2 has already bounded paint work. Width changes still recompute text measurement, and selection snapshots remain enabled whenever selection or trimmed line-end behavior needs them.

Benchmark at 120×50 versus stack PR 2:

  • Retained rich response, 1,000 rows: 0.925 → 0.129 ms (86% faster).
  • Retained rich response, 10,000 rows: 8.56 → 0.598 ms (93% faster).
  • Retained middle frame, 10,000 rows: 8.41 → 0.395 ms (95% faster).
  • Retained streaming tail at end, 10,000 rows: 17.2 → 9.88 ms (42% faster).
  • Invalidated rich response, 10,000 rows: 9.38 → 9.85 ms (~5% slower).
  • Many completed blocks, 10,000: 29.2 → 31.6 µs/frame (~8% slower, still flat with history depth).

The next stack layer removes the remaining repeated streaming-height work and owns auto-scroll reconciliation.

Stack: #14575#145823/4oz/tui-streaming-height-reconciliation.

Agent conversation: https://staging.warp.dev/conversation/2b6af7be-b227-4b20-aaf4-23c9a8494b81
Stack plan: https://staging.warp.dev/drive/notebook/yM2YcQsILFsFzwixBDbD9p
Performance plan: https://staging.warp.dev/drive/notebook/LHzsFd1B8XbQ8AnUqB88LS

Linked Issue

N/A — Warp Agent CLI retained-frame performance.

Testing

  • cargo nextest run -p warpui_core --features tui — 555 passed, 7 skipped.

  • cargo nextest run -p warp_tui — 902 passed.

  • Strict Clippy passed for warpui_core --features tui and warp_tui --features test-util.

  • cargo bench -p warp_tui --features test-util --bench transcript_bench

  • ./script/format

  • Signed-in 120×40 tmux PTY: zero state and unsent input repainted correctly.

  • I have manually tested my changes locally with ./script/run-tui

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-NONE

kevinyang372 commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

@kevinyang372
kevinyang372 force-pushed the oz/tui-bounded-viewport-paint branch from ec59dc4 to e424b6e Compare July 31, 2026 15:20
@kevinyang372
kevinyang372 force-pushed the oz/tui-retained-frame-overhead branch from ef8aa9b to b177932 Compare July 31, 2026 15:20
@kevinyang372
kevinyang372 force-pushed the oz/tui-bounded-viewport-paint branch from e424b6e to 2695304 Compare July 31, 2026 15:23
@kevinyang372
kevinyang372 force-pushed the oz/tui-retained-frame-overhead branch 2 times, most recently from e28b54b to d96944a Compare July 31, 2026 15:44
@kevinyang372
kevinyang372 requested a review from harryalbert July 31, 2026 15:45
@kevinyang372
kevinyang372 marked this pull request as ready for review July 31, 2026 15:45
@oz-for-oss

oz-for-oss Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@kevinyang372

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Base automatically changed from oz/tui-bounded-viewport-paint to master July 31, 2026 15:47

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overview

This PR caches TuiText natural measurements by width and skips viewport selection snapshot allocation when there is no active selection and line-end trimming is disabled.

Concerns

  • The TuiText measurement cache can remain populated across measurement-affecting builder calls, allowing a later layout at the same width to reuse a stale wrapped/truncated natural size.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread crates/warpui_core/src/elements/tui/text.rs

@harryalbert harryalbert left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice. warpy comment seems potentially real but other than that LGTM

@kevinyang372
kevinyang372 force-pushed the oz/tui-retained-frame-overhead branch 2 times, most recently from ef90a56 to bdcbe6f Compare July 31, 2026 16:32
@kevinyang372
kevinyang372 enabled auto-merge (squash) July 31, 2026 16:36
@harryalbert
harryalbert force-pushed the oz/tui-retained-frame-overhead branch from bdcbe6f to daea0c6 Compare July 31, 2026 16:49
@kevinyang372
kevinyang372 merged commit 08ad6e8 into master Jul 31, 2026
27 checks passed
@kevinyang372
kevinyang372 deleted the oz/tui-retained-frame-overhead branch July 31, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants