Files
artcraft/frontend/libs/components
Tanish Manku 456885f618 artcraft: gate PageDraw Generate on a loaded baseImageBitmap and cancel stale base loads
setBaseImageInfo updates baseImageInfo synchronously and only swaps in
baseImageBitmap once the <img> finishes loading. During that gap the canvas
still renders the previous bitmap while baseImageInfo.mediaToken already
points at the new image — clicking Generate would send the new image's token
alongside a mask drawn over the old pixels (inpaint path) or fail silently
(composite path). Worse, with no cancellation, a stale onload from a
previous selection could fire after the user moved on, overwriting
baseImageBitmap (and via applyImageNodes, drawNodes) with the wrong content.

Add a module-level generation counter in SceneState; bump on every
setBaseImageInfo and guard onload/onerror so superseded loads no-op. Wire
PageDraw's <PromptEditor isDisabled> to (!baseImageBitmap &&
!baseImageInfo?.isBlankCanvas) so the button visibly reflects this. Connect
PromptBox2D's existing isDisabled prop to the button's disabled attribute
(it was already checked in handleGenerate but never visualized).

Drop the latest-ref pattern around baseImageBitmap/baseImageInfo in PageDraw;
getCompositeCanvasFile now reads the live snapshot via useSceneStore.getState()
which is the simpler answer for state that already lives in Zustand.
2026-05-09 13:49:37 -07:00
..
2026-04-03 15:19:41 +07:00
2026-03-09 20:37:55 -04:00