diff --git a/bootvine/src/systemd_link/boot_feed.rs b/bootvine/src/systemd_link/boot_feed.rs index 05f3d9d..d3eef6c 100644 --- a/bootvine/src/systemd_link/boot_feed.rs +++ b/bootvine/src/systemd_link/boot_feed.rs @@ -113,6 +113,14 @@ fn queued_units(signals: &[Signal]) -> impl Iterator { }) } +fn connected_inputs(changes: Vec, switching_root: bool) -> Vec { + (!changes.is_empty()) + .then_some(ScreenInput::Boot(changes)) + .into_iter() + .chain(switching_root.then_some(ScreenInput::FullRepaint)) + .collect() +} + struct BootTracker { scope: Scope, target: RootRequest, @@ -160,9 +168,9 @@ impl BusFeed { } Link::Connected(connection) => { let received = self.tracker.receive(connection).await; + let switching_root = matches!(self.tracker.root_switch, RootSwitch::Queued(_)); Some(match received { - Ok(changes) if changes.is_empty() => Vec::new(), - Ok(changes) => vec![ScreenInput::Boot(changes)], + Ok(changes) => connected_inputs(changes, switching_root), Err(_) => self.lose_connection(), }) } @@ -184,7 +192,7 @@ impl BusFeed { Ok(changes) => vec![ScreenInput::Boot(changes), ScreenInput::FullRepaint], Err(_) if Instant::now() < deadline => { sleep(BACKGROUND_CHECK_INTERVAL).await; - Vec::new() + vec![ScreenInput::FullRepaint] } Err(_) => { self.link = Link::Finished; @@ -546,6 +554,23 @@ mod tests { } } + #[test] + fn the_screen_is_repainted_only_while_the_root_switches() { + assert!(connected_inputs(Vec::new(), false).is_empty()); + assert!(matches!( + connected_inputs(Vec::new(), true).as_slice(), + [ScreenInput::FullRepaint] + )); + assert!(matches!( + connected_inputs(vec![BootChange::ForgetJobs], true).as_slice(), + [ScreenInput::Boot(_), ScreenInput::FullRepaint] + )); + assert!(matches!( + connected_inputs(vec![BootChange::ForgetJobs], false).as_slice(), + [ScreenInput::Boot(_)] + )); + } + fn in_state(state: ActiveState) -> Activity { Activity { state: Some(state), diff --git a/docs/architecture.md b/docs/architecture.md index 564a158..c9f2419 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -270,7 +270,10 @@ While it runs, bootvine: `/proc/sys/kernel/printk` to 1, so only emergency messages reach the screen, and sets it again if something raises it; - **silences systemd's status output** with the manager's `SetShowStatus` - call. + call; +- **repaints every cell every 100 ms during a root switch**, because PID 1 + writes to the console and resets it while it re-executes, and drawing only + the cells that changed would leave that on screen. It restores the log level and the status output when it hands the console back. Kernel messages from before it starts are already on screen; see