fix(compose): keep the scene background instead of losing it on refresh - #25
Merged
Merged
Conversation
The background is the scene — the place the figures stand in. The editor collected it into a URL.createObjectURL blob in React state and stopped there: it was never uploaded, and compositions.background_url was never written, even though the column, the storage folder and an authorized, versioned /api/compositions route all already existed. So the background survived exactly one page view. Reopen the project the next day and the canvas is bare black — and the export takes the stage as it finds it, renders the panels from it and reports "print-ready" for a file with no scene in it at all. Same failure shape as the baked-in guides in #20: a confident success message on an artifact nobody re-checks before it goes to the print shop. The upload now goes to storage and the path to the composition row, so the background reloads with the project. Export refuses to run while it is still in flight rather than printing the bare canvas. Only background_url is written. Figure placement already lives on the figures rows, and copying it into layout would give it a second home. An orphaned endpoint is what made this invisible, so wired.test.ts fails if any route family has no caller in the app — verified by removing the new hook, which fails it on /api/compositions. verify: lint 0 errors (8 pre-existing warnings) · tsc clean · 78 tests pass Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014opKWKa65PXxn2MiWSKwwh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
The scene background — the place the figures stand in — was held only in a
URL.createObjectURLblob in React state. It was never uploaded andcompositions.background_urlwas never written, even though the column, thebackgrounds/storage folder, and an authorized, versioned/api/compositionsroute all already existed. Nothing in the app called that route.Two consequences:
handleExportPngrenders the Konva stage as it finds it, so it produces panel files with no scene in them and still reportsPrint-ready — N panel files at 200 DPI. Same failure shape as the baked-in guides in fix(export): produce a file the print shop can actually use #20: a confident success message on an artifact nobody re-checks before it reaches the print shop.The fix
useComposition/useSaveComposition(matching theuseSurfaceidiom) wire the existing endpoint up.backgrounds/, already supported bygetStoragePath; insert is still permitted after fix(storage): take delete and update away from the anon key #24) and the path to the composition row, so it reloads with the project.crossOrigin = 'anonymous', the same asFigureLayer— that is what keeps the stage untainted so the export can still read pixels back out.setStatein an effect).Only
background_urlis written. Figure placement already lives on thefiguresrows — copying it intolayoutwould give it a second home.Regression guard
An orphaned endpoint is what made this invisible.
wired.test.tsfails if any route family has no caller in the app. Mutation-verified: removing the new hook fails it on/api/compositions, and it passes with the hook restored.Verify
🤖 Generated with Claude Code
https://claude.ai/code/session_014opKWKa65PXxn2MiWSKwwh