Skip to content

warpui_core(tui): add ratatui-backed TUI presenter and runtime#12759

Draft
kevinyang372 wants to merge 2 commits into
kevin/integrate-with-ratatuifrom
kevin/tui-presenter-runtime
Draft

warpui_core(tui): add ratatui-backed TUI presenter and runtime#12759
kevinyang372 wants to merge 2 commits into
kevin/integrate-with-ratatuifrom
kevin/tui-presenter-runtime

Conversation

@kevinyang372

@kevinyang372 kevinyang372 commented Jun 17, 2026

Copy link
Copy Markdown
Member

Description

Add the ratatui-backed TUI presenter and runtime on top of the element layer, completing the in-core TUI rendering backend behind the tui feature. Stacked on #12758.

What changed:

  • presenter::tui::TuiPresenter — immediate-mode measure → arrange → present → paint into a ratatui Buffer, reporting child-view embeddings into the shared neutral view hierarchy.
  • runtime::TuiRuntime — drives a TuiView window: raw-mode + alternate-screen RAII guard, invalidate → redraw, crossterm input → shared keymap then element-tree dispatch, and draining of deferred app updates / typed actions.
  • TuiFrameRenderer flushes via ratatui's Buffer::diff + CrosstermBackend (no hand-rolled diff); crossterm comes from ratatui::crossterm.
  • event_conversion maps crossterm 0.29 input to the shared Event vocabulary (identical dispatch to the GUI).
  • Re-export Color / Modifier from elements::tui so consumers can style text without depending on ratatui directly.
  • Flicker fix: a resize repaints authoritatively (clear + redraw) wrapped in a terminal synchronized update, so the frame is applied atomically — no blank flash and no stale fragments left from the previously-wrapped frame.
  • Added an interactive example (examples/tui_demo.rs) for manual validation.

Linked Issue

No linked issue — internal, WIP infrastructure gated behind the tui feature (not user-visible).

Testing

  • cargo nextest run -p warpui_core --features tui — 360 pass, including the end-to-end tui_integration test (model → view → presenter → typed-action dispatch) plus renderer / runtime / event-conversion unit tests.
  • cargo test -p warpui_core --features tui --doc — pass; default build and clippy (both default and --features tui) clean; ./script/format clean.
  • Manual: cargo run -p warpui_core --example tui_demo --features tui — verified paragraph wrapping (resize to re-wrap), emoji / CJK / ZWJ column alignment, the buffer diff, vertical scrolling, and flicker-free resizing.

Screenshots / Videos

Manual TUI smoke test is via the example above; ./script/run is not applicable here (it launches the GUI app, not the TUI backend).

Agent Mode

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

Plan: https://staging.warp.dev/drive/notebook/RQNlhRWhQK3Djnr50YbC4G
Conversation: https://staging.warp.dev/conversation/9293e035-3939-42c7-aeee-110a5a131011

CHANGELOG-NONE

@cla-bot cla-bot Bot added the cla-signed label Jun 17, 2026

kevinyang372 commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

Build the immediate-mode presenter and the draw + event runtime on top of
the ratatui element layer, completing the in-core TUI backend behind the
`tui` feature:

- presenter::tui::TuiPresenter: measure -> arrange -> present -> paint into
  a ratatui Buffer, reporting child-view embeddings into the shared neutral
  view hierarchy.
- runtime::TuiRuntime drives a TuiView window: raw mode + alt screen via a
  RAII guard, invalidate -> redraw, crossterm input -> shared keymap then
  element-tree dispatch, draining deferred app updates / typed actions.
- TuiFrameRenderer flushes via ratatui's Buffer::diff + CrosstermBackend
  instead of a hand-rolled diff; crossterm comes from ratatui::crossterm.
- event_conversion maps crossterm 0.29 input to the shared Event vocabulary.
- Re-export Color/Modifier from elements::tui so consumers can style text
  without depending on ratatui directly.
- tests/tui_integration.rs: end-to-end model -> view -> presenter -> typed
  action flow against the shared core.
@zachbai zachbai force-pushed the kevin/integrate-with-ratatui branch from 2998c72 to fa13e01 Compare June 19, 2026 23:57
@zachbai zachbai force-pushed the kevin/tui-presenter-runtime branch from 72f5550 to 6947675 Compare June 19, 2026 23:57
@harryalbert harryalbert mentioned this pull request Jun 20, 2026
4 tasks
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.

1 participant