From cdde35fe56ab11f81e40757325eb158d2070d1e5 Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Wed, 30 Sep 2026 10:40:18 +0200 Subject: [PATCH] :bug: Skip shape validation in the page index worker The page index worker applies the same changes to its own copy of the pages, which has no file id and no components. :validate-shapes changes then always failed there, so the worker logged "error updating page index" and stopped updating the snap and selection indexes of that page after any validated change. Drop :validate-shapes changes before applying them in the worker. AI-assisted-by: claude-opus-5-5 --- frontend/src/app/worker/index.cljs | 3 +- frontend/test/frontend_tests/runner.cljs | 2 + .../frontend_tests/worker_index_test.cljs | 46 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 frontend/test/frontend_tests/worker_index_test.cljs diff --git a/frontend/src/app/worker/index.cljs b/frontend/src/app/worker/index.cljs index 910fa74fae..fe1b1809b9 100644 --- a/frontend/src/app/worker/index.cljs +++ b/frontend/src/app/worker/index.cljs @@ -39,7 +39,8 @@ :add-typography :mod-typography :del-typography :set-tokens-lib :set-token :set-token-set :set-token-theme :set-tokens-status :set-own-tokens-status :rename-token-set-group :move-token-set - :move-token-set-group :set-base-font-size :set-tokens-source}) + :move-token-set-group :set-base-font-size :set-tokens-source + :validate-shapes}) (defn- index-change? [{:keys [type]}] diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index 53e320c5e2..ce4e83f382 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -222,6 +222,7 @@ [frontend-tests.util-zip-test] [frontend-tests.util.code-gen-markup-svg-wasm-test] [frontend-tests.util.dom.dnd-test] + [frontend-tests.worker-index-test] [frontend-tests.worker-snap-test] [frontend-tests.worker.component-thumbnails-test] [frontend-tests.worker.exports-test] @@ -467,6 +468,7 @@ 'frontend-tests.util.code-gen-markup-svg-wasm-test 'frontend-tests.util.dom.dnd-test 'frontend-tests.util-zip-test + 'frontend-tests.worker-index-test 'frontend-tests.worker-snap-test]) (assert (every? find-ns-obj test-namespaces) diff --git a/frontend/test/frontend_tests/worker_index_test.cljs b/frontend/test/frontend_tests/worker_index_test.cljs new file mode 100644 index 0000000000..d0d74ee2f7 --- /dev/null +++ b/frontend/test/frontend_tests/worker_index_test.cljs @@ -0,0 +1,46 @@ +;; 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 frontend-tests.worker-index-test + (:require + [app.common.files.changes-builder :as pcb] + [app.common.test-helpers.compositions :as ctho] + [app.common.test-helpers.files :as cthf] + [app.common.test-helpers.ids-map :as cthi] + [app.common.test-helpers.shapes :as cths] + [app.common.types.shape :as cts] + [app.common.uuid :as uuid] + [app.worker.impl :as impl] + [app.worker.index :as index] + [cljs.test :as t :include-macros true])) + +(t/use-fixtures :each + {:before cthi/reset-idmap!}) + +(t/deftest update-index-with-validate-shapes-changes + ;; The index only holds pages, without the file id nor its components, so + ;; a :validate-shapes change must not stop it from applying the others + (let [;; ==== Setup + file (-> (cthf/sample-file :file1) + (ctho/add-simple-component :c01 :m01 :r01)) + page (cthf/current-page file) + main (cths/get-shape file :m01) + rect (cts/setup-shape {:id (uuid/next) :type :rect :name "Rect" + :x 0 :y 0 :width 10 :height 10}) + + changes (-> (pcb/empty-changes nil (:id page)) + (pcb/with-objects (:objects page)) + (pcb/add-object rect) + (pcb/validate-shapes (:id page) [(:id main)] "test")) + + ;; ==== Action + _ (impl/handler {:cmd :index/initialize :page page}) + _ (impl/handler {:cmd :index/update + :page-id (:id page) + :changes (:redo-changes changes)})] + + ;; ==== Check + (t/is (some? (get-in @index/state [:pages-index (:id page) :objects (:id rect)])))))