mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
31af7cf3c286dd6994fc91c9270b4be52b895f49
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d4b5b328a4 |
fix: Resolve reproduced bugs reported on Discord (#6639)
## What this fixes This PR fixes the bugs from #6633 that we could reproduce: - Spacing reset no longer triggers canvas Delete; autocomplete selection is readable in both themes. - Breakpoint widths save on Enter or blur, without reordering while someone types. Typed addresses no longer reuse an old history suggestion. - Redirect edits use saved project state, and unchanged old redirects do not block unrelated edits. Client-side links now follow project redirects, including sites with a custom 404 page. A new publish keeps polling past an old failed build. - Editors can open older projects and edit supported Markdown bindings without changing protected styles or permissions. Older Code Text edits now survive save, reload, and a later Builder visit; Editors cannot replace Code Text bindings. - Form writes are sent once per submission, even when a response fails. Safe response redirects still work. - Published pages and Builder Preview restore scroll without unwanted smooth animation. Preview keeps smooth anchors, repeated anchors, Back/Forward positions, and page entry animations. - Large-page selection and paste avoid rerendering unchanged Navigator rows and rescanning unchanged asset references. Keyboard focus now follows a moved row when its new parent expands. ## Checklist - [x] Third deep review: verify the pending legacy Editor permission and remounted scroll-restoration fixes; simplify the 11 modified files and deleted hook; demonstrate regression failures and passes. - [x] Third review: review documentation and fixture impact; run affected tests, typechecks, lint, formatting, and package boundaries. - [x] Third review: commit only the pending changes, push to this PR, review hosted results, and pass required CI. - [x] Second deep review: check save permissions, redirects, scroll, and UI state; fix reproduced problems and rerun affected checks. - [x] Deep-review the full PR, simplify repeated code, fix verified problems, and rerun affected checks. - [x] Make project redirects work on client-side link clicks, including sites with a custom 404 page; add a failing regression test, verify both runtimes, and review documentation impact. - [x] Reproduce the changed behaviors; show regression tests fail and pass. - [x] Check Editor, Preview, Navigator, Form, redirect, publish, and theme behavior in focused tests and browser workflows. - [x] Review the full diff for correctness, duplication, and needless complexity. Simplify redirect validation and strengthen the cross-page anchor test. - [x] Inspect light and dark autocomplete screenshots and approve the one intended new visual story. - [x] Review documentation impact. Update the Form guide for uncertain delivery responses; other changes restore expected behavior. - [x] Complete independent review, package typechecks, lint, boundaries, generated API/docs checks, and fixture build. - [x] Run the approved full agent evaluation suite. Eight of nine scenarios passed; the remaining evaluator and baseline limits are below. - [x] Pass required CI on the earlier review commits; the third-review head is tracked above. ## Implementation notes Preview uses one navigation request between the Builder and canvas. It records scroll before a page changes and restores it before entry animations. Router keys are observed only in Preview. This adds 211 net production lines because shorter approaches failed repeated anchors, delayed navigation, and returns from Design. Navigator and focus changes add 87 lines; the shared published-page hook adds 40. The earlier cleanup added 427 net production lines; this review adds 43 net non-test lines. Legacy document bindings are normalized when loading a snapshot and checking Editor capabilities. Older Code Text content is normalized on reads without saving; the first edit removes its stale property in the same version-checked save. Direct Editor patches cannot add or replace Code Text expressions. Editor reads do not migrate the database. Read-only bindings and template styles remain protected. No schema, package, icon, or product copy changes are included. The visual harness has an opt-in focus setting for the autocomplete story. Its default blur behavior is unchanged. The test now mounts scroll restoration after the route content, matching the production Body; it checks an anchor found only on the destination page. ## Review follow-up The review found two reproducible bugs. Older Code Text edited by an Editor could be overwritten by the legacy `code` property on a later Builder visit. A Navigator row moved into a collapsed parent could lose keyboard focus. Both are fixed with regression tests. The review also removed one duplicate parser, a repeated autocomplete color check, and an unnecessary prop scan on page-only saves. The Remix scroll test now mounts restoration in the same order as production. The legacy Code Text test covers literal and expression content, direct patch permissions, save retries, undo/redo, and Editor → reload → Builder → reload. The local end-to-end test passed. The other focused tests, affected package typechecks, lint, formatting, package boundaries, generated API/docs checks, and fixture build passed. A fixture sync picked up unrelated remote sitemap data; that generated drift was removed from this PR. The full agent evaluation was not rerun for this follow-up. ## Client-side redirects The root loader now checks redirects when the path changes, even when a custom 404 route matches. A generated yes/no flag in its own file avoids extra navigation requests on projects without redirects; the browser does not receive the redirect list. Projects with redirects pay for a root-loader check on each path change. Query-only navigation keeps the router's normal revalidation behavior. The new test reproduced the custom-404 failure before the fix and passes afterward. Both React Router and Remix templates, generated fixtures, typechecks, production builds, and the redirect-settings browser test pass. Existing redirect docs already describe this expected behavior, so no docs change is needed. ## Performance With 3,000 styled elements, median selection fell from 986 ms to 413 ms in a controlled local browser test. Full page paste including save measured 3.4 seconds afterward; the earlier run varied from 4 to 15 seconds, so that is not a reliable whole-paste speed multiplier. Skipping an unchanged asset-reference rewrite reduced that isolated step from 1,500 ms to 7 ms with 200 assets, 3,000 properties, and 12,000 styles. The browser still downloads and syncs project data, traverses the tree, validates and imports assets, inserts content, renders, and saves. Cross-project imports can still transfer assets. ## Second review follow-up Changing a breakpoint from Min width to Max width (or back) now saves the type and width together. A mixed Builder/Editor save now checks each Editor change against the Builder changes before it, including older Code Text bindings and changes to Content block boundaries. If an earlier save fails, later entries do not run against a state that was never saved. A full page reload now restores its saved scroll position without animating through the page. Client navigation still uses the existing hook. The two early scripts add no network request; they run next to the router's restore script, then restore the page's smooth-scroll setting. A nonce on Body is passed to all three scripts. Rebuilding Editor permissions costs a fresh scan only for mixed-permission batches; all-Builder batches keep the fast path. Focused checks passed: 40 patch authorization/save tests, five breakpoint browser tests, two early-scroll browser tests, 12 router navigation browser tests, four package typechecks, lint, formatting, and diff checks. The real SSR test also passed with delayed hydration and a nonce-only script policy, with no scroll animation or hydration warning. The full agent evaluation was not rerun; the earlier 8/9 result and its known evaluator limit remain unchanged. Documentation impact was reviewed again; these changes restore expected behavior and need no new user guide. On commit `b61c3aaf07`, the main workflow, all ten Builder browser shards, lint, submodule checks, and the approved visual rerun passed. The first visual comparison still records the already reviewed autocomplete difference; its approval rerun passed. ## Third review follow-up The pending changes close two Editor permission gaps. IDs hidden by read-time Code Text normalization remain reserved, so an Editor cannot reuse one to overwrite a protected saved prop. New Code Text accepts literal content but cannot introduce expressions. A Builder can deliberately replace a legacy prop and leave the replacement editable. Scroll preparation now runs after the destination DOM is inserted and before the router restores scroll. This preserves smooth anchors when restoration remounts with a page. The shared component replaces the separate hook. The navigation test now covers all six cases with and without remounting, removing the duplicate remount setup. The patch adds 51 net non-test lines, close to the 50-line estimate; the extra state records hidden saved IDs, and the extra component orders the three layout effects. Regression checks reproduced the hidden-ID overwrite, new expression insertion, copied-prop ID reuse, and instant remounted anchor before the fixes. They pass with the fixes. Local checks passed: all 2,677 project-build tests, 48 patch tests, the three SDK package suites (including 219 SDK React tests with one existing skip and 46 React Router tests), all five affected package typechecks, lint, formatting, package boundaries, generated API/docs checks, and fixture regeneration. Two Form tests timed out in the first parallel SDK run; both passed in isolation, and the complete SDK suite passed with one worker. Fixture regeneration used the existing local snapshots and downloaded required assets; it produced no tracked fixture changes. Remote fixture synchronization was not rerun. The Code Text, Content Block, share-link, and Link docs already describe the intended behavior, so no docs change is needed. The full agent evaluation was not rerun; its earlier 8/9 result and baseline limits still apply. A separate local model review was unavailable. Hosted automatic code and security reviews completed on `472dbc103e`; neither posted findings, and there are no unresolved review threads. Committed and pushed as `472dbc103e`. The [main workflow](https://github.com/webstudio-is/webstudio/actions/runs/42071262279) passed, including all ten Builder end-to-end shards, both package/CLI/core/app environments, typechecks, lint, generated checks, migrations, and size checks. Development preview fixture checks passed on Ubuntu and Windows. The [visual approval rerun](https://github.com/webstudio-is/webstudio/actions/runs/42071810156) passed. Its initial run flagged only the previously approved autocomplete story; all 267 stories were compared, with no other differences. The story was unchanged by this commit, so its existing approval was reapplied. The worktree is clean, and the remote branch matches the local commit. The excluded issues and other worktrees were not changed. No production deployment was initiated. ## Remaining follow-ups - #6645: The measured asset-remapping slowdown is fixed here, but the reported 30-second end-to-end paste remains unverified. Closed as not planned until the reporter shares a reproducer. - #6646: MCP can now inspect Global root defaults, but the reporter's original AI run remains unverified. - #5379: The broader proposal to remove the root grid remains open; this PR fixes the narrower overflow bug #6070. - #6644 was closed as not planned after local tests passed. The bad SSL report and unrelated feature requests are outside this PR. No shipped-fix announcement or production release is included. ## Verification The previous commit passed the main workflow, all ten browser shards, lint, submodule checks, and the approved visual rerun. The review commit passed the main workflow, all ten Builder browser shards, lint, submodule checks, and the visual-approval run. The initial visual check flagged the already-reviewed new autocomplete story; the approval run passed without a visual code change. An earlier browser run caught a generated-file format change; the follow-up kept that format intact and passed the same test. The full agent evaluation suite was not rerun for this redirect follow-up; Oleg asked to run it once all remaining work is fixed. Local: 2,675 project-build tests, 1,522 Builder core tests (one existing skip), 40 React Router tests, eight affected-package typechecks, lint, format, boundaries, generated API/docs checks, and fixture build passed. The earlier head also passed the Builder app, SDK, component, CLI, Editor/Preview/Navigator browser tests. On the final commit, all ten hosted browser groups, package and app checks, fixtures, migrations, and the approved visual run passed. The first Builder core job hit its seven-minute CI limit without an assertion failure; its single-job retry passed. The first visual job listed the already reviewed new autocomplete story; its approval rerun passed. The complete Sol/high agent suite finished with **8/9 scenarios passing**. The remaining native Form authoring evaluator rejects a plain HTML action URL as though it were a managed Webstudio Action. That fixture did not test actual browser submission, so no runtime claim is made. The comparison gate remains non-green: five baselines use another model and four fixtures have no accepted baseline. No baseline or validator was changed to hide this. The MCP Form result fix for #6640 is now included below. A fast redirect no longer leaves MCP without the Form result. The older local source failure helped reproduce this case. Closes #6633 Closes #6640 Closes #2439 Closes #6642 Ref #6645 Closes #6641 Closes #6643 Ref #6644 Ref #6646 Closes #6647 Ref #5379 Closes #6070 Ref #980 Ref #4309 Ref #6573 ### Consolidation of follow-up fixes - [x] Include and verify the Resource body, expression Tab, and 404 starter fixes from #6649, #6651, and #6650. - [x] Include and verify the root overflow, Navigator lag, and asset-paste fixes from #6652, #6653, and #6654. - [x] Include the Global root MCP inspection fix from #6655, with its discoverable example. - [x] Review `docs/` and fixture impact for the combined changes. - [x] Pass final CI on the combined branch. - [x] Close the superseded PRs after their changes were verified here. The 30-second end-to-end paste report is closed in #6645 until the reporter shares a reproducer. The original MCP agent outcome in #6646 is still unverified. Oleg approved keeping the public MCP example. The fix from #6656 is now included in this PR. The combined branch passed 236 focused tests, Builder/SDK/project-build typechecks, lint, formatting, package boundaries, generated API and MCP-doc checks, and the fixture pipeline. The fixture sync fetched an unrelated live-project change; rebuilding from the checked-in data restored a clean worktree. All nine agent evaluation scenarios passed, but the comparison gate remains non-green because saved baselines are missing or use a different model. The [main workflow](https://github.com/webstudio-is/webstudio/actions/runs/42090765144) passed all jobs, including ten Builder browser shards. The [approved visual rerun](https://github.com/webstudio-is/webstudio/actions/runs/42091462930) passed; its first run flagged only the already-reviewed new autocomplete story. PRs #6649–#6655 were closed as superseded, with their changes retained here. ### Final MCP Form consolidation - [x] Include the tested MCP Form redirect fix from #6656 without changing submission count or result limits. - [x] Run focused Vision/CLI tests and review the combined diff. - [x] Review `docs/` and fixture impact for this fix. The change is limited to Vision's Form result capture and tests; no docs or fixture update is needed. - [x] Pass CI on the new combined head. - [x] Close #6656 once its change is verified here. The user clarified that all bug-fix PRs from this work should be one PR. The MCP Form redirect fix belongs here too. The two Vision files match #6656 exactly. All 121 Vision tests, Vision and CLI typechecks, formatting, and the 59 focused Form capture tests passed. In the full local CLI run, 1,304 tests passed and two unrelated tests failed under parallel load; both passed in a single-worker rerun. The [main CI run](https://github.com/webstudio-is/webstudio/actions/runs/42093902295) passed, including all ten Builder browser shards. The [approved visual run](https://github.com/webstudio-is/webstudio/actions/runs/42095225165) passed. The initial visual run flagged only the previously approved autocomplete story. #6656 is closed as superseded by this PR. No production release was started. ### Large-project Navigator follow-up - [x] Import the provided large project into an isolated local Builder and measure selection-to-Style-Panel time with the tree expanded. - [x] Measure Navigator scrolling and confirm whether the current scroll path is native. - [x] Fix only the reproduced bottlenecks, with regression checks that fail before the change and pass afterward. - [x] Review `docs/` and fixture impact; run focused tests, typecheck, lint, and browser checks. - [x] Open the fixed local Builder for Oleg's manual check, then pass final CI. This follows the original large-page Navigator report in #6641. The separate 30-second paste report #6645 remains closed because it describes a different action and has no paste reproduction yet. The imported project has about 1,244 visible Navigator rows on the measured page. With the tree expanded, selection took roughly 0.9–2.2 seconds before this change and roughly 0.5–1.3 seconds afterward in local browser runs. Browser style recalculation fell from about 0.4–1.0 seconds to about 0.1–0.3 seconds per selection; times vary by run. The Navigator now uses native scrolling and lets the browser skip layout for rows off-screen. Horizontal wheel scrolling was restored and checked after Oleg spotted a regression. A focused regression test failed before the change and passes now. The Navigator tests, Builder typecheck, lint, formatting, diff check, and local browser selection/vertical/horizontal scrolling passed. The `docs/` guide and fixtures need no change because the interaction stays the same. Oleg reports that performance feels good in the local Builder. The [main CI run](https://github.com/webstudio-is/webstudio/actions/runs/42103807815) passed, including all ten Builder browser shards. One unrelated design-system browser test timed out on the first run and passed on retry. The [visual approval run](https://github.com/webstudio-is/webstudio/actions/runs/42105155951) passed after review of tiny Navigator text-pixel differences and the previously approved autocomplete story. No production release was started. ### Final review: Navigator drop marker - [x] Reproduce the clipped marker with a focused regression test. - [x] Keep the marker visible without losing off-screen-row performance. - [x] Review `docs/` and fixture impact, run focused tests, typecheck, lint, formatting, and browser checks. - [x] Push this fix to the same PR and pass required CI. The regression test failed before the fix (`auto` instead of `visible`) and passed afterward. A sortable row now marks when it has a drop target; only that row skips the off-screen containment rule, so its marker can cross the row edge. Other rows retain containment. Navigator and tree browser tests, both typechecks, lint, formatting, and diff checks passed locally. The Navigator guide still describes the same drag-and-drop behavior; no docs or fixture update is needed. This adds two net non-test lines, matching the small-change estimate. The [main CI run](https://github.com/webstudio-is/webstudio/actions/runs/42109032555) passed all 23 jobs. Two MCP Form browser shards first returned an unexpected `unknown` form status, then passed on rerun without a code change. The [visual approval run](https://github.com/webstudio-is/webstudio/actions/runs/42109658799) also passed. No production release was started. ### Drop marker color follow-up - [x] Remove the white outline and white fill so the marker is blue with a transparent center in both themes. - [x] Add a browser regression check that fails before the fix and passes after it. - [x] Review `docs/` and fixture impact; run focused tests, typecheck, lint, and formatting. - [x] Push to this PR and pass required CI. The old styles failed the new light/dark browser test because the line had a white outline. After removing the outline and the white circle backing, all 20 focused indicator/tree tests pass. Design-system typecheck, lint, formatting, and diff checks pass. The Navigator guide describes behavior, not marker colors, so docs need no update. No fixture input or output changes. The [main CI run](https://github.com/webstudio-is/webstudio/actions/runs/42115118863) passed all 23 jobs. Three MCP Form browser shards first returned an unexpected `unknown` status and passed on rerun without a code change. The [approved visual run](https://github.com/webstudio-is/webstudio/actions/runs/42115696559) passed after GitHub cancelled its first attempt. The intentional indicator difference and the two previously reviewed Navigator text differences were approved. No production release was started. ### MCP Form status follow-up - [x] Review the old first-attempt failures and compare the new first-pass Form CI results; the old reports did not expose which layer failed. - [x] Stop masking pre-submission browser errors as uncertain Form outcomes; confirm the regression test fails before and passes after. - [x] Review `docs/` and fixture impact; run focused tests and package checks. - [x] Push the fix to this PR and pass required CI. The CLI had returned `unknown` for every browser error, including startup failures before any Form submission. It now lets those errors surface. The browser observer still returns `unknown` if a submission may have happened, and neither path retries it. This removes 8 net production lines. The regression test failed before the fix and passes afterward. All 50 CLI preview tests and 59 Vision browser tests passed, as did CLI/Vision typechecks, lint, formatting, and the diff check. No docs or fixtures changed. The approved full agent evaluation ran: 8/9 scenarios passed; the existing managed-Form authoring `contactPage` check failed, while the Form runtime scenario passed. The comparison gate is also non-green because saved baselines are missing or incompatible. Commit: `a2ff0822ad`. The intermittent CI cause still needs a first-attempt check. [Main CI on the new head](https://github.com/webstudio-is/webstudio/actions/runs/42123770480) passed all jobs, including all ten Builder browser shards on their first attempt. The Form-heavy shards 1, 5, 6, 9, and 10 passed. The [approved visual run](https://github.com/webstudio-is/webstudio/actions/runs/42124446769) passed; its initial run showed only the four previously reviewed UI differences, none from this CLI-only patch. The older flaky `unknown` results cannot be attributed to startup versus post-dispatch observation from their logs, so this fix addresses a proven masking bug and adds regression coverage, but does not prove every possible intermittent observer failure is gone. No production release was started. |
||
|
|
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
|
||
|
|
db2d092268 |
ci: replace Lost Pixel with self-hosted visual regression (#6086)
## Summary Replace the defunct Lost Pixel service and the interim Chromatic workflow with a fast, self-hosted visual comparison pipeline. The workflow indexes the existing CSF stories without building Storybook, builds and serves a lightweight browser app with Vite, renders the merge base and current revision through Webstudio's shared browser tooling, and compares screenshots with Webstudio's pixel-diff and OCR engine. It uses GitHub Actions cache and artifacts only—no R2 bucket or external visual-testing service. Closes #6064 ## Implementation - [x] Remove the Lost Pixel workflow, configuration, acknowledgement, and global two-second wait. - [x] Remove the interim Chromatic workflow and settings. - [x] Extract source-agnostic capture, diff, OCR, audit, cache, and report tooling into `@webstudio-is/vision`; rename the Webstudio-specific preview boundary to `@webstudio-is/project-build/preview`. - [x] Expose the reusable browser capture session through the shared vision boundary. - [x] Make OCR and diff-artifact generation conditional on detected pixel changes. - [x] Render existing CSF stories through a typed, lightweight browser harness built with Vite. - [x] Replace the embedded HTML and handwritten HTTP/MIME server with a real HTML entry, Vite production build, and Vite preview server; isolate declarative build configuration in `story-build.ts`. - [x] Apply Storybook preview annotations, decorators, global CSS, backgrounds, and story metadata. - [x] Store story scopes as shared data and load each revision's own configuration. - [x] Discover changed, added, and removed stories from both revisions. - [x] Populate private story sources symmetrically in the baseline worktree. - [x] Isolate every story with a fresh React root and deterministic time, randomness, intervals, focus, animation, and layout readiness. - [x] Preserve story-owned visual options for masking, settling, and interval control. - [x] Reuse Vite preview servers, one Chromium process, grouped browser pages, production bundles, and a bounded CPU worker pool for image comparison. - [x] Recheck initial pixel differences with serial captures, then recapture persistent baseline/current pairs on the same browser page so renderer variance cannot create false failures. - [x] Report individual story render failures without discarding successful captures. - [x] Enforce a 0.1 per-pixel threshold and 0.001% total mismatch tolerance. - [x] Run OCR only for changed comparisons and include text-change evidence. - [x] Move the generic report model, writer, static viewer, and opener into the shared Vision package for reuse by CI and future CLI comparisons. - [x] Bundle report HTML, styling, and browser behavior as static Vision assets without runtime source-file lookups. - [x] Copy external screenshot inputs into self-contained report artifacts for CLI reuse. - [x] Handle cached removed-only comparisons without rendering the removed story on the current server. - [x] Support focused local reproduction and opening the report with one command. - [x] Pin CI to the lockfile's Playwright Chromium, cache complete revision screenshots with matching restore/save paths and automatically derived runtime invalidation, and render both revisions on a miss. - [x] Keep cache archives bounded to one revision instead of accumulating the cache history. - [x] Run the complete visual suite in one CI job and upload one report as a 14-day artifact. - [x] Fail PR checks on visual differences, empty runs, missing screenshots, missing or empty report artifacts, and infrastructure failures. - [x] Rerun fork checks when `safe-to-deploy` is added. - [x] Allow reviewed visual-only differences through `visual-change-approved` and invalidate approval after new commits. - [x] Keep capture, pixel diff, OCR, and report generation source-agnostic for future draft-versus-published project comparisons. - [x] Use Vite for the complete story HTML, module, asset, production-build, and preview-server lifecycle; inline the selected stories and skip ineffective tree-shaking to keep the cached run under one minute. - [x] Review Builder product documentation impact: no user-facing Builder documentation is affected; contributor usage is documented in `scripts/visual-regression/README.md`. - [x] Review fixture impact: no fixture inputs or generated fixture outputs are affected. ## Verification - [x] Project-build Vision tests, including the reusable report test, and entrypoint contract tests pass. - [x] CLI screenshot, preview, and browser-session tests pass. - [x] Project-build, CLI, Builder, design-system, and visual-runner typechecks pass. - [x] Visual runner tests pass (10), and the complete Vision package passes (79), including demonstrated fail-before/pass-after coverage. - [x] Full Storybook production build passes. - [x] Full local Vite run completes all 238 stories in 69.9s cold and 50.3s with a cached baseline plus two same-page serial verifications, with zero differences; identical-image comparison remains sub-second. - [x] The report writer passes a bundled-output smoke test and materializes external screenshot assets. - [x] The generated report validates all 238 entries and referenced images. - [x] Hosted cached-baseline comparison completes all 238 stories in 52.9s with zero differences; the cache-miss fallback completes in 101.3s. - [x] Cache-miss fallback renders both Git revisions on demand. - [x] Visual differences produce baseline, current, diff, OCR, JSON, and HTML evidence and fail without approval. - [x] Hosted single-job visual workflow restores both the pinned browser and baseline cache, validates all 238 public and private stories with zero differences, and uploads the report. - [x] The final Vite production build renders all 238 stories without dependency invalidation or duplicate React runtimes, and restores `NODE_ENV` so cached serial fallback installs the baseline's dev dependencies. - [x] Root lint, package-boundary validation, and relevant formatting checks pass. - [x] Workflow YAML parses successfully. - [x] `git diff --check`, staged-diff review, and final worktree review pass. ## Usage Run the complete local comparison and open the visual report: ```sh pnpm visual-regression:ui ``` Focus one component while iterating: ```sh pnpm visual-regression:ui -- --grep "Design system/Button" ``` Reopen the latest report without rerunning: ```sh pnpm visual-regression:report ``` The CI report is available as the `visual-regression-report` artifact. ## Tradeoffs - Baseline screenshots are a disposable acceleration cache, not source of truth. A missing or invalid cache renders the merge base directly from Git. - GitHub artifact storage provides downloadable one-click reports; permanently hosted browser links would require another hosting surface. - OCR runs after pixel triage because invoking Tesseract for every unchanged story would make the common path unnecessarily slow. - Vite production builds add Rollup's module graph and HTML/asset pipeline. The runner emits one bundle because every selected story is rendered, and skips tree-shaking because it removed little while increasing build time. - The verified local path is 50.3s cached and 69.9s cold. The hosted path is 52.9s cached and 101.3s cold. A new browser/runtime cache must render its baseline once; the pinned browser keeps later runners on the reusable path. - The complete suite stays in one Actions job; browser-page concurrency is internal and bounded. |