Skip to content

[2/4] TUI: bound clipped viewport painting - #14582

Merged
kevinyang372 merged 1 commit into
masterfrom
oz/tui-bounded-viewport-paint
Jul 31, 2026
Merged

[2/4] TUI: bound clipped viewport painting#14582
kevinyang372 merged 1 commit into
masterfrom
oz/tui-bounded-viewport-paint

Conversation

@kevinyang372

Copy link
Copy Markdown
Member

Description

Stack 2 of 4. Removes the full-height scratch buffer from TuiClipped and paints children directly through a nested, buffer-enforced clip. TuiText supplies the logical row offset to ratatui so only the visible paragraph window is painted.

The clip is enforced for cell, style, and widget writes; it is not only scene/hit-test metadata. Regression coverage includes nested clipping, translated rows, negative bounds, cursor visibility, and a retained long child that must not overwrite simulated input/footer rows.

Benchmark at 120×50 versus stack PR 1:

  • Many completed blocks, 10,000: 64.0 → 29.1 µs/frame (55% faster).
  • Retained rich response, 1,000 rows: 2.30 → 0.925 ms (60% faster).
  • Retained rich response, 10,000 rows: 24.5 → 8.56 ms (65% faster).
  • Invalidated rich response, 10,000 rows: 25.7 → 9.38 ms (63% faster).
  • Retained streaming tail at end, 10,000 rows: 33.9 → 17.2 ms (49% faster).

Stack: #145752/4oz/tui-retained-frame-overheadoz/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 transcript rendering 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-IMPROVEMENT: Improved scrolling and typing performance for long Warp Agent CLI transcripts.

@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

@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 replaces TuiClipped's full-height scratch buffer with direct painting through a clipped TuiPaintSurface, and updates TuiText to pass a vertical row offset into ratatui paragraph rendering. The overall direction is performance-focused and the diff includes focused TUI buffer/clipping regression coverage.

Concerns

  • render_vertically_scrollable_widget fails closed when the widget bounds are partially clipped horizontally, which can drop visible text instead of enforcing the visible intersection promised by the new clip surface.
  • No material security findings were identified.
  • spec_context.md contains no approved or repository spec context, so there was no material spec drift to enforce.

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/buffer.rs Outdated
@kevinyang372
kevinyang372 force-pushed the oz/tui-bounded-viewport-paint branch from cb13209 to ec59dc4 Compare July 31, 2026 15:00

kevinyang372 commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

@kevinyang372
kevinyang372 marked this pull request as draft July 31, 2026 15:01
@kevinyang372
kevinyang372 force-pushed the oz/tui-bounded-viewport-paint branch from ec59dc4 to e424b6e Compare July 31, 2026 15:20
Base automatically changed from oz/tui-transcript-benchmark to master 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 marked this pull request as ready for review July 31, 2026 15:23
@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

@kevinyang372
kevinyang372 requested a review from harryalbert July 31, 2026 15:24

@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 updates TUI painting so clipped viewports write directly through a nested buffer-enforced clip, adds visible-window rendering for Paragraph widgets, and adjusts TuiClipped/TuiText to use that path. The added TUI to_lines regression coverage exercises visible rows/columns, nested clipping, negative bounds, and retained clipped content.

Concerns

  • No blocking correctness, security, or spec-alignment concerns found in the annotated diff. The provided spec context says no approved or repository spec context was found.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

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

Powered by Oz

@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.

awesome

@kevinyang372
kevinyang372 enabled auto-merge (squash) July 31, 2026 15:36
@kevinyang372
kevinyang372 merged commit eda0085 into master Jul 31, 2026
41 checks passed
@kevinyang372
kevinyang372 deleted the oz/tui-bounded-viewport-paint branch July 31, 2026 15:47
kevinyang372 added a commit that referenced this pull request Jul 31, 2026
## 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#14582 ← **3/4** →
`oz/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.

- [x] I have manually tested my changes locally with `./script/run-tui`

## Agent Mode
- [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-NONE
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