From 02c75fcaf1165ac0f48d68c3cfbb7e0025b5f9f8 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Thu, 8 Oct 2026 18:30:11 +0700 Subject: [PATCH] Workspaces: leaving Learn closes its tutorials (#272) The Learn workspace opens the Home screen on its Learn tab, but no other workspace closed it, so after Learn the tutorials stayed over Default, Review and the rest until a project was created or Home was toggled. It wasn't about clicking quickly: any switch away from Learn kept them. Leaving Learn for another workspace now closes the Home screen it opened. Test: ui_panels leaving_the_learn_workspace_closes_its_tutorials (clicks through the workspace tabs: the Home screen and the tutorials show only on Learn). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/lib.rs | 15 ++++++++++----- crates/ui-egui/tests/ui_panels.rs | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 53bf34ac..d35630b8 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -383,16 +383,21 @@ impl EffectcraftApp { } pub fn set_workspace(&mut self, name: &str) { - self.ui.workspace = name.to_string(); - self.ui.dock = self.ui.saved_workspaces.get(name).cloned().unwrap_or_else(|| dock::workspace(name)); - self.ui.floating = self.ui.saved_floating.get(name).cloned().unwrap_or_else(|| dock::workspace_floating(name)); - self.ui.maximized = None; - // Learn: the Home screen's Learn tab (tutorials) in the Composition panel. + // Learn: the Home screen's Learn tab (tutorials) in the Composition panel. Leaving it for + // another workspace closes the Home screen again: it stayed over every workspace until a + // project was created (#272). if name == "Learn" { self.ui.start_screen = true; self.ui.home_learn = true; self.ui.home_templates = false; + } else if self.ui.workspace == "Learn" { + self.ui.start_screen = false; + self.ui.home_learn = false; } + self.ui.workspace = name.to_string(); + self.ui.dock = self.ui.saved_workspaces.get(name).cloned().unwrap_or_else(|| dock::workspace(name)); + self.ui.floating = self.ui.saved_floating.get(name).cloned().unwrap_or_else(|| dock::workspace_floating(name)); + self.ui.maximized = None; } /// Built-in workspaces followed by the saved ones (Window ▸ Workspace ▸ Save as New Workspace). diff --git a/crates/ui-egui/tests/ui_panels.rs b/crates/ui-egui/tests/ui_panels.rs index 471e47bf..6b8bd4a5 100644 --- a/crates/ui-egui/tests/ui_panels.rs +++ b/crates/ui-egui/tests/ui_panels.rs @@ -153,6 +153,20 @@ fn saved_workspace_is_listed_in_the_workspace_menu() { assert_eq!(h.state().ui.dock, saved, "its layout came back"); } +/// Learn opens the Home screen's tutorials; clicking another workspace tab closes them again, +/// however quickly the tabs are clicked (they stayed over every workspace, #272). +#[test] +fn leaving_the_learn_workspace_closes_its_tutorials() { + let mut h = harness(); + for name in ["Learn", "Default", "Learn", "Review", "Learn", "Learn", "Small Screen", "Standard", "Learn", "Default"] { + click(&mut h, &format!("header.workspace.{name}")); + assert_eq!(h.state().ui.workspace, name); + let learn = name == "Learn"; + assert_eq!(h.state().ui.start_screen, learn, "{name}: the Home screen shows only for Learn"); + assert_eq!(!h.state().auto.query("home.learn.").is_empty(), learn, "{name}: the tutorials show only for Learn"); + } +} + /// Headless look at the panels (wgpu offscreen; needs a GPU adapter). Run with /// `PANELS_SNAPSHOT=/abs/dir cargo test -p effectcraft-ui-egui --test ui_panels -- --ignored`. #[test]