diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 64d5c3d..db9462e 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1404,6 +1404,11 @@ impl ModelApp { self.selected = None; self.selected_seed = None; self.reply = None; + // Picks are by name, and the names of another document are other things. + if !self.pick.selection.is_empty() { + self.pick.selection.clear(); + self.pick.generation = self.pick.generation.wrapping_add(1); + } } self.framed_document = Some(self.session.opened()); self.reframe = framing::Reframe::merge(self.reframe, framing::Reframe::Home); @@ -1748,6 +1753,7 @@ mod tests { app.run("file.sample", json!({"name": "cantilever"})).unwrap(); assert_eq!(app.model_name(), "Cantilever (sample)"); let status = |app: &ModelApp| app.status.as_ref().map(|s| s.text.clone()).unwrap_or_default(); + assert_eq!(status(&app), "Opened the Cantilever sample"); app.run("solve.run", json!({})).unwrap(); assert_eq!(status(&app), "Solved 2 steps"); app.run("results.deformed", json!({"step": "Load", "show": true})).unwrap(); diff --git a/crates/ui-egui/src/reply.rs b/crates/ui-egui/src/reply.rs index 16c7e8c..7fe704b 100644 --- a/crates/ui-egui/src/reply.rs +++ b/crates/ui-egui/src/reply.rs @@ -112,6 +112,10 @@ pub fn done(command: &str, label: &str, params: &Value, v: &Value) -> String { None => format!("Showing {step}, last frame"), }), "results.clear" => Some("Back to the model".to_string()), + "file.sample" => { + let label = v.get("sample").and_then(Value::as_str).and_then(fieldcraft_engine::sample::find).map(|s| s.label); + label.map(|l| format!("Opened the {l} sample")) + } "solve.run" => v.get("steps").and_then(Value::as_array).map(|s| format!("Solved {}", plural(s.len() as u64, "step"))), c if c.starts_with("solve.") => Some(format!("Solved {step}", step = params["step"].as_str().unwrap_or("the step"))), _ => None,