Timeline: reorder anyway (allow_errors) and report the features the move breaks (#5962) (#5988)

* claim: #5962

* Timeline: reorder anyway (allow_errors) and report the features the move breaks (#5962)

timeline.reorder and timeline.reorder_many refuse a move after which a
feature that worked would fail. Sometimes breaking a later feature is the
point: an agent restructuring a design wants the move made, then the list
of what broke so it can repair those features next.

Both take allow_errors (default false: refused as before). With it the
move is made and the reply lists broken: [{feature, error}] (empty when
nothing broke); one undo puts the order back. timeline.reorder_many also
takes active, as timeline.reorder does.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DuBearte
2026-10-25 01:48:23 +00:00
committed by GitHub
parent b4acd83c78
commit 3f6b9fe89f
2 changed files with 77 additions and 11 deletions
+37
View File
@@ -589,6 +589,43 @@ fn timeline_moves_across_the_marker_are_one_undo_step() {
assert_eq!(s.undo.len(), undo, "a refused move adds no undo step");
}
/// #5962: a reorder that breaks a feature is refused unless `allow_errors`; with it the move is
/// made, the reply lists what broke, and one undo puts the order back. For both reorder commands.
#[test]
fn reorder_with_allow_errors_is_made_and_lists_what_broke() {
let mut s = Session::default();
run(&mut s, "solid.box", json!({"length": 10, "width": 10, "height": 10, "name": "Base"}));
run(&mut s, "solid.fillet", json!({"edges": [[10, 5, 10]], "radius": 1, "name": "Round"}));
let order = |s: &Session| s.doc.features.iter().map(|f| f.name.clone()).collect::<Vec<_>>();
let before = s.doc.clone();
for (cmd, params) in
[("timeline.reorder", json!({"feature": "Round", "position": 0})), ("timeline.reorder_many", json!({"features": ["Round"], "position": 0}))]
{
let error = s.execute(cmd, &params).unwrap_err().to_string();
assert!(error.contains("breaks Round"), "{cmd}: {error}");
assert_eq!(s.doc, before, "{cmd}: refused, nothing moved");
let mut anyway = params.clone();
anyway["allow_errors"] = json!(true);
let r = run(&mut s, cmd, anyway);
assert_eq!(order(&s), ["Round", "Base"], "{cmd}");
let broken = r["broken"].as_array().unwrap();
assert_eq!(broken.len(), 1, "{cmd}: {r}");
assert_eq!(broken[0]["feature"], "Round", "{cmd}: {r}");
assert!(broken[0]["error"].as_str().is_some_and(|e| !e.is_empty()), "{cmd}: {r}");
run(&mut s, "edit.undo", json!({}));
assert_eq!(s.doc, before, "{cmd}: one undo puts the order back");
}
// A move that breaks nothing says so, and refuses anything but a boolean.
run(&mut s, "solid.box", json!({"length": 5, "width": 5, "height": 5, "corner": [20, 0, 0], "operation": "new", "name": "Other"}));
let r = run(&mut s, "timeline.reorder_many", json!({"features": ["Other"], "position": 0, "allow_errors": true}));
assert_eq!(r["broken"], json!([]));
assert!(s.execute("timeline.reorder", &json!({"feature": "Other", "position": 2, "allow_errors": "yes"})).is_err());
// `reorder_many` takes `active` too: the moved feature ends up behind the history marker.
run(&mut s, "timeline.reorder_many", json!({"features": ["Other"], "position": 3, "active": false}));
assert_eq!(order(&s).last().map(String::as_str), Some("Other"));
assert_eq!(s.doc.marker, Some(2));
}
#[test]
fn failed_timeline_move_many_keeps_folder_membership_and_order() {
let mut s = Session::default();