fix(release): align template flow with production baseline
This commit is contained in:
parent
231650dc00
commit
e2806578c0
@ -6,7 +6,6 @@ import type {
|
|||||||
AgentGenerationProjectReplacementResultState,
|
AgentGenerationProjectReplacementResultState,
|
||||||
AgentGenerationProjectResultCollections,
|
AgentGenerationProjectResultCollections,
|
||||||
AgentGenerationResultModeType,
|
AgentGenerationResultModeType,
|
||||||
AgentWorkflowBusinessModeKey,
|
|
||||||
} from "@/types/agent";
|
} from "@/types/agent";
|
||||||
|
|
||||||
const RESULT_COLLECTION_KEYS = [
|
const RESULT_COLLECTION_KEYS = [
|
||||||
@ -21,20 +20,6 @@ const REPLACEMENT_RESULT_KEYS = [
|
|||||||
"sku_replacement",
|
"sku_replacement",
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
function createFallbackWorkspaceState() {
|
|
||||||
return {
|
|
||||||
input: "",
|
|
||||||
attachments: [],
|
|
||||||
selectedModelId: "auto",
|
|
||||||
activeBusinessModeKey: "main_sku" as const,
|
|
||||||
imageParams: {
|
|
||||||
aspectRatio: "auto",
|
|
||||||
imageSize: "2K",
|
|
||||||
imageCount: 1,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeProjectResultUrlList(urls: string[] | null | undefined) {
|
function normalizeProjectResultUrlList(urls: string[] | null | undefined) {
|
||||||
return Array.from(
|
return Array.from(
|
||||||
new Set(
|
new Set(
|
||||||
@ -305,39 +290,6 @@ function mergeWorkflowStateForSave(params: {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasExplicitIncomingBusinessMode(value: unknown) {
|
|
||||||
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const raw = value as Record<string, unknown>;
|
|
||||||
const workspaceState =
|
|
||||||
raw.workspaceState && typeof raw.workspaceState === "object" && !Array.isArray(raw.workspaceState)
|
|
||||||
? (raw.workspaceState as Record<string, unknown>)
|
|
||||||
: {};
|
|
||||||
return Boolean(String(workspaceState.activeBusinessModeKey || "").trim());
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolveMergedBusinessModeKey(params: {
|
|
||||||
existingState: AgentGenerationProjectPersistedState;
|
|
||||||
incomingState: AgentGenerationProjectPersistedState;
|
|
||||||
rawIncomingState: unknown;
|
|
||||||
mergedState: AgentGenerationProjectPersistedState;
|
|
||||||
}): AgentWorkflowBusinessModeKey {
|
|
||||||
if (hasDetailModeSignals(params.mergedState)) {
|
|
||||||
const incomingKey = params.incomingState.workspaceState?.activeBusinessModeKey;
|
|
||||||
const existingKey = params.existingState.workspaceState?.activeBusinessModeKey;
|
|
||||||
const incomingHasExplicitKey = hasExplicitIncomingBusinessMode(params.rawIncomingState);
|
|
||||||
|
|
||||||
if (!incomingHasExplicitKey || existingKey === "detail" || incomingKey === "main_sku") {
|
|
||||||
return "detail";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return params.incomingState.workspaceState?.activeBusinessModeKey ||
|
|
||||||
params.existingState.workspaceState?.activeBusinessModeKey ||
|
|
||||||
"main_sku";
|
|
||||||
}
|
|
||||||
|
|
||||||
export function mergeAgentProjectStateForSave(params: {
|
export function mergeAgentProjectStateForSave(params: {
|
||||||
existingState: AgentGenerationProjectPersistedState;
|
existingState: AgentGenerationProjectPersistedState;
|
||||||
incomingState: unknown;
|
incomingState: unknown;
|
||||||
@ -364,7 +316,7 @@ export function mergeAgentProjectStateForSave(params: {
|
|||||||
resultCollections,
|
resultCollections,
|
||||||
replacementResultState,
|
replacementResultState,
|
||||||
});
|
});
|
||||||
const mergedState = normalizeAgentGenerationProjectPersistedState({
|
return normalizeAgentGenerationProjectPersistedState({
|
||||||
...incomingState,
|
...incomingState,
|
||||||
workflowState,
|
workflowState,
|
||||||
resultCollections,
|
resultCollections,
|
||||||
@ -377,21 +329,6 @@ export function mergeAgentProjectStateForSave(params: {
|
|||||||
...getReplacementResultUrls(replacementResultState),
|
...getReplacementResultUrls(replacementResultState),
|
||||||
]).filter((url) => !deletedUrls.has(url)),
|
]).filter((url) => !deletedUrls.has(url)),
|
||||||
});
|
});
|
||||||
|
|
||||||
const workspaceState = mergedState.workspaceState || createFallbackWorkspaceState();
|
|
||||||
|
|
||||||
return {
|
|
||||||
...mergedState,
|
|
||||||
workspaceState: {
|
|
||||||
...workspaceState,
|
|
||||||
activeBusinessModeKey: resolveMergedBusinessModeKey({
|
|
||||||
existingState,
|
|
||||||
incomingState,
|
|
||||||
rawIncomingState: params.incomingState,
|
|
||||||
mergedState,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function appendAgentProjectResultForSave(params: {
|
export function appendAgentProjectResultForSave(params: {
|
||||||
|
|||||||
@ -467,7 +467,6 @@ async function buildLayoutLockedCompositeImage(params: {
|
|||||||
export async function executeCanvasLayoutReplaceTask(params: {
|
export async function executeCanvasLayoutReplaceTask(params: {
|
||||||
request: CanvasLayoutReplaceTaskRequest;
|
request: CanvasLayoutReplaceTaskRequest;
|
||||||
userId: string;
|
userId: string;
|
||||||
onRequestDispatched?: () => void | Promise<void>;
|
|
||||||
}): Promise<CanvasGenerateImageResult> {
|
}): Promise<CanvasGenerateImageResult> {
|
||||||
const sourceImageUrl = normalizeHttpUrl(params.request.sourceImageUrl);
|
const sourceImageUrl = normalizeHttpUrl(params.request.sourceImageUrl);
|
||||||
const referenceImageUrl = normalizeHttpUrl(params.request.referenceImageUrl);
|
const referenceImageUrl = normalizeHttpUrl(params.request.referenceImageUrl);
|
||||||
@ -544,7 +543,6 @@ export async function executeCanvasLayoutReplaceTask(params: {
|
|||||||
displayPrompt: "排版替换结果",
|
displayPrompt: "排版替换结果",
|
||||||
model: resolvedModelRef,
|
model: resolvedModelRef,
|
||||||
ownerKey: params.userId,
|
ownerKey: params.userId,
|
||||||
onRequestDispatched: params.onRequestDispatched,
|
|
||||||
aspectRatio: referenceGeometry?.aspectRatio || "auto",
|
aspectRatio: referenceGeometry?.aspectRatio || "auto",
|
||||||
imageSize: params.request.imageSize || "2K",
|
imageSize: params.request.imageSize || "2K",
|
||||||
imageCount: 1,
|
imageCount: 1,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user