From a5beebcea26efda5c345ccc03b13c7d10c5d03cb Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 16 Oct 2026 12:25:28 +0200 Subject: [PATCH] :bug: Drop the uniform structure flag of older copy texts Copy texts in files older than mid-2025 can hold :text-content-structure-same-attrs next to :text-content-structure, which marked a structure change of a text with one style. The text override migration recomputed the groups and dropped the structure flag but left this one in :touched, where nothing reads it, and validation did not report it. It is now one of the legacy text groups, so the migration and the :legacy-text-touched repair drop it too. Found in the copy A2 of the QA fixture text-components-propagation.penpot while re-running PENPOT-2261. convert-text-overrides-test: the flag goes with the structure flag and without it. repair-components-test/legacy-text-touched: a copy holding it is reported and repaired. AI-assisted-by: claude-opus-5-5 --- common/src/app/common/files/comp_processors.cljc | 5 +++-- .../files/convert_text_overrides_test.cljc | 15 +++++++++++++++ .../files/repair_components_test.cljc | 8 +++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/files/comp_processors.cljc b/common/src/app/common/files/comp_processors.cljc index 5900fd6e03..fb46ff1c66 100644 --- a/common/src/app/common/files/comp_processors.cljc +++ b/common/src/app/common/files/comp_processors.cljc @@ -409,7 +409,7 @@ (vary-meta assoc ::deferred-swaps true)))) (def ^:private legacy-text-groups - #{:text-content-attribute :text-content-structure}) + #{:text-content-attribute :text-content-structure :text-content-structure-same-attrs}) (defn legacy-text-touched? "Whether `shape` holds the text override groups of files older than the @@ -452,7 +452,8 @@ "Store the text overrides of the file's copies per letters and per style. Files older than the feature components/text-overrides mark a copy text with `:text-content-attribute` (any style) and `:text-content-structure` - (the number of paragraphs or runs); now it holds `:text-content-text` and + (the number of paragraphs or runs, with `:text-content-structure-same-attrs` + when the styles were uniform); now it holds `:text-content-text` and one group per style unit (`cttx/style-units`). Older files still mark it with `:content-group` alone, which allows every group. Each copy text with the old groups is compared with its near main, and takes the groups the diff --git a/common/test/common_tests/files/convert_text_overrides_test.cljc b/common/test/common_tests/files/convert_text_overrides_test.cljc index aff1cd837d..1e532c9ba8 100644 --- a/common/test/common_tests/files/convert_text_overrides_test.cljc +++ b/common/test/common_tests/files/convert_text_overrides_test.cljc @@ -63,6 +63,21 @@ (convert) (touched :copy-child))))) +(t/deftest the-uniform-structure-flag-goes-with-the-others + ;; older files mark a structure change of a uniform text with + ;; `:text-content-structure-same-attrs` too + (t/is (= #{:content-group :text-content-text} + (-> (old-copy [[["Price:"] ["$10" {:weight 700}]]] + #{:content-group :text-content-structure :text-content-structure-same-attrs}) + (convert) + (touched :copy-child)))) + (t/testing "it goes without the structure flag as well" + (t/is (= #{:content-group :text-content-text} + (-> (old-copy [[["Price:"] ["$10" {:weight 700}]]] + #{:content-group :text-content-text :text-content-structure-same-attrs}) + (convert) + (touched :copy-child)))))) + (t/deftest an-old-flag-where-nothing-differs-sets-nothing (t/is (= #{:fill-group} (-> (old-copy main #{:content-group :text-content-attribute :fill-group}) diff --git a/common/test/common_tests/files/repair_components_test.cljc b/common/test/common_tests/files/repair_components_test.cljc index 677ef27558..f00ca3eb03 100644 --- a/common/test/common_tests/files/repair_components_test.cljc +++ b/common/test/common_tests/files/repair_components_test.cljc @@ -369,7 +369,13 @@ #{:content-group :text-content-attribute}))] (t/is (= #{:legacy-text-touched} found)) (t/is (nil? errors)) - (t/is (empty? (:touched (ths/get-shape file' :copy-child)))))) + (t/is (empty? (:touched (ths/get-shape file' :copy-child))))) + (t/testing "the uniform structure flag is an old flag too" + (let [[found file' errors] (repair (ths/update-shape (simple) :copy-child :touched + #{:content-group :text-content-structure-same-attrs}))] + (t/is (= #{:legacy-text-touched} found)) + (t/is (nil? errors)) + (t/is (empty? (:touched (ths/get-shape file' :copy-child))))))) ;; ---- Nesting