refactor: simplify agent workspace header
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-03-21 22:23:42 +08:00
parent c0d4375daa
commit b702440347

View File

@ -886,97 +886,6 @@ export function AgentGenerationWorkspaceDarkV2({
(image) => image.source === "primary" || image.source === "secondary"
);
const hasSatisfiedSlotRequirement = !hasAgentUploadSlots || attachmentCount >= requiredUploadCount;
const workflowSelectionCount = workflowContext?.selections?.length || 0;
const replacementReferenceSummary = isDetailReplacementPreset
? `${detailReplacementReferenceCards.length} 张详情图`
: isSkuReplacementPreset
? `${skuReplacementReferenceCards.length} 张 SKU 图`
: "当前模式不需要";
const taskStatus = !selectedAgentPresetId
? {
label: "待选模式",
className: "border-white/10 bg-white/[0.06] text-white/72",
}
: hasAgentUploadSlots && !hasSatisfiedSlotRequirement
? {
label: "待补图",
className: "border-amber-400/20 bg-amber-500/[0.08] text-amber-100",
}
: isDetailReplacementPreset && detailReplacementReferenceCards.length === 0
? {
label: "待载入详情图",
className: "border-amber-400/20 bg-amber-500/[0.08] text-amber-100",
}
: isSkuReplacementPreset && skuReplacementReferenceCards.length === 0
? {
label: "待载入SKU图",
className: "border-amber-400/20 bg-amber-500/[0.08] text-amber-100",
}
: {
label: "可开始生成",
className: "border-emerald-400/20 bg-emerald-500/[0.08] text-emerald-100",
};
const taskSummaryItems = [
{
label: "当前模式",
value: selectedAgentPreset?.name || "未选择",
},
{
label: "品牌 / 店铺",
value:
workflowContext?.brand || workflowContext?.store
? `${workflowContext?.brand || "未选品牌"} / ${workflowContext?.store || "未选店铺"}`
: "未选择",
},
{
label: "产品图",
value:
hasAgentUploadSlots && selectedAgentPreset?.type === "image"
? `${selectedProductAttachments.length}/${productSlotCount} 张`
: "当前模式无需",
},
{
label: "模特图",
value: modelSlotEnabled ? (selectedModelAttachment ? "已带入" : "待补充") : "当前模式无需",
},
{
label: "风格卡片",
value: workflowSelectionCount > 0 ? `${workflowSelectionCount} 项已选` : "待选择",
},
{
label: "参考图",
value: replacementReferenceSummary,
},
];
const taskDirective = !selectedAgentPresetId
? {
title: "先选择一个生图模式",
description: "模式会决定后续的输入槽位、参考图区和结果执行方式。",
}
: hasMaterialStep && hasAgentUploadSlots && !hasSatisfiedSlotRequirement
? {
title: `先补齐剩余 ${missingAttachmentCount} 张输入图`,
description: "输入图没有准备完成前,系统不会开放生成入口,避免用户走到后面才返工。",
}
: hasWorkflowStyleStep && workflowSelectionCount === 0
? {
title: "继续选择风格步骤卡片",
description: "把风格卡片补齐后,组合 Prompt 会更完整,结果风格也会更稳定。",
}
: isDetailReplacementPreset && detailReplacementReferenceCards.length === 0
? {
title: "先载入详情参考图",
description: "详情替换需要一整套详情参考图,右侧结果会按相同顺序逐屏生成。",
}
: isSkuReplacementPreset && skuReplacementReferenceCards.length === 0
? {
title: "先载入 SKU 参考图",
description: "SKU 替换需要先确定一组参考图,系统才会执行一对一替换。",
}
: {
title: "当前已经可以开始生成",
description: "现在只需要检查补充要求和生成参数,就可以直接开始执行。",
};
const slotRequirementMessage =
hasAgentUploadSlots && !hasSatisfiedSlotRequirement
? `当前还缺少 ${missingAttachmentCount} 张输入图,请先在“选择 SPU / SKU”步骤补齐后再继续。`
@ -992,51 +901,6 @@ export function AgentGenerationWorkspaceDarkV2({
: hasMaterialStep || hasWorkflowStyleStep
? "03"
: "02";
const unifiedAnchorSteps = useMemo(
() => {
const steps = [
{
id: "agent-anchor-mode",
badge: "01",
label: "选择生图模式",
description: "先确定本次要执行的生图模式",
},
];
if (hasMaterialStep) {
steps.push({
id: "agent-anchor-materials",
badge: "02",
label: "选择 SPU / SKU",
description: "查询商品图并确定本次输入素材",
});
}
if (hasWorkflowStyleStep) {
steps.push({
id: "agent-anchor-style",
badge: hasMaterialStep ? "03" : "02",
label: "风格步骤卡片",
description: "补齐风格、品牌和模特等工作流配置",
});
}
steps.push({
id: "agent-anchor-generate",
badge:
hasMaterialStep && hasWorkflowStyleStep
? "04"
: hasMaterialStep || hasWorkflowStyleStep
? "03"
: "02",
label: "生图与结果预览",
description: "确认参数后直接生成,并在底部查看结果",
});
return steps;
},
[hasMaterialStep, hasWorkflowStyleStep]
);
const toolSteps = useMemo(
() => [
@ -1546,53 +1410,6 @@ export function AgentGenerationWorkspaceDarkV2({
}
target.scrollIntoView({ behavior: "smooth", block: "start" });
}, [hasAgentUploadSlots, hasMaterialStep, hasSatisfiedSlotRequirement, slotRequirementMessage]);
const taskSummaryAction = useMemo(() => {
if (!selectedAgentPresetId) {
return {
label: "去选模式",
sectionId: "agent-anchor-mode",
};
}
if (hasMaterialStep && hasAgentUploadSlots && !hasSatisfiedSlotRequirement) {
return {
label: "去补图",
sectionId: "agent-anchor-materials",
};
}
if (hasWorkflowStyleStep && workflowSelectionCount === 0) {
return {
label: "去选风格",
sectionId: "agent-anchor-style",
};
}
if (isDetailReplacementPreset && detailReplacementReferenceCards.length === 0) {
return {
label: "去查详情图",
sectionId: "agent-anchor-results",
};
}
if (isSkuReplacementPreset && skuReplacementReferenceCards.length === 0) {
return {
label: "去查SKU参考图",
sectionId: "agent-anchor-results",
};
}
return {
label: "前往生成区",
sectionId: "agent-anchor-generate",
};
}, [
detailReplacementReferenceCards.length,
hasAgentUploadSlots,
hasMaterialStep,
hasSatisfiedSlotRequirement,
hasWorkflowStyleStep,
isDetailReplacementPreset,
isSkuReplacementPreset,
selectedAgentPresetId,
skuReplacementReferenceCards.length,
workflowSelectionCount,
]);
const updateDetailReplacementState = useCallback(
(
updater:
@ -1994,100 +1811,6 @@ export function AgentGenerationWorkspaceDarkV2({
transition={{ delay: 0.06 }}
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="mb-5 border-b border-white/10 pb-4">
<div className="agent-dark-scrollbar flex gap-2 overflow-x-auto pb-1">
{unifiedAnchorSteps.map((step) => {
const isGenerateAnchor = step.id === "agent-anchor-generate";
const isBlockedGenerateAnchor =
isGenerateAnchor && hasAgentUploadSlots && !hasSatisfiedSlotRequirement;
return (
<button
key={step.id}
type="button"
onClick={() => scrollToSection(step.id)}
className={cn(
"flex min-w-max items-center gap-3 rounded-full border px-4 py-2 text-left transition-colors",
isBlockedGenerateAnchor
? "border-amber-400/20 bg-amber-500/[0.08] text-amber-100/90"
: "border-white/10 bg-white/[0.03] hover:border-white/20 hover:bg-white/[0.06]"
)}
>
<span className="rounded-full bg-white px-2 py-0.5 text-[10px] font-semibold text-black">
{step.badge}
</span>
<span className="flex flex-col">
<span className="text-sm font-medium text-white">{step.label}</span>
<span
className={cn(
"text-[11px]",
isBlockedGenerateAnchor ? "text-amber-100/70" : "text-white/45"
)}
>
{isBlockedGenerateAnchor && slotRequirementMessage
? slotRequirementMessage
: step.description}
</span>
</span>
</button>
);
})}
</div>
</div>
<div className="sticky top-[76px] z-20 mb-6 rounded-[24px] border border-white/10 bg-black/72 px-4 py-4 shadow-[0_12px_36px_rgba(0,0,0,0.22)] backdrop-blur-xl">
<div className="flex flex-col gap-4 xl:flex-row xl:items-center xl:justify-between">
<div className="space-y-3">
<div className="flex items-center gap-2">
<span className="rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-[11px] font-medium text-white/78">
下一步建议
</span>
<span
className={cn(
"rounded-full border px-2.5 py-1 text-[11px] font-medium",
taskStatus.className
)}
>
{taskStatus.label}
</span>
</div>
<div>
<div className="text-base font-semibold text-white">{taskDirective.title}</div>
<div className="mt-1 text-sm leading-6 text-white/45">
{taskDirective.description}
</div>
</div>
<div className="grid grid-cols-2 gap-2 xl:grid-cols-6">
{taskSummaryItems.map((item) => (
<div
key={item.label}
className="rounded-[18px] border border-white/10 bg-white/[0.03] px-3 py-2"
>
<div className="text-[11px] text-white/42">{item.label}</div>
<div className="mt-1 truncate text-sm font-medium text-white/88">
{item.value}
</div>
</div>
))}
</div>
</div>
<div className="flex items-center gap-3">
<div className="max-w-[320px] text-left text-xs leading-5 text-white/45 xl:text-right">
{slotRequirementMessage || taskDirective.description}
</div>
<Button
type="button"
variant="outline"
onClick={() => scrollToSection(taskSummaryAction.sectionId)}
className="border-white/12 bg-white/[0.05] text-white/88 hover:bg-white/[0.10] hover:text-white"
>
{taskSummaryAction.label}
</Button>
</div>
</div>
</div>
<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">
<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">