History: say why an edited feature behind the marker changes nothing (#8100) (#8727)

* claim: #8100

* History: say why an edited feature behind the marker changes nothing (#8100)

Editing a feature that sits after the history marker (double-clicking its
greyed-out item) rolls back to it, previews the change, and on OK puts the
marker back where it was: the feature stays rolled back, so nothing in the
view changes and nothing says why. That is the silent "pattern of a cut
does nothing" in #8100 (the reporter's design has its pattern behind the
marker; on main the pattern itself builds fine once rolled forward).

- timeline.redefine replies `rolled_back` and, when true, a `note`; it also
  carries the feature's `warning` (for a rolled-back feature, the one its
  constructor met building it at its place).
- The window shows that note in the status line after such an edit.
- A rolled-back item's tooltip in both History layouts says it is after
  the history marker and not built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Pending locale: Arabic, Hebrew, Japanese, Vietnamese and Chinese for the rolled-back notes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: bherbruck <brennen.herbruck@gmail.com>
This commit is contained in:
PaddleStroke
2026-10-29 17:11:10 +00:00
committed by GitHub
parent d0b357d532
commit 6ebfe91661
7 changed files with 138 additions and 2 deletions
+16 -2
View File
@@ -67,7 +67,7 @@ pub static COMMANDS: &[CommandSpec] = &[
"features: [id|name], position: insertion slot in the current history; selected features keep their relative order; active?: bool (as timeline.reorder's); refused when a feature that worked would fail, unless allow_errors?: bool (default false): then made, and broken: [{feature, error}] lists the features it broke",
),
CommandSpec::new("timeline.redefine", "Edit Feature", redefine).icon("edit")
.params("feature: id|name, command: the feature's command id, params: its parameters (the feature is rebuilt in place)"),
.params("feature: id|name, command: the feature's command id, params: its parameters (the feature is rebuilt in place) → feature, recomputed, restored, rolled_back: bool (the feature is after the history marker, so the edit is not built yet; `note` then says so), warning?"),
CommandSpec::new("timeline.dependents", "Feature Dependents", dependents).icon("graph")
.noundo()
.params("feature: id|name → features deleted with it, and features that would fail without it"),
@@ -1773,9 +1773,23 @@ fn redefine(s: &mut Session, p: &Value) -> Result<Value> {
if let Some(e) = s.model.result(id).and_then(|r| r.error.clone()) {
return Err(EngineError::Other(e));
}
// A feature behind the history marker is not built, so the edit changes nothing in the model
// yet: the reply says so, or the edit would look as if it had silently failed (#8100). Its
// warning is the one the constructor met building it in the trial, at its place.
let rolled_back = s.doc.marker.is_some_and(|marker| s.doc.feature_index(id).is_some_and(|index| index >= marker));
let warning =
if rolled_back { r.get("warning").and_then(Value::as_str).map(str::to_string) } else { s.model.result(id).and_then(|r| r.warning.clone()) };
// Report the trial's rebuild, plus anything the session still had to compute itself (a kept
// result its budget dropped); `s.model`'s own counters would only report the reuse (#5694).
Ok(json!({"feature": id, "recomputed": rebuilt + s.model.last_recomputed, "restored": reused}))
let mut reply = json!({"feature": id, "recomputed": rebuilt + s.model.last_recomputed, "restored": reused, "rolled_back": rolled_back});
if let Some(warning) = warning {
reply["warning"] = json!(warning);
}
if rolled_back {
let name = s.doc.feature(id).map(|f| f.name.clone()).unwrap_or_default();
reply["note"] = json!(format!("{name} is after the history marker, so it is not built: move the marker past it to build it"));
}
Ok(reply)
}
fn dependents(s: &mut Session, p: &Value) -> Result<Value> {
+38
View File
@@ -1049,3 +1049,41 @@ fn pattern_count_integer_parameters_survive_save_and_reject_fractional_edits() -
assert!(invalid.model.results.iter().any(|r| r.error.as_ref().is_some_and(|e| e.contains("a count must be a whole number;"))));
Ok(())
}
/// Editing a pattern behind the history marker (double-clicking its greyed-out item and pressing
/// OK) changes nothing in the model: the reply says so, where the edit used to look as if it had
/// silently failed, and it still carries what building the copies met (#8100).
#[test]
fn editing_a_rolled_back_pattern_says_it_is_not_built() {
let mut s = Session::default();
run(&mut s, "solid.box", json!({"length":40,"width":30,"height":10,"corner":[0,0,0],"body_name":"Plate"}));
run(&mut s, "solid.cylinder", json!({"radius":2,"height":20,"base":[10,15,-5],"operation":"cut","targets":["Plate"],"name":"Cut"}));
let pattern = |count: u32, origin: [f64; 3]| json!({"features":["Cut"],"axis":{"origin":origin,"dir":[0,0,1]},"count":count});
let redefine = |count, origin| json!({"feature":"Pattern","command":"solid.pattern.circular","params":pattern(count, origin)});
let centre = [20.0, 15.0, 0.0];
let hole = PI * 4.0 * 10.0;
let mut first = pattern(2, centre);
first["name"] = json!("Pattern");
let id = run(&mut s, "solid.pattern.circular", first)["feature"].as_u64().unwrap();
assert!(rel(volume(&mut s), 12000.0 - 2.0 * hole) < 1e-4);
// A pattern that is built: the edit is built at once, with nothing to say.
let reply = run(&mut s, "timeline.redefine", redefine(3, centre));
assert_eq!(reply["rolled_back"], json!(false), "{reply}");
assert!(reply.get("note").is_none(), "{reply}");
assert!(rel(volume(&mut s), 12000.0 - 3.0 * hole) < 1e-4);
// Behind the marker: the edit is kept but not built, and the reply says why nothing changed.
run(&mut s, "timeline.roll_to", json!({"position": 2}));
let reply = run(&mut s, "timeline.redefine", redefine(4, centre));
assert_eq!(reply["rolled_back"], json!(true), "{reply}");
assert_eq!(reply["note"], "Pattern is after the history marker, so it is not built: move the marker past it to build it");
assert!(reply.get("warning").is_none(), "{reply}");
assert!(rel(volume(&mut s), 12000.0 - hole) < 1e-4);
assert!(s.model.result(id).is_some_and(|r| r.skipped && r.error.is_none()));
run(&mut s, "timeline.roll_to", json!({}));
assert!(rel(volume(&mut s), 12000.0 - 4.0 * hole) < 1e-4);
// What building the rolled-back copies met still reaches the reply: here a copy that misses.
run(&mut s, "timeline.roll_to", json!({"position": 2}));
let reply = run(&mut s, "timeline.redefine", redefine(2, [0.0, 0.0, 0.0]));
assert_eq!(reply["rolled_back"], json!(true), "{reply}");
assert_eq!(reply["warning"], "1 of 1 cut copies remove no material", "{reply}");
}