From 02c475c92eec38f65ae1617a1a571d540292ddd1 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 22 Oct 2026 20:28:50 +0200 Subject: [PATCH] :bug: Preserve main overrides across repeated component updates F114: updating a nested copy's main cleared the groups transferred by a previous update whenever the source still carried remote-synced. A later edit of the inner component could then overwrite those authored values. Union the main's and copy's groups on every update. The focused nested regression failed before the fix and now passes. Common lint, JVM/JS suites, golden masters and format checks pass. Seeded frontend replay passes 2 tests and 253 assertions. Benchmark lower-quantile ratios against Phase 1e: main 10/100/1000 copies: 0.61/0.63/0.67; three levels: 0.61; chain: 0.56; library: 0.62; many shapes: 0.63; switch: 0.76. No regression flag. AI-assisted-by: GPT-6 --- common/src/app/common/logic/libraries.cljc | 5 ++- .../logic/comp_remote_synced_test.cljc | 38 +++++++++++++++++++ common/test/common_tests/runner.cljc | 1 + 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 common/test/common_tests/logic/comp_remote_synced_test.cljc diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 00fd6d45c4..b18f2732bc 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -552,9 +552,10 @@ (update-attrs shape-main shape-inst root-main root-inst main-container false) ;; the copy keeps its swap, and the main takes the copy's overrides (set-touched shape-inst container (when (ctk/swapped? shape-inst) #{:swap-group})) + ;; A previous update is not a reset of the main's authored + ;; overrides. Repeating it must retain the groups it pushed. (set-touched shape-main main-container - (when-not (:remote-synced shape-inst) - (set/union (:touched shape-main) (:touched shape-inst))))) + (set/union (:touched shape-main) (:touched shape-inst)))) (ctsl/any-layout? shape-main) (update-layout-children main-container shape-main shape-inst #(ctf/get-shape-in-copy container % shape-inst) false) diff --git a/common/test/common_tests/logic/comp_remote_synced_test.cljc b/common/test/common_tests/logic/comp_remote_synced_test.cljc new file mode 100644 index 0000000000..b4dac4c336 --- /dev/null +++ b/common/test/common_tests/logic/comp_remote_synced_test.cljc @@ -0,0 +1,38 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS SUBSIDIARY SL + +(ns common-tests.logic.comp-remote-synced-test + (:require + [app.common.test-helpers.composable.comp.nodes :as n] + [app.common.test-helpers.composable.comp.runner :as r] + [app.common.test-helpers.composable.comp.setups :as setup] + [app.common.test-helpers.composable.core :as tm] + [app.common.test-helpers.ids-map :as thi] + [clojure.test :as t])) + +(t/use-fixtures :each thi/test-fixture) + +(t/deftest updating-main-keeps-overrides-authored-since-the-previous-update + (let [middle-copy (fn [s] + (:parent-id (tm/shape-by-id s ((n/nested-head-of "a" 1) s)))) + nested-main-rect (fn [s] (n/level-rect s "a" 0)) + situation + (r/run-variant + {:setup setup/empty-situation + :operation + (tm/in-sequence + [(n/create-component "a" "#abcdef" :size 100) + (n/make-nested-component "a" 2) + (n/change-property middle-copy :fills "#ff0000") + (n/update-main middle-copy) + ;; Push a nested override, then update again for another edit. + (n/change-property (n/main-rect-of "a") :name "Authored name") + (n/update-main middle-copy) + (n/change-property middle-copy :opacity 0.4) + (n/update-main middle-copy)])}) + main (tm/shape-by-id situation (nested-main-rect situation))] + (t/is (= "Authored name" (:name main))) + (t/is (contains? (:touched main) :name-group)))) diff --git a/common/test/common_tests/runner.cljc b/common/test/common_tests/runner.cljc index a35b11cb7b..feb0d51fbf 100644 --- a/common/test/common_tests/runner.cljc +++ b/common/test/common_tests/runner.cljc @@ -69,6 +69,7 @@ [common-tests.logic.comp-flex-interactions-test] [common-tests.logic.comp-main-edit-breaks-copy-slots-test] [common-tests.logic.comp-move-swapped-copies-test] + [common-tests.logic.comp-remote-synced-test] [common-tests.logic.comp-reset-test] [common-tests.logic.comp-sync-layout-items-test] [common-tests.logic.comp-sync-test]