Skip to main content

Crate apalis_tui

Crate apalis_tui 

Source
Expand description

Most users should not add this crate as a dependency. Use apalis-rtui’s ui feature, which serves this crate’s web build for you, or install the standalone terminal client with cargo install apalis-tui and run apalis-tui --api http://127.0.0.1:8080/api/v1 (docs/PLAN.md §8.4).

The apalis-rtui ratatui dashboard: one codebase, a native terminal binary and a WebAssembly bundle, both plain HTTP clients of the apalis-rtui JSON API. A host application depends on apalis-rtui to mount that API and ServeUI, and ServeUI already serves this crate’s web build as a static asset (apalis-rtui/assets/tui-web-dist/, built once by CI and vendored in, never rebuilt on a consumer’s machine). Reach for the crate itself to work on the dashboard. Repository: https://github.com/ngriaznov/apalis-rtui.

Every module here compiles and runs on the host target with no feature enabled (cargo test -p apalis-tui), which is what makes it unit- and snapshot-testable without a browser, a wasm target, or a running server:

  • app: App, the one state machine both backends drive: screens, selection, the hit-region mouse model, the confirm dialog, capability-gated actions.
  • data: the data::DataSource trait a backend implements, the pure apply_* functions that fold a fetched value into App’s data, and the Compact-args decode (§7.3).
  • theme: the Phosphor Slate palette and style helpers.
  • keymap: the keyboard reference App::key and the Help overlay both read from.
  • draw: one draw function per screen.
  • input: backend-agnostic key/mouse event types.
  • hash: the web build’s #/<screen>/… deep-link format, parsed and formatted with no web_sys dependency so it is unit-tested here on the host target.
  • backend: the web (wasm32 + ratzilla) and native (crossterm + reqwest) data/event loops. See its module docs for the wiring points a backend implementation builds against. native is a default feature, so cargo install apalis-tui builds the terminal client and nothing else. web is opt-in and only build-web.sh asks for it.

Re-exports§

pub use app::Action;
pub use app::App;
pub use app::Origin;
pub use app::PendingAction;
pub use app::Screen;
pub use app::describe_action_outcome;
pub use data::Data;
pub use hash::Route;
pub use hash::RouteScreen;
pub use input::KeyCode;
pub use input::KeyEvent;
pub use input::MouseButton;
pub use input::MouseEvent;
pub use input::MouseEventKind;
pub use theme::Theme;

Modules§

app
App: the one state machine both the web and native backends drive. Owns every screen’s selection state, the hit-region mouse model, the confirm dialog and toast, and the capability-gated action pipeline. Nothing here performs I/O (docs/PLAN.md §5.2). A backend feeds it fetched/SSE data through crate::data’s apply_* functions and App::data_mut, then drains App::take_pending_action to actually perform a confirmed action.
backend
The web and native data/event loops. web (feature web, wasm32) and native (feature native, any other target) both implement the same contract, documented once below.
data
The data boundary: query constants, the pure functions that fold a fetched wire value into Data, the best-effort Compact byte-array decode (§7.3), and the DataSource trait the web/native backends implement against.
draw
Draw orchestration: the tab bar, statusline, and modal overlays every screen shares, plus the button/gated_button helpers every per-screen module composes from. One draw function per screen lives in the sibling modules. This file is only what wraps around all of them.
hash
The #/<screen>/<queue>/<status>/<page>/<task_id> hash-fragment route format (docs/PLAN.md §3.7), used by apalis-tui’s web build only.
input
Backend-agnostic input types: this crate’s own small mirrors of ratzilla::event, so crate::app has no web dependency. The web backend converts real ratzilla events into these. The native backend converts real crossterm events into these. Native tests construct them directly.
keymap
The keyboard reference shown by the Help overlay, as data instead of hand-typed text.
theme
The “Phosphor Slate” palette (docs/design/variant-a-terminal.md §2.1) as Color::Rgb constants, plus the eight style-helper functions every draw_* module composes from (§2.2) and the status/level glyph tables (§2.4).