Rust TUI Notes Showcase VM Layer

Ratatui renders snapshots; VMx owns application state, commands, and lifecycle

Rust TUI Notes Showcase VM Layer Ratatui renders snapshots; VMx owns application state, commands, and lifecycle Rust TUI Notes Showcase VM Layer Ratatui renders snapshots; VMx owns application state, commands, and lifecycle Pure VMx MVVM layer Terminal host adapter WorkspaceVm AggregateVm6 composition root constructs/destructs child VMs exposes host-safe commands NotebooksVm ComponentVm lifecycle current notebook id selection command NotesViewVm CompositeVm<NoteVm> FilteredCompositeVm search PagedComposition pages NoteFormVm FormVm<NoteDraft> strict dirty tracking field + model validators GlobalSearchVm SearchableState TokenPagedComposition load-more command NotificationsVm NotificationHub NotificationVm wrappers confirmation messages EditorModeVm DiscriminatorVm edit preview Repository + models NotebookModel / NoteModel NoteDraft snapshots in-memory persistence RelayCommand seams save/revert delete request mode toggle Search and paging state note search term global query current page/token Message surfaces property changes collection reset pending notifications Ratatui views.rs pure render functions read VM getters own no domain state app.rs event shell keyboard -> VM command smoke mode terminal lifecycle crossterm terminal input events alternate screen raw mode MVVM rule The terminal shell may keep focus and quit state only. Note data, filtering, paging, validation, notifications, and editor mode live in VMx view models. component1 component2 component3 component4 component5 component6 load notes commands query/token post/resolve snapshots execute events

VMx-owned state

  • The example uses ComponentVm, CompositeVm, FilteredCompositeVm, PagedComposition, FormVm, SearchableState, TokenPagedComposition, NotificationHub, and DiscriminatorVm.
  • WorkspaceVm composes the six child surfaces through AggregateVm6.
  • Tests target the VM layer before the TUI adapter.

Thin terminal adapter

  • Ratatui only renders snapshots from view model getters.
  • crossterm events are translated into VM commands and methods.
  • The smoke path exercises the same VM commands without an interactive terminal.

Showcase behavior

  • Notebook selection, note filtering, paging, edit validation, save/revert, global token search, delete confirmation, and notifications are all represented.
  • The app remains cross-platform and CI-friendly.
  • No TUI framework state model competes with VMx.