697 Commits

Author SHA1 Message Date
Thomas Ramé
e6f3d21dce
🐛 Keep context menu submenus inside the window (#13302)
* 🐛 Keep context menu submenus inside the window

A submenu opens at the height of its entry, so one opened from an entry
near the bottom of the window ran past it and its last entries could
not be reached. It now moves up to end 8px above the window's bottom.

Signed-off-by: Florian Schroedl <flo.schroedl@gmail.com>
Signed-off-by: Thomas Ramé <thomas@rame.fr>

* 🐛 Keep nested context submenus inside the window

* ♻️ Compute the context submenu position in a testable function

---------

Signed-off-by: Florian Schroedl <flo.schroedl@gmail.com>
Signed-off-by: Thomas Ramé <thomas@rame.fr>
Co-authored-by: Florian Schroedl <flo.schroedl@gmail.com>
2026-11-25 18:29:18 +01:00
Alejandro Alonso
a0bbafaf12 Merge remote-tracking branch 'origin/staging' into develop 2026-11-25 15:45:00 +01:00
Eva Marco
edd487cddd
🐛 Normalize legacy svg attrs of pasted shapes (#13334)
* 🐛 Normalize legacy svg attrs of pasted shapes

Shapes copied from a version before 2.20 can hold camelCase svg attrs,
for example :strokeLinejoin. Files get them normalized by migration
0037 when they load, but clipboard data skips the migrations, so the
closed SvgAttrs schema rejected the pasted shape and the whole paste was
cancelled.

Move the shape normalization of migration 0037 to csvg/normalize-shape
and run it on every pasted shape in paste-shapes.

Closes #13327

AI-assisted-by: claude-opus-5-5

* 📚 Name the shared svg repair in the data model checklist

From the review: the checklist still named the withdrawn migration 0035
as the svg repair site. Point it to csvg/normalize-shape, used by
migration 0037 and by paste-shapes.

AI-assisted-by: claude-opus-5-5
2026-11-25 13:58:36 +01:00
Eva Marco
efe420e3e4
✨ Count the trips of a throttled update loop before reporting it (#12941)
* ✨ Count the trips of a throttled update loop before reporting it

The report of a throttled update loop could not tell a loop that goes
on from a long chain of updates that ends. It now waits five seconds
and reports how many times the scheduler tripped meanwhile, the stack
of the last trip and the number of objects of the page. The trace still
shows the first trip.

Relates #12580

AI-assisted-by: claude-opus-5-5

* ♻️ Drop the bang suffix from the update loop report function

Review asked for no new functions with a ! suffix.

AI-assisted-by: claude-opus-5-5
2026-11-25 13:52:15 +01:00
Elena Torró
1438be5b26
🐛 Keep variant property order and remove the right property past eight
Variants.properties and currentValues() went through a set, which loses
order past eight items, so index-based removeProperty/renameProperty from a
plugin hit the wrong property. Use distinct to keep the order.

In the sidebar, input-with-meta* kept the input node after a real blur and
replayed a stale rename with an old position when its row unmounted,
undoing a property removal. Clear the node in on-stop-edit.

Add a unit test, a plugin-api-test-suite case and a plugins changelog entry.

Closes #13247
2026-11-25 13:39:09 +01:00
Eva Marco
6337810676
🐛 Keep the image when Selected colors changes a text color (#13313)
color-att->text built the text fill without the :image of the color,
so picking an image in Selected colors left a fill with only
:fill-opacity. The backend rejected the text as an invalid shape. The
same gap made an image fill impossible to match, so changing it back
to a plain color did nothing.

AI-assisted-by: claude-opus-5-5
2026-11-25 12:42:21 +01:00
Eva Marco
fc4c7bb82c
🐛 Expect the other padding sides at 0 in the dimension token test (#13321)
Since #13266, a padding change on a layout without padding fills the
four sides, so the sides not chosen become 0 instead of staying nil.
The test from #13215 still expected nil and failed on develop.

AI-assisted-by: claude-opus-5-5
2026-11-25 11:21:23 +01:00
Andrey Antukh
805b648265 Merge remote-tracking branch 'origin/staging' into develop 2026-11-25 09:44:03 +01:00
Andrey Antukh
2b67de0e29 📎 Fix copyright header on several files 2026-11-25 09:26:43 +01:00
Andrey Antukh
d94518ec41 Merge remote-tracking branch 'origin/staging' into develop 2026-11-24 22:48:49 +01:00
Andrey Antukh
a7f66b18f9
✨ Honor trusted alternate origins for backend links and OIDC (#11892)
* ✨ Honor trusted alternate origins for backend links and OIDC

Add PENPOT_TRUSTED_ORIGINS, an optional list of bare scheme://host[:port]
alternate origins. A request whose Origin matches (exact, trimmed and
lowercased) uses that origin as the base for links generated while serving
it: emails, asset URLs, audit and webhook link fields, and redirects.
Unlisted origins, requests without Origin, and background or server-to-server
work keep the canonical public-uri (fail-closed). Malformed entries warn at
startup and never match.

Stamp the trusted origin on the request with a global http middleware that
binds config public-uri for the request extent; expose the chain as
root-middleware so tests assert it runs before auth and errors. Build every
backend link through the canonical cf/get-public-uri.

Carry the origin in the signed OIDC state (auth and organization SSO) so the
callback, a navigation without Origin, re-applies it with with-public-uri for
the token-exchange redirect_uri and every redirect, including logout. Verify
the state token once per callback and reuse the claims; build redirect URIs
with ensure-path-slash plus join and append-query-param for hash routes. A
removed origin does not invalidate states signed before it (up to four hours).

Bring MCP OAuth into scope: wrap its routes, stage the origin in the Redis
request record at authorize time, and re-apply it in decision so issuer,
resource, the approval redirect and the code-exchange iss agree on one base.

Keep the log-capture watch installed while waiting for the async rejection
record in the save tests; a watch removed first lost late records and read
nil. Add a delayed-executor regression test that makes the race deterministic
and document the rule in the backend testing memory.

Closes #11625

AI-assisted-by: deepseek-v4.1-flash
AI-assisted-by: qwen3.7-plus
AI-assisted-by: gpt-5.6-luna
AI-assisted-by: muse-spark-1.3-contributor

* ✨ Serve trusted alternate origins across frontend and backend

Let one installation serve a canonical domain plus trusted alternate
origins, without letting request headers pick arbitrary link bases.

The backend normalizes `PENPOT_TRUSTED_ORIGINS` on load: it drops malformed
entries with a warning and warns about HTTP origins outside localhost. It
selects the first trusted origin from `X-Penpot-Origin`, then `Origin`, and
applies only scheme, host and port to the public URI, keeping the configured
path. MCP OAuth keeps the canonical base because its authorize navigation
has no usable origin.

The frontend reads the same list from `config.js`, filled by the container
entrypoint, and selects the browser origin only on an exact match. It sends
`X-Penpot-Origin` on RPC calls (including GETs and multipart) and OIDC
initiation, not on asset, font or external requests. SSE captures the request
bindings, and export jobs store the effective base so the download link uses
it after the request ends. A closed export creation schema excludes
`:public-uri`, which the backend adds only after validation.

Register the OIDC callback for each alias. Removing an alias does not stop
already signed OIDC state, queued mail or export jobs from using it.

Add regression tests across backend, frontend and the nginx entrypoint, and
document the proxy setup, worker upgrade and rollback, and alias retirement.

Refs #11625

AI-assisted-by: hy4-flash-free
AI-assisted-by: gpt-6-luna
AI-assisted-by: gpt-6.2-sol
2026-11-24 20:02:29 +01:00
Eva Marco
dadf4d3076
🐛 Keep all padding sides when setting one on a layout without padding (#13266)
* 🐛 Keep all padding sides when setting one on a layout without padding

Setting one padding side on a board whose layout had no stored padding
(made through the API or MCP) saved only that side, for example {:p1 12}.
The backend rejected the shape as invalid.

Start a padding change from the four sides at 0 when the shape has no
padding yet.

Closes #13265

AI-assisted-by: claude-opus-5-5

* 🐛 Complete the layout padding after patching it

From the review: fill the four padding sides after the patch instead of
before, so a side cleared to nil also becomes 0, and any layout change
completes a partial padding saved before the fix.

AI-assisted-by: claude-opus-5-5
2026-11-24 16:08:08 +01:00
Eva Marco
590c3add36
🐛 Leave gradient mode when undo removes a stroke gradient (#13262)
* 🐛 Leave gradient mode when undo removes a stroke gradient

Undoing a gradient with the color picker open sent a plain color.
The picker dropped the stops but stayed in gradient mode, so adding
a stop built a gradient with no coordinates or colors and applied it
to the stroke. The backend rejected it as an invalid shape.

Switch the picker to color (or image) when the color is no longer a
gradient, and skip invalid gradients before applying them.

Closes #13261

AI-assisted-by: claude-opus-5-5

* 🐛 Cover more colorpicker cases in the stroke gradient tests

From the review: plain and image colors still reach on-change through
the gradient guard, both gradient types leave the gradient tab, and a
plain color keeps the color tab. The image tab test is renamed after
what it checks.

AI-assisted-by: claude-opus-5-5
2026-11-24 16:07:17 +01:00
Eva Marco
915d405a9c
🐛 Drop nil style attrs when the legacy text editor saves (#13253)
The legacy editor writes the attrs it gets into the data of an empty
paragraph, nil values included, so turning off a text decoration there
leaves :text-decoration nil. finalize-editor-state copied that data into
the shape content as it was, the only commit path that skipped
ensure-valid-text-content, and the backend rejected the shape. Build the
content with a helper that runs it, shared by both renderer branches.

Closes #13252

AI-assisted-by: claude-opus-5-5
2026-11-24 15:47:45 +01:00
Eva Marco
07c3409ad0
🐛 Show the full library name in a tooltip when it is cut (#13237)
* 🐛 Show the full library name in a tooltip when it is cut

Long library names are cut with an ellipsis in the Libraries modal and
in the Assets panel, with no way to read the full name, so libraries
that share a long prefix cannot be told apart.

A new truncated-text* component shows the text and, only while CSS cuts
it, wraps it in the DS tooltip with the full text. A ResizeObserver
checks the size again when the box changes; it follows the node that the
tooltip mounts, so the tooltip also goes away when the text fits again.
The Libraries modal (new and legacy layouts) and the library titles in
the Assets panel use it.

Closes #13223

AI-assisted-by: claude-opus-5-5

* 🐛 Keep a cut library name visible inside its tooltip

The DS tooltip trigger sets line-height: 0. A cut name inside it
inherited that value and collapsed, so the Assets panel hid the name of
a long shared library. The trigger of truncated-text* now inherits the
line height of its parent through an inline style; a class would tie
with the trigger class and depend on the order of the stylesheets.

AI-assisted-by: claude-opus-5-5
2026-11-24 15:47:25 +01:00
andrés gonzález
aa5e62a417
🐛 Fix SVG upload frame when the selection is inside a group (#13282)
* 🐛 Fix SVG upload frame when the selection is inside a group

With a shape selected inside a group, an uploaded or pasted SVG goes
into that group, but its frame-id came from the board under the drop
point. When the two boards differ, the save fails with invalid-frame.
Take the frame from the group instead.

AI-assisted-by: claude-opus-5-5

* 🐛 Keep SVG upload frame aligned with its parent

Keep the SVG upload frame and parent from the same source.

When a shape inside a group was selected, the frame for the new SVG
came from the board under the cursor while the parent came from the
group, so saving failed with invalid-frame. The parent and frame now
come from one shared predicate, which also prevents a repeat of the
original drift between two copies of the condition.

Add the board-parent test for the frame branch this change rewrote,
and make the group checker assert that the SVG exists and that its
frame is the expected one. Add mutation evidence for both.

AI-assisted-by: deepseek-v4.1-flash

---------

Co-authored-by: Luis de Dios <luis.dedios@kaleidos.net>
2026-11-24 15:15:46 +01:00
Eva Marco
271f5af784
🐛 Give a color to the stroke created when its style changes (#13264)
* 🐛 Give a color to the stroke created when its style changes

Changing the width, style or alignment of a stroke that a shape did not
have built the stroke from the style attributes only, with no color. The
backend rejected the shape as invalid.

Start from the default stroke, as the per-side width and the stroke width
tokens already do.

Closes #13263

AI-assisted-by: claude-opus-5-5

* 🐛 Read bool strokes in the multiple selection menu

The bool type lacked :strokes in its editable attrs, so the multiple
selection menu ignored bool strokes. With a bool without strokes and a
shape with one selected, the menu showed that stroke as shared, and
editing it created a stroke on the bool. Two bools with the same stroke
showed none.

Relates to #13263

AI-assisted-by: claude-opus-5-5
2026-11-24 14:34:28 +01:00
Andrey Antukh
4427b83ae0 Merge remote-tracking branch 'origin/staging' into develop 2026-11-24 13:12:08 +01:00
Andrey Antukh
2da9bddd05 Merge remote-tracking branch 'origin/staging' into develop 2026-11-24 12:22:16 +01:00
Andrey Antukh
719f154b49 🐛 Clarify plugin save recovery warning
Warn that recovery may discard unsaved edits instead of implying that
reopening is the only recovery path. Update the API docs and test.

AI-assisted-by: gpt-6.1-terra
2026-11-24 11:43:48 +01:00
Belén Albeza
35278f3917 🐛 Restore the WASM stack pointer after a failed call (#12978)
A failed render-wasm call traps without popping its shadow-stack frames.
Each failure leaked stack until it overwrote static data, and from then on
every call trapped as wasm-critical. h/call now saves the stack pointer
before the call and restores it on failure.

Closes #12977
Related to #12906

AI-assisted-by: claude-opus-5-5
2026-11-24 10:39:52 +01:00
Florian Schrödl
8490d2a18a
🔧 Tighten the token helper tests after review (#13242)
Follow-up to #13210, from its review. The warning and error message
tests now echo the translation arguments, so they fail when the value
goes missing from the message. The generic shape attributes also check
sizing, opacity and rotation, and the group renaming cases talk about
group membership rather than the group's name in the path.

The token tests now share one `tr` stub instead of three copies.

Signed-off-by: Florian Schroedl <flo.schroedl@gmail.com>
Co-authored-by: Eva Marco <eva.marco@kaleidos.net>
2026-11-24 10:24:56 +01:00
Alonso Torres
70c37934af
✨ Expose the file features and active renderer to plugins (#13169)
Plugins and the MCP could not tell whether the new render engine (WebGL)
or the SVG engine draws the open file.

Add file.features with the sorted features of the open file: its stored
features plus the features active in the session. render-wasm/v1 comes
from the session alone, so it is present only when WebGL draws the file,
whether the renderer comes from the wasm query param, the profile setting
or the workspace menu. The backend never stores that feature on the file,
so the stored features alone cannot answer it. For any other file, such
as a library or a File kept after opening another file, features is null.

Add penpotUtils.isWasmRenderer() to the MCP plugin and list it in the
MCP instructions. It throws a clear error when the Penpot version does
not expose the file features. Regenerate the MCP API docs, which also
picks up the missing penpot.location entry, and the plugin API test
suite surface.

Add plugin API test suite tests for the open file and for a file that is
not open. Note in the plugins memory that every new or changed Plugin API
member gets a suite test whenever the suite can reach the case.

Closes #13167

AI-assisted-by: claude-opus-5-5
2026-11-23 15:58:41 +01:00
Luis de Dios
340f5e36cf
🐛 Fix batch edit of colors in the selected colors menu (#13087)
* 🐛 Fix batch edit of colors in the selected colors menu

Restore the colorpicker flag that commit 20d2d22 lost when it replaced
the flag with the row index. Every change was treated as a picker change,
so the colors already applied were kept and reused by the next edit. That
made an edit on one row change the first color instead.

Direct edits of the color and opacity inputs now target the exact color
of the row. Picker changes keep the previous-color fallback needed while
the selected shapes are still updating.

Add unit tests for the new operation resolver.

AI-assisted-by: deepseek-v4.1-flash

* ♻️ Remove unused picker history from token detachment

Resolve token detachment operations directly from the current groups.

Picker color history is not needed for token detachment.

AI-assisted-by: gpt-6-luna

* ♻️ Clarify color row change arguments

Bind the row color once and name the change arguments.

Treat the picker flag as optional for direct edits.

AI-assisted-by: gpt-6-luna

* 🐛 Fix linting issue
2026-11-23 13:01:35 +01:00
andrés gonzález
3346c67a3b
✨ Add Copy link to the file and project menus in the dashboard (#13200)
Both menus get a Copy link option after Move to. The file menu copies
the workspace URL of the file and the project menu the URL of the
project page, then show a confirmation toast. A copy error shows a
toast that closes on its own; errors that are not clipboard ones are
also logged.

Also tidy both menus:
- Add a separator before Import Penpot files in the project menu.
- Rename "Open file in a new tab" to "Open in new tab".
- Add a separator before the download option in the multiple files
  menu, as in the single file menu.
- Show Pin or Unpin depending on the project state.

Viewers already had no project menu in the project list and on the
project page. Disable it, and rename on double-click, for pinned
projects in the sidebar too, so viewers can copy file links but not
project links. The user guide documents both options.

New translation keys are in en and es only.

Closes #13182

AI-assisted-by: claude-opus-5-5
2026-11-23 12:21:02 +01:00
Alejandro Alonso
5c768aeca0
🐛 Skip WASM font checks while the renderer is not live (#13235)
Page switches tear down the WebGL canvas before openPage resolves, so
font-stored? must not call _is_font_uploaded against a null resource
pool. Guard with wasm/live? like the other font FFI helpers, and cover
the skip path with a unit test.

Closes #13205
2026-11-23 12:01:10 +01:00
Florian Schrödl
888e2d9368
🔧 Test applying dimension and spacing tokens (#13215)
Covers how dimension, spacing and sizing tokens change position,
corners, stroke sides, paddings, gaps, margins and size limits, the
fallback to the closest font weight with its warning, and detaching
tokens from attributes without knowing the token.

The sizing test in token_actions_test now applies the token through
the function the app uses for sizing tokens, not the dimensions one.

Signed-off-by: Florian Schroedl <flo.schroedl@gmail.com>
2026-11-23 10:44:20 +01:00
Andrey Antukh
35a7189682 Merge remote-tracking branch 'origin/staging' into develop 2026-11-23 10:08:48 +01:00
Andrey Antukh
174596db1d Merge remote-tracking branch 'origin/main' into staging 2026-11-23 10:08:15 +01:00
Florian Schrödl
f216ae921d
🔧 Add tests for token helpers (#13210)
Covers the error and warning messages, how token values and color
bullets show, which token attributes each shape type takes, group
and set renaming helpers, and the duplicated set id migration.

Signed-off-by: Florian Schroedl <flo.schroedl@gmail.com>
2026-11-23 09:57:17 +01:00
Andrey Antukh
0572645d97 🔧 Fix CI module commands
Set a default key for exporter tests and use the library format script.
Add dry-run tests for both commands. Format the backend merge resolution.
Align the token test with its selected fixture.

AI-assisted-by: gpt-6-luna
2026-11-20 17:55:33 +00:00
Andrey Antukh
adb61a9b96 Merge remote-tracking branch 'origin/staging' into develop 2026-11-20 17:58:20 +01:00
Andrey Antukh
f27bfdf76a
♻️ Reduce the routes, viewer, theme and typography e2e specs (#13059)
* ♻️ Reduce the routes, viewer, theme and typography e2e specs

The five specs of Task 10 (routes, theme, viewer and roles) go from 14
tests to 6, and the two of Task 11 (missing font and add typography)
from 9 to 4. Nine unit tests cover rules that had none: five for the
private legacy-match and four for the viewer frame navigation. No
skipped test and no fixture removed.

The browser keeps the wiring: the known and unknown hash as two steps
of one test, the theme applied live without a reload, the viewer role
walked in two loads with the context menu counted instead of trusted,
and the typography states merged around shared fixtures. The viewer
zoom click comes back as a header step; the arrows e2e becomes unit
tests, with the Next button still clicked by the child-click test. The
missing-font test asserts the renamed, disabled typography button
instead of a hidden one it never described.

WorkspacePage gains reloadWorkspace, which clears the socket registry,
reloads and reopens the mock, and settles on the sitemap page name or
on the canvas when the restored sidebar tab hides it. layerRow matches
rows by anchored text, because a selected row's action buttons can join
its accessible name, and selectLayer accepts click options for the
shift-click steps. The font specs use both and no longer import
MockWebSocketHelper.

The viewer role asserts its two absences by testid: new-project-button
already existed and add-custom-font is new in fonts.cljs, the only
product change, with the visible side covered by dashboard.spec.
routes_test adds the path-params case for legacy-match; viewer_test
asserts the first event and the page id of the frame navigation, and
watch-events delivers asynchronously and handles the nil a watch can
return.

Measured at four workers: 23 to 10 tests; Task 10 from 141.3 to
68.5/72.3 worker-seconds and Task 11 from 150.1 to 109.0/109.3.

Closes #13058

AI-assisted-by: deepseek-v4.1-flash

* 🐛 Let the two reduced e2e steps fail when they should

The typography step selected the next layer with Shift, which in the layers
panel is a range selection: the range also brought in the text with a
typography token, so the button was hidden by the applied token and not by
the mixed values. A mod-click adds only that shape, and two new assertions
keep the token and the asset texts out of the selection.

The logo step clicked 100 px below the logo and asserted the URL, which
potok updates after the click returns, so the assertion matched the old URL
on its first poll. Probing elementFromPoint under the logo answers the
hit-area question directly.

AI-assisted-by: deepseek-v4.1-flash
2026-11-20 17:41:43 +01:00
Andrey Antukh
1439bc7605
♻️ Cut the shortcuts and inspect tab e2e specs (#13010)
* ♻️ Cut shortcuts and inspect e2e specs and harden their assertions

Shortcuts spec: drop the enable-custom-shortcuts mock, since no frontend,
common or backend code reads the flag, and cut 18 tests to 6. A header
comment records where the removed rules went: named steps here and the
77 unit tests of settings_shortcuts_test.cljs. The six keep only what a
browser proves: the file input and diff modal, the alert for a file with
nothing to apply, the download of a bound and an empty entry, the RPC
write with reload, the conflict that disables the previous binding, and
both reset flows.

Fix the shortcuts review findings: the invalid-file step dismisses the
timeout-free toast before the next import and covers both removed payloads
in one import. The conflict test records a default-bound and a custom-bound
key on one page load, then resets and imports a key a default binding
holds, so the diff modal's apply path runs with a default in the way, and
checks the alert, the disabled row and the exported payload; the export
test resets and imports the file it just downloaded.

Inspect tab spec: cut 27 tests to 8 with 25 named steps, from 622.9 to
181.5 worker-seconds and 162.5 to 46.7 seconds of wall time. Layout,
shadow and blur, fill, stroke, typography and clipboard cases run as steps
in one page load per group; the two cases that mutate the shape with
Design-tab controls keep their own. Replace 500 ms sleeps with waits on
rendered state, make layer expansion idempotent, match layer names exactly,
poll row counts and await every matcher. Drop the false comment about name
capitalisation, the three unused shapeToLayerName entries and the skip the
"Layer info" assertion now covers.

Move layerRow and selectLayer into WorkspacePage with the helpers the next
PR in the stack needs: layerRow matches an anchored name on the layer-row
test id, because a selected row's hide and lock button titles join its
accessible name, and selectLayer waits for aria-checked instead of the
shape name. waitForSelectedShapeName takes options. The inspect spec drops
its escapeRegExp, getLayerRow and inline selection. Rename the fixture
token to radius-md so the radius assertion is not satisfied by the row
label.

Closes #13009

AI-assisted-by: deepseek-v4.1-flash

* 🐛 Pass the translation flag in the sync text undo test

The merge of staging into develop brought back the required :translation
key of an undo entry, and the test added in ef0333eafe calls append-undo
without it. check-undo-entry throws, the exception escapes the promise
and the whole frontend run exits before printing the summary.

The entry stands for the commit of a component sync, which is not a
translation, so it carries :translation false, the value the production
watcher derives from the commit.

AI-assisted-by: deepseek-v4.1-flash
2026-11-20 15:52:00 +01:00
Pablo Alba
c9c9a574a0
🐛 Repair variant property set when removing a property (#12960)
* 🐛 Repair variant property set when removing a property

Removing a property could leave two variants with the same value
combination. The remaining property vectors now go through
ctv/sanitize-properties-set, and each main's variant name is refreshed, so
the set stays valid, as the 0038 migration leaves it.

On a clash, the variant higher in the layers panel keeps its values and
the lower one gets a " (n)" suffix. The plugin docs for removeProperty
say so.

The rename-in-layers path removes properties that are empty in every
variant. That cannot make two variants equal, so it skips the clean-up:
a duplicate made by the rename stays and its warning shows.

Closes #12959

AI-assisted-by: claude-opus-5-5

* 🐛 Keep the top variant on a clash in migration 0038

Migration 0038 cleaned the members of a set in :shapes order, so on a
value clash the bottom variant in the layers panel kept its values and
the top one got a " (n)" suffix. The top variant is the primary one, and
removing a property already keeps it. update-variant-container-properties
now passes the members top first, so both paths agree: the primary
variant keeps its values and its property names lead the set. 0038 is
not in a release yet, so it changes in place.

The removeProperty plugin docs now cover three or more clashing variants
and all-blank values, and the plugins CHANGELOG has an entry for the fix.

AI-assisted-by: claude-opus-5-5
2026-11-20 15:35:40 +01:00
Alonso Torres
84a7471ea2
🐛 Keep the MCP connection when an account first leaves the workspace (#13192)
The MCP controller restarts its runtime when the profile id changes, and
it compared ids by object identity. Leaving the workspace clears the
transit uuid cache, and on the first visit it also saves the
workspace-visited prop, which reloads the profile. The reloaded id came
back as a new uuid instance, so MCP init ran again: it closed the plugin,
dropped the WebSocket and left the new plugin disconnected.

Compare profile ids by value, and add a regression test that sends the
same id as two distinct uuid instances.

Closes #13128

AI-assisted-by: claude-opus-5-5
2026-11-20 14:13:55 +01:00
Florian Schrödl
3c4ae62db5
⚡ Resolve tokens incrementally with tokenscript (#12437)
With the tokenscript flag every resolution rebuilt the whole library:
each sidebar render, each propagation and each keystroke in a token
form. The adapter now keeps the interpreter state of the last
resolutions and updates it with set-sets, so only the tokens that
changed and their dependents are re-resolved and converted. Every other
output token stays the same object.

- common/deps.edn moves penpot/tokenscript-interpreter to v0.3.0:
  token readers and writers and a set-sets that looks only into changed
  sets (#1), on top of the DTCG import and export (#4) Penpot already
  uses.
- The sidebar, token propagation, token application and the plugin API
  pass the active sets unmerged (cfo/get-active-token-sets and its
  force variant); the interpreter merges them. The plugin API's own
  resolution cache is gone.
- The adapter hands Penpot's token records to the interpreter with a
  reader (value and DTCG type, an error for a token without a value)
  and a writer (the conversion to :resolved-value or :errors), which
  runs only for the re-resolved names.
- The cache resolves new sets from the last resolution with the same
  set ids, else from one sharing a set id, else from scratch.
- The token form controls resolve the draft in a set of its own on top
  of the library's sets, the selected set last
  (cfo/get-token-sets-for-edit). The form leaves the edited token's old
  name out of them (cfo/without-token). A keystroke re-resolves only
  the draft and its dependents. The last draft is cached apart, so
  typing doesn't evict the sidebar's resolutions. Without the flag the
  controls don't build these sets. The plugin API's token name and
  value setters validate the candidate the same way.
- The token form hint shows resolved font families as a name list.
- Tests cover the unmerged set helpers, a plugin rename to a name below
  the old one (which needs the old name left out), and compare renames,
  with and without updating the references, against StyleDictionary.

Signed-off-by: Florian Schroedl <flo.schroedl@gmail.com>
2026-11-20 13:54:15 +01:00
Andrey Antukh
d6e816daa0
✨ Cover subscription rules with unit tests and trim e2e specs (#13006)
Move the pure subscription rules out of the browser specs and into unit
tests, then keep only the cases a browser can prove.

- Extract show-manage-subscription-link? and show-main-menu-power-up? from
  the dashboard team panel and the workspace main menu, and use them at
  both call sites. A new subscription_dashboard_test.cljs covers which
  plan a subscription reads to, including unpaid and canceled demotion, the
  owner and enterprise sides of both affordances, and the banner and
  members-CTA boundaries: four editors over the seats, no usage data, and
  the demoted plans.
- Add get-versions-stored-days tests to workspace_versions_test.cljs: an
  active nitrate or enterprise license keeps 90 days, a canceled one lets
  the team plan decide, a license without the admin console does not count,
  and unlimited, enterprise, professional and planless teams keep 30, 90
  and 7 days.
- Rewrite the profile usage tests as async tests with mock/with-mocks* and
  an async transport double: the editors from the usage call reach
  [:props :subscription :editors], a failing call leaves the profile
  untouched and logs once, and the call is skipped without the
  subscriptions flag.
- Cut the e2e suite from 13 cases to 7. Five dashboard cases keep the menu
  icon, the two sidebar plan names, the owner-only settings link and the
  members CTA; two workspace cases keep the translated days warning with
  the upsell step and the enterprise menu with no upsell. Assert the
  unlimited glyph and drop the CTA count.
- Drop the three get-team-info mocks the dashboard never calls and six
  unreferenced subscription fixtures, reusing the invitations fixture.
- Sort the subscription test requires in runner.cljs: cljfmt's
  :sort-ns-references? wants subscription-dashboard-test first.

Closes #13005

AI-assisted-by: deepseek-v4.1-flash
2026-11-20 13:45:59 +01:00
Pablo Alba
2f86049377 ♻️ Address review of the nested swap slot fixes
When pasting, read each child to advance from the objects being built,
not from the page, so a later change to the parent cannot make it read a
stale shape.

Fix the docs of ignore-children-fn in get-children-ids and delete-shapes:
it receives a shape id, not a shape.

Add a unit test for ctf/get-swap-level, a paste test where the swap sits
at the last level the copied head drops, and a detach test where the
swapped copy sits under two non-swapped nested copies.

AI-assisted-by: claude-opus-5-5
2026-11-20 11:41:37 +01:00
Pablo Alba
ad4359efec 🐛 Keep swap slots when pasting a nested copy with a swapped component
Copying a copy nested inside another copy moved the shape-ref of every
shape under it up by the same number of levels. Below a nested copy that
was swapped in one of the dropped levels that count is too high: the swap
already points it into the swapped-in main, so its children ended up one
level too far and the paste failed to save with :missing-slot.

Count the levels per nested head instead, stopping at the level where it
was swapped (new ctf/get-swap-level), for the copied head too. The ref
chain used to collect touched flags now also follows deleted components,
like advance-shape-ref already did, so inherited slots are kept.

Closes #13076

AI-assisted-by: claude-opus-5-5
2026-11-20 11:41:37 +01:00
Andrey Antukh
d446926202
🐛 Fix compile warnings in the frontend test tree (#13109)
* 🐛 Fix compile warnings in the frontend test tree

The frontend test build printed 25 analyzer warnings, all of them in test
namespaces: 7 :fn-arity and 18 :infer-warning.

The arity ones were latent bugs. Both builds use the :esm target, where a
call that crosses a namespace boundary becomes a plain JS call, so CLJS
arity dispatch never runs and the missing argument arrives as undefined
instead of throwing: the warning was the only signal. One `wait-for` call
had no message, and five `interaction-proxy` calls still passed five
arguments after the six-argument signature landed in #11621.

The rest were JS property reads whose target type could not be inferred
(proxies, atoms, awaited promises). A `^js` hint on the target fixes them,
the convention already used under src/. Inside `set!` a form-level hint
does not reach the target, so the two per-side stroke widths bind the
stroke first.

Test behavior is unchanged: the same 27 tests in shape-bugfixes-test keep
their 63 assertions, and the full frontend suite passes (1901 tests, 7686
assertions). The memories record why `:fn-arity` cannot be ignored in this
build and how to force a clean recompile before checking for warnings.

AI-assisted-by: deepseek-v4.1-flash

* ♻️ Split the tokens plugin tests into one test per case

`tokens_test.cljs` drove five tests from `doseq` tables, one of them a
nested loop over three catalogs and seventeen mutations. A failure only
named the case through its `t/testing` label, and the nested one shared a
single store across all fifty-one combinations.

Each row is now a test of its own: twelve stroke property edits, four
`tokensSource` rejections, seventeen catalog mutations (each asserting the
local, source and other connected catalog), five activation changes and
three token application paths, taking the namespace from 67 to 104 tests.
Fixtures (`stroke-tokens-fixture`, `external-tokens-fixture`, ...) keep the
arrangement in one place, and every test builds a fresh store.

Two helpers return JS objects with `^js` on their names, so the test bodies
stay free of interop hints. Assertions drop from 430 to 345 because the
cross product no longer repeats `isEditableTokens` and `tokens-unchanged?`
once per catalog and mutation; every write is still asserted against the
three catalogs.

`mem:testing` now says tables are for short identical bodies only;
`frontend/testing` records the `defn ^js` return-tag trick.

Verified: namespace 104 tests / 345 assertions, full frontend suite 1938
tests / 7601 assertions, 0 failures; test build 0 warnings; cljfmt and
clj-kondo clean.

AI-assisted-by: deepseek-v4.1-flash

* 📎 Apply suggestion from @elenatorro

Co-authored-by: Elena Torró <elenatorro@gmail.com>
Signed-off-by: Andrey Antukh <niwi@niwi.nz>

---------

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
Co-authored-by: Elena Torró <elenatorro@gmail.com>
2026-11-20 11:30:59 +01:00
Andrey Antukh
15a099f118 Merge remote-tracking branch 'origin/staging' into develop 2026-11-20 09:54:54 +01:00
Filip Sajdak
c40287254c
✨ Explain why a library cannot be disconnected in its modal (#12921)
* ✨ Explain why a library cannot be disconnected in its modal

A library that another connected library uses cannot be disconnected from
a file, but the Libraries modal showed it with the same disconnect button
as any other library, only disabled, and said nothing about why.

Replace that button with an icon and a tooltip. A nested library ("Connected
through ...") says it is inherited from its parent, and a direct library
that another connected library uses says which one. Both name the library
to disconnect first. A library nothing else uses keeps its button.

library-disconnect-hint decides the case from the same data the disabled
state used, so the buttons that were disabled are the ones that change.
The legacy libraries tab keeps its button.

Closes #12838

AI-assisted-by: claude-opus-5-5
AI-assisted-by: claude-sonnet-5-5
Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>

* 🐛 Name every library to disconnect in the disconnect hint

The hint named only the parent of a nested library as the one to
disconnect. That was wrong when several libraries use it (disconnecting
one leaves it linked through the others) and no help when the parent is
nested too and has no disconnect button either.

The removal step now lists the libraries the user can actually disconnect:
those that use the library directly or through others, and that no linked
library uses. The parent is still named as the reason it is inherited. In
a cycle nothing is removable, so the parent is named as before.

Tests cover a shared dependency, a deep chain and a cycle.

AI-assisted-by: claude-opus-5-5
AI-assisted-by: claude-sonnet-5-5
Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>

* 🐛 List directly linked libraries in the disconnect hint

A library linked to the file directly stays until the user disconnects
it, even when another linked library uses it. The hint skipped those: for
a file linked to A and B, with A using B and B using C, it told the user
to disconnect only A, and C stayed linked through B.

Collect the libraries that use it, however far up, and that are either
linked directly or used by no linked library. A directly linked library
that another one uses cannot be disconnected yet, and its own tooltip
says to disconnect that one first.

The test covers a directly linked intermediate library.

AI-assisted-by: claude-opus-5-5
AI-assisted-by: claude-sonnet-5-5
Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>

* 🐛 Count a library linked in this session as direct in the hint

Only the libraries fetched when the workspace opens carry :is-indirect.
One linked afterwards comes back without it, so the hint did not treat it
as directly linked: after connecting B (which uses C) and then A (which
uses B) without reloading, C's tooltip said to disconnect only A, and C
stayed linked through B.

A library the user linked has no flag and is direct by construction, so
only one known to be indirect is skipped.

The test covers that sequence.

AI-assisted-by: claude-opus-5-5
AI-assisted-by: claude-sonnet-5-5
Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>

* 🐛 Flag libraries linked in this session as direct or indirect

Only the libraries fetched when the workspace opens carried :is-indirect.
Linking a library afterwards loads it and its dependencies through
load-library-file, and none of them got the flag, so a missing flag could
mean either. The disconnect hint in the Libraries modal reads it to tell
which libraries the user can disconnect, and it listed the wrong ones for
a chain connected in the same session (it named a dependency that has no
disconnect button).

Set the flag where the library is loaded: the library the user links is
direct and the libraries it brings in are indirect. The hint is back to
trusting only a flag that says false, because a missing one no longer
means a direct link.

The test links a library with one dependency and checks both flags.

AI-assisted-by: claude-opus-5-5
AI-assisted-by: claude-sonnet-5-5
Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>

* 🐛 Keep a library's direct flag when it is loaded twice

When links overlap, a library can be requested twice: once because the
user linked it and once because a library linked right after brings it
in. Each load stored its own :is-indirect value, so whichever answer
landed last won, and an indirect one could erase the direct link. The
disconnect hint then listed the wrong libraries.

Store a loaded library through one event that never turns a known direct
link into an indirect one. The reverse order already ends direct, since
the user's link is stored with the flag false.

The test links a library and then one that uses it before the first
answer arrives, and answers in the order that used to lose the flag.

AI-assisted-by: claude-opus-5-5
AI-assisted-by: claude-sonnet-5-5
Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>

* 🐛 Scope a library's kept direct flag to the file it belongs to

The flag kept when a library is loaded twice was read from :files, which
outlives a workspace. A library that was a direct link of the file visited
before could keep that flag in the next file, where another library only
brings it in, and the disconnect hint then listed one library too many.

Keep the flag only when it was recorded for the file being loaded, using
the :library-of the entry already carries.

The test leaves a library flagged direct for another file and links a
library that brings it in.

AI-assisted-by: claude-opus-5-5
AI-assisted-by: claude-sonnet-5-5
Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>

* 💄 Name the libraries in the disconnect hint as design asked

The nested library hint now reads "Connected through <parent>. To
remove it, disconnect <libraries>." instead of "Inherited from ...".
The library names in both hints (connected through and used by) show
in the primary foreground color, so they stand out from the text.

The translation is split on its two placeholders instead of rendered
as HTML, because the library names are written by users. The full
plain sentence stays as the aria label of the icon.

The new key is workspace.libraries.connected-through-hint, since
workspace.libraries.connected-through already labels the parent in the
list.

AI-assisted-by: claude-sonnet-5-5
Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>

---------

Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>
Co-authored-by: Eva Marco <evamarcod@gmail.com>
2026-11-20 09:49:28 +01:00
Filip Sajdak
454e461c1e
✨ Copy stable deep link to selected boards from context menu (#10170)
* ✨ Copy stable deep link to selected boards from context menu

The workspace "Copy link" action copied the raw current location, which
only carries file and page ids, so the link did not point at any specific
board. Build the link from the current route plus a `board-id` query param
derived from the selection: a selected board contributes its own id, and a
selected shape contributes the id of the board it belongs to.

`board-id` is an existing workspace route param (`zoom-to-frame` already
selects and zooms to it on load), and board ids are stable across renames
and reordering, so the link keeps resolving to the same board. When the
selection contains no board, it falls back to the previous behavior.

Relates to #4584

AI-assisted-by: claude-opus-5-5
Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>

* 📎 Add tests for copying a stable board link

copy-link-to-clipboard now links to the boards of the selection through
their ids, and nothing covered it. The tests run the event on a state
with two boards, a rectangle in each and a rectangle on the root, with
the router and the clipboard replaced.

They check that a selected board, and a shape in a board, link to that
board; that shapes in two boards link to both and a board with its child
gives one id; that the route params are kept next to the board ids; and
that an empty selection, or a shape on the root, copies the current
location. The five board cases fail on the version of the function before
the change.

AI-assisted-by: claude-opus-5-5
AI-assisted-by: claude-sonnet-5-5
Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>

* ♻️ Share how the selection maps to its boards

select-shape and copy-link-to-clipboard each worked out which boards
a selection belongs to, with slightly different rules for a shape on
the root. Both now call selected-board-ids.

A selection with a shape on the root has no board to point at, so the
URL and the copied link both leave out the board ids. Before, the
copied link kept the boards of the rest of the selection. The URL also
lists each board once now, and has no board-id for an empty selection.

AI-assisted-by: claude-opus-5-5
Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>

---------

Signed-off-by: Filip Sajdak <filip.sajdak@siili.com>
Co-authored-by: Eva Marco <eva.marco@kaleidos.net>
2026-11-20 09:47:11 +01:00
Pablo Alba
6d0be9f47f 🐛 Undo a main text edit and its follow-up sync in one step
After a font size change on a main text, the main resizes itself in a
commit that stacks onto the edit's undo entry. That commit still took
the group its undo transaction was opened with, and the component sync
it starts inherited that group. So the sync became a separate undo
entry: the first Ctrl+Z undid only that sync, the copies were measured
again right away, and nothing visible changed. The user had to press
Ctrl+Z twice to undo the edit.

A stack-undo? commit that records undo (save-undo? and undo changes,
the same test the history watcher uses) and has no undo group of its
own now takes the group of the entry at the current undo index. The
commits it starts, such as the component sync, inherit it, so one
Ctrl+Z reverts the edit, the resize and the sync.

A stacked commit that records no undo joins no entry, so it keeps a
group of its own: the automatic text heals must not take the rollback
unit of the user's last action. A stacked commit that joins an open
transaction that already holds changes keeps the transaction's group,
as append-undo adds it to the transaction.

The rule for commit groups in
mem:frontend/workspace-state-persistence-subtleties now includes the
stacked-entry step.

Tests: frontend-tests.data.workspace-undo-test covers a stacked commit
with no transaction, in an empty transaction and in a transaction that
already holds changes; a stacked commit that records no undo; and one
undo over an edit, its stacked commit and a follow-up commit of the
same group. frontend-tests.data.workspace-heal-undo-test drives the
real resize-text and component watcher on a main text with a copy:
one undo reverts the edit, the resize and the syncs on both.

Closes #13207
Relates to #12721
Relates to #13065

AI-assisted-by: claude-opus-5-5
2026-11-19 23:33:24 +01:00
Pablo Alba
8a9e87e33e 🐛 Skip WebGL auto-grow heals for texts with a failed font
On the WebGL renderer, a face that failed to load counts as ready,
because WASM lays the text out with a fallback font. The page-open
check skipped only texts waiting for a font, so it measured texts with
a failed face using the fallback and saved that size with no undo
step, on every page open. A team font that was deleted or returns 404
changed the size of every auto-grow text using it.

The check after fonts load had the same problem: a face that was
pending at page load and then failed was measured with the fallback
and resized, also without undo.

Both checks now skip texts that use a failed face, as the SVG :check
phase already does. The font relayout still runs for them, so they
show in the fallback font, but their stored size stays as it was.
app.render-wasm.api.fonts/font-failed? reports a failed face, and
shape-ids-for-failed-fonts finds the texts that use one.

Tests: frontend-tests.render-wasm.stale-text-selrects-test covers a
page load and a font load where one stale text uses a failed face;
only the other text is resized. The tests now mock font-failed?, so
they do not read failed faces left by other tests.

Relates to #12721

AI-assisted-by: claude-opus-5-5
2026-11-19 21:12:21 +01:00
Pablo Alba
ef0333eafe 🐛 Fix auto-grow text sizes after sync and page open
On the WebGL renderer, a sync re-measure of copies shared a 40 ms
batch with user resizes of the main text. The batch skipped the
component sync when any request asked for that. So a resize of the
main (grow type, font size, paste, search and replace) often never
reached copies on other pages or in other files, and the viewer and
exports showed the old size.

A batch now skips the sync only when every request asks for it, the
same rule as :save-undo?. Such an edit costs one extra short sync
round. That round holds only skip requests, so it stops after one
pass.

A copy that the sync switched from fixed to auto-grow was never
re-measured, because the check read the grow type before the sync.
The check now reads the grow type that the change sets. A copy that
the sync makes fixed is not re-measured.

A sync started without an undo group (library update dialog, color
and typography sync) committed with a fresh group, and its re-measure
and layout pass took other ones. Ctrl+Z first undid only the
re-measure and left the copies in the old box. The sync now picks its
group when it runs: inside an undo transaction (color, typography and
asset deletes) it takes the transaction's, otherwise a fresh one. The
re-measure and layout pass share it, so one undo reverts the edit, the
sync and its follow-ups, and a failed save rolls them back together.

On the SVG renderer, opening a page resized a copy with no position
data even when its size had not drifted. Measured sizes round up, so
17.4 became 18. The measurement from that resize then landed on the
user's last undo entry. The heal now reports whether it resized, and
the check phase resizes only when the size drifted.

The SVG page-open check covered only texts with overridden content.
A copy loses its touched flags, so a label overridden inside a main
(a Button label in a Card main) was never checked in the main's
copies, and its heal skips the component sync. The check now covers
every auto-grow text inside a copy, as the WebGL check does. The
heal's reflow now skips the component sync too: without undo it
touched the main component on every page open.

A page-open check measured with a font that failed to load wrote the
fallback font size. It now writes no size then; a copy without
position data still gets it. The WebGL and SVG renderers can measure
a text differently; a gap over 1 px makes each page open by a user of
the other renderer write the size back. Two browsers on the SVG
renderer can do the same: a long auto-width line can differ by more
than 1 px, and an auto-height text can wrap a line differently. This is
a known limit, noted in the text-heal docstring.

The drift check moves to text-size-drifted? in
app.common.geom.shapes.text, and takes a tolerance. Both renderers use
it: 1 px for the SVG check and the WebGL page-open check, 0.1 px for
the WebGL font-load check. The WebGL check did not skip axes that fill
their layout parent, so those texts looked stale on every page open
and were resized for nothing. It now reads the stored width and height
and skips fill axes.

The sync docstring and a test message gave the wrong reason for
:skip-component-sync?. :ignore-touched stops the resize from marking
:geometry-group. :skip-component-sync? stops the re-measure commit from
starting another sync. "Remasure" is now "re-measure" in
identifiers, test names and comments. The sync docstring now states
that an auto-grow copy takes the main's size on each geometry sync,
also with overridden content, until the re-measure or the page-open
check corrects it. The sync's undo comment no longer says the layout
pass gets the sync's undo group: the layout buffer drops it, and the
pass joins the same undo entry through :stack-undo?.

Tests: heal undo tests cover mixed user and sync batches in both
orders, and undo for both renderers. A heal leaves the undo stack
unchanged, and undo reverts the user edit. A heal reflow skips the
component sync. Sync tests cover a copy that becomes auto-grow
(re-measured) and one that becomes fixed (not), and a sync with no
undo group that shares one with its re-measure, also inside an undo
transaction, with and without a group of the edit. Viewport tests cover
no resize without drift, a drifted copy that resizes and settles, the
check of every auto-grow text in a copy, and no size write from a
failed font. Component tests mount the SVG renderer: a drifted copy is
measured once to check and once to settle, with no undo step, and a
matching copy is measured once. Stale-selrect tests cover skipped fill
axes. The drift tests move to common-tests.geom-shapes-text-test, with
tolerance and grow-type cases.

Relates to #12721

AI-assisted-by: claude-opus-5-5
2026-11-19 21:12:21 +01:00
Pablo Alba
2964e88a8c ⚡ Re-measure auto-grow texts only on size changes
On the WebGL renderer, a sync from a main component re-measures every
auto-grow text it changes on the page. The sync runs on every edit to
a main component, so an edit that cannot change a text size, such as
opacity, shadow or text color, still re-measures and re-lays out every
synced text.

The sync now re-measures a text only when the change sets an attribute
that can change its size: :grow-type, :width, :height,
:layout-item-h-sizing, :layout-item-v-sizing, or :content that differs
in more than its fills. A text color change reaches copies as a
:content change, so fills are removed from both contents before
comparing. Sync emits operations only for attributes that changed, so
the operation attributes are enough. Moves (x and y only) do not
re-measure.

Tests: frontend-tests.data.workspace-sync-text-wasm-test adds cases for
a fill change and an opacity change on the main text (no re-measure),
and for a font size change and a width change on an auto-height text
(re-measure).

Relates to #12721

AI-assisted-by: claude-opus-5-5
2026-11-19 21:12:21 +01:00
Pablo Alba
0e103fb215 🐛 Skip undo step for SVG auto-grow heal resizes
On the SVG renderer, opening a page measures auto-grow text copies
with overridden content and writes back their size and position data
when they drifted. The write went through the normal text commits,
which stack onto the user's last undo entry. So the first Ctrl+Z after
opening a page also reverted the heal.

A component sync also set the position data of a copy to nil, even
for a fill change on the main. Such a copy skipped the check and went
through the normal path, with undo.

Heal requests now take :save-undo? false. resize-text and
update-position-data accept optional opts, and a request with
:save-undo? false marks its text as a heal for the current batch. A
later user request for the same text in the batch removes that mark.

The batch commit splits in two. User texts commit as before. Heal
texts commit with :save-undo? false and :skip-component-sync? true,
so each copy heals on its own page open instead of syncing.

The heal resize asks for the parents' reflow with :save-undo? false.
The layout buffer lays out heal updates apart from user ones and
passes the flag to apply-modifiers, so the reflow records no undo
step either.

The :check phase also heals a copy without position data, with no
undo. When the size drifted, the text moves to a new :settle phase.
The measurement that the heal resize causes also commits without undo.

Known limit: when the heal's reflow moves the text (for example,
re-centering it in a flex parent), the renderer measures the text
again with no phase. That position-data commit still stacks onto the
last undo entry. Left for a follow-up.

Tests: frontend-tests.data.workspace-heal-undo-test (SVG store) covers
a heal resize with no undo, no component sync and a reflow without
undo; a heal and a user change in one batch; a user request after a
heal of the same text; and the layout buffer keeping a heal's reflow
apart. frontend-tests.ui.viewport-texts-html-test covers the options
each phase sends: drifted copy, matching copy, copy without position
data, unmeasurable text, settle, and no phase.

Relates to #12721
Relates to #13065

AI-assisted-by: claude-opus-5-5
2026-11-19 21:12:21 +01:00
Pablo Alba
c34cd056e4 🐛 Skip undo step for auto-grow heal resizes
On the WebGL renderer, the workspace resizes auto-grow texts whose
stored size no longer matches their WASM layout. This runs when a page
opens and when fonts finish loading. These resizes are not user
actions, but each one recorded an undo step. So the first Ctrl+Z after
opening a page undid the resize instead of the user's last edit, and
the copy went back to the wrong size.

The listener for the stale-text event now asks for the resize with
:save-undo? false. The flag passes through the resize debounce to the
commit, which hands it to apply-wasm-modifiers, so the shape update
records no undo step.

Resizes are batched in a debounce window. A batch skips the undo step
only when every request in it asked for that. A user resize that lands
in the same window keeps its undo entry. Batch options are now merged
for every request, including those without options, so this check
works.

Tests: frontend-tests.data.workspace-heal-undo-test covers a heal
resize that commits without an undo step, a resize without the flag
that still records one, a mixed batch that keeps the undo step in
either order, and a batch of heals that skips it.

Relates to #12721
Relates to #13065

AI-assisted-by: claude-opus-5-5
2026-11-19 21:12:21 +01:00