feat(editor): adopt backend final-fix contract (client_id, warnings, limits, head parity)

client_id per editor load (memory only), already_saved, save warnings via notices,
upload_max_bytes enforced client-side with the server error text on 413,
project_max_bytes warning, headCode in the Preview font scan, pinned backend heads.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-10-07 13:49:53 -07:00
1 parent eb401cd979
commit 9d425afa29
17 files changed
+581 -38

No files matched your search

+7 -3
View File
@@ -1,6 +1,7 @@
import { useState, useCallback } from 'react';
import { useEditorConfig } from '../state/EditorConfigContext';
import { AssetData } from '../types';
import { uploadSizeError, uploadFailureText } from '../utils/site-limits';
export function useAssets() {
const { whpConfig, isWHP } = useEditorConfig();
@@ -38,6 +39,8 @@ export function useAssets() {
const uploadAsset = useCallback(async (file: File): Promise<string | null> => {
if (!isWHP || !whpConfig) return null;
const tooBig = uploadSizeError(file);
if (tooBig) { setError(tooBig); return null; }
setLoading(true);
setError(null);
try {
@@ -52,9 +55,10 @@ export function useAssets() {
body: formData,
}
);
if (!resp.ok) throw new Error(`Upload failed: ${resp.status}`);
const data = await resp.json();
if (!data.success) throw new Error(data.error || 'Upload failed');
let data: any = null;
try { data = await resp.json(); } catch { /* non-JSON body */ }
// The server's `error` is human text (the 413 size message included): show it as-is.
if (!resp.ok || !data?.success) throw new Error(uploadFailureText(data, resp.status));
const newAsset: AssetData = {
name: data.name || file.name,