Skip to content

Migrate TUI from cursive to ratatui#3905

Open
iho wants to merge 3 commits into
mimblewimble:stagingfrom
iho:tui-ratatui-migration
Open

Migrate TUI from cursive to ratatui#3905
iho wants to merge 3 commits into
mimblewimble:stagingfrom
iho:tui-ratatui-migration

Conversation

@iho

@iho iho commented Jul 10, 2026

Copy link
Copy Markdown

Summary

  • Replaces the cursive/cursive_table_view TUI (which pulls in pancurses/ncurses) with ratatui + crossterm, which have no external C dependency
  • Fixes the cross-compilation failures, macOS mouse-click crashes, and Windows first-run crashes described in the issue
  • All 5 screens (Basic Status, Peers and Sync, Mining, Logs, Version Info) and their keybindings (j/k/arrows, Tab, Enter, Esc, q, plus w/d to toggle the Mining sub-view) are preserved
  • New: mouse support (click a menu item to switch tabs, scroll wheel moves table selection — safe now that ncurses is gone), PageUp/PageDown/Home/End navigation in tables, and throttled redraws (repaint only on input or new data, 250ms cap) to reduce idle CPU
  • Interactive column sorting (cursive_table_view) is dropped, since ratatui::widgets::Table has no equivalent — tables render in the order ServerStats provides. Can be revisited as a follow-up if wanted.
  • Controller::new/Controller::run()'s public API (used by src/bin/cmd/server.rs) is unchanged
  • Windows note: key events are filtered to KeyEventKind::Press, avoiding the classic doubled-keystroke issue with crossterm on Windows

Test plan

  • cargo build --bin grin — 0 errors
  • cargo test --bin grin tui::status — both update_sync_status unit tests pass unmodified
  • cargo clippy --bin grin — zero findings in src/bin/tui
  • Confirmed via otool -L the built binary has no ncurses/pancurses linkage
  • Manually drove the TUI against a live testnet node in a tmux pty: all 5 tabs render with real peer/mining/sync data; keyboard navigation, mining workers/difficulty toggle, table selection clamping, Home/End/PageUp/PageDown, mouse tab-clicks and wheel scrolling (via SGR escape injection) all verified; error-dialog path renders correctly; q exits cleanly with exit code 0 and the terminal fully restored (raw mode off, alternate screen left, mouse capture disabled)

Fixes #3841

Replaces the cursive/pancurses-backed TUI with ratatui + crossterm,
which has no external C dependency (no more linking libncurses). This
fixes cross-compilation failures, macOS crashes on mouse clicks, and
Windows crashes on first run reported in mimblewimble#3841.

The cursive retained-mode widget tree is replaced with a single App
struct (src/bin/tui/app.rs) that every screen renders from each frame.
All previous behavior (status fields, peer/mining table columns and
formatting, bottom-anchored log view, keybindings, Controller's public
API) is preserved, with a few additions:

- Mouse support: click a menu item to switch tabs, scroll wheel moves
  table selection (safe now that ncurses is gone)
- PageUp/PageDown/Home/End navigation in tables, with selection
  clamped to the table's row count
- Redraws are throttled: the UI only repaints on input or new data,
  with a 250ms cap to keep time-based fields fresh

Interactive column sorting (cursive_table_view) is dropped since
ratatui's Table has no equivalent; tables render in the order
ServerStats provides.

Fixes mimblewimble#3841
@iho iho changed the base branch from master to staging July 10, 2026 16:39
Comment thread src/bin/tui/app.rs Outdated
@@ -0,0 +1,152 @@
// Copyright 2024 The Grin Developers

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.

2026?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate tui from cursive to ratatui

2 participants