From d2f8bd3a8fe4397c1b4a2df075118a70b3267cd7 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Tue, 16 Jun 2026 08:58:19 -0700 Subject: [PATCH] pagedraw(webapp): map resolution/aspect-ratio labels to omni-gen enums MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shared PageDraw lib's PromptBox emits resolution and aspect ratio as UI labels ("1k", "wide", …), and each host adapter is responsible for mapping them to the server's CommonResolution / CommonAspectRatio enum values ("one_k", …) — the desktop adapter does this, but the webapp adapter forwarded the raw label. The omni-gen endpoint then rejected the whole body with 'unknown variant 1k', so every generation 400'd. Add mapAspectRatio / mapResolution helpers mirroring the desktop PageDraw adapter and apply them when building the OmniGenImageRequest. --- .../src/pages/pagedraw/web-adapter.tsx | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/frontend/apps/artcraft-webapp/src/pages/pagedraw/web-adapter.tsx b/frontend/apps/artcraft-webapp/src/pages/pagedraw/web-adapter.tsx index ae316ce501..3ecee971c6 100644 --- a/frontend/apps/artcraft-webapp/src/pages/pagedraw/web-adapter.tsx +++ b/frontend/apps/artcraft-webapp/src/pages/pagedraw/web-adapter.tsx @@ -21,6 +21,7 @@ import { type BaseSelectorImage, useSceneStore, } from "@storyteller/ui-pagedraw"; +import { CommonAspectRatio, CommonResolution } from "@storyteller/model-list"; import { OmniGenApi, StorytellerApiHostStore, @@ -141,6 +142,29 @@ const uploadBlobAsImage = async ( return mediaToken; }; +// The PromptBox UI emits resolution/aspect-ratio as display labels ("1k", +// "wide", …); the omni-gen REST body wants the CommonResolution / +// CommonAspectRatio enum values ("one_k", "wide", …). Mirror the desktop +// PageDraw adapter's mappers so an unmapped "1k" doesn't 400 the request. +const mapAspectRatio = (ratio?: string): CommonAspectRatio | undefined => { + switch (ratio) { + case "auto": return CommonAspectRatio.Auto; + case "wide": return CommonAspectRatio.Wide; + case "tall": return CommonAspectRatio.Tall; + case "square": return CommonAspectRatio.Square; + default: return undefined; + } +}; + +const mapResolution = (res?: string): CommonResolution | undefined => { + switch (res) { + case "1k": return CommonResolution.OneK; + case "2k": return CommonResolution.TwoK; + case "4k": return CommonResolution.FourK; + default: return undefined; + } +}; + // PageDrawEditRequest.model is an ImageModel object (or possibly a raw id); // the omni-gen REST body wants the string id. const modelIdOf = (model: unknown): string => { @@ -177,8 +201,8 @@ export const useWebPageDrawAdapter = (): PageDrawAdapter => { model: modelIdOf(req.model), prompt: req.prompt ?? null, idempotency_token: crypto.randomUUID(), - aspect_ratio: req.aspectRatio ?? null, - resolution: req.imageResolution ?? null, + aspect_ratio: mapAspectRatio(req.aspectRatio) ?? null, + resolution: mapResolution(req.imageResolution) ?? null, image_batch_count: req.imageCount ?? 1, image_media_tokens: refTokens.length ? refTokens : null, };