Files
webstudio/packages
Oleg Isonen bc7e58af84 fix: Stabilize Preview and MCP issue reports (#6572)
## Problem

A fresh iterative Preview can lose its rendered content on the first
client navigation with a React `useContext` error. MCP issue reports can
also miss the page or instance ID needed to locate a problem, and
concurrent tool calls can overwrite newer report context with an older
snapshot.

## Fix

- Have Vite scan generated routes before the first navigation. This
applies to the base React Router template and the Netlify and Cloudflare
overlays. It changes local iterative Preview, not saved project data or
production routing.
- Include up to three recent, validated tool targets in MCP issue
reports. A project-relative screenshot path is matched to its page ID;
the CLI does not store the path, full URL, token, or page content. It
cannot read the Builder's current UI selection, but includes an instance
ID when a tool call names one.
- Treat structured MCP error results as failures and serialize
report-state writes within a CLI session, so a concurrent older write
cannot replace a newer result.

The reporting work from #6574 is now included here. #6574 is superseded.

## Verification

- Reproduced #6569 twice with CLI 0.306.0 and a cold optimizer cache.
With the Vite change, a cold `/` → `/blog` navigation and direct article
load rendered without browser errors.
- The config assertion failed without the Vite entry and passed with it.
A proposed optimizer test also passed without the fix, so it was
removed; the real cold-navigation check remains the behavioral evidence.
- The new concurrent-write test passed with serialization and failed
when the queue was temporarily removed. All 106 focused CLI tests, CLI
typecheck, root lint, formatting, and generated API check passed on the
combined branch.
- Earlier checks of the same Preview and reporting code passed: 133
prebuild tests, 144 project-build MCP tests, protocol and Builder
reporting tests, affected typechecks, CLI build, generated docs, and CI
on the separate PRs.
- The fixture build passed without changing tracked files. The full
local fixture pipeline stopped at sync because the development server
returned bundle version `bundle-17o6sch` while this checkout expects
`bundle-1sh9iaz`. The combined commit passed Linux and Windows fixture
checks and all other required CI jobs.
- Full Luna/low agent evaluations were run earlier on the combined
branch: the latest run passed 8 of 9 fixture tasks, while the
managed-form assertion failed on an unrelated task. Saved baselines were
missing or incompatible, so the command failed overall. No baselines
changed. Evaluations were not rerun for this final concurrent-write
change.

## Checklist

- [x] Reproduce and fix the first-navigation Preview failure
- [x] Cover the base, Netlify, and Cloudflare templates and generated
fixtures
- [x] Include safe recent page and instance IDs in MCP issue reports
- [x] Treat structured MCP errors as failures
- [x] Serialize concurrent report-state writes and verify the regression
test fails without the queue
- [x] Review documentation impact: Preview usage and user guidance are
unchanged; no docs change
- [x] Run focused local checks and attempt the fixture pipeline
- [x] Confirm required CI passes on the final combined commit

Closes #6569
Ref #6571
2026-10-21 10:09:05 +02:00
..