From 4a21c4f93806bea3743a79eb6f0e6be8b8eee06d Mon Sep 17 00:00:00 2001 From: David Montero Date: Sun, 7 Jun 2026 01:13:55 +0200 Subject: [PATCH] fix(frontend): restore project library manifest inside buildLoadPayload (P2.4) The inline manifest-restore in the load .then was being tree-shaken out of the lazy ProjectByIdPage chunk (the deployed bundle had the save wiring but not the load). Move it into buildLoadPayload, which is an exported helper (used by tests) so its body is never dropped. Reloaded projects now re-send their manifest. --- frontend/src/pages/ProjectByIdPage.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/ProjectByIdPage.tsx b/frontend/src/pages/ProjectByIdPage.tsx index 2c9b311e..42453598 100644 --- a/frontend/src/pages/ProjectByIdPage.tsx +++ b/frontend/src/pages/ProjectByIdPage.tsx @@ -55,16 +55,9 @@ export const ProjectByIdPage: React.FC = () => { getProjectById(id) .then((project) => { + // buildLoadPayload also restores the library manifest (P2.4). const payload = buildLoadPayload(project); loadProjectState(payload); - // P2.4 — restore the declared library manifest (compile scope), also - // clearing any stale example manifest from before this load. - try { - const libs = JSON.parse(project.libraries_json || '[]'); - useLibraryManifestStore.getState().setLibraries(Array.isArray(libs) ? libs : null); - } catch { - useLibraryManifestStore.getState().setLibraries(null); - } setCurrentProject({ id: project.id, slug: project.slug, @@ -146,6 +139,7 @@ interface RawProject { files: { name: string; content: string }[]; file_groups?: { groupId: string; files: { name: string; content: string }[] }[]; boards_json?: string; + libraries_json?: string; // P2.4 — declared library manifest (compile scope) code: string; components_json: string; wires_json: string; @@ -239,6 +233,16 @@ export function buildLoadPayload(project: RawProject) { wires = []; } + // P2.4 — restore the project's declared library manifest as the compile + // scope (clearing any stale example manifest from before this load). Done + // here, inside this exported helper, so the call is never tree-shaken. + try { + const libs = JSON.parse(project.libraries_json || '[]'); + useLibraryManifestStore.getState().setLibraries(Array.isArray(libs) ? libs : null); + } catch { + useLibraryManifestStore.getState().setLibraries(null); + } + return { boards, fileGroups,