feat: add workflow page feature toggles
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-04-19 15:36:29 +08:00
parent 9422c5de73
commit 076e4f55e6
6 changed files with 512 additions and 232 deletions

View File

@ -33,6 +33,7 @@ import {
import { import {
AGENT_WORKFLOW_PROMPT_FRAGMENT_MAX_LENGTH, AGENT_WORKFLOW_PROMPT_FRAGMENT_MAX_LENGTH,
defaultAgentWorkflowConstraintSettings, defaultAgentWorkflowConstraintSettings,
defaultAgentWorkflowPageFeatureSettings,
AGENT_WORKFLOW_MAX_OPTION_DEPTH, AGENT_WORKFLOW_MAX_OPTION_DEPTH,
AGENT_WORKFLOW_MAX_TREE_DEPTH, AGENT_WORKFLOW_MAX_TREE_DEPTH,
countAgentWorkflowOptions, countAgentWorkflowOptions,
@ -46,6 +47,7 @@ import {
getEnabledAgentWorkflowOptionTree, getEnabledAgentWorkflowOptionTree,
getAgentWorkflowCategoryLabels, getAgentWorkflowCategoryLabels,
getAgentWorkflowConstraintSettings, getAgentWorkflowConstraintSettings,
getAgentWorkflowPageFeatureSettings,
normalizeAgentWorkflowOptionOrdering, normalizeAgentWorkflowOptionOrdering,
flattenAgentWorkflowSteps, flattenAgentWorkflowSteps,
normalizeAgentWorkflowStepOrdering, normalizeAgentWorkflowStepOrdering,
@ -1511,6 +1513,10 @@ export function AgentWorkflowSettingsClient({
() => getAgentWorkflowConstraintSettings(config), () => getAgentWorkflowConstraintSettings(config),
[config] [config]
); );
const workflowPageFeatureSettings = useMemo(
() => getAgentWorkflowPageFeatureSettings(config),
[config]
);
const firstCategoryLabel = categoryLabels.firstCategory; const firstCategoryLabel = categoryLabels.firstCategory;
const secondCategoryLabel = categoryLabels.secondCategory; const secondCategoryLabel = categoryLabels.secondCategory;
const thirdCategoryLabel = categoryLabels.thirdCategory; const thirdCategoryLabel = categoryLabels.thirdCategory;
@ -4642,6 +4648,91 @@ export function AgentWorkflowSettingsClient({
variants={containerVariants} variants={containerVariants}
className="grid gap-6 lg:grid-cols-2" className="grid gap-6 lg:grid-cols-2"
> >
<motion.div variants={itemVariants} className="lg:col-span-2">
<Card>
<CardHeader className="pb-4">
<div className="flex items-center gap-3">
<div className="flex h-8 w-8 items-center justify-center rounded-lg bg-violet-500/10">
<Settings2 className="h-4 w-4 text-violet-600" />
</div>
<div>
<CardTitle className="text-base">前台流程功能开关</CardTitle>
<CardDescription>
控制风格化页面是否展示选择生图模式、选择 SPU / SKU 和套 PSD 模板入口
</CardDescription>
</div>
</div>
</CardHeader>
<CardContent className="grid gap-3 md:grid-cols-3">
<div className="flex items-center justify-between rounded-lg border bg-muted/20 px-4 py-3">
<div className="pr-4">
<div className="text-sm font-medium">开启第一步:选择生图模式</div>
<div className="text-xs text-muted-foreground">
关闭后前台不再要求选择生图模式,直接进入后续配置并选择模型生图。
</div>
</div>
<Switch
checked={workflowPageFeatureSettings.presetStepEnabled}
onCheckedChange={(checked) =>
setConfig((prev) => ({
...prev,
pageFeatureSettings: {
...(prev.pageFeatureSettings ||
defaultAgentWorkflowPageFeatureSettings),
presetStepEnabled: checked,
},
}))
}
/>
</div>
<div className="flex items-center justify-between rounded-lg border bg-muted/20 px-4 py-3">
<div className="pr-4">
<div className="text-sm font-medium">开启第二步:选择 SPU / SKU</div>
<div className="text-xs text-muted-foreground">
关闭后前台跳过商品素材搜索,不再强制补齐 SPU / SKU 输入图槽位。
</div>
</div>
<Switch
checked={workflowPageFeatureSettings.materialStepEnabled}
onCheckedChange={(checked) =>
setConfig((prev) => ({
...prev,
pageFeatureSettings: {
...(prev.pageFeatureSettings ||
defaultAgentWorkflowPageFeatureSettings),
materialStepEnabled: checked,
},
}))
}
/>
</div>
<div className="flex items-center justify-between rounded-lg border bg-muted/20 px-4 py-3">
<div className="pr-4">
<div className="text-sm font-medium">开启套 PSD 模板</div>
<div className="text-xs text-muted-foreground">
关闭后前台隐藏所有“套PSD”按钮和 PSD 模板编辑弹窗入口。
</div>
</div>
<Switch
checked={workflowPageFeatureSettings.psdTemplateEnabled}
onCheckedChange={(checked) =>
setConfig((prev) => ({
...prev,
pageFeatureSettings: {
...(prev.pageFeatureSettings ||
defaultAgentWorkflowPageFeatureSettings),
psdTemplateEnabled: checked,
},
}))
}
/>
</div>
</CardContent>
</Card>
</motion.div>
<motion.div variants={itemVariants} className="lg:col-span-2"> <motion.div variants={itemVariants} className="lg:col-span-2">
<Card> <Card>
<CardHeader className="pb-4"> <CardHeader className="pb-4">

View File

@ -1060,6 +1060,13 @@ const updateSchema = z.object({
crossLevelMutualExclusionEnabled: z.boolean().optional(), crossLevelMutualExclusionEnabled: z.boolean().optional(),
}) })
.optional(), .optional(),
pageFeatureSettings: z
.object({
presetStepEnabled: z.boolean().optional(),
materialStepEnabled: z.boolean().optional(),
psdTemplateEnabled: z.boolean().optional(),
})
.optional(),
steps: z steps: z
.array(agentWorkflowStepSchema) .array(agentWorkflowStepSchema)
.max(20), .max(20),

View File

@ -177,6 +177,7 @@ import {
defaultAgentWorkflowUiConfig, defaultAgentWorkflowUiConfig,
flattenVisibleAgentWorkflowSteps, flattenVisibleAgentWorkflowSteps,
getEnabledAgentWorkflowStepTree, getEnabledAgentWorkflowStepTree,
getAgentWorkflowPageFeatureSettings,
normalizeAgentWorkflowUiConfig, normalizeAgentWorkflowUiConfig,
sanitizeAgentWorkflowSelections, sanitizeAgentWorkflowSelections,
} from "@/lib/agents/workflow-ui-config"; } from "@/lib/agents/workflow-ui-config";
@ -1552,6 +1553,11 @@ export default function CanvasEditorLegacyPage({ params }: PageProps) {
agentWorkflowBrandModelConfig?: unknown; agentWorkflowBrandModelConfig?: unknown;
agentPsdTemplateCategoryTagIndex?: AgentPsdTemplateCategoryTagIndex; agentPsdTemplateCategoryTagIndex?: AgentPsdTemplateCategoryTagIndex;
agentWorkflowUiConfig?: { agentWorkflowUiConfig?: {
pageFeatureSettings?: {
presetStepEnabled?: boolean;
materialStepEnabled?: boolean;
psdTemplateEnabled?: boolean;
};
steps?: Array<{ steps?: Array<{
key: AgentWorkflowStepKey; key: AgentWorkflowStepKey;
title: string; title: string;
@ -1600,6 +1606,14 @@ export default function CanvasEditorLegacyPage({ params }: PageProps) {
normalizeAgentWorkflowUiConfig(siteSettingsData?.agentWorkflowUiConfig), normalizeAgentWorkflowUiConfig(siteSettingsData?.agentWorkflowUiConfig),
[siteSettingsData?.agentWorkflowUiConfig] [siteSettingsData?.agentWorkflowUiConfig]
); );
const workflowPageFeatureSettings = useMemo(
() => getAgentWorkflowPageFeatureSettings(resolvedWorkflowUiConfig),
[resolvedWorkflowUiConfig]
);
const isWorkflowPresetStepEnabled =
workflowPageFeatureSettings.presetStepEnabled !== false;
const isWorkflowMaterialStepEnabled =
workflowPageFeatureSettings.materialStepEnabled !== false;
const sanitizedWorkflowSelections = useMemo( const sanitizedWorkflowSelections = useMemo(
() => () =>
sanitizeAgentWorkflowSelections({ sanitizeAgentWorkflowSelections({
@ -8152,11 +8166,14 @@ export default function CanvasEditorLegacyPage({ params }: PageProps) {
selections: workflowSelectionsRef.current, selections: workflowSelectionsRef.current,
}); });
}, [resolvedWorkflowUiConfig]); }, [resolvedWorkflowUiConfig]);
const effectiveSelectedAgentPresetId = isWorkflowPresetStepEnabled
? selectedAgentPresetId
: null;
const { data: selectedAgentPresetResponse } = useSWR<{ const { data: selectedAgentPresetResponse } = useSWR<{
success?: boolean; success?: boolean;
data?: AgentPreset; data?: AgentPreset;
}>( }>(
selectedAgentPresetId ? `/api/agents/${selectedAgentPresetId}` : null, effectiveSelectedAgentPresetId ? `/api/agents/${effectiveSelectedAgentPresetId}` : null,
fetcher fetcher
); );
const selectedAgentPresetData = useMemo( const selectedAgentPresetData = useMemo(
@ -8519,35 +8536,39 @@ export default function CanvasEditorLegacyPage({ params }: PageProps) {
/> />
} }
brandStorePanel={ brandStorePanel={
<AgentWorkflowBrandStorePanel isWorkflowPresetStepEnabled ? (
config={resolvedWorkflowUiConfig} <AgentWorkflowBrandStorePanel
inputs={workflowInputs} config={resolvedWorkflowUiConfig}
onInputsChange={handleWorkflowInputsChange} inputs={workflowInputs}
psdTemplateCategoryTagIndex={ onInputsChange={handleWorkflowInputsChange}
siteSettingsData?.agentPsdTemplateCategoryTagIndex psdTemplateCategoryTagIndex={
} siteSettingsData?.agentPsdTemplateCategoryTagIndex
theme="dark" }
/> theme="dark"
/>
) : null
} }
chatId={agentModeChatId} chatId={agentModeChatId}
deletedResultCollections={agentProjectDeletedResultCollections} deletedResultCollections={agentProjectDeletedResultCollections}
getLatestWorkflowContext={getLatestWorkflowContext} getLatestWorkflowContext={getLatestWorkflowContext}
materialSelectionPanel={ materialSelectionPanel={
<AgentWorkflowMaterialSelectionPanel isWorkflowMaterialStepEnabled ? (
appearanceRecognitionEnabled={appearanceRecognitionEnabled} <AgentWorkflowMaterialSelectionPanel
disabled={!selectedAgentPresetId} appearanceRecognitionEnabled={appearanceRecognitionEnabled}
inputs={workflowInputs} disabled={isWorkflowPresetStepEnabled && !selectedAgentPresetId}
materials={workflowMaterials} inputs={workflowInputs}
modelImageRequirement={materialModelImageRequirement} materials={workflowMaterials}
onAppearanceRecognitionEnabledChange={ modelImageRequirement={materialModelImageRequirement}
handleAppearanceRecognitionEnabledChange onAppearanceRecognitionEnabledChange={
} handleAppearanceRecognitionEnabledChange
onInputsChange={handleWorkflowInputsChange} }
onMaterialsChange={handleWorkflowMaterialsChange} onInputsChange={handleWorkflowInputsChange}
productSelectionLimit={materialProductSelectionLimit} onMaterialsChange={handleWorkflowMaterialsChange}
theme="dark" productSelectionLimit={materialProductSelectionLimit}
totalUploadRequirement={materialTotalUploadRequirement} theme="dark"
/> totalUploadRequirement={materialTotalUploadRequirement}
/>
) : null
} }
onAgentModeStateChange={setAgentModeState} onAgentModeStateChange={setAgentModeState}
onClearPreset={() => setSelectedAgentPresetId(null)} onClearPreset={() => setSelectedAgentPresetId(null)}
@ -8560,17 +8581,19 @@ export default function CanvasEditorLegacyPage({ params }: PageProps) {
onResultPreviewUrlsChange={handleAgentResultPreviewUrlsChange} onResultPreviewUrlsChange={handleAgentResultPreviewUrlsChange}
onWorkspaceStateChange={setAgentWorkspaceState} onWorkspaceStateChange={setAgentWorkspaceState}
presetPanel={ presetPanel={
<AgentPresetPanelDarkV2 isWorkflowPresetStepEnabled ? (
embedded <AgentPresetPanelDarkV2
embeddedEntityLabel="生图模式" embedded
onSelectPreset={setSelectedAgentPresetId} embeddedEntityLabel="生图模式"
selectedPresetId={selectedAgentPresetId} onSelectPreset={setSelectedAgentPresetId}
/> selectedPresetId={selectedAgentPresetId}
/>
) : null
} }
projectId={agentProjectId} projectId={agentProjectId}
resultCollections={agentProjectResultCollections} resultCollections={agentProjectResultCollections}
selectedAgentPresetId={ selectedAgentPresetId={
isAgentWorkspaceEnabled ? selectedAgentPresetId : null isAgentWorkspaceEnabled ? effectiveSelectedAgentPresetId : null
} }
selectedBrandModel={selectedBrandModel} selectedBrandModel={selectedBrandModel}
showcaseConfig={siteSettingsData?.agentWorkflowShowcaseConfig} showcaseConfig={siteSettingsData?.agentWorkflowShowcaseConfig}
@ -8580,6 +8603,7 @@ export default function CanvasEditorLegacyPage({ params }: PageProps) {
syncGeneratedResultsToCanvas={false} syncGeneratedResultsToCanvas={false}
topNavRightSlot={agentProjectNavSlot} topNavRightSlot={agentProjectNavSlot}
workflowContext={workflowContext} workflowContext={workflowContext}
workflowFeatureSettings={workflowPageFeatureSettings}
// 嵌入的风格化选择面板 // 嵌入的风格化选择面板
workflowPromptOptimizationEnabled={appearanceRecognitionEnabled} workflowPromptOptimizationEnabled={appearanceRecognitionEnabled}
workflowStylePanel={ workflowStylePanel={

View File

@ -82,6 +82,9 @@ import {
import { import {
normalizeAgentPresetModeConfig, normalizeAgentPresetModeConfig,
} from "@/lib/agents/preset-mode-config"; } from "@/lib/agents/preset-mode-config";
import {
normalizeAgentWorkflowPageFeatureSettings,
} from "@/lib/agents/workflow-ui-config";
import { buildAgentSceneImageRolePrompt } from "@/lib/agents/scene-image-role-prompt"; import { buildAgentSceneImageRolePrompt } from "@/lib/agents/scene-image-role-prompt";
import type { AgentPsdTemplateMode } from "@/lib/agents/psd-template-config"; import type { AgentPsdTemplateMode } from "@/lib/agents/psd-template-config";
import type { Attachment, ChatMessage } from "@/lib/types"; import type { Attachment, ChatMessage } from "@/lib/types";
@ -100,6 +103,7 @@ import type {
AgentWorkflowShowcaseConfig, AgentWorkflowShowcaseConfig,
AgentWorkflowComposerContext, AgentWorkflowComposerContext,
AgentWorkflowMaterialQueryType, AgentWorkflowMaterialQueryType,
AgentWorkflowPageFeatureSettings,
AgentWorkflowSelectedBrandModel, AgentWorkflowSelectedBrandModel,
} from "@/types/agent"; } from "@/types/agent";
import { import {
@ -116,6 +120,7 @@ interface AgentGenerationWorkspaceDarkV2Props {
selectedAgentPresetId?: string | null; selectedAgentPresetId?: string | null;
selectedBrandModel?: AgentWorkflowSelectedBrandModel | null; selectedBrandModel?: AgentWorkflowSelectedBrandModel | null;
workflowContext?: AgentWorkflowComposerContext | null; workflowContext?: AgentWorkflowComposerContext | null;
workflowFeatureSettings?: AgentWorkflowPageFeatureSettings | null;
workflowPromptOptimizationEnabled?: boolean; workflowPromptOptimizationEnabled?: boolean;
getLatestWorkflowContext?: () => AgentWorkflowComposerContext | null; getLatestWorkflowContext?: () => AgentWorkflowComposerContext | null;
onBack?: () => void; onBack?: () => void;
@ -955,6 +960,7 @@ export function AgentGenerationWorkspaceDarkV2({
selectedAgentPresetId, selectedAgentPresetId,
selectedBrandModel = null, selectedBrandModel = null,
workflowContext = null, workflowContext = null,
workflowFeatureSettings = null,
workflowPromptOptimizationEnabled = true, workflowPromptOptimizationEnabled = true,
getLatestWorkflowContext, getLatestWorkflowContext,
onBack, onBack,
@ -1018,6 +1024,16 @@ export function AgentGenerationWorkspaceDarkV2({
}).workspaceState || createEmptyAgentGenerationProjectWorkspaceState(), }).workspaceState || createEmptyAgentGenerationProjectWorkspaceState(),
[workspaceState] [workspaceState]
); );
const resolvedWorkflowFeatureSettings = useMemo(
() => normalizeAgentWorkflowPageFeatureSettings(workflowFeatureSettings),
[workflowFeatureSettings]
);
const isPresetStepEnabled = resolvedWorkflowFeatureSettings.presetStepEnabled !== false;
const isMaterialStepEnabled = resolvedWorkflowFeatureSettings.materialStepEnabled !== false;
const isPsdTemplateEnabled = resolvedWorkflowFeatureSettings.psdTemplateEnabled !== false;
const requiresPresetSelection = isPresetStepEnabled;
const isDirectModelGenerationMode = !requiresPresetSelection;
const hasMaterialStep = isMaterialStepEnabled && Boolean(materialSelectionPanel);
const [input, setInput] = useState(normalizedIncomingWorkspaceState.input); const [input, setInput] = useState(normalizedIncomingWorkspaceState.input);
const [attachments, setAttachments] = useState<Array<PickedAttachment | null>>( const [attachments, setAttachments] = useState<Array<PickedAttachment | null>>(
@ -1088,6 +1104,10 @@ export function AgentGenerationWorkspaceDarkV2({
mode?: AgentPsdTemplateMode | null; mode?: AgentPsdTemplateMode | null;
resultModeType?: AgentGenerationResultModeType | null; resultModeType?: AgentGenerationResultModeType | null;
}) => { }) => {
if (!isPsdTemplateEnabled) {
toast.info("套 PSD 模板功能已关闭");
return;
}
setPsdTemplateDialogSourceUrl( setPsdTemplateDialogSourceUrl(
isValidChatHttpUrl(params?.sourceImageUrl) isValidChatHttpUrl(params?.sourceImageUrl)
? String(params?.sourceImageUrl).trim() ? String(params?.sourceImageUrl).trim()
@ -1103,7 +1123,7 @@ export function AgentGenerationWorkspaceDarkV2({
); );
setIsPsdTemplateDialogOpen(true); setIsPsdTemplateDialogOpen(true);
}, },
[activeResultModeType] [activeResultModeType, isPsdTemplateEnabled]
); );
const normalizedDeletedResultCollections = useMemo( const normalizedDeletedResultCollections = useMemo(
() => ({ () => ({
@ -1144,11 +1164,17 @@ export function AgentGenerationWorkspaceDarkV2({
saveStoredAgentPendingGenerations(allItems); saveStoredAgentPendingGenerations(allItems);
}, [chatId, pendingGeneration]); }, [chatId, pendingGeneration]);
useEffect(() => {
if (!isPsdTemplateEnabled && isPsdTemplateDialogOpen) {
closePsdTemplateDialog();
}
}, [closePsdTemplateDialog, isPsdTemplateDialogOpen, isPsdTemplateEnabled]);
const { data: historyData } = useSWR<{ messages: ChatMessage[] }>( const { data: historyData } = useSWR<{ messages: ChatMessage[] }>(
rawChatId ? `/api/messages?chatId=${rawChatId}` : null, rawChatId ? `/api/messages?chatId=${rawChatId}` : null,
fetcher, fetcher,
{ {
refreshInterval: selectedAgentPresetId ? 3000 : 0, refreshInterval: selectedAgentPresetId || isDirectModelGenerationMode ? 3000 : 0,
revalidateOnFocus: true, revalidateOnFocus: true,
} }
); );
@ -1228,7 +1254,9 @@ export function AgentGenerationWorkspaceDarkV2({
: true : true
: false; : false;
const modelSlotIndex = modelSlotEnabled ? productSlotCount : -1; const modelSlotIndex = modelSlotEnabled ? productSlotCount : -1;
const hasAgentUploadSlots = Boolean(selectedAgentPreset && selectedAgentPreset.type !== "text"); const hasAgentUploadSlots = Boolean(
hasMaterialStep && selectedAgentPreset && selectedAgentPreset.type !== "text"
);
const agentUploadSlots = useMemo( const agentUploadSlots = useMemo(
() => { () => {
if (!hasAgentUploadSlots) return []; if (!hasAgentUploadSlots) return [];
@ -1330,6 +1358,31 @@ export function AgentGenerationWorkspaceDarkV2({
}, [referenceImages]); }, [referenceImages]);
const sceneSecondaryReferenceCount = sceneSecondaryReferenceAttachments.length; const sceneSecondaryReferenceCount = sceneSecondaryReferenceAttachments.length;
const sceneMessageAttachments = useMemo(() => { const sceneMessageAttachments = useMemo(() => {
if (isDirectModelGenerationMode && hasMaterialStep) {
const seenKeys = new Set<string>();
return referenceImages
.map((image) =>
toWorkflowReferenceAttachment({
url: image.url,
name: image.name,
label: image.label,
mimeType: image.mimeType,
assetId: image.assetId || null,
})
)
.filter((attachment): attachment is PickedAttachment => {
if (!attachment) return false;
const key = getAttachmentIdentityKey(attachment);
if (key && seenKeys.has(key)) {
return false;
}
if (key) {
seenKeys.add(key);
}
return true;
});
}
if (!isSceneGenerationPreset) { if (!isSceneGenerationPreset) {
return attachments return attachments
.map((attachment) => sanitizeChatAttachment(attachment)) .map((attachment) => sanitizeChatAttachment(attachment))
@ -1384,7 +1437,10 @@ export function AgentGenerationWorkspaceDarkV2({
return ordered; return ordered;
}, [ }, [
attachments, attachments,
hasMaterialStep,
isDirectModelGenerationMode,
isSceneGenerationPreset, isSceneGenerationPreset,
referenceImages,
scenePrimaryReferenceCount, scenePrimaryReferenceCount,
sceneSecondaryReferenceAttachments, sceneSecondaryReferenceAttachments,
selectedModelAttachment, selectedModelAttachment,
@ -1577,8 +1633,33 @@ export function AgentGenerationWorkspaceDarkV2({
); );
const [activeToolStep, setActiveToolStep] = useState<ToolStepKey>("preset"); const [activeToolStep, setActiveToolStep] = useState<ToolStepKey>("preset");
const hasBrandModelStep = Boolean(brandModelPanel) && modelSlotEnabled; const hasBrandModelStep = Boolean(brandModelPanel) && modelSlotEnabled;
const hasMaterialStep = Boolean(materialSelectionPanel);
const hasWorkflowStyleStep = Boolean(workflowStylePanel) || hasBrandModelStep; const hasWorkflowStyleStep = Boolean(workflowStylePanel) || hasBrandModelStep;
const visibleWorkflowSectionKeys = useMemo(
() => [
...(isPresetStepEnabled ? ["mode"] : []),
...(hasMaterialStep ? ["materials"] : []),
...(hasWorkflowStyleStep ? ["style"] : []),
"generate",
],
[hasMaterialStep, hasWorkflowStyleStep, isPresetStepEnabled]
);
const getWorkflowSectionBadge = useCallback(
(key: "mode" | "materials" | "style" | "generate") => {
const index = visibleWorkflowSectionKeys.indexOf(key);
return String(index >= 0 ? index + 1 : visibleWorkflowSectionKeys.length + 1).padStart(
2,
"0"
);
},
[visibleWorkflowSectionKeys]
);
const firstWorkflowSectionAnchor = isPresetStepEnabled
? "agent-anchor-mode"
: hasMaterialStep
? "agent-anchor-materials"
: hasWorkflowStyleStep
? "agent-anchor-style"
: "agent-anchor-generate";
const { messages, setMessages, sendMessage, status, stop } = useChat<ChatMessage>({ const { messages, setMessages, sendMessage, status, stop } = useChat<ChatMessage>({
id: chatId, id: chatId,
@ -1591,11 +1672,15 @@ export function AgentGenerationWorkspaceDarkV2({
prepareSendMessagesRequest(request) { prepareSendMessagesRequest(request) {
const transportState = transportStateRef.current; const transportState = transportStateRef.current;
const resolvedAgentPresetId = const resolvedAgentPresetId =
transportState.selectedAgentPresetId || selectedAgentPresetId || undefined; requiresPresetSelection
? transportState.selectedAgentPresetId || selectedAgentPresetId || undefined
: undefined;
const resolvedSelectedModelId = const resolvedSelectedModelId =
transportState.selectedModelId !== "auto" transportState.selectedModelId !== "auto"
? transportState.selectedModelId ? transportState.selectedModelId
: selectedAgentPreset?.defaultModelId || transportState.selectedModelId; : selectedAgentPreset?.defaultModelId ||
modelsData?.defaultModelId ||
transportState.selectedModelId;
const replacementModePayload = const replacementModePayload =
transportState.selectedAgentPresetType === "image" && transportState.selectedAgentPresetType === "image" &&
(transportState.isDetailReplacementPreset || transportState.isSkuReplacementPreset) (transportState.isDetailReplacementPreset || transportState.isSkuReplacementPreset)
@ -1652,12 +1737,14 @@ export function AgentGenerationWorkspaceDarkV2({
MAX_CHAT_HIDDEN_PROMPT_LENGTH MAX_CHAT_HIDDEN_PROMPT_LENGTH
) || undefined, ) || undefined,
workflowPromptOptimizationEnabled, workflowPromptOptimizationEnabled,
agentPresetId: isValidChatUuid(resolvedAgentPresetId) agentPresetId: requiresPresetSelection && isValidChatUuid(resolvedAgentPresetId)
? resolvedAgentPresetId ? resolvedAgentPresetId
: undefined, : undefined,
selectedChatModel: String(resolvedSelectedModelId || "auto").trim() || "auto", selectedChatModel: String(resolvedSelectedModelId || "auto").trim() || "auto",
composerMode: composerMode:
selectedAgentPreset?.type === "image" ? ("image" as const) : ("agent" as const), isDirectModelGenerationMode || selectedAgentPreset?.type === "image"
? ("image" as const)
: ("agent" as const),
selectedVisibilityType: "private", selectedVisibilityType: "private",
imageParams: transportState.imageParams, imageParams: transportState.imageParams,
contextPayload: { contextPayload: {
@ -2268,25 +2355,26 @@ export function AgentGenerationWorkspaceDarkV2({
const mergedSettingsStepDescription = hasMaterialStep const mergedSettingsStepDescription = hasMaterialStep
? "搜索素材、补充要求、确认槽位并开始生成" ? "搜索素材、补充要求、确认槽位并开始生成"
: "补充要求并开始生成"; : "补充要求并开始生成";
const styleStepBadge = hasMaterialStep ? "03" : "02"; const modeStepBadge = getWorkflowSectionBadge("mode");
const generateStepBadge = const materialStepBadge = getWorkflowSectionBadge("materials");
hasMaterialStep && hasWorkflowStyleStep const styleStepBadge = getWorkflowSectionBadge("style");
? "04" const generateStepBadge = getWorkflowSectionBadge("generate");
: hasMaterialStep || hasWorkflowStyleStep
? "03"
: "02";
const toolSteps = useMemo( const toolSteps = useMemo(
() => [ () => [
{ ...(isPresetStepEnabled
key: "preset" as const, ? [
label: "生图模式", {
description: "先选择一个模式,再继续后续配置", key: "preset" as const,
icon: Wand2, label: "生图模式",
disabled: false, description: "先选择一个模式,再继续后续配置",
completed: Boolean(selectedAgentPresetId), icon: Wand2,
optional: false, disabled: false,
}, completed: Boolean(selectedAgentPresetId),
optional: false,
},
]
: []),
...(hasBrandModelStep ...(hasBrandModelStep
? [ ? [
{ {
@ -2294,7 +2382,7 @@ export function AgentGenerationWorkspaceDarkV2({
label: "品牌模特", label: "品牌模特",
description: "根据品牌选择模特图", description: "根据品牌选择模特图",
icon: UserRound, icon: UserRound,
disabled: !selectedAgentPresetId, disabled: requiresPresetSelection && !selectedAgentPresetId,
completed: hasBrandModelSelection, completed: hasBrandModelSelection,
optional: true, optional: true,
}, },
@ -2305,9 +2393,9 @@ export function AgentGenerationWorkspaceDarkV2({
label: mergedSettingsStepLabel, label: mergedSettingsStepLabel,
description: mergedSettingsStepDescription, description: mergedSettingsStepDescription,
icon: Settings2, icon: Settings2,
disabled: !selectedAgentPresetId, disabled: requiresPresetSelection && !selectedAgentPresetId,
completed: completed:
Boolean(selectedAgentPresetId) && (!requiresPresetSelection || Boolean(selectedAgentPresetId)) &&
(Boolean(input.trim()) || hasMaterialSelections || hasSatisfiedSlotRequirement), (Boolean(input.trim()) || hasMaterialSelections || hasSatisfiedSlotRequirement),
optional: false, optional: false,
}, },
@ -2317,10 +2405,12 @@ export function AgentGenerationWorkspaceDarkV2({
hasBrandModelStep, hasBrandModelStep,
hasMaterialSelections, hasMaterialSelections,
hasSatisfiedSlotRequirement, hasSatisfiedSlotRequirement,
isPresetStepEnabled,
mergedSettingsStepDescription, mergedSettingsStepDescription,
mergedSettingsStepLabel, mergedSettingsStepLabel,
hasMaterialStep, hasMaterialStep,
input, input,
requiresPresetSelection,
selectedAgentPresetId, selectedAgentPresetId,
] ]
); );
@ -2492,7 +2582,7 @@ export function AgentGenerationWorkspaceDarkV2({
}, [hasAgentUploadSlots, selectedAgentPresetId]); }, [hasAgentUploadSlots, selectedAgentPresetId]);
useEffect(() => { useEffect(() => {
if (!selectedAgentPresetId) { if (requiresPresetSelection && !selectedAgentPresetId) {
setActiveToolStep("preset"); setActiveToolStep("preset");
return; return;
} }
@ -2511,14 +2601,15 @@ export function AgentGenerationWorkspaceDarkV2({
}); });
}, [ }, [
hasBrandModelStep, hasBrandModelStep,
requiresPresetSelection,
selectedAgentPresetId, selectedAgentPresetId,
]); ]);
useEffect(() => { useEffect(() => {
if (!toolSteps.some((step) => step.key === activeToolStep)) { if (!toolSteps.some((step) => step.key === activeToolStep)) {
setActiveToolStep(selectedAgentPresetId ? "settings" : "preset"); setActiveToolStep(toolSteps[0]?.key || "settings");
} }
}, [activeToolStep, selectedAgentPresetId, toolSteps]); }, [activeToolStep, toolSteps]);
useEffect(() => { useEffect(() => {
if (!syncGeneratedResultsToCanvas) { if (!syncGeneratedResultsToCanvas) {
@ -2705,7 +2796,7 @@ export function AgentGenerationWorkspaceDarkV2({
void handleRunAiDetailGeneration(); void handleRunAiDetailGeneration();
return; return;
} }
if (!selectedAgentPresetId) { if (requiresPresetSelection && !selectedAgentPresetId) {
toast.error("请先选择生图模式"); toast.error("请先选择生图模式");
return; return;
} }
@ -2725,7 +2816,7 @@ export function AgentGenerationWorkspaceDarkV2({
const resolvedModelId = const resolvedModelId =
selectedModelId !== "auto" selectedModelId !== "auto"
? selectedModelId ? selectedModelId
: selectedAgentPreset?.defaultModelId || selectedModelId; : selectedAgentPreset?.defaultModelId || modelsData?.defaultModelId || selectedModelId;
if (!resolvedModelId) { if (!resolvedModelId) {
toast.error("当前风格化未配置模型"); toast.error("当前风格化未配置模型");
return; return;
@ -2846,7 +2937,9 @@ export function AgentGenerationWorkspaceDarkV2({
isDetailAiGenerationMethod, isDetailAiGenerationMethod,
isDetailReplacementPreset, isDetailReplacementPreset,
isSkuReplacementPreset, isSkuReplacementPreset,
modelsData?.defaultModelId,
requiredProductUploadCount, requiredProductUploadCount,
requiresPresetSelection,
selectedAgentPreset, selectedAgentPreset,
selectedAgentPresetId, selectedAgentPresetId,
selectableModels, selectableModels,
@ -3022,12 +3115,12 @@ export function AgentGenerationWorkspaceDarkV2({
const nextStep = toolSteps.find((step) => step.key === nextKey); const nextStep = toolSteps.find((step) => step.key === nextKey);
if (!nextStep) return; if (!nextStep) return;
if (nextStep.disabled) { if (nextStep.disabled) {
toast.error("请先选择生图模式"); toast.error(requiresPresetSelection ? "请先选择生图模式" : "当前步骤暂不可用");
return; return;
} }
setActiveToolStep(nextKey); setActiveToolStep(nextKey);
}, },
[toolSteps] [requiresPresetSelection, toolSteps]
); );
const scrollToSection = useCallback((sectionId: string) => { const scrollToSection = useCallback((sectionId: string) => {
if ( if (
@ -4323,9 +4416,9 @@ export function AgentGenerationWorkspaceDarkV2({
> >
<AgentWorkflowShowcaseBanner <AgentWorkflowShowcaseBanner
config={showcaseConfig} config={showcaseConfig}
actionLabel="开始选择模式" actionLabel={isPresetStepEnabled ? "开始选择模式" : "开始配置"}
secondaryActionLabel={allGeneratedImages.length > 0 ? "查看结果预览" : undefined} secondaryActionLabel={allGeneratedImages.length > 0 ? "查看结果预览" : undefined}
onActionClick={() => scrollToSection("agent-anchor-mode")} onActionClick={() => scrollToSection(firstWorkflowSectionAnchor)}
onSecondaryActionClick={() => scrollToSection("agent-anchor-results")} onSecondaryActionClick={() => scrollToSection("agent-anchor-results")}
/> />
</motion.section> </motion.section>
@ -4338,85 +4431,87 @@ export function AgentGenerationWorkspaceDarkV2({
className="rounded-[28px] border border-white/12 bg-white/[0.04] p-5 shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]" className="rounded-[28px] border border-white/12 bg-white/[0.04] p-5 shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]"
> >
<div className="space-y-6"> <div className="space-y-6">
<section id="agent-anchor-mode" className="scroll-mt-24 rounded-[24px] border border-white/10 bg-black/20 p-4"> {isPresetStepEnabled ? (
<div className="mb-4 flex flex-col gap-4 border-b border-white/10 pb-4 lg:flex-row lg:items-start lg:justify-between"> <section id="agent-anchor-mode" className="scroll-mt-24 rounded-[24px] border border-white/10 bg-black/20 p-4">
<div className="space-y-1"> <div className="mb-4 flex flex-col gap-4 border-b border-white/10 pb-4 lg:flex-row lg:items-start lg:justify-between">
<div className="flex items-center gap-2"> <div className="space-y-1">
<span className="rounded-full bg-emerald-500/18 px-2.5 py-1 text-[11px] font-semibold text-emerald-200"> <div className="flex items-center gap-2">
01 <span className="rounded-full bg-emerald-500/18 px-2.5 py-1 text-[11px] font-semibold text-emerald-200">
</span> {modeStepBadge}
<span className="text-sm font-semibold text-white">选择生图模式</span> </span>
</div> <span className="text-sm font-semibold text-white">选择生图模式</span>
<p className="text-sm text-white/45"> </div>
先确定本次使用的模式,并完成品牌和店铺选择,后续的商品图、品牌模特、参考图和结果展示都会随之联动。 <p className="text-sm text-white/45">
</p> 先确定本次使用的模式,并完成品牌和店铺选择,后续的商品图、品牌模特、参考图和结果展示都会随之联动。
{isDetailReplacementPreset || isSkuReplacementPreset ? (
<p className="text-xs text-amber-300/80">
{isDetailReplacementPreset
? isDetailAiGenerationMethod
? "当前模板已切换到 AI详情生成,系统会直接复用智能规划详情链路生成整套详情图。"
: "当前模板属于参考图替换模式,结果区会按参考图顺序逐屏展示。"
: "当前模板属于 SKU 替换模式,结果区会按参考图顺序一对一展示。"}
</p> </p>
) : null} {isDetailReplacementPreset || isSkuReplacementPreset ? (
</div> <p className="text-xs text-amber-300/80">
<div className="flex flex-wrap items-center gap-2"> {isDetailReplacementPreset
{selectedAgentPreset ? ( ? isDetailAiGenerationMethod
<div className="flex items-center gap-3 rounded-[20px] border border-white/10 bg-black/20 px-3 py-2"> ? "当前模板已切换到 AI详情生成,系统会直接复用智能规划详情链路生成整套详情图。"
{selectedAgentPreset.avatarUrl ? ( : "当前模板属于参考图替换模式,结果区会按参考图顺序逐屏展示。"
<img : "当前模板属于 SKU 替换模式,结果区会按参考图顺序一对一展示。"}
src={selectedAgentPreset.avatarUrl} </p>
alt={selectedAgentPreset.name} ) : null}
className="h-10 w-10 rounded-xl object-cover" </div>
/> <div className="flex flex-wrap items-center gap-2">
) : ( {selectedAgentPreset ? (
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-500/18"> <div className="flex items-center gap-3 rounded-[20px] border border-white/10 bg-black/20 px-3 py-2">
<Wand2 className="h-5 w-5 text-emerald-300" /> {selectedAgentPreset.avatarUrl ? (
</div> <img
)} src={selectedAgentPreset.avatarUrl}
<div> alt={selectedAgentPreset.name}
<div className="text-sm font-medium text-white">{selectedAgentPreset.name}</div> className="h-10 w-10 rounded-xl object-cover"
<div className="text-xs text-white/40"> />
{selectedAgentPreset.type === "image" ? "生图模式" : "视频模式"} ) : (
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-500/18">
<Wand2 className="h-5 w-5 text-emerald-300" />
</div>
)}
<div>
<div className="text-sm font-medium text-white">{selectedAgentPreset.name}</div>
<div className="text-xs text-white/40">
{selectedAgentPreset.type === "image" ? "生图模式" : "视频模式"}
</div>
</div> </div>
</div> </div>
</div> ) : null}
) : null} {selectedAgentPreset && onClearPreset ? (
{selectedAgentPreset && onClearPreset ? ( <button
<button type="button"
type="button" onClick={onClearPreset}
onClick={onClearPreset} className="rounded-full border border-white/10 bg-white/[0.03] px-3 py-2 text-xs text-emerald-300 transition-colors hover:border-emerald-300/35 hover:text-emerald-200"
className="rounded-full border border-white/10 bg-white/[0.03] px-3 py-2 text-xs text-emerald-300 transition-colors hover:border-emerald-300/35 hover:text-emerald-200" >
> 更换生图模式
更换生图模式 </button>
</button> ) : null}
) : null} </div>
</div> </div>
</div>
{presetPanel ? ( {presetPanel ? (
<div className="agent-dark-scrollbar max-h-[760px] overflow-y-auto pr-1"> <div className="agent-dark-scrollbar max-h-[760px] overflow-y-auto pr-1">
{presetPanel} {presetPanel}
</div> </div>
) : ( ) : (
<div className="flex min-h-[220px] items-center justify-center rounded-[24px] border border-dashed border-white/12 bg-black/20 text-sm text-white/45"> <div className="flex min-h-[220px] items-center justify-center rounded-[24px] border border-dashed border-white/12 bg-black/20 text-sm text-white/45">
暂无可用的生图模式配置。 暂无可用的生图模式配置。
</div> </div>
)} )}
{brandStorePanel ? ( {brandStorePanel ? (
<div className="mt-4 border-t border-white/10 pt-4"> <div className="mt-4 border-t border-white/10 pt-4">
{brandStorePanel} {brandStorePanel}
</div> </div>
) : null} ) : null}
</section> </section>
) : null}
{hasMaterialStep ? ( {hasMaterialStep ? (
<section id="agent-anchor-materials" className="scroll-mt-24 rounded-[24px] border border-white/10 bg-black/20 p-4"> <section id="agent-anchor-materials" className="scroll-mt-24 rounded-[24px] border border-white/10 bg-black/20 p-4">
<div className="mb-4 space-y-1 border-b border-white/10 pb-4"> <div className="mb-4 space-y-1 border-b border-white/10 pb-4">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span className="rounded-full bg-emerald-500/18 px-2.5 py-1 text-[11px] font-semibold text-emerald-200"> <span className="rounded-full bg-emerald-500/18 px-2.5 py-1 text-[11px] font-semibold text-emerald-200">
02 {materialStepBadge}
</span> </span>
<span className="text-sm font-semibold text-white">选择 SPU / SKU</span> <span className="text-sm font-semibold text-white">选择 SPU / SKU</span>
</div> </div>
@ -4607,7 +4702,7 @@ export function AgentGenerationWorkspaceDarkV2({
onClick={handleSend} onClick={handleSend}
disabled={ disabled={
isAnyGenerationRunning || isAnyGenerationRunning ||
!selectedAgentPresetId || (requiresPresetSelection && !selectedAgentPresetId) ||
(isDetailAiGenerationMethod (isDetailAiGenerationMethod
? detailGenerationValidationIssues.length > 0 ? detailGenerationValidationIssues.length > 0
: hasAgentUploadSlots && !hasSatisfiedSlotRequirement) : hasAgentUploadSlots && !hasSatisfiedSlotRequirement)
@ -5067,18 +5162,20 @@ export function AgentGenerationWorkspaceDarkV2({
{detailGenerationExpectedCount} {detailGenerationExpectedCount}
</div> </div>
) : null} ) : null}
<button {isPsdTemplateEnabled ? (
type="button" <button
onClick={() => type="button"
openPsdTemplateDialog({ onClick={() =>
mode: getPsdTemplateModeByResultMode(activeResultModeType), openPsdTemplateDialog({
}) mode: getPsdTemplateModeByResultMode(activeResultModeType),
} })
className="inline-flex items-center gap-1.5 rounded-full border border-white/10 bg-white/[0.03] px-3 py-1 text-xs text-white/72 transition-colors hover:border-white/20 hover:bg-white/[0.08] hover:text-white" }
> className="inline-flex items-center gap-1.5 rounded-full border border-white/10 bg-white/[0.03] px-3 py-1 text-xs text-white/72 transition-colors hover:border-white/20 hover:bg-white/[0.08] hover:text-white"
<ImagePlus className="h-3.5 w-3.5" /> >
<span>套PSD</span> <ImagePlus className="h-3.5 w-3.5" />
</button> <span>套PSD</span>
</button>
) : null}
</div> </div>
</div> </div>
@ -5913,28 +6010,30 @@ export function AgentGenerationWorkspaceDarkV2({
> >
<Maximize2 className="h-4 w-4" /> <Maximize2 className="h-4 w-4" />
</button> </button>
<button {isPsdTemplateEnabled ? (
type="button" <button
onClick={(event) => { type="button"
event.stopPropagation(); onClick={(event) => {
setSelectedResultUrl(card.url!); event.stopPropagation();
openPsdTemplateDialog({ setSelectedResultUrl(card.url!);
sourceImageUrl: card.url!, openPsdTemplateDialog({
mode: getPsdTemplateModeByResultMode(activeResultModeType), sourceImageUrl: card.url!,
}); mode: getPsdTemplateModeByResultMode(activeResultModeType),
}} });
className="absolute left-14 top-3 flex items-center gap-1 rounded-full border border-white/10 bg-black/60 px-2.5 py-1 text-[11px] text-white transition-colors hover:border-white/20" }}
aria-label="套用 PSD 模板" className="absolute left-14 top-3 flex items-center gap-1 rounded-full border border-white/10 bg-black/60 px-2.5 py-1 text-[11px] text-white transition-colors hover:border-white/20"
> aria-label="套用 PSD 模板"
<ImagePlus className="h-3.5 w-3.5" /> >
<span>套PSD</span> <ImagePlus className="h-3.5 w-3.5" />
</button> <span>套PSD</span>
</button>
) : null}
<div className="pointer-events-none absolute inset-x-3 bottom-3 rounded-2xl border border-white/10 bg-black/55 px-3 py-2 text-[11px] text-white/78 backdrop-blur"> <div className="pointer-events-none absolute inset-x-3 bottom-3 rounded-2xl border border-white/10 bg-black/55 px-3 py-2 text-[11px] text-white/78 backdrop-blur">
双击查看大图 双击查看大图
</div> </div>
</> </>
) : null} ) : null}
{!isSceneResultCard ? ( {!isSceneResultCard && isPsdTemplateEnabled ? (
<button <button
type="button" type="button"
onClick={(event) => { onClick={(event) => {
@ -6031,29 +6130,35 @@ export function AgentGenerationWorkspaceDarkV2({
<Wand2 className="h-8 w-8 text-white/20" /> <Wand2 className="h-8 w-8 text-white/20" />
</div> </div>
<p className="text-base font-medium text-white/60"> <p className="text-base font-medium text-white/60">
{selectedAgentPresetId ? `${getResultModeLabel(activeResultModeType)}结果暂为空` : "请选择生图模式"} {!requiresPresetSelection || selectedAgentPresetId
? `${getResultModeLabel(activeResultModeType)}结果暂为空`
: "请选择生图模式"}
</p> </p>
<p className="mt-2 text-sm text-white/30"> <p className="mt-2 text-sm text-white/30">
{selectedAgentPresetId {!requiresPresetSelection || selectedAgentPresetId
? "切换到对应生图模式并开始生成后,结果会保留在当前项目的对应分类中。" ? "选择模型并开始生成后,结果会保留在当前项目的对应分类中。"
: "请先从顶部流程线选择一个生图模式"} : "请先从顶部流程线选择一个生图模式"}
</p> </p>
<Button {isPsdTemplateEnabled ? (
type="button" <>
variant="outline" <Button
onClick={() => type="button"
openPsdTemplateDialog({ variant="outline"
mode: getPsdTemplateModeByResultMode(activeResultModeType), onClick={() =>
}) openPsdTemplateDialog({
} mode: getPsdTemplateModeByResultMode(activeResultModeType),
className="mt-5 rounded-full border-white/10 bg-white/[0.03] px-5 text-white hover:bg-white/[0.08]" })
> }
<ImagePlus className="mr-2 h-4 w-4" /> className="mt-5 rounded-full border-white/10 bg-white/[0.03] px-5 text-white hover:bg-white/[0.08]"
套PSD >
</Button> <ImagePlus className="mr-2 h-4 w-4" />
<p className="mt-2 text-xs text-white/35"> 套PSD
可直接进入模板页,并通过手动上传图片开始套版。 </Button>
</p> <p className="mt-2 text-xs text-white/35">
可直接进入模板页,并通过手动上传图片开始套版。
</p>
</>
) : null}
</motion.div> </motion.div>
)} )}
</AnimatePresence> </AnimatePresence>
@ -6080,61 +6185,63 @@ export function AgentGenerationWorkspaceDarkV2({
/> />
) : null} ) : null}
<ClientErrorBoundary {isPsdTemplateEnabled ? (
resetKeys={[ <ClientErrorBoundary
isPsdTemplateDialogOpen ? "open" : "closed", resetKeys={[
psdTemplateDialogSourceUrl || "", isPsdTemplateDialogOpen ? "open" : "closed",
workflowContext?.brand || "", psdTemplateDialogSourceUrl || "",
workflowContext?.fifthCategory || "", workflowContext?.brand || "",
psdTemplateDialogMode, workflowContext?.fifthCategory || "",
]} psdTemplateDialogMode,
fallback={ ]}
<Dialog fallback={
<Dialog
open={isPsdTemplateDialogOpen}
onOpenChange={(open) => {
if (!open) {
closePsdTemplateDialog();
}
}}
>
<DialogContent
overlayClassName="bg-black/85 backdrop-blur-sm"
className="max-w-lg border border-white/10 bg-[#09090b] text-white"
>
<DialogHeader>
<DialogTitle>PSD 模板暂时无法打开</DialogTitle>
<DialogDescription>
已拦截本次客户端异常,避免整个风格化工作台被一起打断。
</DialogDescription>
</DialogHeader>
<div className="space-y-3 text-sm leading-6 text-white/72">
<p>请关闭弹窗后重试一次。</p>
<p>如果仍然出现,优先检查当前品牌下的 PSD 模板配置、图层数据或字体资源是否完整。</p>
</div>
</DialogContent>
</Dialog>
}
>
<AgentPsdTemplateEditorDialog
open={isPsdTemplateDialogOpen} open={isPsdTemplateDialogOpen}
onOpenChange={(open) => { onOpenChange={(open) => {
if (!open) { if (!open) {
closePsdTemplateDialog(); closePsdTemplateDialog();
} }
}} }}
> sourceImageUrl={psdTemplateDialogSourceUrl}
<DialogContent brandName={workflowContext?.brand || null}
overlayClassName="bg-black/85 backdrop-blur-sm" selectedCategoryNames={[workflowContext?.fifthCategory || ""].filter(Boolean)}
className="max-w-lg border border-white/10 bg-[#09090b] text-white" sizeInfoText={workflowContext?.summaryText || null}
> templateMode={psdTemplateDialogMode}
<DialogHeader> onDerivedImageCreated={
<DialogTitle>PSD 模板暂时无法打开</DialogTitle> onResultPreviewUrlsChange ? handlePsdDerivedImageCreated : undefined
<DialogDescription>
已拦截本次客户端异常,避免整个风格化工作台被一起打断。
</DialogDescription>
</DialogHeader>
<div className="space-y-3 text-sm leading-6 text-white/72">
<p>请关闭弹窗后重试一次。</p>
<p>如果仍然出现,优先检查当前品牌下的 PSD 模板配置、图层数据或字体资源是否完整。</p>
</div>
</DialogContent>
</Dialog>
}
>
<AgentPsdTemplateEditorDialog
open={isPsdTemplateDialogOpen}
onOpenChange={(open) => {
if (!open) {
closePsdTemplateDialog();
} }
}} onRenderedResultCreated={
sourceImageUrl={psdTemplateDialogSourceUrl} onResultPreviewUrlsChange ? handlePsdRenderedResultCreated : undefined
brandName={workflowContext?.brand || null} }
selectedCategoryNames={[workflowContext?.fifthCategory || ""].filter(Boolean)} />
sizeInfoText={workflowContext?.summaryText || null} </ClientErrorBoundary>
templateMode={psdTemplateDialogMode} ) : null}
onDerivedImageCreated={
onResultPreviewUrlsChange ? handlePsdDerivedImageCreated : undefined
}
onRenderedResultCreated={
onResultPreviewUrlsChange ? handlePsdRenderedResultCreated : undefined
}
/>
</ClientErrorBoundary>
{/* Fullscreen Preview */} {/* Fullscreen Preview */}
<AnimatePresence> <AnimatePresence>

View File

@ -4,6 +4,7 @@ import type {
AgentWorkflowConstraintSettings, AgentWorkflowConstraintSettings,
AgentWorkflowFourthCategoryEntry, AgentWorkflowFourthCategoryEntry,
AgentWorkflowOptionUiConfig, AgentWorkflowOptionUiConfig,
AgentWorkflowPageFeatureSettings,
AgentWorkflowStoreEntry, AgentWorkflowStoreEntry,
AgentWorkflowThirdCategoryEntry, AgentWorkflowThirdCategoryEntry,
AgentWorkflowStepKey, AgentWorkflowStepKey,
@ -25,6 +26,11 @@ export const defaultAgentWorkflowCategoryLabels: AgentWorkflowCategoryLabels = {
export const defaultAgentWorkflowConstraintSettings: AgentWorkflowConstraintSettings = { export const defaultAgentWorkflowConstraintSettings: AgentWorkflowConstraintSettings = {
crossLevelMutualExclusionEnabled: false, crossLevelMutualExclusionEnabled: false,
}; };
export const defaultAgentWorkflowPageFeatureSettings: AgentWorkflowPageFeatureSettings = {
presetStepEnabled: true,
materialStepEnabled: true,
psdTemplateEnabled: true,
};
export interface AgentWorkflowBrandCategoryOption { export interface AgentWorkflowBrandCategoryOption {
value: string; value: string;
@ -169,6 +175,7 @@ export const defaultAgentWorkflowUiConfig: AgentWorkflowUiConfig = {
brandStoreEntries: [], brandStoreEntries: [],
}, },
constraintSettings: defaultAgentWorkflowConstraintSettings, constraintSettings: defaultAgentWorkflowConstraintSettings,
pageFeatureSettings: defaultAgentWorkflowPageFeatureSettings,
steps: defaultSteps.map((step, index) => steps: defaultSteps.map((step, index) =>
cloneStep({ cloneStep({
...step, ...step,
@ -230,6 +237,30 @@ export function normalizeAgentWorkflowConstraintSettings(
}; };
} }
export function normalizeAgentWorkflowPageFeatureSettings(
value: unknown
): AgentWorkflowPageFeatureSettings {
const record =
value && typeof value === "object" && !Array.isArray(value)
? (value as Record<string, unknown>)
: {};
return {
presetStepEnabled: normalizeBoolean(
record.presetStepEnabled ?? record.modeStepEnabled ?? record.enablePresetStep,
defaultAgentWorkflowPageFeatureSettings.presetStepEnabled
),
materialStepEnabled: normalizeBoolean(
record.materialStepEnabled ?? record.skuStepEnabled ?? record.enableMaterialStep,
defaultAgentWorkflowPageFeatureSettings.materialStepEnabled
),
psdTemplateEnabled: normalizeBoolean(
record.psdTemplateEnabled ?? record.enablePsdTemplate,
defaultAgentWorkflowPageFeatureSettings.psdTemplateEnabled
),
};
}
export function flattenAgentWorkflowSteps( export function flattenAgentWorkflowSteps(
steps: AgentWorkflowStepUiConfig[], steps: AgentWorkflowStepUiConfig[],
depth = 1, depth = 1,
@ -1036,6 +1067,13 @@ export function normalizeAgentWorkflowUiConfig(value: unknown): AgentWorkflowUiC
crossLevelMutualExclusionEnabled: raw.crossLevelMutualExclusionEnabled, crossLevelMutualExclusionEnabled: raw.crossLevelMutualExclusionEnabled,
} }
), ),
pageFeatureSettings: normalizeAgentWorkflowPageFeatureSettings(
raw.pageFeatureSettings ?? {
presetStepEnabled: raw.presetStepEnabled ?? raw.modeStepEnabled,
materialStepEnabled: raw.materialStepEnabled ?? raw.skuStepEnabled,
psdTemplateEnabled: raw.psdTemplateEnabled,
}
),
steps: sanitizedSteps, steps: sanitizedSteps,
}; };
} }
@ -1056,6 +1094,12 @@ export function getAgentWorkflowConstraintSettings(
return normalizeAgentWorkflowConstraintSettings(config?.constraintSettings); return normalizeAgentWorkflowConstraintSettings(config?.constraintSettings);
} }
export function getAgentWorkflowPageFeatureSettings(
config?: AgentWorkflowUiConfig | null
) {
return normalizeAgentWorkflowPageFeatureSettings(config?.pageFeatureSettings);
}
export function getAgentWorkflowCategoryOptionsByBrand(params: { export function getAgentWorkflowCategoryOptionsByBrand(params: {
config?: AgentWorkflowUiConfig | null; config?: AgentWorkflowUiConfig | null;
brand?: string | null; brand?: string | null;

View File

@ -105,6 +105,12 @@ export interface AgentWorkflowConstraintSettings {
crossLevelMutualExclusionEnabled: boolean; crossLevelMutualExclusionEnabled: boolean;
} }
export interface AgentWorkflowPageFeatureSettings {
presetStepEnabled: boolean;
materialStepEnabled: boolean;
psdTemplateEnabled: boolean;
}
export interface AgentWorkflowUiConfig { export interface AgentWorkflowUiConfig {
inputOptions?: { inputOptions?: {
brands: string[]; brands: string[];
@ -117,6 +123,7 @@ export interface AgentWorkflowUiConfig {
brandStoreEntries?: AgentWorkflowBrandStoreEntry[]; brandStoreEntries?: AgentWorkflowBrandStoreEntry[];
}; };
constraintSettings?: AgentWorkflowConstraintSettings; constraintSettings?: AgentWorkflowConstraintSettings;
pageFeatureSettings?: AgentWorkflowPageFeatureSettings;
steps: AgentWorkflowStepUiConfig[]; steps: AgentWorkflowStepUiConfig[];
} }