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.
This commit is contained in:
SnapOtter
2026-05-13 15:46:08 +08:00
parent cc2c182e67
commit 2743d9df22
+10 -6
View File
@@ -39,6 +39,7 @@ const settingsSchema = z.object({
extendRight: z.number().int().min(0).default(0), extendRight: z.number().int().min(0).default(0),
extendBottom: z.number().int().min(0).default(0), extendBottom: z.number().int().min(0).default(0),
extendLeft: 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 format: z
.enum(["auto", "png", "jpg", "jpeg", "webp", "tiff", "gif", "avif", "heic", "heif", "jxl"]) .enum(["auto", "png", "jpg", "jpeg", "webp", "tiff", "gif", "avif", "heic", "heif", "jxl"])
.default("auto"), .default("auto"),
@@ -155,7 +156,7 @@ export function registerAiCanvasExpand(app: FastifyInstance) {
} catch (err) { } catch (err) {
request.log.error({ err, toolId: "ai-canvas-expand" }, "Input decoding failed"); request.log.error({ err, toolId: "ai-canvas-expand" }, "Input decoding failed");
return reply.status(422).send({ return reply.status(422).send({
error: "Content-aware crop failed", error: "AI canvas expand failed",
details: err instanceof Error ? err.message : "Unknown error", details: err instanceof Error ? err.message : "Unknown error",
}); });
} }
@@ -171,7 +172,7 @@ export function registerAiCanvasExpand(app: FastifyInstance) {
} catch (err) { } catch (err) {
request.log.error({ err, toolId: "ai-canvas-expand" }, "Workspace creation failed"); request.log.error({ err, toolId: "ai-canvas-expand" }, "Workspace creation failed");
return reply.status(422).send({ return reply.status(422).send({
error: "Content-aware crop failed", error: "AI canvas expand failed",
details: err instanceof Error ? err.message : "Unknown error", details: err instanceof Error ? err.message : "Unknown error",
}); });
} }
@@ -185,9 +186,10 @@ export function registerAiCanvasExpand(app: FastifyInstance) {
extendRight: settings.extendRight, extendRight: settings.extendRight,
extendBottom: settings.extendBottom, extendBottom: settings.extendBottom,
extendLeft: settings.extendLeft, extendLeft: settings.extendLeft,
tier: settings.tier,
format, format,
}, },
"Starting content-aware crop", "Starting AI canvas expand",
); );
// Reply immediately so the HTTP connection closes within proxy timeout limits. // Reply immediately so the HTTP connection closes within proxy timeout limits.
@@ -212,6 +214,7 @@ export function registerAiCanvasExpand(app: FastifyInstance) {
extendRight: settings.extendRight, extendRight: settings.extendRight,
extendBottom: settings.extendBottom, extendBottom: settings.extendBottom,
extendLeft: settings.extendLeft, extendLeft: settings.extendLeft,
tier: settings.tier,
}, },
join(workspacePath, "output"), join(workspacePath, "output"),
onProgress, 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) => { })().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({ updateSingleFileProgress({
jobId: progressJobId, jobId: progressJobId,
phase: "failed", phase: "failed",
percent: 0, 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, extendRight: s.extendRight,
extendBottom: s.extendBottom, extendBottom: s.extendBottom,
extendLeft: s.extendLeft, extendLeft: s.extendLeft,
tier: s.tier,
}, },
join(workspacePath, "output"), join(workspacePath, "output"),
); );