Files
webstudio/apps/builder/app/shared/clipboard.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

13 lines
356 B
TypeScript

import { builderApi } from "./builder-api";
const clipboardReadErrorMessage =
"Webstudio cannot read the clipboard. Allow clipboard access in your browser, then try again.";
export const readClipboardText = async () => {
try {
return await navigator.clipboard.readText();
} catch {
builderApi.toast.error(clipboardReadErrorMessage);
}
};