From 44485aee910c0ef31bd385b9176c64a4f174aafd Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 23 Oct 2026 20:10:30 +0200 Subject: [PATCH] :bug: Clear source overrides after pushing a swapped subtree When update-main clones a swapped subtree into the main, the new main owns its authored groups. Clear those groups from every source shape when relinking it to the clone, instead of clearing only swap-group. The regression fails on retained source flags before the fix. All five assertions now pass, including retained geometry and opacity values, new-main groups and exact undo. The swap suite passes 43 tests and 173 assertions. Benchmark vs Phase 1e: main 10/100/1000 0.57/0.65/0.73; levels 0.59; chain 0.59; library 0.61; many shapes 0.65; switch 0.68. No flags. AI-assisted-by: GPT-6 --- common/src/app/common/logic/libraries.cljc | 2 +- .../test/common_tests/logic/swap_group_test.cljc | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index b74aae398b..edad15736b 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -764,7 +764,7 @@ update-original-shape (fn [original-shape new-shape] (-> original-shape (assoc :shape-ref (:id new-shape)) - (ctk/remove-swap-group))) + (dissoc :touched))) [new-head new-shapes updated-shapes] (ctst/clone-shape child-inst diff --git a/common/test/common_tests/logic/swap_group_test.cljc b/common/test/common_tests/logic/swap_group_test.cljc index bae1db42a3..0072848e98 100644 --- a/common/test/common_tests/logic/swap_group_test.cljc +++ b/common/test/common_tests/logic/swap_group_test.cljc @@ -29,6 +29,7 @@ [app.common.test-helpers.compositions :as tho] [app.common.test-helpers.files :as thf] [app.common.test-helpers.ids-map :as thi] + [app.common.test-helpers.normalize :as thn] [app.common.test-helpers.shapes :as ths] [app.common.test-helpers.variants :as thv] [app.common.types.component :as ctk] @@ -769,3 +770,18 @@ (t/is (ctk/touched-group? head :geometry-group)) (t/is (mth/close? 45 (:rotation head) 0.001)) (t/is (gsh/close-attrs? :points (:points head) (:points (ths/get-shape-by-id full (:id head))) 0.001)))) + +(t/deftest update-main-clears-overrides-on-the-swapped-subtree-it-pushes + (let [edited (-> (tm/make-situation (setup-sized)) + (r/step (n/swap-shape :copy-star :heart)) r/settle + (r/step (n/change-height :copy-star 80)) r/settle + (r/step (n/change-property :copy-star :opacity 0.4)) r/settle) + updated (-> edited (r/step (n/update-main :copy)) r/settle) + head (tm/resolve-shape updated :copy-star) + main (tm/shape-by-id updated (:shape-ref head))] + (t/is (empty? (:touched head))) + (t/is (= #{:geometry-group :layer-effects-group} (:touched main))) + (t/is (= 0.4 (:opacity head) (:opacity main))) + (t/is (mth/close? 80 (:height head) 0.001)) + (t/is (= (thn/normalize-file (tm/file edited)) + (thn/normalize-file (tm/file (r/step updated (n/undo))))))))