From dabda4a752b27e26c0902a2899b83c229d89fd59 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 16 Nov 2026 09:07:04 +0100 Subject: [PATCH] :bug: Close the outline of a rect converted to a path Converting a rect to a path gave an outline that went back to its start with a line and stayed open, so a stroke missed its join at the first corner. With the WASM engine on, the engine converts the rect and closes the outline, so the two engines gave different paths for one shape. The rect's outline now ends with `close-path`, as the WASM engine's does (user decision). The path editor closes subpaths its own way on entry, which its lifecycle test now expects. Found by the WASM replay of the pinned generated programs (program 329), which passes with the change. Tests: `path-data-test/shape-to-path-rect-closes-its-outline`. The conversion is outside the paths the component benchmark measures; it is not run. AI-assisted-by: claude-opus-5-5 --- common/src/app/common/types/path/shape_to_path.cljc | 3 ++- common/test/common_tests/types/path_data_test.cljc | 11 +++++++++++ .../frontend_tests/logic/path_lifecycle_test.cljs | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/types/path/shape_to_path.cljc b/common/src/app/common/types/path/shape_to_path.cljc index 665eb592fe..62cf231479 100644 --- a/common/src/app/common/types/path/shape_to_path.cljc +++ b/common/src/app/common/types/path/shape_to_path.cljc @@ -123,7 +123,8 @@ (conj (helpers/make-line-to p7)) (cond-> (not= p7 p8) (conj (make-corner-arc p7 p8 :bottom-left r4))) - (conj (helpers/make-line-to p1)))))) + ;; the outline closes, so a stroke joins at its first corner too + (conj {:command :close-path :params {}}))))) (defn- rect->path "Creates a bezier curve that approximates a rounded corner rectangle" diff --git a/common/test/common_tests/types/path_data_test.cljc b/common/test/common_tests/types/path_data_test.cljc index 42a40d3abc..dbf92931d5 100644 --- a/common/test/common_tests/types/path_data_test.cljc +++ b/common/test/common_tests/types/path_data_test.cljc @@ -2545,6 +2545,17 @@ ;; so we just check it doesn't throw and returns a :path type (t/is (some? (:content result))))) +(t/deftest shape-to-path-rect-closes-its-outline + ;; as the WASM engine converts it: a stroke joins at the first corner too + (doseq [r [0.0 10.0]] + (let [shape {:type :rect :x 0.0 :y 0.0 :width 100.0 :height 50.0 + :r1 r :r2 r :r3 r :r4 r + :selrect (make-selrect 0.0 0.0 100.0 50.0)} + segs (vec (:content (path/convert-to-path shape {})))] + (t/is (= :move-to (:command (first segs)))) + (t/is (= :close-path (:command (peek segs)))) + (t/is (= 1 (count (filter #(= :close-path (:command %)) segs))))))) + (t/deftest shape-to-path-circle (let [shape {:type :circle :x 0.0 :y 0.0 :width 100.0 :height 100.0 :selrect (make-selrect 0.0 0.0 100.0 100.0)} diff --git a/frontend/test/frontend_tests/logic/path_lifecycle_test.cljs b/frontend/test/frontend_tests/logic/path_lifecycle_test.cljs index 2dca2a405f..3b765025a1 100644 --- a/frontend/test/frontend_tests/logic/path_lifecycle_test.cljs +++ b/frontend/test/frontend_tests/logic/path_lifecycle_test.cljs @@ -310,8 +310,9 @@ drawing-copy (get-in new-state [:workspace-drawing :object])] (t/is (= original-rect stored-shape)) (t/is (= :path (:type drawing-copy))) + ;; the editor edits the converted outline with its subpaths closed (t/is (= (path/move-content - (:content (path/convert-to-path original-rect)) + (path/close-subpaths (:content (path/convert-to-path original-rect))) delta) (:content drawing-copy)))))))))