diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index 180445e2a6cd..37357bac2a60 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -868,17 +868,23 @@ impl App { /// The welcome screen can be displayed only when a blueprint is available (and no recording is /// loaded). This function implements the heuristic which determines when the welcome screen /// should show up. - fn handle_default_blueprint(&mut self, store_hub: &mut StoreHub) { - if store_hub.current_recording().is_some() - || store_hub.selected_application_id().is_some() - || self.startup_options.skip_welcome_screen + fn should_show_welcome_screen(&mut self, store_hub: &mut StoreHub) -> bool { + // Don't show the welcome screen if we have actual data to display. + if store_hub.current_recording().is_some() || store_hub.selected_application_id().is_some() { - return; + return false; + } + + // Don't show the welcome screen if the `--skip-welcome-screen` flag was used (e.g. by the + // Python SDK), until some data has been loaded and shown. This way, we *still* show the + // welcome screen when the user closes all recordings after, e.g., running a Python example. + if self.startup_options.skip_welcome_screen && !store_hub.was_recording_active() { + return false; } // Here, we use the type of Receiver as a proxy for which kind of workflow the viewer is // being used in. - let welcome = match self.rx.source() { + match self.rx.source() { // These source are typically "finite". We want the loading screen so long as data is // coming in. SmartChannelSource::Files { .. } | SmartChannelSource::RrdHttpStream { .. } => { @@ -894,10 +900,6 @@ impl App { // where it's not the case, including Python/C++ SDKs and possibly other, advanced used, // scenarios. In this cases, `--skip-welcome-screen` should be used. SmartChannelSource::TcpServer { .. } => true, - }; - - if welcome { - store_hub.set_app_id(StoreHub::welcome_screen_app_id()); } } } @@ -1014,7 +1016,9 @@ impl eframe::App for App { // Heuristic to set the app_id to the welcome screen blueprint. // Must be called before `read_context` below. - self.handle_default_blueprint(&mut store_hub); + if self.should_show_welcome_screen(&mut store_hub) { + store_hub.set_app_id(StoreHub::welcome_screen_app_id()); + } let store_context = store_hub.read_context(); diff --git a/crates/re_viewer/src/store_hub.rs b/crates/re_viewer/src/store_hub.rs index 8bf28e001436..848cc71445d9 100644 --- a/crates/re_viewer/src/store_hub.rs +++ b/crates/re_viewer/src/store_hub.rs @@ -28,6 +28,9 @@ pub struct StoreHub { blueprint_by_app_id: HashMap, store_dbs: StoreBundle, + /// Was a recording ever activated? Used by the heuristic controlling the welcome screen. + was_recording_active: bool, + // The [`StoreGeneration`] from when the [`StoreDb`] was last saved #[cfg(not(target_arch = "wasm32"))] blueprint_last_save: HashMap, @@ -69,6 +72,8 @@ impl StoreHub { blueprint_by_app_id: blueprints, store_dbs: Default::default(), + was_recording_active: false, + #[cfg(not(target_arch = "wasm32"))] blueprint_last_save: Default::default(), } @@ -114,6 +119,13 @@ impl StoreHub { }) } + /// Keeps track if a recording was every activated. + /// + /// This useful for the heuristic controlling the welcome screen. + pub fn was_recording_active(&self) -> bool { + self.was_recording_active + } + /// Change the selected/visible recording id. /// This will also change the application-id to match the newly selected recording. pub fn set_recording_id(&mut self, recording_id: StoreId) { @@ -128,6 +140,7 @@ impl StoreHub { } self.selected_rec_id = Some(recording_id); + self.was_recording_active = true; } pub fn remove_recording_id(&mut self, recording_id: &StoreId) {