fix(release): align template flow with production baseline
This commit is contained in:
parent
231650dc00
commit
e2806578c0
@ -6,7 +6,6 @@ import type {
|
||||
AgentGenerationProjectReplacementResultState,
|
||||
AgentGenerationProjectResultCollections,
|
||||
AgentGenerationResultModeType,
|
||||
AgentWorkflowBusinessModeKey,
|
||||
} from "@/types/agent";
|
||||
|
||||
const RESULT_COLLECTION_KEYS = [
|
||||
@ -21,20 +20,6 @@ const REPLACEMENT_RESULT_KEYS = [
|
||||
"sku_replacement",
|
||||
] 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) {
|
||||
return Array.from(
|
||||
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: {
|
||||
existingState: AgentGenerationProjectPersistedState;
|
||||
incomingState: unknown;
|
||||
@ -364,7 +316,7 @@ export function mergeAgentProjectStateForSave(params: {
|
||||
resultCollections,
|
||||
replacementResultState,
|
||||
});
|
||||
const mergedState = normalizeAgentGenerationProjectPersistedState({
|
||||
return normalizeAgentGenerationProjectPersistedState({
|
||||
...incomingState,
|
||||
workflowState,
|
||||
resultCollections,
|
||||
@ -377,21 +329,6 @@ export function mergeAgentProjectStateForSave(params: {
|
||||
...getReplacementResultUrls(replacementResultState),
|
||||
]).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: {
|
||||
|
||||
@ -467,7 +467,6 @@ async function buildLayoutLockedCompositeImage(params: {
|
||||
export async function executeCanvasLayoutReplaceTask(params: {
|
||||
request: CanvasLayoutReplaceTaskRequest;
|
||||
userId: string;
|
||||
onRequestDispatched?: () => void | Promise<void>;
|
||||
}): Promise<CanvasGenerateImageResult> {
|
||||
const sourceImageUrl = normalizeHttpUrl(params.request.sourceImageUrl);
|
||||
const referenceImageUrl = normalizeHttpUrl(params.request.referenceImageUrl);
|
||||
@ -544,7 +543,6 @@ export async function executeCanvasLayoutReplaceTask(params: {
|
||||
displayPrompt: "排版替换结果",
|
||||
model: resolvedModelRef,
|
||||
ownerKey: params.userId,
|
||||
onRequestDispatched: params.onRequestDispatched,
|
||||
aspectRatio: referenceGeometry?.aspectRatio || "auto",
|
||||
imageSize: params.request.imageSize || "2K",
|
||||
imageCount: 1,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user