From a8f20d40b65e410401c2fd891068d382b1ab8698 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 23 Oct 2026 19:11:47 +0200 Subject: [PATCH] :bug: Keep parent orientation when resetting a nested copy Resetting a selected nested copy must compose its parent placement even when that parent remains a component copy. Red regression reproduced; reset suite passes 16 tests / 63 assertions. Benchmark vs Phase 1e: main 10/100/1000 0.51/0.64/0.65; levels 0.50; chain 0.57; library 0.53; many shapes 0.47; switch 0.59. No flags. AI-assisted-by: GPT-6 --- common/src/app/common/logic/libraries.cljc | 6 +++--- common/test/common_tests/logic/comp_reset_test.cljc | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index f8953981b6..84cc438e67 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -263,12 +263,12 @@ (defn- main-in-parent-orientation "Place a main in the orientation of an ordinary instance parent. Such a parent can survive detach, while the nested copy stays untouched." - [main-container shape-main container shape-inst] + [main-container shape-main container shape-inst reset?] (let [parent (ctn/get-shape container (:parent-id shape-inst)) main-parent (get-in main-container [:objects (:parent-id shape-main)]) relative (gmt/multiply (or (:transform parent) (gmt/matrix)) (or (:transform-inverse main-parent) (gmt/matrix)))] - (if (or (nil? parent) (:shape-ref parent) (gmt/unit? relative)) + (if (or (nil? parent) (and (:shape-ref parent) (not reset?)) (gmt/unit? relative)) main-container (let [transform (gmt/transform-in (gsh/shape->center shape-main) relative) angle (- (or (:rotation parent) 0) (or (:rotation main-parent) 0)) @@ -299,7 +299,7 @@ (ctf/get-content-ref-shape library component shape-inst)) main-container (find-main-container container shape-inst shape-main library file libraries component) - main-container (main-in-parent-orientation main-container shape-main container shape-inst) + main-container (main-in-parent-orientation main-container shape-main container shape-inst reset?) shape-main (ctn/get-shape main-container (:id shape-main))] (sync-copy-recursive changes {:container container diff --git a/common/test/common_tests/logic/comp_reset_test.cljc b/common/test/common_tests/logic/comp_reset_test.cljc index c941bc5048..3dd2bf348e 100644 --- a/common/test/common_tests/logic/comp_reset_test.cljc +++ b/common/test/common_tests/logic/comp_reset_test.cljc @@ -639,3 +639,14 @@ (t/is (= 0 (:rotation (ths/get-shape reset :copy-child)))) (t/is (nil? (:touched (ths/get-shape reset :copy-root)))) (t/is (= (thn/normalize-file rotated) (thn/normalize-file undone))))) + +(t/deftest reset-a-nested-copy-keeps-its-rotated-parent-placement + (let [initial (-> (setup/nested-component-with-copy) + (r/step (n/rotate :copy-root 45)) r/settle) + head (tm/role-shape initial :copy-instance) + child (tm/shape-by-id initial (first (:shapes head))) + reset (-> initial (r/step (n/reset :copy-instance)) r/settle) + after (tm/shape-by-id reset (:id child))] + (t/is (gsh/close-attrs? :points (:points child) (:points after) 0.001)) + (t/is (= (:rotation child) (:rotation after))) + (t/is (nil? (:touched (tm/role-shape reset :copy-instance))))))