diff --git a/.serena/memories/common/changes.md b/.serena/memories/common/changes.md
index 5a0b567499..a498bc98a6 100644
--- a/.serena/memories/common/changes.md
+++ b/.serena/memories/common/changes.md
@@ -11,6 +11,7 @@
## Application and schema validation
- `process-changes` validates the change vector once by default, reduces it and then processes collected touched changes; `verify? false` is for callers that already validated. `:set` delegates to `ctn/set-shape-attr`, while `:assign` decodes attrs before per-attr sets. Component touched and copy rules are in `mem:common/components`.
+- `:restore-component` restores only the component record: it removes `:objects` and `:deleted`, optionally updates the main instance page, and takes a variant's `:variant-id` from the existing main shape. `prepare-restore-component` generates separate `:add-obj` changes before it to restore the shape tree. Affected-file validation conservatively selects the referenced page for the restore operation itself.
- `shape-tree/add-shape` falls back invalid parents or frames to root and keeps parent `:shapes` a vector without duplicate IDs. `delete-shape` removes descendants from the objects map as well as unlinking the parent; render-wasm deletion has different undo internals.
- Page-object maps can carry metadata indexes. Rebuild them with `start-page-index` / `update-page-index` as appropriate; frontend commit application calls `ctst/update-object-indices` after page changes.
- `update-file` uses change-scoped schema validation: `touched-page-ids` selects pages while non-page data is checked whole. Register new change types as page-writing or file-level; unknown types fall back to the full schema check, which loads every page. Referential integrity and repair are in `mem:common/components`.
diff --git a/.serena/memories/frontend/ui-package.md b/.serena/memories/frontend/ui-package.md
index 4bf3bf869a..d9ab9e9e92 100644
--- a/.serena/memories/frontend/ui-package.md
+++ b/.serena/memories/frontend/ui-package.md
@@ -1,6 +1,6 @@
# Shared UI package
- `frontend/packages/ui` builds `@penpot/ui`, a React/Vite library separate from the CLJS Design System. Keep reusable primitives independent of the Penpot app store. React and ReactDOM are peers and must remain external to the library build.
-- The Vite build emits ESM and type declarations and copies `dist/ui.css` to `frontend/resources/public/css/ui.css`. If shared styles are stale, check the package build and copy before debugging CLJS.
+- The Vite build emits ESM and type declarations; the public `@penpot/ui/style.css` export resolves to `dist/ui.css`, which the build also copies to `frontend/resources/public/css/ui.css`. If shared styles are stale, check the package build and copy before debugging CLJS.
- From `frontend/packages/ui`, use `pnpm run build`, `pnpm run watch` or `pnpm run test`. From `frontend/`, `pnpm run build:app:libs` builds app-side packages; `pnpm run build:storybook`, `watch:storybook` and `test:storybook` cover Storybook. Validate changed exports in both the package and consuming app or Storybook.
- Other packages under `frontend/packages/` are workspace dependencies and need not implement behavior in CLJS. App components and the CLJS Design System are described in `mem:frontend/ui-cljs`; text editing is `mem:frontend/text-editor`.
diff --git a/common/src/app/common/files/validate.cljc b/common/src/app/common/files/validate.cljc
index 9c292e6db6..d54e04bd7e 100644
--- a/common/src/app/common/files/validate.cljc
+++ b/common/src/app/common/files/validate.cljc
@@ -953,9 +953,8 @@
:mod-page
(conj page-ids id)
- ;; restore-component resurrects a deleted component (touches the
- ;; component definition) and places its main instance on a page
- ;; (touches that page's shape tree)
+ ;; Conservatively validate the referenced page as well as the
+ ;; restored component. Separate add-obj changes restore shapes.
:restore-component
(conj page-ids page-id)
diff --git a/common/src/app/common/types/file.cljc b/common/src/app/common/types/file.cljc
index 490981fb13..a295da9504 100644
--- a/common/src/app/common/types/file.cljc
+++ b/common/src/app/common/types/file.cljc
@@ -652,7 +652,9 @@
(ctkl/mark-component-deleted component-id)))))
(defn restore-component
- "Recover a deleted component and all its shapes and put all this again in place."
+ "Restore a deleted component record, optionally updating its main instance page.
+ Remove the stored objects and, for a variant, take its variant id from the
+ existing main instance shape. This does not restore shapes to the page."
[file-data component-id page-id]
(let [update-page? (not (nil? page-id))
component (ctkl/get-component file-data component-id true)
@@ -1382,4 +1384,4 @@
(get (:objects container) %2)))
refs
(:shapes shape)))
- {})))
\ No newline at end of file
+ {})))
diff --git a/common/test/common_tests/files_changes_test.cljc b/common/test/common_tests/files_changes_test.cljc
index bd497e72a7..18a07cce7d 100644
--- a/common/test/common_tests/files_changes_test.cljc
+++ b/common/test/common_tests/files_changes_test.cljc
@@ -172,6 +172,20 @@
:child-id child-id
:component-id component-id}))
+(t/deftest restore-component-alone-does-not-restore-shapes
+ (let [{:keys [data page-id main-id child-id component-id]} (make-deleted-component)
+ deleted (ch/process-changes data [{:type :del-obj :id main-id :page-id page-id}])
+ restored (ch/process-changes deleted [{:type :restore-component
+ :id component-id :page-id page-id}])
+ component (get-in restored [:components component-id])]
+ (t/is (true? (get-in deleted [:components component-id :deleted])))
+ (t/is (some? (get-in deleted [:components component-id :objects main-id])))
+ (t/is (not (contains? component :deleted)))
+ (t/is (not (contains? component :objects)))
+ (t/is (= page-id (:main-instance-page component)))
+ (t/is (nil? (get-in restored [:pages-index page-id :objects main-id])))
+ (t/is (nil? (get-in restored [:pages-index page-id :objects child-id])))))
+
(t/deftest update-component-does-not-carry-the-objects-map
(let [{:keys [data component-id]} (make-deleted-component)
changes (pcb/update-component (pcb/with-library-data (pcb/empty-changes nil) data)
diff --git a/common/test/common_tests/logic/comp_creation_test.cljc b/common/test/common_tests/logic/comp_creation_test.cljc
index eb0fb36d01..6f9147663f 100644
--- a/common/test/common_tests/logic/comp_creation_test.cljc
+++ b/common/test/common_tests/logic/comp_creation_test.cljc
@@ -471,7 +471,7 @@
page-deleted
(:objects page-deleted))
- file' (thf/apply-changes file changes)
+ file' (thf/apply-changes file-deleted changes)
;; ==== Get
component1' (thc/get-component file' :component1 :include-deleted? false)
@@ -483,12 +483,20 @@
saved-objects' (:objects component1')]
;; ==== Check
+ (t/is (true? (:deleted (thc/get-component file-deleted :component1 :include-deleted? true))))
+ (t/is (nil? (ths/get-shape file-deleted :main1-root)))
+ (t/is (nil? (ths/get-shape file-deleted :main1-child)))
+ (t/is (some? component1'))
(t/is (nil? (:deleted component1')))
(t/is (some? copy1-root'))
(t/is (some? main1-root'))
(t/is (some? main1-child'))
(t/is (ctk/main-instance? main1-root'))
(t/is (ctk/main-instance-of? (:id main1-root') (:id page) component1'))
+ (t/is (= (:id main1-root') (:parent-id main1-child')))
+ (t/is (some #{(:id main1-child')} (:shapes main1-root')))
+ (t/is (some #{(:id main1-root')}
+ (:shapes (get-in (thf/current-page file') [:objects (:parent-id main1-root')]))))
(t/is (nil? saved-objects'))))
(t/deftest test-instantiate-component
diff --git a/docs/technical-guide/developer/frontend.md b/docs/technical-guide/developer/frontend.md
index 6a28339a8a..7df103655d 100644
--- a/docs/technical-guide/developer/frontend.md
+++ b/docs/technical-guide/developer/frontend.md
@@ -303,15 +303,15 @@ Ensure your development environment docker image is up to date.
**NOTE** You can learn more about how to set up, start and stop our development environment [here](/technical-guide/developer/devenv)
-#### Release mode
+#### Build the frontend
-This is not required, but it may be convenient to compile Penpot in release mode before running the tests. This way they will be much quicker and stable. For this, go to the frontend window in the tmux session (Ctrl + b 1), interrupt the watch process with Ctrl + C and type:
+Playwright serves the release bundle from frontend/resources/public, not the live sources. Before running the tests, build the frontend from the frontend window in the tmux session (Ctrl + b 1). Interrupt the watch process with Ctrl + C and run:
```bash
./scripts/build
```
-Obviously, in this mode if you make changes to the source code, you will need to repeat the build manually each time. It may be useful to use wath mode when debugging a single test, and use release mode to run all the suite.
+Rebuild after product code or asset changes, or after switching to a branch with different sources or assets. Changes only to integration specs do not require a rebuild. Watch mode does not replace the release build for these tests.
### Running the integration tests
diff --git a/frontend/packages/ui/package.json b/frontend/packages/ui/package.json
index 64f6f57122..1196f2d440 100644
--- a/frontend/packages/ui/package.json
+++ b/frontend/packages/ui/package.json
@@ -16,7 +16,7 @@
"import": "./dist/menu.js",
"types": "./dist/menu.d.ts"
},
- "./style.css": "./dist/style.css"
+ "./style.css": "./dist/ui.css"
},
"scripts": {
"watch": "vite build --watch",
diff --git a/frontend/packages/ui/tests/build-css.test.ts b/frontend/packages/ui/tests/build-css.test.ts
new file mode 100644
index 0000000000..cb1b2c7763
--- /dev/null
+++ b/frontend/packages/ui/tests/build-css.test.ts
@@ -0,0 +1,77 @@
+import {
+ cpSync,
+ mkdtempSync,
+ mkdirSync,
+ readFileSync,
+ rmSync,
+ symlinkSync,
+} from "node:fs";
+import { createRequire } from "node:module";
+import os from "node:os";
+import path from "node:path";
+import { spawnSync } from "node:child_process";
+import { expect, it } from "vitest";
+
+it("exports the built CSS and copies it to the app", () => {
+ const packageDir = path.resolve(import.meta.dirname, "..");
+ const frontendDir = path.resolve(packageDir, "../..");
+ const temporaryDir = mkdtempSync(path.join(os.tmpdir(), "penpot-ui-build-"));
+ const isolatedFrontend = path.join(temporaryDir, "frontend");
+ const isolatedPackage = path.join(isolatedFrontend, "packages", "ui");
+
+ try {
+ mkdirSync(isolatedPackage, { recursive: true });
+ for (const entry of [
+ "src",
+ "package.json",
+ "vite.config.mts",
+ "tsconfig.json",
+ "tsconfig.lib.json",
+ "tsconfig.spec.json",
+ "tsconfig.storybook.json",
+ ".babelrc",
+ ]) {
+ cpSync(path.join(packageDir, entry), path.join(isolatedPackage, entry), {
+ recursive: true,
+ });
+ }
+ symlinkSync(
+ path.join(packageDir, "node_modules"),
+ path.join(isolatedPackage, "node_modules"),
+ );
+ symlinkSync(
+ path.join(frontendDir, "node_modules"),
+ path.join(isolatedFrontend, "node_modules"),
+ );
+ symlinkSync(
+ path.join(frontendDir, "src"),
+ path.join(isolatedFrontend, "src"),
+ );
+
+ const build = spawnSync(
+ process.execPath,
+ [
+ path.join(frontendDir, "node_modules/vite/bin/vite.js"),
+ "build",
+ "--configLoader",
+ "runner",
+ ],
+ { cwd: isolatedPackage, encoding: "utf8" },
+ );
+ expect(build.status, `${build.stdout}\n${build.stderr}`).toBe(0);
+
+ const resolve = createRequire(
+ path.join(isolatedPackage, "package.json"),
+ ).resolve;
+ const exportedCss = resolve("@penpot/ui/style.css");
+ const css = readFileSync(exportedCss, "utf8");
+ const copiedCss = readFileSync(
+ path.join(isolatedFrontend, "resources/public/css/ui.css"),
+ "utf8",
+ );
+ expect(css.length).toBeGreaterThan(0);
+ expect(copiedCss).toBe(css);
+ } finally {
+ rmSync(temporaryDir, { recursive: true, force: true });
+ }
+}, 120_000);