From 83790139b1d633fdbdae9b09ec802015576e59c1 Mon Sep 17 00:00:00 2001 From: phanoob Date: Tue, 20 Oct 2026 15:28:52 +0000 Subject: [PATCH] Editing a sketch past the history marker rolls the marker to it (#2716) (#3339) * claim: #2716 Co-Authored-By: Claude Opus 5.5 * Editing a sketch past the history marker rolls the marker to it (#2716) Edit Sketch rolled the timeline back to just after the sketch only when the marker was later. With the marker before the sketch it stayed there: the sketch wasn't built, so it opened with no palette and couldn't be edited. The marker now moves to just after the sketch either way, and Finish Sketch puts it back as before. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Phanoob Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/lib.rs | 8 ++++---- crates/ui-egui/src/sketch_edit_tests.rs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 8e68c929b..514331e98 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -991,9 +991,9 @@ impl SolveApp { } } - /// Edit a sketch: roll the timeline back to just after it (so later - /// features don't hide it), turn the camera to face it, and remember both so Finish Sketch - /// puts them back. Editing the sketch that is already open does nothing; editing another one + /// Edit a sketch: roll the timeline to just after it (back, so later features don't hide + /// it, or forward from before it, where it isn't built yet: #2716), turn the camera to face + /// it, and remember both so Finish Sketch puts them back. Editing the sketch that is already open does nothing; editing another one /// finishes the current sketch first, so edit sessions never nest. pub fn edit_sketch(&mut self, id: u64) { if let solidcraft_engine::doc::FaceAttachmentStatus::Lost { message, .. } = @@ -1013,7 +1013,7 @@ impl SolveApp { self.dialog = None; let Some(idx) = self.session.doc.feature_index(id) else { return }; let marker = self.session.doc.marker; - let rolled = marker.is_none_or(|m| m > idx + 1) && self.run("timeline.roll_to", json!({ "position": idx + 1 })).is_ok(); + let rolled = marker != Some(idx + 1) && self.run("timeline.roll_to", json!({ "position": idx + 1 })).is_ok(); let before = self.cam; if self.run("sketch.edit", json!({ "sketch": id })).is_err() { if rolled { diff --git a/crates/ui-egui/src/sketch_edit_tests.rs b/crates/ui-egui/src/sketch_edit_tests.rs index 2430b5c7c..bbb9b6d1b 100644 --- a/crates/ui-egui/src/sketch_edit_tests.rs +++ b/crates/ui-egui/src/sketch_edit_tests.rs @@ -28,6 +28,25 @@ fn edit_sketch_rolls_back_and_finish_restores() { assert_eq!(app.session.doc.marker, marker, "marker restored"); } +/// #2716: with the history marker before a sketch, editing it rolls the marker forward to it +/// (it is built, its palette shows), and Finish puts the marker back. +#[test] +fn edit_sketch_rolls_forward_from_before_it_and_finish_restores() { + let mut app = sample_app(); + let id = first_sketch(&app); + let idx = app.session.doc.feature_index(id).unwrap(); + app.run("timeline.roll_to", serde_json::json!({ "position": idx })).unwrap(); + let marker = app.session.doc.marker; + assert!(app.session.model.state().sketch(id).is_none(), "the sketch is past the marker"); + app.edit_sketch(id); + assert_eq!(app.session.active_sketch, Some(id)); + assert_eq!(app.session.doc.marker, Some(idx + 1), "rolled forward to just after the sketch"); + assert!(app.session.model.state().sketch(id).is_some(), "the sketch is built"); + app.finish_sketch(); + assert_eq!(app.session.active_sketch, None); + assert_eq!(app.session.doc.marker, marker, "marker restored"); +} + #[test] fn editing_twice_does_not_nest() { let mut app = sample_app();