Skip to content

Commit 31c507a

Browse files
authored
2D: Composite draw layer into ref image for default gen (#1156)
3D nodes and drawings on the canvas were missing from the reference image sent to the model in the default generation path. The fix mirrors the Nano Banana Pro approach: render a composite of the base image and the draw layer, upload it via uploadSceneSnapshot, and pass it as scene_image_media_token rather than putting editedImageToken in image_media_tokens.
1 parent 42bb07c commit 31c507a

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

frontend/apps/artcraft/app/src/pages/PageDraw/PageDraw.tsx

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -854,15 +854,33 @@ const PageDraw = () => {
854854
result = await EnqueueEditImage(request);
855855
} else {
856856
// CASE 3 - DEFAULT
857+
// Tech debt: we upload the composite first then enqueue the generation as two
858+
// separate HTTP requests. Ideally the backend API would accept inline image
859+
// bytes in the generation request so this could be a single call.
860+
const compositeFile = await getCompositeCanvasFile();
861+
862+
if (!compositeFile) {
863+
console.error("Failed to create composite canvas");
864+
return;
865+
}
866+
867+
const api = new PromptsApi();
868+
const snapshotResult = await api.uploadSceneSnapshot({
869+
screenshot: compositeFile,
870+
});
871+
872+
if (!snapshotResult.data) {
873+
console.error("Failed to upload scene snapshot");
874+
return;
875+
}
876+
857877
const imgs = options?.images || [];
858878
const request: EnqueueEditImageRequest = {
859879
model: selectedImageModel,
860-
image_media_tokens: [
861-
editedImageToken,
862-
...imgs
863-
.filter((img) => img.mediaToken !== editedImageToken)
864-
.map((img) => img.mediaToken),
865-
].filter((t) => t.length > 0),
880+
scene_image_media_token: snapshotResult.data,
881+
image_media_tokens: imgs
882+
.map((img) => img.mediaToken)
883+
.filter((t) => t.length > 0),
866884
disable_system_prompt: true,
867885
prompt: prompt,
868886
image_count: generationCount,
@@ -874,9 +892,6 @@ const PageDraw = () => {
874892
if (options?.selectedProvider) {
875893
request.provider = options.selectedProvider;
876894
}
877-
// if (selectedImageModel?.supportsNewAspectRatio()) {
878-
// request.common_aspect_ratio = commonAspectRatio;
879-
// }
880895
result = await EnqueueEditImage(request);
881896
}
882897
if (result?.status === "success") {

0 commit comments

Comments
 (0)