mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
005f4992a66016a4fa78d4fd41864e86f71acf73
435
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8454113d31 |
fix: Restore Tag selectors and speed up selection (#6679)
The Builder was stalling when selecting instances because Tag selector resolution repeatedly scanned and parsed project styles for every displayed property. This PR indexes that data when styles change, reuses style source suggestions, and avoids an unnecessary stylesheet rebuild on multi-selection. It also restores the documented `:hover .button` and `:hover > .icon` selectors, fixes their editing preview, and adds sharp light and dark Tag styles screenshots. Ref #5657 Closes #6678 ### Plan and tools - [x] Reproduce the selector rejection in shared validator and runtime tests. - [x] Restore one shared validation path for new and saved selectors. Keep CSS parsing through css-tree. - [x] Update Tag styles and States and selectors docs, navigation emoji, and paired Storybook screenshots. - [x] Measure the instance selection slowdown and remove repeated full scans while preserving source order. - [x] Audit the full selection path and reuse existing style indexes in state matching and style controls. - [x] Avoid redundant Tag CSS rebuild on multi-selection and test that real preview styles still clear. - [x] Fix descendant state previews for Token, Local, and Tag styles; verify live Tag editing. - [x] Run targeted tests, typechecks, lint, formatting, and inspect both screenshot themes. - [ ] Monitor PR checks and address failures. - [ ] Approve the new Storybook baseline after user review. Verification: CSS data 62 tests; project build styles 167 tests; Builder style panel/model 113 targeted tests; canvas selection and styles 89 targeted tests; CSS data/project build/Builder typechecks; lint; formatting. A local benchmark with 5,100 styles, 5,001 instance selections, and 100 property reads fell from 99 ms to 6 ms for reads after the second fix, plus 6 ms to build indexes when data changed. The original repeated style scan measured 716 ms for 100 reads with no instance selection map. These measure the affected calculation, not total Builder selection time. Two older selection-time style scans remain and cost about 0.1 ms each per 5,100 declarations in a synthetic Node scan; their output ordering needs a separate check before changing them. Previewing an unrelated Token or Local edit still rebuilds the Tag stylesheet, an editing-time cost outside the reported selection path. No fixture inputs or generated fixture bundles changed. Agent evaluations were not run because they require separate approval. |
||
|
|
b0d7cc2e7b |
fix: Show scoped Tag colors on selected descendants (#6677)
When an H2 gets its color from a Tag selector on its container, selecting the H2 can show black in the Style panel. The panel now shows the matching color. A Token or Local style on the H2 can still override the container's Tag selector. ## Plan and progress - [x] Reproduce the selected H2 showing the container color instead of its nested Tag color. - [x] Give descendant Tag selectors the intended CSS specificity in Builder and published CSS. - [x] Include matching ancestor Tag declarations in the Style panel's color calculation. - [x] Cover the selected H2 and regular and atomic CSS output with focused tests. - [x] Review documentation impact and update the Tag styles and selectors guides. - [x] Match the panel's competing ancestor Tag rules to CSS breakpoint and stylesheet order. - [x] Match the editing preview's selector specificity to the saved rule. - [x] Use the descendant separator directly when detecting nested selectors. - [x] Allow the same supported selector forms in Tag, Token, and Local sources. - [x] Match global Tag descendant styles in the editing preview and Style panel. - [x] Document nested Tag selector examples in the Tag styles guide. - [x] Explain supported selectors in Add more while its input is focused. - [x] Review and simplify nested state matching; preserve the entered selector text. - [x] Consolidate cascade declaration lookup and reuse the validated selector parse result. - [x] Align Builder and MCP selector entry with one validation rule; preserve saved selectors. - [x] Fix nested-selector source badges and preserve valid instance selection. - [x] Keep descendant conditions scoped to the matched element during inheritance. - [x] Match saved nested selectors regardless of tag casing or leading whitespace. - [ ] Verify both fixes, resolve review threads, and review CI. The panel model needs ancestor matching because it computes styles without querying the rendered element. The complete PR adds about 195 net non-test lines. The added work covers selector entry, active nested states, and matching Tag rules in the panel; the saved CSS output already supported nested tags. CSS generation uses `:where()` around the container selector so the nested tag can override the global tag style while the H2's own Token can override the nested tag style. No stored data changes. Checks passed locally: focused Builder style source, active state, panel model, and canvas preview tests; CSS data and runtime tests; Builder, CSS data, and project-build typechecks; lint, formatting, and `git diff --check`. The focused Add more menu was checked in Storybook in both themes. CI passed for commit `838cf4293f`; CI for `224f11e274` is pending. The full Builder app suite was started but stopped after it stopped producing results; the two affected suites passed independently. This follow-up adds 67 net non-test lines to track matching states by instance and match saved descendant selectors using the shared parser. No fixture inputs or generated fixture outputs changed. Ref #5657 |
||
|
|
2b9ce760bb |
feat: Add global styles with Tag styles (#6666)
## What this adds A developer can style an HTML tag once and have that style apply across every page, including content imported into Content Blocks. The selected element's matching **Tag style** appears first in Style Sources. Its chip is temporary; its saved styles remain global. ## Plan and todos 1. [x] Add a distinct `tag` style source with a fixed tag and ID. Create it on the first edit, without a migration or instance attachment. 2. [x] Emit Tag style CSS in the canvas and published output after presets and before instance styles. Keep normal CSS specificity and source order. Include global styles when collecting page assets. 3. [x] Show only the selected element's Tag style in the picker. Keep its temporary chip first and fixed, and identify it in the property source tooltip. 4. [x] Support scoped descendant tag selectors in ordinary tokens, while limiting Tag styles to states of their own tag. 5. [x] Regenerate the runtime contract and cover CSS output, selector validation, runtime updates, and style provenance with focused tests. 6. [x] Revalidate and version the eight stored fixture bundles for the renamed source type, then rerun fixture checks. 7. [x] Use the raw lowercase tag name as the Tag style label, use a singular picker heading, and fix scoped tag-state preview so only matching descendants are highlighted. 8. [x] Let Global root select and edit the `html` Tag style with the same temporary, fixed-first behavior as other tags. 9. [x] Name the feature Tag styles in the UI and code, and replace the draft-only saved type and ID. 10. [x] Rebase onto `main`, keep the publish CSS validation integration working, and move the PR to `5657.staging`. 11. [x] Review the new PR's CI and staging deployment. 12. [x] Make Tag styles discoverable through MCP, verify the existing edit path, and add focused coverage. 13. [x] Update Tag styles product docs and add paired light/dark screenshots. 14. [x] Pin the visual regression runner to supported Ubuntu and review the visual diff. 15. [x] Make the selected Tag style source distinct from unselected tokens in dark mode, review both themes, and refresh documentation screenshots. 16. [x] Copy and paste Tag styles through the style source menu, merging declarations into the matching tag with pasted values winning. 17. [x] Copy and paste Local styles into the selected instance’s Local source, merge with pasted declarations winning, and share one source-transfer command pair with Tag styles. 18. [x] Adjust the compact MCP schema size budget for the new source type input, then rerun the CLI schema test and CI. 19. [x] Add Tag style to the shared design-system style-source color and label variants, and use its shared color in the Builder. 20. [x] Restore the style source and input colors from `main`; use the Slot global color for Tag styles in Builder and design-system variants; refresh and review paired documentation screenshots. 21. [x] Monitor CI for `aba723fc0a` to completion. 22. [x] Address the four canvas cascade and live-preview review comments, add focused regression coverage, and verify the Builder and published CSS agree. 23. [x] Review documentation impact and monitor CI for the review fixes. 24. [x] Normalize the HTTP client paste-style-source result for Token clipboard data, preserve paste-design-token, and verify both response shapes. 25. [x] Use `tag` for Style panel items and verify the picker and menu. 26. [x] Check CI for the Style panel rename. 27. [x] Use `tag` across saved Tag style records, Builder items, and CLI and MCP inputs and results. Keep existing Tag style IDs and the CSS clipboard format. 28. [x] Regenerate runtime contracts and MCP docs, refresh fixture bundle versions, and verify the updated schema, CSS, and transfers. 29. [x] Check CI for the saved style source rename. 30. [x] Fix Select option descriptions clipping in narrow menus, allow wrapped descriptions to grow vertically, and review documentation impact (no docs update needed). 31. [x] Fix marketplace consent checkbox vertical alignment and keep checked and unchecked dimensions identical; add both states to Storybook and review documentation impact (no docs update needed). 32. [x] Resolve Tag-style review comments for selected-state cascade preview, active-state discovery, and html Tag CSS-variable clipboard dependencies. 33. [x] Describe Copy for Tag styles, disable copying empty sources, and keep the style source menu width stable while descriptions change. 34. [x] Increase the splash screen logo-to-progress gap by 8px in total. 35. [x] Align the style source menu to the chip’s left edge when space allows, and determine Copy availability from all saved declarations. 36. [x] Keep arrow-key navigation inside the open style source menu so it does not toggle the combobox. 37. [x] Move focus left and right across source chips, input, and Local at the matching caret boundaries. 38. [x] Preserve instance-style precedence while previewing ephemeral Tag-state edits. 39. [x] Synchronize temporary Tag style selection to the canvas so saved Tag-state previews render. 40. [x] Keep the selected Tag style in autocomplete and ensure keyboard events reach the combobox once. 41. [x] Show a 1px keyboard focus outline one pixel outside each style source chip, and open the focused source’s menu with Arrow Down. 42. [x] Preserve Tag-state preview precedence across breakpoints and include matching Tag states without requiring the temporary chip. 43. [x] Rename the autocomplete section labels to “Tag” and “Tokens.” 44. [x] Return focus to the input when Escape closes a style source menu. 45. [x] Rename Tag style color recipe and design-system variant keys from `tagStyle` to `tag`. 46. [x] Review and simplify style-source changes while preserving keyboard behavior. 47. [x] Simplify style source menu alignment offset arguments to numbers. 48. [x] Import React’s `KeyboardEvent` type directly without an alias. ## Deferred and blocked - **Agent evaluations:** Repository guidance requires separate approval before running them. ## Technical choices and compatibility Tag styles use the same global purple and contrasting text as Slot outlines. The style source field, inactive chips, and their hover behavior match `main`; the earlier neutral color experiments in this PR are superseded. Tag styles are saved with `type: "tag"` and an ID such as `tag-style:button`. Projects from released versions need no migration. Draft development records with `type: "tagStyle"` are incompatible with this revision. They emit CSS even when no instance uses them. Ordinary tokens still need an instance selection and can target descendants such as `.card p`. The CSS cascade decides conflicts; there is no custom priority rule. Token, Tag, and Local styles share the existing `copy-design-token` and `paste-design-token` MCP/CLI commands. Copy accepts `styleSourceId` and `sourceType` (`token`, `tag`, or `local`). The older `tokenId` input remains valid. The CSS clipboard payload identifies the source type on paste. Tokens still create a numbered copy. Tag styles merge into the matching global tag, and Local styles merge into the selected instance’s Local source, creating it when needed. Pasted declarations win for matching properties, states, and breakpoints. All three share asset and breakpoint transfer. The original Tag style feature added about 435 net non-test lines. This follow-up reuses the Token transfer path for Tag and Local styles and adds no new MCP/CLI commands. Older clients that do not recognize the new source type may need to update before editing a project that contains Tag styles. ## Verification - Imported React’s `KeyboardEvent` type directly; no alias is needed. Oxfmt and `git diff --check` passed. - Replaced `Pick<DOMRect, "left">` alignment-helper inputs with `number`, and updated the existing focused assertion. Oxfmt and `git diff --check` passed; tests were not run locally. - Style-source simplification reviewed by a Sol medium subagent: consolidated duplicate input arrow checks, removing 13 non-test lines. Oxfmt and `git diff --check` passed; tests were not run locally. - On `2a11120b69`: renamed Tag color recipe and Label/NestedIconLabel variant keys from `tagStyle` to `tag` without changing colors. The focus outline is 1px, offset outside the chip. Oxfmt and `git diff --check` passed; CI is running. - On `80803a5094`: moved the source chip focus outline one pixel outside its bounds and return focus to the input when Escape closes its menu. Oxfmt and `git diff --check` passed. Tests were not run locally; CI is running. - On `55681dda89`: formatted the keyboard handler with Oxfmt after CI caught the line wrap; `pnpm dlx oxfmt@0.58.0` and `git diff --check` passed. Tests were not run locally. - On `3b00225d33`: arrow navigation now traverses source chips in both directions, with the input between global sources and Local. `git diff --check` passed; local tests were not run. No documentation update is needed. - On `256ad1e797`: increased the splash logo-to-progress distance by another 4px (8px total from the original spacing). `git diff --check` passed. No documentation or tests changed. - On `4167ba4b85`: moved the keyboard focus ring from the inner label button to the full source chip edge. `git diff --check` passed; local formatting was unavailable because this worktree has no installed `oxfmt` executable. No documentation or tests changed. - On `4167ba4b85`: moved the keyboard focus ring from the inner label button to the full source chip edge. `git diff --check` passed; formatting was unavailable because this worktree has no installed `oxfmt` executable. No docs or tests are affected. - Passed on `3b4a2bc3ce`: style-source input tests (10), formatting, and diff checks. The autocomplete section labels now read “Tag” and “Tokens.” - Passed on `bb2c60d3e4`: canvas style tests (65), formatting, and diff checks. Tag state previews use lower selector specificity than instance styles across breakpoints, and matching Tag states participate even when the temporary Tag chip is absent. The full Builder typecheck uses a local shared dependency tree with unrelated stale color-variable declarations; CI is rerunning. - Passed on `7bac6f25cb`: style-source input tests (10), formatting, and diff checks. Keyboard focus now has a visible ring, and Arrow Down opens the focused source menu, including on an unselected source. - Passed on `11df83f889`: style-source input tests (10), formatting, and diff checks. Arrow-key autocomplete now retains the selected Tag style ahead of Tokens; the combobox key handler runs once per input event. The local Builder typecheck has only the pre-existing shared color-variable declaration errors; CI is rerunning. - Passed on `10060fac6c`: sync-store tests (15), formatting, and diff checks. Temporary Tag style selection now synchronizes to the canvas for saved-state previews. - Passed on `b775384f2f`: Builder canvas/style-source tests (75), formatting, and diff checks. Ephemeral Tag-state edits now respect the effective source reported by the style model when an instance declaration overrides them. CI is running. - Passed on `87d5f0529e`: style source input/menu tests (12), formatting, and diff checks. Arrow-key focus moves between the input, last global source, and Local source; open menu arrow keys no longer bubble to the outer combobox. CI is running. - Passed on `1e34af257f`: Builder style source menu tests (10), formatting, and diff checks. Menu aligns to the chip’s left edge, with viewport collision handling retained. Copy availability now checks saved declarations across states and breakpoints. CI is running. - Passed on `699bd8ee81`: formatting and diff checks. Increased the logo-to-progress gap by 4px using the next spacing token. CI is running. - Passed on `af8affb589`: style source menu browser tests (6), formatting, and diff checks. Copy now has a focused description, is disabled without declarations, and the menu keeps its 176px width when the description changes. CI is running. - Passed on `1485781bca`: focused HTTP-client tests (52), project-build token-transfer tests (27), and Builder canvas tests (67); formatting and diff checks passed. CI is running. Local HTTP-client typecheck passed. Project-build and Builder typechecks could not complete because the temporary shared `node_modules` links resolved workspace packages incompletely; errors were missing package exports/dependencies and color variable declarations. - Passed on `bae690edc4` (with Select fix `b1e49b1cfd`): checkbox browser regression (both states remain 14×14 px and align to the first label line), design-system and Builder typechecks, focused lint and formatting, and diff check. Reviewed the checked and unchecked Storybook example in light and dark themes. Docs review found no user-facing documentation change needed; no fixture inputs or outputs are affected. - Passed on `b1e49b1cfd`: the focused Select description browser regression passed in light and dark themes (2 tests); design-system and Builder typechecks, focused lint and formatting, and diff check passed. Reviewed the narrow Select dropdown story in both themes; the description wraps without clipping. Docs review found no user-facing documentation update needed. - CI on `ba274d0dec` passed, including Linux and Windows fixture sync and builds, staging and development deployments, and all ten Builder browser shards. Shard 6 passed on retry after Chromium failed to start in the original run. The approved visual rerun passed after comparison with `6f2404d987` confirmed all 272 story results and all 549 screenshots were identical. - Passed on `ba274d0dec`: focused SDK (14), project-build (353), Builder (78), CLI (168), protocol (15), and HTTP-client (51) tests. Builder, SDK, project-build, protocol, CLI, and MCP docs typechecks passed. The HTTP-client typecheck passed with an unrelated local test edit excluded. The SDK test for `type: "tag"` failed with the earlier schema and passed with the updated schema. Generated contracts and MCP docs, focused lint and formatting, package boundaries, and diff check passed. All eight validated bundles use `bundle-1u9ug3c`, and all eight local fixture builds passed. - CI on `6f2404d987`: 34 latest checks passed and 4 were skipped, including all ten Builder browser shards and the approved visual comparison. The five previously approved visual differences had identical screenshots. - Passed on `6f2404d987`: 16 focused Builder browser tests, Builder typecheck, focused lint and formatting, package boundaries, and diff check. Only the Style panel item value changes. No documentation, fixture, clipboard, or saved project changes. - Passed on `aba723fc0a`: design-system and Builder type checks, focused lint and formatting, package boundaries, and diff check. Restored main's field and inactive source colors; Tag styles now use Slot's `--background-accent-secondary` and matching foreground. Refreshed and reviewed the paired light/dark source screenshots; the menu screenshots were unchanged. All 51 check runs completed; the approved visual comparison and all ten Builder browser shards passed. The earlier unapproved visual comparison showed the intended color changes. - Passed on `bd39fb09e5`: Builder typecheck, focused lint and format, package boundaries, and diff check. The style source field keeps its default 8% neutral fill while no longer following the theme surface-contrast slider, so the track (4%), field (8%), chip hover (about 10%), and selected Tag style (14% light / 22% dark) stay ordered. The default-theme docs screenshots remain accurate; no documentation text changed. All CI checks completed. The approved visual comparison passed with the same six differences as the prior revision; all ten Builder browser shards passed after two shards were retried for CI Chromium startup errors. - Passed on `5c782e8d09`: design-system and Builder type checks, focused lint and formatting, package boundaries, and diff check. The shared Tag color now drives the Builder chip and label variants. Documentation review found no product behavior or screenshot change; the palette story now shows Tag. All 49 CI check runs completed: the approved visual rerun and all ten Builder browser shards passed. The initial unapproved visual comparison reported the expected story changes before approval. - Passed on `091dea695c`: Builder and design-system type checks, lint, package boundaries, formatting, and Storybook inspection of idle, hover, and selected sources in both themes. Refreshed the light docs screenshot; the dark idle screenshot is unchanged. - On `53826757d6`, CI completed: 43 passed, 5 skipped, and one superseded visual run was cancelled. The approved visual check and all ten Builder browser shards passed. - Passed on `53826757d6`: design-system and Builder type checks, lint, package boundaries, formatting, and paired light/dark Storybook inspection. The light screenshot is unchanged; the dark screenshot was refreshed. - Passed on `50bc57eb70`: the focused 11-test CLI schema file, formatting, and diff checks. The MCP handshake is 224,046 bytes with the three source type options; the budget is now 224,500 bytes. - Passed on `3c38222811`: focused runtime (270), Builder (3), CLI (5), and HTTP client (51) tests; five package type checks; lint; package boundaries; generated API and docs checks. The paired light/dark screenshots were reviewed. Local fixture inputs and outputs are unchanged by this follow-up. - Passed: workspace type checks, lint, package boundaries, generated contract regeneration, focused SDK/CSS-data/runtime/Builder tests, token-transfer and copy/paste tests, all local fixture builds, and fixture bundle tests. - Passed: CLI prebuild suite (152 tests) and the 54-test publish validation file after fixing its fixture. - Blocked: remote fixture sync reports a bundle-version mismatch against the development API. Agent evaluations require separate approval. - Passed on `38d1705f8a`: Builder app, project-build, CLI, core, and package CI suites; all ten Builder browser shards; Linux and Windows fixture checks; visual regression; and staging/development builds. Oxfmt and `git diff --check` passed locally. Local Vitest was unavailable because this worktree has no installed `node_modules`. Ref #5657 - Rebased onto `main` at `0589b18ce` and moved to `5657.staging`. Focused checks, five package type checks, generated API, lint, formatting, and package boundaries passed locally. On `9e38ff743b`, 38 CI checks passed, one was skipped, and visual regression found the intended Tag style color change. Staging deployment and all ten browser test shards passed. A focused Tag style story and paired light/dark documentation screenshots were reviewed. - MCP discovery and edit support passed focused project-build, protocol, CLI, type, lint, and generated-doc checks locally. The missing runtime cutover and HTTP client entries were fixed; both package suites now pass on the latest commit. - Tag styles docs now explain global application, temporary source selection, states, and CSS cascade. Two paired screenshots show the source and states menu; Storybook rendering, Builder typecheck, formatting, and relative links passed. Visual regression now passes on Ubuntu 24.04 with the reviewed change approved. - On `a8a3c27423`, all 44 CI checks completed: 39 passed and 5 were skipped. Visual regression and all ten Builder browser shards passed. Replaces #6663. - Review fixes on `f9af16d063`: canvas root presets now yield to `html` Tag styles; responsive Tag styles no longer displace instance styles in the style model; selected Tag states and descendant selectors update during live edits. The existing Tag styles documentation needs no change for these bug fixes. Builder focused tests (133), SDK CSS tests (11), Builder typecheck, lint, formatting, and diff checks passed locally. Each new regression test was verified against the old behavior. No fixture inputs or outputs changed. CI completed on `f9af16d063`: 35 latest checks passed and 3 were skipped, including all ten Builder browser shards and the approved visual check. 49. [x] Move the Tag and Token focus outline to the chip edge; no documentation update is needed. 50. [x] Return focus to the style source input when Escape closes its autocomplete; no documentation update is needed. 51. [x] Return focus to the style source input when Escape closes a source chip menu; no documentation update is needed. 52. [x] Add a regression test that Escape in a style source chip menu returns focus to the input; no documentation update is needed. 53. [x] Avoid duplicating an html Tag's own variables as root dependencies when copying it. 54. [x] Exclude descendant selectors from active-state matching. 55. [x] Preserve Tag state preview specificity over base styles and instance state precedence during saved and ephemeral previews. 56. [x] Restore the style source dropdown's default Radix placement from main; remove the custom chip offset. |
||
|
|
f30bdb7679 |
fix: Keep malformed styles from blocking publish (#6665)
Malformed saved CSS can stop a site from publishing. This restores Vite's stylesheet pipeline with Lightning CSS and lets publishing continue when generated CSS is invalid. ## What changed - Save validation uses the shared CSS parser for touched declarations and now rejects malformed style state selectors. The CSS editor already reports malformed pasted declarations and omits them from saved styles. - Publish skips older malformed declarations and warns without including their values. - Generated CSS is imported by Remix, React Router, and Vike, so Vite processes the stylesheet and emits its asset. - Before Vite runs, the CLI checks generated CSS with Lightning CSS and esbuild. If the stylesheet cannot build, it warns and uses preset and font CSS; if that also fails, it uses an empty stylesheet. - The domain publish check parses the current project CSS and shows a warning without blocking publish. The parser catches the malformed cases reproduced with Lightning CSS and esbuild; the CLI's compiler check remains the final guard. It skips malformed declarations just as the CLI does. The early check reads assets and generates and parses CSS once more per validation. Content Block styles created during publishing and static template publishing are covered by the CLI fallback, but not by this early warning. - The temporary hashed public stylesheet path and its larger fixture size allowances are removed. The direct PostCSS dependency remains removed. ## Checklist - [x] Restore Vite CSS imports with Lightning CSS in every site template. - [x] Keep malformed CSS from failing publish and warn when fallback CSS is used. - [x] Test the reported escaped property in React Router and Cloudflare Remix builds. - [x] Test malformed CSS recovery in React Router and Vike builds. - [x] Verify the prerendered Vike page links to the generated CSS asset. - [x] Regenerate fixtures and review the diff. - [x] Review documentation impact: the existing publishing guide needs no change for this warning in the publish flow. - [x] Run CLI typecheck, lint, formatting, package boundaries, CLI build, and frozen lockfile check. - [x] Confirm CSS compiler failure cases with focused tests. - [x] Validate CSS-affecting inputs at save, including style states that bypass the editor picker. - [x] Warn in domain pre-publish validation when current project CSS fails compiler checks. - [x] Verify pasted CSS diagnostics and save behavior in the editor. - [x] Review the new diff and rerun relevant tests, typechecks, and Builder build. - [x] Remove the Builder runtime's native Lightning CSS dependency and test the known compiler failure cases with CSS-tree. - [x] Verify staging Builder and CLI workflows for the latest commit. - [ ] Verify a site publish on staging with a project compatible with this branch. The first attempt used a project with a style source type this branch cannot read. - [x] Reject CSS-tree recoverable parse errors in declaration validation and add a regression test. - [x] Keep project-build within its existing package entrypoints and rerun the affected checks. - [x] Monitor required PR checks to completion. ## Verification Local: affected tests, four package typechecks, Builder and CLI builds, root lint, formatting, package boundaries, and frozen lockfile check passed. The fixture pipeline passed for the earlier commit; this commit changes no fixture inputs or outputs. The new invalid-declaration regression test failed when its filter was removed, then passed when restored. The incomplete `rgb()` parser test failed before the review fix and passed afterward. Full css-data and project-build test suites passed. The Builder runtime uses CSS-tree for the early warning because Vercel omitted Lightning CSS's native binary from the deployed function; the CLI still runs Lightning CSS and esbuild during publishing. The replacement staging deployment, fixture checks, both CLI R2 workflows, main workflow, and all required PR checks passed. Staging publish attempt: CLI sync stopped at `build.styleSources[520]` before CSS generation. This branch accepts only `token` and `local` sources; open PR #6663 adds `tagStyle` and the CSS generation it needs. The failing record could not be read directly with the available share token, so the exact saved type remains unconfirmed. Use a project without Tag styles, or test a combined integration branch after an explicit scope decision. Replaces #6662. --------- Co-authored-by: Codex <codex@users.noreply.github.com> |
||
|
|
1b9ae61fa1 |
feat: Copy and paste tokens across projects (#6660)
Closes #5727 Copy a design token from its menu and paste it into another project or the style source input. Paste creates and attaches a new numbered token (for example, `Button copy 1`). It carries all breakpoint styles, referenced CSS variables, images, and fonts, and creates missing breakpoints. MCP offers the same copy and paste commands; `instanceId` attaches the token when supplied. The clipboard format is CSS with one `@webstudio/token-css/v1` comment. The old JSON format is removed. HTML and CSS use the same Webstudio pragma parser, and token CSS reuses the existing CSS declaration parser. Builder and MCP share token copy, parsing, paste, fragment asset import, and asset reference remapping. The latest cleanup also reuses the existing copy-name helper. Repeated Builder pastes reuse the existing content-hash asset deduplication path, including SVG and fonts. The source bytes still download and hash on each paste. MCP downloads and uploads asset bytes on each paste, using the upload path's deduplication; both projects must use the same Webstudio origin for assets. - [x] Implement CSS token copy and paste in Builder and MCP, including selection attachment and numbered names. - [x] Preserve breakpoint styles, variable dependencies, image and font assets, and missing breakpoints. - [x] Detect token CSS pasted into the style source input. - [x] Remove the JSON transfer format and update Builder and MCP documentation. - [x] Reuse CSS parsing, asset transfer, naming, and existing upload deduplication paths. - [x] Resolve review findings, including shorthand variables and selector state positions. - [x] Verify focused tests, typechecks, lint, formatting, package boundaries, and the approved Storybook visual check. - [x] Trace existing CSS editor and HTML paste flows; reuse their parser, declaration mapper, and CSS variable reference collector. - [x] Preserve breakpoint cascade order when copying equal media conditions; add a regression and resolve the review thread. - [x] Share CSS variable traversal between collection and renaming; preserve nested fallbacks and resolve the review comment. - [x] Discover and remap image URLs inside raw variable fallbacks; share the CSS value traversal and resolve the review comment. - [x] Preserve fallback variables in mixed shorthands and custom non-pixel breakpoint styles; add regressions and resolve review threads. - [x] Preserve combined width and custom media conditions in token CSS; add a regression and resolve the review thread. - [x] Preserve range-syntax custom breakpoints in token CSS; add a regression and resolve the review thread. - [x] Preserve negated custom and width media conditions; add regressions and resolve the review thread. - [x] Preserve boolean operators between width conditions; add a regression and resolve the review thread. - [x] Monitor required CI checks for the latest commit. - [x] Reuse the existing asset usage collector for copied token image and font dependencies; verify token and asset usage tests. - [x] Review documentation impact of this internal refactor (none; no user-facing behavior or contract changed). The reuse audit traced CSS editor, HTML paste, instance/page paste, asset usage, and MCP from input to state change. Token copy now uses the existing asset usage collector for image and variable-backed font dependencies. CSS parsing, declaration mapping, variable traversal, breakpoint matching, asset import/remapping, copy naming, and Builder/MCP token mutation also have shared owners. Fragment insertion may reuse tokens and merge overflow breakpoints; token paste must always create a numbered copy and report overflow. The regex-based rename path remains for arbitrary authored text; token transfer uses syntax-aware rewriting to avoid changing text outside `var()`. The asset collector refactor changes no user-facing behavior. The follow-up parser fixes keep fallback variables, non-pixel breakpoint styles, and combined media conditions, range syntax, negation, and width-condition operators intact when copied. No documentation or fixture inputs changed. Focused token, asset usage, HTML, and CSS parser tests, affected typechecks, lint, formatting, package boundaries, and `git diff --check` passed. Agent evaluations were offered and declined. |
||
|
|
d9e3394c18 |
feat: Improve Advanced styles and CSS variables (#6638)
Closes #6470 Closes #4806 Closes #4392 Closes #4804 Closes #4616 Closes #4863 Closes #4912 Ref #1798 Advanced styles now uses a CSS block editor in the panel and a centered editor. Local declarations are editable. Cascaded or inherited, preset, and global declarations are grouped below them and are read-only. The editor suggests properties and values, highlights search matches, shows source details and color swatches, and previews valid local edits on the canvas. Keyframe CSS declarations use the reusable local block editor. The old Add styles field, property-row editor, declaration menu actions, and Navigator CSS Preview are removed. ### Delivery checklist - [x] Edit and validate local CSS declarations, including shorthand display and likely typo hints - [x] Show other style sources with source colors, tooltips, and read-only protection - [x] Add search navigation, color swatches, and the centered editor shortcut - [x] Reuse the block editor for animation keyframes and preserve transform controls - [x] Preserve uploaded background layers when editing gradients or reordering layers - [x] Remove superseded editor and Navigator UI - [x] Review and update the Style panel and Navigator guides - [x] Remove the outdated CSS Preview sentence from the Builder anatomy guide - [x] Rename the stale Code view test title to match the Advanced editor - [x] Regenerate fixtures and keep the Vercel build manifest through regeneration - [x] Resolve review threads and verify required CI ### Implementation notes Styles remain stored as individual properties; equivalent shorthand text is reconstructed for editing. Unknown property names become CSS variables unless they resemble a known property, in which case the editor warns and skips the typo. Editing is limited to the selected local style block; read-only source groups remain visible for reference. Existing uploaded image and hidden background layers are retained when neighboring layers change. No schema migration is needed. The Vercel manifest setting lives in the React Router template, so fixture regeneration produces a clean worktree. The shared template also generates the setting for the Docker fixture. ### Verification On commit `7fb44d358`, both fixture checks, `check-size`, the main workflow, all ten end-to-end shards, and the label-approved visual comparison passed. The fixture regeneration, Vercel build, Builder typecheck, focused lint, and formatting checks passed locally before the final documentation and test-title cleanup; `git diff --check` passed afterward. No local tests were run for the final cleanup, which changes no behavior. |
||
|
|
659e953869 |
fix: Preserve transitions and animation preview behavior (#6602)
Transition variables no longer get copied into unrelated timing fields. Generated Text/Stagger animations use the saved `slidingWindow` prop, while older `charWindow` configurations still work. Easing moves in the expected direction. Windows preview-install reports include the process failure code when available. Closes #6598 Ref #6593 Ref #6599 Ref #6594 The animation runtime lives in [sdk-components-animation #38](https://github.com/webstudio-is/sdk-components-animation/pull/38). The private PR is merged; this PR points to its merged commit. #6593 was tested on its exact saved project in headless Chromium and closed as not reproducible; the confirmed prop leak is fixed here. #6594 was closed after a documented local repro attempt; this PR improves the next report. ## Work - [x] Reproduce the transition bug; add regression coverage in parsing and generated CSS. - [x] Preserve unresolved `transition` shorthands for the browser to resolve. - [x] Keep old `charWindow` values working in Text and Stagger animations, with a red/green regression test in the linked private PR. - [x] Reproduce and fix the saved animation prop mismatch in generated helpers. - [x] Verify text/stagger easing in unit tests and Chromium/Firefox. - [x] Add safe preview-install process details for future Windows reports. - [x] Update Builder property help and both animation docs pages. - [x] Run focused animation tests, typecheck, lint, package build, and animation fixture build after the compatibility fix. - [x] Point the animation submodule to the merged #38 commit. - [x] Verify required CI on the final commit (all workflows passed; one unrelated E2E shard passed on rerun). - [x] Find the production share token and build #6593’s exact project with its reported 0.307.0 packages. - [x] Compare intermediate scroll styles on #6593’s exact project. Visible targets animate in both builds; the leaked attributes disappear with this fix. Known limit: the reported static-target symptom in #6593 and the Windows environment in #6594 were not reproduced. The confirmed animation prop leak and reporting gap are fixed, without claiming the unreproduced symptoms are solved. |
||
|
|
f08b72439c |
fix: Preserve calc flex basis in fragment styles (#6585)
Closes #6584 ## Change A `flex` shorthand with a nested `calc()` and CSS variable could lose its basis during expansion. Keep the complete basis when it appears alone, before the numeric flex factors, or after one or two factors. The parser handles these forms without a function-name list. Also update `mdn-data` from 2.33.0 to 2.37.2, as requested for this PR. Regenerated CSS data adds `scroll-axis-lock` and `window-drag`, marks `zoom` animatable, and refreshes MDN links. The two new property article links currently lead to missing pages, so the generator uses its existing MDN search fallback for them. The flex grammar in MDN data did not change. The flex parser changes add 20 net non-test lines. The dependency update adds 3 net handwritten lines in the generator; the rest is package metadata and generated output. ## Verification - The reported shorthand regression and a `parseCss` comparison against explicit longhands failed before the parser fix and pass afterward. - CSS-data tests: 4,657 passed, 1 skipped. CSS-engine tests: 173 passed. Targeted Builder Chromium tests: 27 passed. - CSS-data, CSS-engine, and Builder typechecks; root lint; formatting; and `git diff --check` passed. - Frozen lockfile install and the full fixture link/sync/build pipeline passed. The only fixture output drift came from unrelated synced sitemap content and was excluded. - Both CSS generators produced stable output on a second run. Both fallback MDN search links returned HTTP 200. - Reviewed Builder `docs/`: no documentation change is needed. Existing guidance covers property status and animation choices. ## Known limitation `calc-size()` is preserved during shorthand expansion, but the separate longhand validator still marks it invalid in non-browser builds. Numeric and basis functions can also be ambiguous until CSS variables resolve; this fallback handles the reproduced basis forms, not every possible calculation. ## Checklist - [x] Reproduce the reported nested `calc()` value and cover shorthand and saved-style parsing. - [x] Preserve the full basis without changing simple flex expansion. - [x] Simplify the fallback parsing, remove the function-name list, and test another valid basis function. - [x] Update `mdn-data` to 2.37.2 and regenerate CSS data and variable fixtures. - [x] Use working MDN search links for the two new properties whose articles return 404. - [x] Review generated CSS, type, and fixture changes. - [x] Run CSS tests, typechecks, lint, formatting, and fixtures. - [x] Review Builder `docs/` for both changes; no documentation update is needed. - [x] Review the diff and commit only related files. - [x] Resolve review feedback for calculated flex bases with optional factors and basis-first order. - [x] Verify required PR CI checks after the final update. |
||
|
|
cdfef44a6a |
fix: Resolve recent content and CSS issues (#6567)
Closes #6554 Closes #6555 Closes #6557 Closes #6559 Closes #6560 Closes #6563 Ref #6558 Ref #6564 ## Change - Preserve `color-mix(... var(...))` in border shorthands, including when width or style is omitted. - Keep bound JSON-LD objects intact, generate valid conditional Content Block JSX, accept truly empty content queries, and reject missing source fields. - Let custom Open Graph values replace defaults and avoid evaluating a Content Block source in the server loader when it has no Resource dependencies. - Add bounded error type and request ID diagnostics to automatic MCP reports. This helps investigate future #6558/#6564 occurrences; it does not claim to fix those unreproduced write failures. The generated API contract is updated. - No persisted-data migration or new user-facing format is needed. ## Verification - New border and missing-source regressions failed before their fixes and pass afterward. Focused package tests, all eight affected package typechecks, lint, generated-API and package-boundary checks pass on the combined branch. - `pnpm fixtures` completed. Its only differences were unrelated remote fixture content (`/acme-test` → `/olegs-test`), excluded from this PR. - Full local Luna/low agent evaluations: 8/9 fixtures passed. `managed-form-runtime-v1` missed its action check, also seen on earlier separate runs. Comparison baselines are incompatible or absent; none were updated. - Required CI is green after the simplification: main workflow (including all Builder E2E shards), visual regression, submodules, and PR lint. ## Checklist - [x] Reproduce the six fixable reports and cover them with regressions. - [x] Investigate #6558/#6564 and add safe diagnostics for future reports. - [x] Address and resolve all review comments on the three original PRs. - [x] Review documentation impact: existing product docs describe the intended behavior; report diagnostics are internal, so no docs update is needed. - [x] Critically review and simplify the combined diff; verify focused tests and package checks. - [x] Simplify recursive content-query evaluation state and verify its regressions. - [x] Required PR CI passes after the simplification. |
||
|
|
2c20db0d01 |
fix: Parse font shorthand with variable families (#6551)
## Summary - Parse `font-size / line-height` structurally so a custom-property font family does not swallow the line-height. - Add parser, shorthand-expansion, and fragment-insertion regression coverage. - Document the semantic conversion sequence for composite media, preserving wrappers while deleting obsolete provider parts. Closes #6547 Closes #6544 ## Verification - `pnpm --filter @webstudio-is/css-data test -- src/shorthands.test.ts src/parse-css.test.ts` — 4,326 passed, 1 skipped - `pnpm --filter @webstudio-is/project-build test -- src/runtime/components.test.ts src/runtime/instances.test.ts` — 181 passed - CSS data, project-build, and CLI typechecks - CLI docs generation - GitHub Actions: all workflows passed (including all six Builder E2E shards) ## Checklist - [x] Regression tests added for the reported behavior. - [x] Docs impact reviewed; MCP manuals and generated docs updated. - [x] Diff and generated documentation verified. |
||
|
|
c389cd3bb2 |
fix: classify errors with structured codes and types (#6539)
Invalid or revoked share links now return an actionable 401 response instead of an unexpected server error. Missing project and workspace records receive distinct responses at their lookup sites. Token, project, and workspace lookups use `.maybeSingle()` and rely on database uniqueness. Missing projects have an explicit `ProjectNotFoundError`; the loader no longer interprets `PGRST116`. The API preserves `UNAUTHORIZED` and `INVALID_AUTH_TOKEN` when authorization fails during context creation, so CLI and MCP clients can offer relinking guidance without inspecting error text. Tokens without API access carry `API_ACCESS_DISABLED`. A repository audit replaces error-message matching with typed errors, stable codes, or structured diagnostics in CLI argument/configuration handling, session conflicts, preview cleanup, import retries, domain unpublishing, asset validation, JSX/expression diagnostics, CSS validation, and publish diagnostics. `AGENTS.md` now explicitly prohibits message-based error classification and recovery. The existing build-permission preflight now advertises structured import-error support. Clients upload assets before importing into older servers that do not advertise it; newer servers keep selective retries using structured missing-file details. The internal template-validation error class remains outside public JSX bindings and input descriptions. Shared Builder `parseError` normalizes tRPC and local validation errors, so UI components only add display context instead of decoding transport payloads. Simplification removes three redundant error classes, catch-and-ignore handlers, an unused formatter, and nested loader error handling. Unpublishing an already unpublished domain succeeds after authorization. CLI configuration failures use the existing shared error handling, and plan parsing catches only JSON parsing failures. Validation: affected suites passed (271 tests across 8 suites in the latest simplification checks), affected package typechecks passed, and lint, package-boundary checks, and `git diff --check` passed. The audit replaced synthetic parser branches and private-method assertions with actual tRPC round trips, PostgREST responses, and public VM behavior. Controlled regressions confirmed that removing serialized validation details and exposing the internal JSX error class both fail the revised tests. Astra reviewed the production changes at medium effort; its compatibility finding and the GitHub JSX-binding comment are fixed, and follow-up review found no remaining substantive issues. |
||
|
|
a4c3b37fc2 |
fix: Unblock reported MCP workflows and improve issue diagnostics (#6438)
## What this fixes
MCP authors can reuse an existing design token in JSX fragments, create
valid border shorthands with CSS variables, and bypass a font that never
settles during responsive screenshots. Common fixed page titles with
spaced separators are also accepted. Issue reports now include the
project ID and safe, bounded IDs from the failed operation, plus clearer
response and browser-startup diagnostics.
## Scope and tradeoffs
- `token("name")` attaches an existing design token; an unknown name
returns a not-found error. Empty token definitions from Builder/UI
remain definitions and follow the normal conflict rules.
- Border shorthands map a single unresolved `var()` to the remaining
width, style, or color field when the other fields are explicit.
- `waitForFonts: false` skips font readiness but still waits for stable
layout frames. The default remains unchanged.
- Fixed titles such as `Pricing - Plans` stay literal. Addition such as
`first + second` remains an expression. Wrap ambiguous subtraction in
parentheses, for example `(first - second)`. Other ambiguous title forms
may still need an exact report.
- Only recognized operation-level IDs are attached to a public GitHub
issue. Authored values, raw arguments, URLs, and credentials are
excluded. IDs from later successful diagnostic reads are not captured.
- This does not fix the underlying response-transform failure; it
improves future reports for that case.
Closes #6424
Closes #6425
Closes #6434
Closes #6439
Ref #6435
Ref #6430
Ref #6417
## Verification
- [x] Reproduced the privacy, page-expression, empty-token, and
content-mode token-reference regressions with failing tests, then
confirmed the fixes pass. A regression test also covers parenthesized
subtraction.
- [x] Full protocol, template, vision, project-build, and CLI test
suites pass; focused Builder issue-report and fragment tests pass. The
protocol, CLI, and project-build suites were rerun after the CI fix.
- [x] Relevant package typechecks, lint, package-boundary check, fixture
pipeline, generated API check, and generated docs check pass. Fixture
output has no diff.
- [x] Reviewed the authoritative MCP documentation and regenerated the
API metadata and MCP docs.
- [x] CSS parser regressions cover border, each side shorthand, and
unresolved variables in width, style, and color positions; css-data
tests, typecheck, and lint pass.
- [x] Fixed the local evaluation runner to pass the task and Webstudio
MCP tools to Luna/low. Each of the six fixtures passed at least once;
focused MCP/evaluator tests, CLI and project-build typechecks, lint, and
formatting pass.
- [x] The complete Luna/low suite passed all six fixtures in two
consecutive sequential runs. Baselines remain incompatible with this
model/effort override and were not updated.
## Follow-up
- If another fixed-title form still fails, use the new project-level
report context and the exact title shape to narrow the parser case.
|
||
|
|
39c290bfa7 |
fix: resolve MCP-reported runtime and component issues (#6362)
## Summary - harden MCP runtime behavior around asset uploads and resources, HTTP responses, component and Content Block application, data reads, and Chromium screenshots - reject shared Slots inside Content Block templates and avoid unsafe unused-asset findings when Content Blocks can hide MDX dependencies - expand named grid-area values according to CSS shorthand fallback rules - add a consent-safe YouTube preconnect control and only warm origins that are actually used - add focused and end-to-end regression coverage for the reported paths ## Verification - project-build: 2,419 tests passed - css-data: 4,623 tests passed, 1 skipped - sdk-components-react: 134 tests passed, 1 skipped - high-impact CLI fixture: 7 tests passed - Builder asset REST service: 22 tests passed Closes #6336 Closes #6339 Closes #6353 Closes #6354 Closes #6355 Closes #6356 Closes #6357 Closes #6358 Closes #6359 |
||
|
|
f6c524572d |
feat: add Builder dark theme and rebuild colors
## Summary
Rebuilds Webstudio’s color system, migrates the entire Builder to it,
and introduces a complete dark theme.
A small set of theme colors and contrast controls now drives the
interface through relative CSS colors:
```text
Theme colors and contrast
↓
Light/dark derivation bounds
↓
Derived color families
↓
Reusable semantic colors
↓
Component composition
↓
Builder interface
```
CSS is the runtime source of truth. Light and dark modes share the same
theme inputs, so changing a theme color automatically updates its
surfaces, content, borders, states, and component presentation. The
refactor turns dark mode into a first-class Builder theme rather than a
separately maintained palette.
This is an atomic migration. Legacy color names and compatibility
aliases will not remain after all consumers have moved.
## Scope
- The color source, derivation model, semantic vocabulary, validation,
typing, and Storybook overview.
- Every design-system component.
- Builder, dashboard, authentication, shared UI, Query Builder, stories,
and tests that consume the legacy color scale.
- Removal of the legacy Stitches color scale after its final consumer is
migrated.
- A complete dark theme across application UI while keeping authored
canvas content independent.
- Complete light and dark visual verification.
- Unified browser-test infrastructure: Vitest Browser Mode for Design
System browser contracts and standard Playwright Test for all Builder
E2E workflows.
Literal colors remain only where color is the actual content or belongs
to a deliberately separate system, such as user-authored values,
external previews, brand artwork, data visualization, functional canvas
overlays, and source assets. Every remaining exception must have an
explicit owner.
## Architecture decisions
- Theme authors control six color families and three bounded contrast
controls.
- Relative CSS colors derive the rest of the system.
- Dark mode changes derivation bounds instead of maintaining a second
independent palette.
- Components consume a small reusable semantic vocabulary.
- Component states and exceptional presentation are composed inside
components.
- Builder-specific categorical meaning uses focused composite recipes,
not intent semantics or a larger global vocabulary.
- TypeScript validates public semantic CSS-variable names but does not
generate runtime colors.
- No token-manager dependency, compatibility aliases, or
component-specific public color tokens.
- A new semantic or theme variable is added only when existing semantics
and local composition cannot represent a reusable cross-feature
decision.
## Todo
### Color-system foundation
- [x] Establish direct CSS as the runtime source of truth.
- [x] Define bounded theme colors and contrast controls.
- [x] Derive light and dark modes from the same theme inputs.
- [x] Reduce the semantic inventory to reusable decisions and explicit
accessibility pairs.
- [x] Generate only TypeScript names for public semantic CSS variables.
- [x] Validate layers, references, cycles, consumption, naming,
generated types, and browser-computed contrast.
- [x] Add the Storybook color-system overview and theme controls.
- [x] Document the architecture and its relationship to the public Craft
specification.
### Design-system migration
- [x] Replace every active legacy color consumer in design-system
components and Storybook chrome.
- [x] Compose component states locally without component-specific public
tokens.
- [x] Preserve intentional preview and sample-content colors.
- [x] Add complete positive, negative, warning, informative, and accent
accessibility pairings.
- [x] Validate light and dark scheme-bound references independently.
- [x] Verify the design-system package with typecheck, lint, formatting,
Storybook, and 222 tests.
### Inventory and contract
- [x] Inventory all 319 legacy references across 107 Builder, Query
Builder, story, test, and design-system files.
- [x] Classify every reference as a direct semantic replacement, local
composite recipe, documented literal exception, or removable code.
- [x] Record the intentional authored-content, external-preview,
functional-preview, data-visualization, brand, and source-asset
exceptions.
- [x] Treat the public semantic vocabulary as closed by default and
justify any proposed addition by cross-feature reuse and accessibility
need.
- [x] Keep Builder code limited to typed public variables accepted by
`cssVar()`.
### Theme infrastructure
- [x] Add `system` (default), `light`, and `dark` application
preferences.
- [x] Persist the preference in existing client settings and resolve
`system` through `matchMedia`.
- [x] Apply the resolved scheme before paint and respond to
operating-system changes.
- [x] Expose the persisted theme control under **View → Color scheme**.
- [x] Keep authored canvas documents independent from the application
theme.
- [x] Ensure portals, overlays, embedded surfaces, and third-party
controls receive the correct interface scheme.
### Generic interface migration
- [x] Migrate shared dialogs, project settings, notifications, controls,
and Query Builder.
- [x] Migrate dashboard, authentication, publishing, and shared
application UI.
- [x] Migrate the Builder loading state, topbar, sidebars, navigator,
workspace, footer, settings, pages, alerts, and menus.
- [x] Replace fixed interface literals alongside their owning surfaces.
- [x] Remove the old scrollbar variable and hardcoded loading color.
### Style panel and style-source recipes
- [x] Migrate ordinary style-panel inputs, labels, layouts, spacing,
alignment, menus, property states, and value editors.
- [x] Model style-source provenance, kind, interaction, and error as
separate axes.
- [x] Compose categorical style-source colors from neutral and
accent-relative colors.
- [x] Use negative semantics only for actual errors, not overwritten
provenance.
- [x] Reuse one feature-owned recipe across style-source controls,
badges, menus, and values without adding global tokens.
### Canvas and editors
- [x] Migrate canvas selection, reusable outlines, grid guides, resize
handles, labels, badges, and overlays.
- [x] Keep collaborator colors as data visualization while guaranteeing
readable labels.
- [x] Prevent Builder theme values from leaking into authored content.
- [x] Migrate editor surfaces, selections, autocomplete, lint states,
and tooltips.
- [x] Derive syntax visualization from neutral and accent-relative
colors; reserve intent colors for diagnostics.
### Explicit color domains
- [x] Isolate external search and social previews from the application
scheme.
- [x] Preserve user-authored CSS values, functional color previews, and
checkerboards.
- [x] Review brand surfaces independently in both schemes.
- [x] Document every retained literal in the exception ledger.
### Stories, tests, and legacy removal
- [x] Migrate all affected Builder stories and tests.
- [x] Replace the design-system test that intentionally references the
legacy scale.
- [x] Add theme-preference and scheme-resolution behavior tests.
- [x] Remove the legacy `design-tokens.color` registry.
- [x] Remove the Stitches `colors` scale and `rawTheme.colors`.
- [x] Remove color-name conversion code that exists only for the legacy
scale.
- [x] Add a focused repository check that rejects legacy references.
- [x] Confirm no compatibility mappings or deprecated aliases remain.
### Browser-test infrastructure
- [x] Run pure Design System tests in Node and browser-dependent tests
in Vitest Browser Mode with Playwright Chromium.
- [x] Migrate all 79 Builder E2E workflows from the custom harness to
standard Playwright Test.
- [x] Replace filename-based shard discovery with standard Playwright
sharding.
- [x] Preserve clean-backend shard retries and upload Playwright failure
artifacts in CI.
- [x] Remove the custom runner, registry, and timeout infrastructure.
### Verification and documentation
- [x] Compare light-mode visual regressions directly with `main`; review
every difference rather than accepting snapshots wholesale.
- [x] Add representative dark coverage for dashboard, Builder shell,
style panel, dialogs, editors, canvas tools, and status states.
- [x] Test default and extreme custom-theme presets.
- [x] Verify semantic and categorical-recipe contrast.
- [x] Test first paint, persistence, system changes, portals, and canvas
isolation.
- [x] Run affected tests, typechecks, lint, formatting, and Storybook
checks.
- [x] Review fixture impact; no fixture inputs or generated outputs are
affected.
- [x] Review authoritative `docs/` content and update it where needed.
- [x] Review the final diff and make this checklist reflect delivered
scope.
## Current verification
- Design-system typecheck and generated-type freshness: passed.
- Design-system tests: 222 passed, including the full theme-parameter
contrast sweep and browser component coverage.
- Builder typecheck and production build: passed.
- Theme preference and scheme-resolution tests: 10 passed.
- Scoped Oxlint, formatting, and diff checks: passed.
- Design-system Storybook build and representative light/dark visual
review: passed.
- Builder E2E: 80/80 Playwright entries passed (setup plus 79
workflows).
Ref #3818
Closes #6267
|
||
|
|
b2d62b2e49 |
fix: Restore scoped descendant selectors (#6195)
## Summary Restore custom state selectors that target descendants of the selected instance, including `:hover .button` and `:hover > .icon`. The CSS engine already generated these selectors correctly. #5886 unintentionally rejected them while hardening MCP style inputs against selectors that can escape instance scope. ## Technical choices - Parse exactly one selector with `css-tree`. - Require the selector to begin with a pseudo-class, pseudo-element, or attribute state anchored to the selected instance. - Allow only descendant and direct-child combinators after that anchor. - Continue rejecting selector lists, unanchored type/class/ID selectors, sibling combinators, unknown pseudo-selectors, and pseudo-elements used as ancestors. - Document CSS variables as the preferred parent-child interaction pattern; use descendant selectors when selector-based targeting is specifically required. ## Todo - [x] Restore scoped descendant and direct-child selectors. - [x] Preserve instance-scope protections. - [x] Cover real authoring inputs and generated CSS. - [x] Demonstrate new tests fail without the restored behavior and scope guards. - [x] Verify the reported workflow through the local CLI/MCP and generated preview. - [x] Review documentation impact and update the authoritative Builder docs. - [x] Verify generated API contracts remain current. ## Verification - `pnpm --filter @webstudio-is/css-data test` — 4,623 passed, 1 skipped - `pnpm --filter @webstudio-is/css-data typecheck` - `pnpm --filter @webstudio-is/project-build exec vitest run src/runtime/styles.test.ts src/runtime/audit.test.ts` — 198 passed - `pnpm --filter @webstudio-is/project-build typecheck` - `pnpm lint` - `pnpm check:generated-api` - Documentation targets and anchors verified - Local MCP disposable-fixture workflow: - Discovered `insert-fragment` and `update-styles` through MCP metadata. - Inserted a card with a descendant `<button class="button">`. - Dry-run and committed `state: ":hover .button"`; `get-styles` returned the persisted state. - MCP preview generated `.chjrfuf:hover .button` while the card used the `chjrfuf` instance class, proving the selector remained instance-anchored. - Preview screenshot completed and returned HTTP 200. - Agent evaluations were not run because the suite has no custom-selector coverage ## Known limitation Sibling combinators remain unsupported because they can select elements outside the selected instance. Selector lists remain unsupported because later list entries can escape the generated instance prefix. Closes #6175 |
||
|
|
ab5717c9cf |
feat: Support CSS properties of every status (#6166)
## Summary - Make every CSS property in the current MDN dataset available in the Advanced style workflow, regardless of standards status. - Mark experimental, nonstandard, and obsolete properties with a yellow warning icon, status-specific tooltip, and MDN link. - Add complete CSS anchor-positioning property and value support. - Update `mdn-data` from 2.28.0 to 2.33.0 and `css-tree` from 3.1.0 to 3.2.1. ## Root cause Webstudio generated its supported property list from MDN data but filtered by status and then manually allowed a few experimental and nonstandard entries. A property could therefore exist in the installed MDN package without being exposed by the Builder. Runtime validation had a separate grammar gap. CSS-tree 3.2.1 now includes the anchor functions and alignment values, but its bundled data predates the current `position-anchor: normal | match-parent` additions. ## Implementation - Remove status-based property filtering and the nonstandard-property allowlist. - Generate one property-to-status map for 486 standard, 40 experimental, 119 nonstandard, and 15 obsolete properties. - Show status-specific browser-compatibility guidance for every non-standard status. Active declarations keep the warning after the value with 3px left spacing. - Infer MDN links from existing property metadata and fall back to MDN search for entries without a direct URL. - Preserve known vendor prefixes from the generated property inventory instead of maintaining a prefix allowlist. - Generate WebKit text fill/stroke longhands directly from MDN instead of preserving them through parser exceptions. - Preserve unsupported initial-value shapes as unparsed CSS rather than excluding their properties. - Use CSS-tree 3.2.1's native anchor-function and alignment grammars. Keep one narrow extension for the current `position-anchor` keywords missing from its bundled MDN data. - Generate recursively flattened shorthand longhands and initial values from MDN. - Expand syntax-defined shorthands generically from CSS-tree's matched property captures, including function-valued components. - Decline generic expansion when CSS-tree and MDN disagree about the longhand set or a longhand repeats. - Update the font grammar reference and CSS math validation for CSS-tree 3.2.1 compatibility. - Regenerate CSS metadata and property-variable fixtures. ## Checklist - [x] Include MDN properties regardless of status. - [x] Generate status metadata for standard, experimental, nonstandard, and obsolete properties. - [x] Show warning icons in Add styles results and active declarations. - [x] Add status-specific consequences and MDN links. - [x] Preserve generated vendor-prefixed properties during CSS import. - [x] Generate WebKit text fill/stroke longhands without parser exceptions. - [x] Support `anchor()`, `anchor-size()`, and `anchor-center`. - [x] Support current `position-anchor` keywords. - [x] Expand syntax-compatible shorthands through generic MDN metadata and CSS-tree captures. - [x] Cover ordered optional, unordered, slash-separated, function-valued, omitted, CSS-wide, variable, invalid, and incompatible-data cases. - [x] Verify new status, warning, prefix, and shorthand tests fail without their implementations and pass when restored. - [x] Update to CSS-tree 3.2.1. - [x] Regenerate CSS metadata and property-variable fixtures. - [x] Review documentation impact; no authoritative Builder documentation lists individual supported CSS properties, so no update is needed. - [x] Review fixture impact; 668 fixtures and 2,030 valid cases were regenerated with zero unsupported. ## Verification - `pnpm --filter @webstudio-is/css-data test` — 4,618 passed, 1 skipped. - Builder CSS editor and property-status tests — 25 passed. - CSS data, CSS engine, Project Build, and Builder typechecks passed. - Lint, formatting, repeated regeneration, and diff checks passed. ## Known limitation This change covers CSS declarations and values. It does not add a dedicated Builder editor for the `@position-try` at-rule. Closes #6162 |
||
|
|
87968f40ff |
fix: Improve MCP authoring and preview reliability (#6105)
## Summary
Fix MCP reliability failures reported in ten issues against CLI 0.288.0
and 0.289.0:
- keep every advertised array input schema client-valid, including
compact and tuple schemas
- report a text asset update as successful when its persisted revision
and bytes confirm that the server committed despite a failed response
- preserve standard package import resolution in generated React Router
previews
- upload variable WOFF2 fonts when callers provide the documented static
font metadata shape
- explain unmatched JSX as a stateless fragment syntax error
- distinguish the `animation` component namespace from value helpers and
reject unsupported CSS at-rules with an actionable validation error
- forward optional session tools such as `download-asset` through
top-level CLI shortcuts
- isolate published generated-preview dependencies from parent
workspaces
- return structured screenshot failures when React Router production
builds fail
Sensitive visual regression checks also run automatically for
organization-authored fork PRs. External fork PRs remain gated by
`safe-to-deploy`.
## Root causes and implementation
The MCP handshake compactor retained an array's type but discarded its
`items` schema. Unconstrained and tuple arrays could also be advertised
without `items`. Schema normalization now adds `items: {}` whenever an
array omits it, while focused discovery retains complete constraints.
Catalog coverage rejects every missing array item, including tuple
schemas, and the handshake remains below its 200 KB budget.
Asset content updates previously treated any failed response as a failed
mutation, even when the server had already swapped the revision.
Recovery now reads the current revision, compares the persisted bytes,
and confirms the revision remains stable across the read. It returns the
updated asset only when all evidence agrees. Otherwise it returns
`ASSET_UPDATE_COMMIT_UNCERTAIN` with guidance not to retry blindly.
Definitive 4xx responses retain their original errors.
The generated React Router Vite config replaced the client and SSR
resolver condition lists without explicitly retaining the standard
`import` condition. Both lists now preserve `import`. The regression
test generates a dynamic route, stages the built React Router SDK as a
published dependency without the local `webstudio` source condition, and
runs the generated build.
Variable fonts are detected with `variationAxes`. Merging the documented
static `style` and `weight` upload metadata into that detected variable
shape made validation fail after the binary was read. Font override
validation and shape-aware merging now live in `@webstudio-is/fonts`.
The SDK delegates to that domain function, which validates the complete
override before applying compatible fields, retains the detected
static-or-variable shape, and keeps the detected format.
Fragment parsing is stateless. Unmatched opening and closing tags now
explain that every opening element must use the same closing tag or be
self-closing, and that refreshing the session cannot repair malformed
JSX.
The `animation` binding is a component namespace, not a callable helper.
Tool schema text, evaluation errors, and the MCP manual now separate
component namespaces from value helpers. The MCP JSX `css` binding
parses the final interpolated CSS with CSS-tree and recursively rejects
selectors and unsupported at-rules such as `@keyframes`, while
preserving supported declarations and case-insensitive `@media` rules.
Keeping this validation at the external binding avoids changing internal
component templates.
CLI shortcut discovery previously omitted optional session tools even
though the runtime registered their handlers. Shortcut discovery now
includes the same optional tool categories as the CLI MCP host, while
real top-level CLI commands keep precedence.
Published generated previews could reuse a stale `node_modules` symlink
into a parent source workspace. Only development manifests containing
the local placeholder version may now reuse the CLI dependency tree.
Published manifests replace symlinks with a local install and disable
npm workspace discovery.
React Router could report a bundler failure while its build command
exited successfully outside CI, allowing screenshot startup to terminate
without a structured result. Managed production builds now set `CI=1`,
so the existing MCP error boundary receives the nonzero build failure
and prints structured JSON.
Visual regression authorization now distinguishes repository members
from external contributors. Organization members' fork PRs run on open,
synchronize, and reopen events; external fork code runs only from a
`safe-to-deploy` label event, and a later commit does not reuse that
approval.
## Implementation checklist
- [x] Preserve valid array item schemas in compact MCP discovery
- [x] Normalize tuple input schemas with an `items` fallback
- [x] Keep the MCP handshake below its 200 KB size budget
- [x] Cover the real `update-props` schema and oversized array
compaction
- [x] Reconcile failed asset-update responses against stable persisted
content
- [x] Reject recovery when a concurrent asset revision is detected
- [x] Preserve `import` resolution in generated React Router client and
SSR builds
- [x] Build a generated dynamic route against a staged published SDK
package
- [x] Regenerate and verify affected React Router fixtures
- [x] Preserve detected variable-font axes with documented upload
metadata
- [x] Add actionable unmatched-tag and unsupported-CSS validation
- [x] Correct animation namespace guidance in tool discovery and errors
- [x] Forward optional session tools through top-level CLI shortcuts
- [x] Replace parent-workspace dependency links for published previews
- [x] Disable npm workspace discovery for isolated preview installs
- [x] Make React Router build failures return nonzero in managed
previews
- [x] Run visual regression automatically for organization-authored PRs
- [x] Verify each regression test fails without its corresponding fix
- [x] Review documentation impact and update the authoritative MCP
manual plus generated outputs
- [x] Confirm no database migration or compatibility migration is
required
- [ ] Run `pnpm evaluations` after explicit approval; not run because
repository policy requires approval before agent evaluations
## Verification
- `packages/cli/src/prebuild.test.ts`: 57 tests passed
- `packages/cli/src/commands/schema.test.ts` and `mcp.test.ts`: 51 tests
passed
- `packages/project-build/src/runtime/components.test.ts` and
`mcp.test.ts`: 194 tests passed
- `packages/asset-uploader`: 196 tests passed
- focused font schema, SDK asset schema, CSS parser, and template CSS
tests passed
- `packages/http-client/src/index.test.ts`: 38 tests passed
- relevant CLI, project-build, asset-uploader, fonts, SDK, CSS data,
template, HTTP client, and React Router SDK typechecks passed
- MCP documentation tests, typecheck, generation, and Markdown source
tests passed
- React Router SDK package build passed
- full fixture link, sync, and generation pipeline passed
- affected Docker and Vercel fixture typechecks and locally bootstrapped
production builds passed
- complete CLI suite: 61 test files and 966 tests passed
- CLI typecheck passed
- preserved nested-workspace dynamic preview installed local `0.289.0`
dependencies and completed its production build
- visual-regression workflow YAML parsing and authorization truth table
passed
- repository lint passed with warnings denied
- formatting and `git diff --check` passed
## Tradeoffs and limitations
Deferred array schemas advertise unconstrained `items` in the compact
handshake to remain client-valid without duplicating detailed
constraints. Agents can retrieve the complete item schema through
focused `meta.get-more-tools` discovery.
Asset reconciliation performs three read requests only after an
uncertain 5xx, malformed response, or transport failure. This keeps the
normal successful path unchanged and avoids claiming success if the
revision changes during recovery.
For variable fonts, detected axes define the metadata shape. Static
`style` and `weight` hints are ignored because they cannot be
represented alongside `variationAxes`; compatible fields such as
`family` still override detection.
Native CSS keyframe authoring remains unsupported in fragment `css`
templates. The tool now rejects it before rendering and directs callers
to editable Webstudio Animation components instead of advertising a
nonexistent callable helper.
Published previews perform one isolated npm install when no valid local
dependency tree is cached. Local source development keeps the fast
workspace symlink path for placeholder-version manifests.
Closes #6104
Closes #6099
Closes #6098
Closes #6106
Closes #6107
Closes #6108
Closes #6114
Closes #6115
Closes #6116
Closes #6117
|
||
|
|
54aa7be145 |
fix: Make MCP authoring reliable across assets, styles, and embeds (#5932)
Closes #5924 Closes #5925 Closes #5926 Closes #5927 Closes #5928 Closes #5929 ## Outcome Makes MCP and CLI authoring predictable across project-wide CSS variables, font uploads, retried asset uploads, destructive asset selection, design-token collisions, and SVG HtmlEmbed edits. ## Delivered ### Project-global CSS variables - [x] `define-css-variable` writes to `ROOT_INSTANCE_ID` / `:root` instead of the home-page Body. - [x] Breakpoint and overwrite behavior is preserved, and compact results identify the root scope. - [x] Existing body-local declarations remain untouched. - [x] Runtime and Builder integration tests cover root selection and generated project behavior. ### Font metadata and upload overrides - [x] Static fonts prefer authoritative `OS/2.usWeightClass`. - [x] Fallback matching normalizes spaces, hyphens, and underscores and checks specific aliases before shorter ones. - [x] Explicit format and partial metadata overrides travel through HTTP, filesystem, and S3 upload paths and are validated after merging with detected metadata. - [x] Regression tests cover ExtraBold, Extra-Bold, Semi Bold Italic, Ultra Light, valid weight classes, invalid weight classes, partial overrides, and invalid overrides. ### Idempotent asset uploads - [x] API uploads compute a project-scoped SHA-256 content hash. - [x] Sequential and concurrent duplicate uploads reuse the existing asset and return `deduplicated: true`. - [x] `force: true` bypasses deduplication for intentional duplicates. - [x] A partial unique index enforces one non-null content hash per uploader project. - [x] Stale reservations are cleaned up and active concurrent uploads are bounded by polling and an actionable retry error. - [x] HTTP, protocol, uploader, and CLI tests cover hash reuse, uniqueness races, force propagation, and result markers. The migration does not backfill historical files. Existing assets begin participating in deduplication when uploaded through the new path; matching content keeps the existing asset's metadata rather than silently rewriting it. ### Consistent asset inputs and permissions output - [x] `delete-asset` exposes exact `assetIds` and explicit `assetIdPrefixes`. - [x] The legacy `assetIdsOrPrefixes` input remains accepted and is marked deprecated. - [x] Exact ids no longer accidentally select longer prefixed ids. - [x] `webstudio permissions` prints a readable role/capability summary by default while `--json` remains unchanged for machine callers. - [x] Help and discovery describe JSON output as optional. - [x] Runtime, CLI, metadata, and generated-contract tests cover canonical and compatibility behavior. ### Deterministic fragment design tokens - [x] Fragment insertion reconciles incoming tokens against project tokens and earlier tokens in the same fragment. - [x] Equal name/style tokens are reused instead of creating suffixed twins. - [x] Same-name/different-style fragments require an explicit `ours`, `theirs`, or `merge` policy at the public runtime boundary. - [x] Builder's established internal paste behavior retains its explicit incoming-value default. - [x] `create-design-token` accepts documented CSS strings through the property-aware CSS parser as well as typed style values. - [x] Tests cover same-fragment reuse/conflicts, persisted tokens, explicit policies, and CSS string parsing. ### Editable SVG HtmlEmbed content - [x] HtmlEmbed validation uses parse5 parser errors and source structure instead of serialization-string equality. - [x] Valid inline SVG is accepted without silently normalizing authored markup. - [x] Fragment insertion now uses the same validator as prop update and text replacement paths. - [x] Malformed markup is rejected before mutation. - [x] Regression tests cover realistic SVG, parser failures, and no-partial-mutation behavior. ## Verification - [x] `pnpm checks`: all workspace tests, typechecks, lint, package boundaries, generated API/docs checks, and fixtures passed on the final committed tree. - [x] `pnpm --filter webstudio test:release-smoke`: packaged install, compact comparison, preview, agent workflow, stdio MCP, and structured commands passed. - [x] Prisma schema validation passed with test connection variables. - [x] Two minimally prompted weak-model subagents independently exercised the changed CLI/MCP discovery and focused workflows. - [x] The subagent-found stale `permissions --help` requirement was fixed, regression-tested, and retested. - [x] Final diff and worktree are clean. |
||
|
|
12ad74584a |
feat: Improve MCP authoring, auditing, and verification (#5886)
## Summary This improves how coding agents discover, author, verify, and audit Webstudio projects through the CLI and MCP. The work focuses on making agents more reliable with less context, while keeping edits semantic and Builder-editable. ## What changes for users - Agents can verify dynamic bindings after authoring and receive actionable diagnostics when expressions, resources, scopes, or component props do not line up. - Agents can create complete resource-backed runtime UI through a semantic operation instead of coordinating fragile low-level edits. - MCP discovery and command output are compact by default, with pagination and focused verbose detail when an agent needs more context. - Asset, style, token, font, page, and component inspection provides stronger usage context so agents can preserve the existing design system. - Rendered audits provide better evidence for responsive behavior, geometry, contrast, generated-build size, and large-project runs. - Cross-project MCP workflows can run from a manifest with explicit mutation approval, isolated failures, resumable progress, and persistent checkpoints. - Project-specific agent onboarding is clearer and does not add telemetry. - Packaged CLI releases gain stronger smoke verification for install, MCP startup, authoring, preview, screenshots, and audits. ## Reliability and architecture - Runtime operation output schemas are generated from the runtime registry and remain client-compatible. - Project-build exports are consolidated around architectural boundaries instead of feature-by-feature convenience entry points. - HTTP, preview, screenshot, and project-session paths are hardened for longer autonomous workflows. - Craft compatibility work is read-only and provenance-aware; it does not silently opt ordinary projects into Craft behavior. - A minimal-context evaluation harness exercises key workflows with a weaker model and stores bounded, privacy-safe evidence. ## Validation - Rebased on the latest `origin/main`. - `pnpm lint` - Repository-wide `oxfmt --check` - CLI typecheck and full test suite: 773 tests passed. - Project-build typecheck and full test suite: 1,866 tests passed. - Protocol typecheck and full test suite: 83 tests passed. - HTTP client tests: 23 passed. - CSS data tests: 3,620 passed, 1 skipped. - Focused Builder tests: 67 passed. - Package-boundary, generated API, and generated documentation checks passed. - Minimal-context agent evaluations passed for authenticated resource-backed UI and design-system-aware responsive authoring. |
||
|
|
de23e2a888 |
chore: migrate toolchain to oxc (oxfmt, oxlint, rolldown-vite) and typeScript 7 (#5868)
## prettier -> oxfmt (0.58.0)
- .oxfmtrc.json generated with `oxfmt --migrate=prettier`: trailingComma
es5, printWidth 80 (oxfmt defaults to 100), sortPackageJson disabled,
.prettierignore patterns folded in (file deleted).
- ignorePatterns additionally exclude yml/yaml/toml/jsonc and
packages/cli/templates/** so oxfmt covers exactly the file set prettier
used to format (ts,tsx,js,json,css,md) and never touches user-facing
scaffolding artifacts.
- root `format` script, nano-staged pre-commit hook and the CI check
(`pnpm oxfmt --check`, replacing `prettier --cache --check` and its
actions/cache step — oxfmt checks the whole repo in ~0.7s) now run
oxfmt.
- every generator script that ran `prettier --write` on __generated__
output now runs `oxfmt` (css-data, icons, html-data, postgrest, sdk,
sdk-components-*, apps/builder tailwind preflight).
- the four scripts that used prettier's JS `format()` API write raw
source instead and their package.json scripts pipe the generated file
through the oxfmt CLI: project-build generate-docs +
generate-runtime-operation-contracts, cli generate-docs, apps/builder
generate-server-only-api-metadata. oxfmt rejects paths containing "..",
so cross-package generated files are formatted via a subshell cd into
the owning package.
- one-time reformat: oxfmt's canonical output differs from prettier on 8
repo source files (binary-operator continuation indent, import() call
wrapping, sub-pixel spacing of empty for-clauses); oxfmt honors existing
`// prettier-ignore` comments so intentional layouts are kept.
- prettier remains ONLY as a cli devDependency for the
prettier/standalone HTML normalizer inside html-to-jsx.test.ts, and
inside fixtures/ + packages/cli/templates/ (ships to scaffolded user
projects; out of scope here).
- editor config switched from esbenp.prettier-vscode to oxc.oxc-vscode
(devcontainer extension list, .vscode editor.defaultFormatter).
## oxlint 1.56 -> 1.73
- oxlint 1.73 rules-of-hooks special-cases hooks NAMED useEffectEvent:
their results may only be called from effects. Our
app/shared/hook-utils/effect-event.ts is a stable-callback helper
(useEvent pattern), intentionally called from event handlers and passed
as props. The rule is disabled via .oxlintrc.json overrides for the five
files doing this (product code untouched); note those files lose
hook-order linting entirely until the rule becomes configurable.
## TypeScript 5.8.2 -> 7.0.2 (native compiler)
- `tsc` is now the Go-based native binary; all `tsgo` script usages
(workspace packages and fixtures) renamed back to `tsc` and
@typescript/native-preview removed (the package is being phased out).
- fixes for TS7 changed defaults and stricter checks:
- `types` now defaults to [] -> base tsconfig sets "types": ["node"]
(restores the implicit-@types/node behavior of TS5).
- `rootDir` now defaults to ./ -> every tsconfig.dts.json sets
"rootDir": "./src" (TS5011 otherwise).
- import assertions removed -> cli/src/cli.ts uses `with { type: "json"
}` (TS2880).
- stricter isolatedDeclarations inference -> explicit annotations in
css-data bin/property-filter.ts (TS9010) and image image-dev.stories.tsx
(TS9013).
- declaration serialization limit -> project-build builder-runtime.ts
runtimeOperationContracts gets an explicit type (TS7056); the annotation
preserves the narrow RuntimeOperationId union.
- TS7 ships no stable programmatic API:
- react-sdk (component-generator tests drive the compiler API) aliases
its typescript devDependency to @typescript/typescript6@^6.0.2; its bin
is `tsc6`, so the package's typecheck still runs native TS7 tsc from the
workspace root.
- generate-arg-types keeps typescript 5.8.2 for react-docgen-typescript.
- fixtures/ and packages/cli/templates/ keep typescript 5.8.2
(user-facing); fixture scripts still work because plain `tsc` resolves
to their local dependency.
## vite -> rolldown-vite 7.3.1 (oxc bundler)
- global pnpm override `"vite": "npm:rolldown-vite@^7.3.1"`: the builder
app (remix v2 vite plugin works unmodified), every package vite build
and the storybook build now bundle on rolldown/oxc.
- vitest is scoped BACK to vanilla vite via `vitest>vite`,
`vite-node>vite` and `@vitest/mocker>vite` overrides because vitest
3.1's runner does not understand rolldown's SSR transform
(__vite_ssr_exportName__ ReferenceError in every suite).
- those overrides pin vite EXACTLY to 6.3.4: letting ^6.3.4 float to
6.4.3 breaks cli prebuild tests (dynamic import of a generated
app/routes/$.tsx fails to resolve under 6.4.3's loader).
## unrelated cleanup requested during review
- apps/builder commands.ts imports duplicate-tokens-group statically
instead of via dynamic import. The circular dependency the dynamic
import guarded against only exists through the command-panel barrel
(command-panel.tsx > groups/index.ts > commands-group.tsx >
commands.ts); importing the group module directly is cycle-free
(verified with madge), matching the neighboring wrap-group and
convert-group imports.
## verification
- pnpm lint, oxfmt --check: clean.
- pnpm -r typecheck (TS7 native) and pnpm dts: clean.
- pnpm -r test: all suites pass (builder 2093 tests, cli 630, react-sdk
45, project-build 11, ...).
- builder app build, full workspace build, cli build and storybook build
all succeed on rolldown-vite.
## Description
1. What is this PR about (link the issue and add a short description)
## Steps for reproduction
1. click button
2. expect xyz
## Code Review
- [ ] hi @kof, I need you to do
- conceptual review (architecture, feature-correctness)
- detailed review (read every line)
- test it on preview
## Before requesting a review
- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")
## Before merging
- [ ] tested locally and on preview environment (preview dev login:
0000)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
|
||
|
|
d291e4b671 |
feat: Builder api runtime contracts guardrails for MCP (#5857)
This PR expands Webstudio MCP and CLI into a more complete agent authoring interface. Agents can discover project capabilities, edit real Webstudio content, use data/resources, verify visual output, and report useful issues when workflows fail. ## MCP User Capabilities - Create, update, duplicate, reorder, and delete pages. - Create pages from templates and manage reusable page templates. - Inspect project pages, instances, props, styles, assets, variables, resources, and metadata. - Insert Webstudio components and authored JSX fragments into pages. - Edit text, props, styles, breakpoints, design tokens, and CSS variables. - Update page metadata, SEO fields, redirects, marketplace metadata, and project settings. - Create and use static data variables. - Create and use dynamic resources fetched over HTTP. - Use REST, GraphQL, and built-in system resources in authored pages. - Bind data variables and resources to visible page content. - Create resource-backed pages such as sitemap XML, structured SEO data, and API-driven content sections. - Preview current project state without requiring a publish step. - Capture screenshots for visual verification. - Verify responsive designs across desktop, tablet, and mobile breakpoints. - Use screenshot diff and OCR-style checks to inspect rendered output. - Reset and refresh local MCP project state when needed. - Discover available CLI/MCP commands from generated manuals. - Use clearer examples for resources, data variables, JSX authoring, previewing, and visual checks. - Read marketplace product metadata without requiring a full project snapshot. - Get safer guidance when using low-level patch tools. - Get a ready-to-copy Discord report template when MCP/CLI behavior is confusing or broken. |
||
|
|
82c3d83fd1 |
fix: optimize CLI import for large data amount (#5831)
## Summary - Add CLI project import support from synced `.webstudio/data.json` into another project via a destination share link. - Move project bundle import/export contract into `@webstudio-is/protocol`, including bundle versioning, staged upload constants, schema validation, and fixture coverage. - Upload project bundle data through staged TUS upload before calling the import RPC to avoid request body limits. - Upload referenced assets as binary files through the existing asset upload route before importing asset rows. - Add `--skip-assets` and `--ignore-version-check` import options. - Add retry handling for transient missing imported asset files by re-uploading only the reported missing assets. - Share missing-asset import error formatting/parsing through protocol to avoid duplicated string contracts. - Preserve browser asset upload behavior while adding API upload support. - Normalize schema naming across the branch to lower-case names without `Schema` suffix. |
||
|
|
95dc7f0a75 |
fix: Validate malformed CSS variable values (#5787)
**Summary** Validates CSS custom property values as raw CSS token streams before saving/parsing them. This prevents malformed values like `#sd'` from being normalized into `sd` or serialized into broken canvas CSS that invalidates the whole generated rule. **Changes** - Added tokenizer-based validation for custom property values. - Rejects malformed strings, URLs, comments, unmatched blocks, and trailing backslashes. - Preserves raw custom property declaration values before `css-tree` can repair/normalize them. - Prevents custom property value editing from coercing invalid input through fallback parsing like `kebabCase()` or color recovery. - Added regression tests for advanced panel input and CSS data parsing. **Verification** - `pnpm --filter @webstudio-is/css-data test -- parse-css-value.test.ts parse-css.test.ts` - `pnpm --filter @webstudio-is/builder test -- parse-intermediate-or-invalid-value.test.ts parse-style-input.test.ts` |
||
|
|
5ed7588877 |
feat: Add tooltip when transforms are unavailable (#5778)
Closes https://github.com/webstudio-is/webstudio/issues/5336 Adds a tooltip to the Transforms section `+` button when transforms are unavailable for the selected element. The Transforms section now stays visible but inactive for unsupported elements, and the tooltip explains that transforms do not work with `display: inline` and suggests changing display to `inline-block` or `block`. Also adds shared CSS data helpers for HTML replaced elements so the transform availability check can distinguish regular inline elements from replaced inline elements like `img`. |
||
|
|
976ffd33f4 |
fix: Fix pasted CSS math values (#5759)
## Summary - Preserve browser-valid CSS math values during CSS value parsing when `css-tree` can parse the value but cannot fully validate the property syntax. - Fix pasted HTML/imported inline styles like nested `clamp()` + `calc()` font sizes being marked invalid. - Keep malformed math values and numeric functions in non-numeric properties invalid. - Add regression coverage for CSS value parsing and HTML paste/import behavior. ## Testing - `pnpm --filter @webstudio-is/css-data test src/parse-css-value.test.ts` - `pnpm --filter @webstudio-is/builder test app/shared/html.test.tsx app/shared/tailwind/tailwind.test.tsx` ## Notes This prevents valid pasted CSS math expressions from becoming invalid style values and crashing the builder on import. |
||
|
|
6b09e91324 | build: Release 29 04 26.staging (#5742) | ||
|
|
b4941aaaf1 | fix: Tailwind border color arbitrary var (#5717) | ||
|
|
f052200d07 |
fix: preserve CSS variable and gradient references on paste (#5716)
Preserve var() references in pasted gradient shorthand (css-data/parse-css.ts) When expanding shorthand properties (e.g. background), unresolved var() tokens were lost. Now they're recovered by probing each longhand with a placeholder, mapping which longhands the var belongs to, and restoring it. Fix border-(--x) Tailwind v4 syntax not recognized (tailwind.ts) borde |
||
|
|
89188bede8 |
fix: resolve transitive var() references in shorthand expansion (#5705)
## Description 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file |
||
|
|
198ae5d65a |
fix: Cross rule CSS var resolution (#5698)
## Description
Pasting this will now resolve correctly
```html
<style>
.my-parent {
--clr-red: #f00;
min-height: 75vh;
}
.my-child {
background: var(--clr-red);
min-height: 50%;
}
</style>
<div class="my-parent">
<div class="my-child"></div>
</div>
```
|
||
|
|
8de2fd47f6 |
fix: CSS shorthand properties not saved when value contains var() (#5688)
Shorthand properties like background: var(--color) were silently dropped when pasting into the CSS editor because the shorthand expander can't handle unresolved var() references. Fix: CSS vars from the current element's computed styles are now resolved before expanding shorthands. Inline and nested fallbacks (var(--a, var(--b))) are supported. If a var still can't be resolved, a toast error is shown instead of silently dropping the property. |
||
|
|
9e72cc23c0 |
feat: New color formats and color picker (#5661)
https://github.com/webstudio-is/webstudio/issues/3574 |
||
|
|
44a5c5f265 |
feat: Parse color functions with CSS variable alpha channel (#5660)
ref https://github.com/webstudio-is/webstudio/issues/3574#issuecomment-4116312483 (e.g. Taillwind's rgb(r g b / var(--tw-opacity))) - css-engine/schema: extend ColorValue.alpha to number | VarValue - css-engine/to-value: serialize VarValue alpha using toValue() - css-data/parse-css-value: add parseColorWithVarAlpha using css-tree AST substitution (no fragile string replacement); inject fallback: 1 when var has no explicit CSS fallback - style-object-model: resolve VarValue alpha in substituteVars so the color picker receives a number when the custom property is defined - color-control: use VarValue.fallback for the picker when alpha is still unresolved, falling back to 1 only as a last resort |
||
|
|
1784d635c0 |
feat: Paste HTML with CSS with full selectors and regular syntax support (#5648)
## Description 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file |
||
|
|
04188dbbf4 |
feat: CSS Grid UI (#5614)
## Description 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file |
||
|
|
942b81b8ff |
refactor: upgrade colorjs.io to v0.6 and adopt functional API (#5617)
## Summary Upgrades colorjs.io from v0.5.x to v0.6.x and adopts the new functional API to fix TypeScript compatibility issues and reduce bundle size. ## Breaking Changes in v0.6 This release includes two major changes from colorjs.io that required code updates: 1. `null` instead of `NaN` for "none" values — Coordinates now use `number | null` instead of the custom `Number` instance that previously used `"none"` strings. This eliminates runtime casting and improves TypeScript DX. 2. Plain numbers instead of `Number` objects — Coordinates are now plain number primitives rather than `Number` objects with parsing metadata, improving performance and bundle size. ## Changes Made - Upgraded colorjs.io to v0.6.x - Adopted functional API (`/fn` entry point) for tree-shakeable imports and reduced bundle size - Updated coordinate handling to use `number | null` directly instead of custom `Number` instances with `"none"` values - Removed runtime casting previously required for TypeScript compatibility - Aligned with engramma and hdr-color-input — both already use the functional style, enabling code deduplication ## Migration Notes See [colorjs.io v0.6.0 release notes](https://github.com/color-js/color.js/releases/tag/v0.6.0) for full details on the breaking changes. |
||
|
|
d87142965c |
feat: Breakpoint simulator (#5608)
## Problem
When defining CSS variables with different values for condition-based
breakpoints (e.g., `prefers-color-scheme:dark` vs
`prefers-color-scheme:light`), designers had no way to preview these
variations without manually changing system preferences.
Example:
```css
:root {
--primary-color: #000;
--background: #fff;
}
@media (prefers-color-scheme: dark) {
:root {
--primary-color: #fff;
--background: #000;
}
}
```
Previously, testing dark mode required switching OS settings back and
forth.
## Solution
Implements runtime CSS media rule manipulation to simulate
condition-based breakpoints without changing system settings. When a
designer selects a condition-based breakpoint, the simulator dynamically
modifies CSS media rules:
- Matching rules (e.g., `prefers-color-scheme:dark` when dark is
selected) → replaced with `(min-width: 0px)` (always true)
- Non-matching rules → appended with `(max-width: 0px)` (always false)
- Original media queries are stored and restored when switching away
## Features
**Core Functionality:**
- Simulates media query conditions by replacing them with
always-true/false queries
- Supports all condition-based media features (`prefers-color-scheme`,
`prefers-reduced-motion`, etc.)
- Handles both spaced and non-spaced formats
**Performance:**
- Caches media rules by feature to avoid repeated DOM traversal
- Debounces rapid breakpoint changes (50ms)
- Uses WeakMap for automatic memory management
**Robustness:**
- Validates restoration success with warning logs
- Handles CORS-restricted stylesheets gracefully
- Proper cleanup on abort signal with cache clearing
## Technical Implementation
**Key Functions:**
- `parseCondition()` - Parses condition strings
- `getMediaRulesForFeature()` - Caches and retrieves relevant media
rules
- `applySimulation()` - Debounced application of media rule
modifications
- `restoreAllRules()` - Restores original media queries
- `subscribeBreakpointSimulator()` - Integrates with nano-states and
lifecycle
**Integration:**
- Subscribes to `$selectedBreakpoint` nano-state
- Runs in design mode only
- Cleanup via AbortSignal
## Testing Instructions
**Setup:**
1. Create CSS variables with condition-based values
2. Configure breakpoints with conditions (e.g.,
`prefers-color-scheme:light`, `prefers-color-scheme:dark`)
**Test Cases:**
- Select condition-based breakpoint → verify canvas reflects correct
theme without changing OS settings
- Rapidly switch between breakpoints → verify smooth transitions
- Switch to width-based breakpoint → verify original media queries are
restored
- Check console for errors (should only see warnings for legitimate
issues)
## Impact
Designers can now preview dark/light themes and other condition-based
styles instantly without changing system settings, significantly
improving the workflow for building modern, accessible interfaces.
---------
Co-authored-by: zehjotkah <111518041+zehjotkah@users.noreply.github.com>
|
||
|
|
c5431eb96e |
fix: preserve -webkit-text-stroke prefix in CSS parsing (#5584)
When entering -webkit-text-stroke in the advanced style section, it was incorrectly converted to --text-stroke (CSS variable). This happened because normalizeProperty() strips vendor prefixes from properties not in the prefixedProperties allowlist, and then parse-style-input.ts sees the unknown property 'text-stroke' and converts it to a CSS variable. Changes: - Add -webkit-text-stroke, -webkit-text-stroke-color, and -webkit-text-stroke-width to prefixedProperties list - Add test for -webkit-text-stroke preservation ## Description 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file |
||
|
|
fdee339de0 | chore: Migrate to tsgo (#5578) | ||
|
|
1f4c53419d |
feat: Pseudo elements (#5572)
This PR replaces the limited "States" dropdown in the Style Panel with a flexible input field that supports any CSS selector, pseudo-class, or pseudo-element. This allows for advanced styling capabilities such as `:has()`, `:focus-visible`, and complex combinators. ## Key Changes ### Flexible Selector Input - Replaced the fixed "States" category list with a free-form input field. - Supports **any** valid CSS selector (e.g., `:hover`, `::before`, `:has(:checked)`). - Validation logic ensures only valid selectors are accepted (triggered on `Enter` key). ## How to Test 1. Select an element and open the Style Panel. 2. Click on the Local style source or a Token. 3. In the input field (bottom of menu), type a selector like `:hover` or `:first-child` and press Enter. 4. Verify the selector is added and selected. --------- Co-authored-by: zehjotkah <111518041+zehjotkah@users.noreply.github.com> |
||
|
|
e9a3a1ac00 |
feat: Support any media query condition as a breakpoint (#5547)
## Description - [x] add a list of conditions - [x] allow other units for min/max ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file |
||
|
|
f7d56b8bac | fix: parse tailwind colors with css variables correctly (#5479) | ||
|
|
21bce61052 |
feat: support modern color spaces in color inputs (#5465)
Ref https://github.com/webstudio-is/webstudio/issues/3574 Here improved css value parser to parse and store any color space. oklch(), hsl(), color() and others can be used in any color input. Color picker converts to rgb on the fly and do not support any other color space at the moment. --------- Co-authored-by: Oleg Isonen <oleg008@gmail.com> |
||
|
|
7139a35c68 |
refactor: migrate to colorjs.io (#5463)
colord library we used does not support new color spaces like oklch. colorjs.io is mature library and handles this stuff just well. |
||
|
|
8d14d1b5e3 |
refactor: generate modern color syntax (#5456)
Ref https://github.com/webstudio-is/webstudio/issues/3574#issuecomment-3529164146 Here added ColorValue to styles schema. toValue now generates modern syntax like rgb(0 0 0 / 0.5) for both color and rgb values. |
||
|
|
02ca084a0c |
refactor: upgrade to csstree v3 (#5455)
The new version is aware of modern colors and other new css features. |
||
|
|
dc508445ce |
feat: Gradients UI (#5449)
## Description Closes https://github.com/webstudio-is/webstudio/issues/3448 ## Todo - [x] linear gradient - [x] without stops linear-gradient(red,green) - [x] delete stops - [x] support variables - [x] tweak design - [x] conic - [x] one-color - [x] radial |
||
|
|
0484d9c26f |
experimental: add gradient controller to update color stops using ui (#4159)
## Description The `GradientControl` helps in displaying the colour stops that are available in the linear-gradient that users added. There are two knows issues at the moment. - The only limitation is. We can't swap the colours when a colour stop crosses an existing colour stop. In some tools, the colours are swapped resulting in the swiping of the gradient too. This is because of a limitation/bug on the radix side, they pre-sort the slider stops. So, we can never know which crosses an existing stop and changed it's value. https://github.com/radix-ui/primitives/issues/2247 ## Steps for reproduction - Passing a linear-gradient should show all the `color-stops` in the gradient. - The `color-hints` are displayed at the bottom of the gradient bar. These can't be moved along, more info about it is in the code component. Because, this basically changes the whole gradient just by moving. - The `color-hints` are showed at the bottom of the gradient. Just to notify users about the existence of the hints. - Users should be able to move the color-stops along the slider track. - The color-stops can be moved using the arrow keys from the keyboard. <img width="299" alt="Screenshot 2024-09-25 at 10 32 47 AM" src="https://github.com/user-attachments/assets/d65e6af5-bba9-490d-96ff-0e58b8fb93bc"> <img width="289" alt="Screenshot 2024-09-25 at 10 32 43 AM" src="https://github.com/user-attachments/assets/a3ac83e1-d379-49dc-a5d8-42936960f761"> <img width="560" alt="Screenshot 2024-09-25 at 10 32 38 AM" src="https://github.com/user-attachments/assets/fef11d9e-2d0c-4d71-8587-227f22551edb">  ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 5de6) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file --------- Co-authored-by: Oleg Isonen <oleg008@gmail.com> |
||
|
|
aff636940b |
chore: drop legacy AI prompts and logic (#5345)
All of this is very outdated and does not make a lot of sense to have in our code base. |
||
|
|
4abb7cf3e2 |
feat: support svg properties in style panel (#5332)
Ref https://github.com/webstudio-is/webstudio/issues/5258 Newer mdn-data contains all stylable svg properties (they finally got through some documentation and implementation process). Tweaked all experimental stuff and ditched obsolete properties. <img width="286" height="538" alt="image" src="https://github.com/user-attachments/assets/1e579be0-0a12-4013-ab04-09d5e008aeed" /> |