From 2743d9df22af59bdd879c1183b0ae85831a63c5e Mon Sep 17 00:00:00 2001 From: SnapOtter Date: Wed, 13 May 2026 15:46:08 +0800 Subject: [PATCH] feat(api): add quality tier to ai-canvas-expand schema and routes Add tier enum (fast/balanced/high) with balanced default to the Zod settings schema. Pass tier through to outpaint options in both the HTTP route and the pipeline/batch registry. Fix log message to say "Starting AI canvas expand" and include tier in structured log fields. --- apps/api/src/routes/tools/ai-canvas-expand.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/api/src/routes/tools/ai-canvas-expand.ts b/apps/api/src/routes/tools/ai-canvas-expand.ts index 06239908..85acea93 100644 --- a/apps/api/src/routes/tools/ai-canvas-expand.ts +++ b/apps/api/src/routes/tools/ai-canvas-expand.ts @@ -39,6 +39,7 @@ const settingsSchema = z.object({ extendRight: z.number().int().min(0).default(0), extendBottom: z.number().int().min(0).default(0), extendLeft: z.number().int().min(0).default(0), + tier: z.enum(["fast", "balanced", "high"]).default("balanced"), format: z .enum(["auto", "png", "jpg", "jpeg", "webp", "tiff", "gif", "avif", "heic", "heif", "jxl"]) .default("auto"), @@ -155,7 +156,7 @@ export function registerAiCanvasExpand(app: FastifyInstance) { } catch (err) { request.log.error({ err, toolId: "ai-canvas-expand" }, "Input decoding failed"); return reply.status(422).send({ - error: "Content-aware crop failed", + error: "AI canvas expand failed", details: err instanceof Error ? err.message : "Unknown error", }); } @@ -171,7 +172,7 @@ export function registerAiCanvasExpand(app: FastifyInstance) { } catch (err) { request.log.error({ err, toolId: "ai-canvas-expand" }, "Workspace creation failed"); return reply.status(422).send({ - error: "Content-aware crop failed", + error: "AI canvas expand failed", details: err instanceof Error ? err.message : "Unknown error", }); } @@ -185,9 +186,10 @@ export function registerAiCanvasExpand(app: FastifyInstance) { extendRight: settings.extendRight, extendBottom: settings.extendBottom, extendLeft: settings.extendLeft, + tier: settings.tier, format, }, - "Starting content-aware crop", + "Starting AI canvas expand", ); // Reply immediately so the HTTP connection closes within proxy timeout limits. @@ -212,6 +214,7 @@ export function registerAiCanvasExpand(app: FastifyInstance) { extendRight: settings.extendRight, extendBottom: settings.extendBottom, extendLeft: settings.extendLeft, + tier: settings.tier, }, join(workspacePath, "output"), onProgress, @@ -287,14 +290,14 @@ export function registerAiCanvasExpand(app: FastifyInstance) { }, }); - log.info({ toolId: "ai-canvas-expand", jobId, downloadUrl }, "Content-aware crop complete"); + log.info({ toolId: "ai-canvas-expand", jobId, downloadUrl }, "AI canvas expand complete"); })().catch((err) => { - log.error({ err, toolId: "ai-canvas-expand" }, "Content-aware crop failed"); + log.error({ err, toolId: "ai-canvas-expand" }, "AI canvas expand failed"); updateSingleFileProgress({ jobId: progressJobId, phase: "failed", percent: 0, - error: err instanceof Error ? err.message : "Content-aware crop failed", + error: err instanceof Error ? err.message : "AI canvas expand failed", }); }); }, @@ -331,6 +334,7 @@ export function registerAiCanvasExpand(app: FastifyInstance) { extendRight: s.extendRight, extendBottom: s.extendBottom, extendLeft: s.extendLeft, + tier: s.tier, }, join(workspacePath, "output"), );