From b51d13d2a4d72cf233227e8bcf9dc050fa75c2cf Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 2 Dec 2026 17:28:48 -0800 Subject: [PATCH] New document: a replayed rows count over 1000 is kept to 1000 A file.new step replayed from a journal or the Actions panel rounded artboardLayout.rows and then refused a result over 1000, so a step with rows 1000.5 or 5000 stopped the playback. The rows count now follows the columns rule: it is rounded, must be 1 or more, and is kept to at most 1000. Recent stores the kept count. docs/mcp.md says the same. --- crates/engine/src/cmd/newdoc.rs | 2 +- crates/engine/src/tests/newdoc.rs | 7 ++++++- crates/engine/src/tests/script_dom.rs | 4 ++-- docs/mcp.md | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/newdoc.rs b/crates/engine/src/cmd/newdoc.rs index 79ce3f97fa..3dc7f579d8 100644 --- a/crates/engine/src/cmd/newdoc.rs +++ b/crates/engine/src/cmd/newdoc.rs @@ -395,7 +395,7 @@ impl DocSettings { } "rows" => { self.rows = if replaying { - v.as_f64().map(f64::round).filter(|n| (1.0..=f64::from(MAX_ARTBOARDS)).contains(n)).map(|n| n as u32) + v.as_f64().map(f64::round).filter(|n| *n >= 1.0).map(|n| n.min(f64::from(MAX_ARTBOARDS)) as u32) } else { count(v) } diff --git a/crates/engine/src/tests/newdoc.rs b/crates/engine/src/tests/newdoc.rs index 200792d5fe..a320b09b18 100644 --- a/crates/engine/src/tests/newdoc.rs +++ b/crates/engine/src/tests/newdoc.rs @@ -219,6 +219,8 @@ fn replayed_counts_keep_their_rounding_and_range_rules() { ("rows", 2.4, 2), ("rows", 0.6, 1), ("rows", 1000.4, 1000), + ("rows", 1000.6, 1000), + ("rows", 5000.0, 1000), ] { let mut p = json!({"width": 10, "height": 10, "artboards": 4, "artboardLayout": {"layout": "gridByColumn", "spacing": 0}}); @@ -236,8 +238,11 @@ fn replayed_counts_keep_their_rounding_and_range_rules() { p["artboardLayout"][key] = json!(expected); } assert_eq!(boards(&s), boards(&new_doc(p))); + if key == "rows" { + assert_eq!(presets(&mut s, "Recent")[0]["artboardLayout"]["rows"], json!(expected), "{value}"); + } } - for layout in [json!({"columns": 0.6}), json!({"rows": 0.4}), json!({"rows": 1000.6})] { + for layout in [json!({"columns": 0.6}), json!({"rows": 0.4})] { let mut p = json!({"artboardLayout": layout}); p["artboardLayout"]["layout"] = json!("gridByColumn"); let mut s = Session::new(); diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index ca827eb2ab..e4d2f62350 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -1306,10 +1306,10 @@ fn file_new_takes_the_rows_of_a_grid_by_column() { #[test] fn file_new_replays_legacy_fractional_and_large_rows() { - for (rows, rounded) in [(3.6, 4), (1000.4, 1000)] { + for (rows, rounded) in [(3.6, 4), (1000.4, 1000), (1000.5, 1000), (5000.0, 1000)] { let params = json!({"width": 100, "height": 100, "artboards": 5, "artboardLayout": {"layout": "gridByColumn", "rows": rows}}); let mut s = Session::new(); - // A direct call refuses a fraction; a replay rounds it to a count from 1 to 1000. + // A direct call refuses a fraction or a count over 1000; a replay rounds it and keeps it to at most 1000. let direct = Session::new().execute("file.new", ¶ms); assert!(direct.is_err(), "{rows}: {direct:?}"); s.replay("file.new", ¶ms).unwrap(); diff --git a/docs/mcp.md b/docs/mcp.md index 5a0fb08062..14fd04a184 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -636,7 +636,7 @@ left out or null; `appearance.setActiveItem` reads a null `index` as clearing th whole number from 1 to 1000, such as `2.4`, `0` or `1001`, and opens no document. A null `artboards` keeps the default or the preset's count; a null `columns` or `rows` is an error. A `file.new` step replayed from a journal or played from the Actions panel keeps the earlier rules: `artboards` is rounded and kept within 1 to 1000, a `columns` of -1 or more is rounded and kept to at most 1000, and a `rows` is rounded and must then be from 1 to 1000. +1 or more is rounded and kept to at most 1000, and a `rows` is rounded, must then be 1 or more, and is kept to at most 1000. A command that leaves out an object selected inside a selected group also leaves it out when `ids` list it together with a group that holds it. Every command that takes `ids` (or `slices`, for the slice commands) refuses a list with an entry that is not a non-negative integer, or a value