pub async fn run(
app: TuiApp,
bus: EventBus,
bus_rx: Receiver<Event>,
cancel: CancellationToken,
profile_path: Option<PathBuf>,
profile: Profile,
) -> Result<()>Expand description
Drive the TUI main loop until cancelled or the user requests quit.
Owns the ratatui terminal + crossterm event stream; restores cooked
mode + leaves the alternate screen on return (including on Err).
§Parameters
app— the preparedTuiApp; caller seeds device summary, initialSerialConfig, line endings, modem lines, and modal style before handing in.bus— the sharedEventBus, used to publishEvent::TxBytesfor keystrokes andEvent::ProfileSaved/Event::ProfileLoadFailedfor profile-IO outcomes.bus_rx— a pre-subscribed bus receiver; subscribe before spawning the session task so no events are missed.cancel— the sharedCancellationToken. Tripping it (via signal, session exit, orDispatch::Quit) unwinds the loop.profile_path— where to read/write the profile TOML when the user triggers a save-flavored dialog action.Nonewhen no path is discoverable (tests,$HOME-less CI); save actions become no-ops +tracing::warnin that case.profile— the currently-loaded profile, owned by the run loop. Mutated in place whenApplyAndSave/ApplyModalStyleAndSave/ReadProfilerewrite sections; persisted on disk throughrtcom_config::write.
§Errors
Propagates terminal setup, IO, and render errors. Bus Lagged
warnings are logged and the loop continues; a bus Closed error
is treated as an implicit cancel and the function returns Ok(()).