From a1339154cb22640b7574ba4d493dffa68e11458c Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 12 Nov 2026 12:29:47 +0100 Subject: [PATCH] :paperclip: Compare the corners of a bool in any order when checking undo A bool computes its corners again from its shapes, so the same bounds can come back in another order: undoing an edit left two flipped copy bools with their corners listed the other way round, and the undo check took it for a change. The undo check now compares a bool's corners in any order, as the oracle already does. Test: undoing-an-edit-compares-the-corners-of-a-copy-bool-in-any-order (a shape structure program of seed 489). Harness only; the benchmark is not run. AI-assisted-by: claude-opus-5-5 --- .../test_helpers/composable/comp/undo_check.cljc | 13 ++++++++++++- .../common_tests/logic/composable_gen_test.cljc | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/test_helpers/composable/comp/undo_check.cljc b/common/src/app/common/test_helpers/composable/comp/undo_check.cljc index 555f64807d..1cd2e765fc 100644 --- a/common/src/app/common/test_helpers/composable/comp/undo_check.cljc +++ b/common/src/app/common/test_helpers/composable/comp/undo_check.cljc @@ -169,6 +169,12 @@ (into (entities-signature :component (:components ed) (:components ad) #{} (constantly nil))))))) +(defn- corner-order + "The corners of a bool by their rounded position: a bool computes them + again from its children, in any order." + [points] + (sort-by (juxt #(Math/round (* 100.0 (:x %))) #(Math/round (* 100.0 (:y %)))) points)) + (defn same-state? "Compare exact data with an absolute tolerance only in shape geometry. Undo defaults to 1e-10; design equivalence can supply its own tolerance." @@ -188,7 +194,12 @@ (and (map? expected) (map? actual) (= (set (keys expected)) (set (keys actual)))) (every? (fn [key] - (same-state? (get expected key) (get actual key) + (same-state? (cond-> (get expected key) + (and (= :points key) (= :bool (:type expected)) (contains? expected :parent-id)) + corner-order) + (cond-> (get actual key) + (and (= :points key) (= :bool (:type expected)) (contains? expected :parent-id)) + corner-order) ;; a bool or path stores its segments in single precision, and ;; a bool computes them again from its children (if (and (contains? expected :parent-id) (#{:bool :path} (:type expected))) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 292d776ab9..7eacbb786b 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2360,6 +2360,12 @@ :grid-empty false :layout-copies false :text false}] :ops [[:nest 4] [:resize 1] [:style 15 9 3]]})))) +(t/deftest undoing-an-edit-compares-the-corners-of-a-copy-bool-in-any-order + (t/is (map? (cg/run {:world [3 1 {:variants true :rich-variants true :text true :layout nil + :layout-copies true :layout-children false}] + :ops [[:detach 0 0 0 0] [:detach 14 0 0 0] [:add-child 0] [:structure 9 4 0] + [:transform 7 16 0 4] [:edit 21 0 1 1] [:update-main 21]]})))) + (t/deftest unmasking-in-a-flex-main-leaves-its-layout-as-the-unmask-event-does (t/is (map? (cg/run {:world [2 0 {:variants false :rich-variants false :text true :layout :flex :layout-copies false :layout-children true}]