feat(canvas): resolution/ratio composer settings and quality/count controls

Replace the ratio-baked size presets with a resolution tier (1K/2K/4K) plus
ratio selection and normalized dimensions, send imageQuality/imageCount to
the agent, and add the output_format field to GeneratorTaskInputArgs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-09 20:43:35 +08:00
parent f0ae237da5
commit 4ff246a294
9 changed files with 174 additions and 42 deletions
@@ -357,25 +357,9 @@ function expandImageSize(ratio: ExpandOptions["ratio"], fallbackRatio: number) {
return `1024x${Math.round(1024 / safeRatio)}`;
}
function withImageModeSettings(
contents: AgentContent[],
settings: ComposerImageSettings,
t: (key: string, values?: Record<string, string | number>) => string,
targetNodeId?: string
) {
function withImageGeneratorTarget(contents: AgentContent[], targetNodeId?: string) {
return [
...contents,
{
type: "text" as const,
text: t("imageModeDirective", {
quality: t(`quality${settings.quality === "auto" ? "Auto" : settings.quality === "high" ? "High" : settings.quality === "medium" ? "Medium" : "Low"}`),
ratio: settings.ratio,
width: settings.width,
height: settings.height,
count: settings.count
}),
textSource: "settings"
},
...(targetNodeId
? [
{
@@ -2637,7 +2621,7 @@ export function CanvasWorkspace({ projectId }: { projectId: string }) {
const hasUserText = baseContents.some((content) => content.type === "text" && content.text.replace(/\u00a0/g, " ").trim());
const contents =
activeMode === "image"
? withImageModeSettings(baseContents, composerImageSettings, t, selectedGeneratorNode?.id)
? withImageGeneratorTarget(baseContents, selectedGeneratorNode?.id)
: baseContents;
const visibleContents = activeMode === "image" ? baseContents : contents;
if (!project || !hasUserText) return;
@@ -2687,6 +2671,8 @@ export function CanvasWorkspace({ projectId }: { projectId: string }) {
threadIdType: 9,
imageModel: toImageApiModel(selectedCanvasModel.id),
imageSize: activeMode === "image" ? composerImageSize(composerImageSettings) : undefined,
imageQuality: activeMode === "image" ? composerImageSettings.quality : undefined,
imageCount: activeMode === "image" ? composerImageSettings.count : undefined,
enableWebSearch: enableSearch,
toolConfig: {
preferToolCategories: {