Files
webstudio/apps/builder/app/services/api-compatibility.server.ts
Oleg Isonen 7d781bdc86 fix: MCP fixes (#5870)
Improves CLI and MCP reliability across project synchronization, asset
editing, imports, audits, and clipboard workflows.

## Changes

- Keeps asset filename and description updates after session refresh.
- Prevents intermittent Immer patch errors during consecutive MCP
mutations.
- Prevents false edit conflicts caused by stale local session state.
- Preserves asset uploads without treating them as redundant metadata
updates.
- Exposes editable asset filenames consistently through MCP.
- Imports project assets correctly when copying projects between
environments.
- Supports refreshing partially available project snapshots.
- Keeps MCP operations working when optional project data is
unavailable.
- Produces clearer compatibility errors when the API and CLI versions
differ.
- Makes rendered audits more resilient when individual screenshots fail.
- Prevents rendered audits from hanging while starting browser captures.
- Handles denied clipboard permissions without uncaught browser errors.
- Improves copy and paste reliability for pages, components, styles, and
animations.

## Verification

- Asset uploader tests and typechecking pass.
- Focused asset workflow E2E passes.
- Complete E2E shard 1 passes.
- Realistic MCP subagent test confirms:
  - Asset filename and description persist after refresh.
  - Consecutive mutations work without manual refresh.
  - No Immer patch error occurs.
  - No false conflict occurs.
  - Original asset values can be restored successfully.
2026-07-13 02:32:27 +02:00

19 lines
505 B
TypeScript

import { TRPCError } from "@trpc/server";
import {
createApiCompatibilityPayload,
type ApiCompatibilityTarget,
} from "@webstudio-is/trpc-interface/api-compatibility";
export const throwApiClientUpdateRequired = (
target: ApiCompatibilityTarget
): never => {
throw new TRPCError({
code: "PRECONDITION_FAILED",
message: "The API client must be updated before continuing.",
cause: createApiCompatibilityPayload({
reason: "clientVersionUnsupported",
target,
}),
});
};