From 00f4399ccd2d9e4694e3a9aae19ec39395d5d47e Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Fri, 1 May 2026 16:29:00 -0700 Subject: [PATCH] =?UTF-8?q?PageScene:=20cold-load=20letterbox=20sync=20onl?= =?UTF-8?q?y=20=E2=80=94=20don't=20reapply=20on=20model=20switch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Almost every entry in ImageModels.ts declares `defaultAspectRatio: Square`, so the per-model-switch sync was forcing the letterbox to Square on every model swap and overriding whatever the user had picked. Replace `lastSyncedModelIdRef` with a single `didColdSyncRef` so the sync fires exactly once — when the engine and a `supportsNewAspectRatio()` model are both ready — and then never again. Subsequent letterbox changes flow only through user picks via PromptBox3D's `handleCommonAspectRatioSelect`. --- .../app/src/pages/PageScene/PageEditor.tsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/apps/artcraft/app/src/pages/PageScene/PageEditor.tsx b/frontend/apps/artcraft/app/src/pages/PageScene/PageEditor.tsx index a46530c83d..73fb79432f 100644 --- a/frontend/apps/artcraft/app/src/pages/PageScene/PageEditor.tsx +++ b/frontend/apps/artcraft/app/src/pages/PageScene/PageEditor.tsx @@ -293,23 +293,23 @@ export const PageEditor = () => { setCameraAspect(editorEngine, newRatio); }; - // Sync the editor letterbox to the model's default aspect ratio once - // both the engine and the selected model are ready. The earlier - // PromptBox3D-side effect raced: it fired before `editorEngine` was - // initialized (EngineProvider is async), so `setCameraAspect` was - // never called. Owning it here lets us depend directly on - // `editorEngine` being non-null. The ref guard prevents the effect - // from clobbering a later user pick on the same model. - const lastSyncedModelIdRef = useRef(null); + // Cold-load sync: align the editor letterbox with the picker's + // initial display (which falls back to `model.defaultAspectRatio`). + // Fires once when the engine and a `supportsNewAspectRatio()` model + // are both ready, then never again — every later change goes through + // user picks. We can't sync per-model-switch because almost every + // model declares `defaultAspectRatio: Square`, which would force the + // letterbox to Square on every swap and override the user's pick. + const didColdSyncRef = useRef(false); useEffect(() => { + if (didColdSyncRef.current) return; if (!editorEngine || !selectedImageModel?.supportsNewAspectRatio()) return; - if (lastSyncedModelIdRef.current === selectedImageModel.id) return; const def = selectedImageModel.defaultAspectRatio; if (!def) return; const mapped = commonToCameraAspect(def); if (!mapped) return; setCameraAspect(editorEngine, mapped); - lastSyncedModelIdRef.current = selectedImageModel.id; + didColdSyncRef.current = true; }, [editorEngine, selectedImageModel]); // MOVE THIS don't throw this in here