diff --git a/components/agents/AgentDetailReferenceStitchDialog.tsx b/components/agents/AgentDetailReferenceStitchDialog.tsx
index f17caa105..c33e35a24 100644
--- a/components/agents/AgentDetailReferenceStitchDialog.tsx
+++ b/components/agents/AgentDetailReferenceStitchDialog.tsx
@@ -358,6 +358,13 @@ export function AgentDetailReferenceStitchDialog({
setCutLines(snapshot.defaultCutLines);
}, [snapshot]);
+ const handleClearCutLines = useCallback(() => {
+ setCutLines([]);
+ setDraggingLineIndex(null);
+ setIsAddingCutLine(false);
+ setPreviewCutLineY(null);
+ }, []);
+
const handleRemoveCutLine = useCallback((index: number) => {
setCutLines((current) => current.filter((_, currentIndex) => currentIndex !== index));
}, []);
@@ -549,6 +556,16 @@ export function AgentDetailReferenceStitchDialog({
恢复原页边界
+
默认切线已按原始详情页边界生成,可直接拖动横线微调。
{isAddingCutLine ? " 当前已进入加线模式,移动鼠标预览位置后点击长图即可落线。" : ""}
diff --git a/components/agents/AgentGenerationWorkspace.tsx b/components/agents/AgentGenerationWorkspace.tsx
index a9cdd8091..c1544aa57 100644
--- a/components/agents/AgentGenerationWorkspace.tsx
+++ b/components/agents/AgentGenerationWorkspace.tsx
@@ -234,6 +234,24 @@ export function AgentGenerationWorkspace({
() => selectableModels.find((model) => model.id === selectedModelId) || selectableModels[0],
[selectableModels, selectedModelId]
);
+ const transportStateRef = useRef<{
+ selectedAgentPresetId: string | null;
+ selectedModelId: string;
+ imageParams: ImageGenerationParams;
+ }>({
+ selectedAgentPresetId: null,
+ selectedModelId: "auto",
+ imageParams: {
+ aspectRatio: "auto",
+ imageSize: "2K",
+ imageCount: 1,
+ },
+ });
+ transportStateRef.current = {
+ selectedAgentPresetId: selectedAgentPresetId || null,
+ selectedModelId,
+ imageParams,
+ };
const { messages, setMessages, sendMessage, status } = useChat({
id: chatId,
@@ -244,15 +262,16 @@ export function AgentGenerationWorkspace({
api: "/api/chat",
fetch: fetchWithErrorHandlers,
prepareSendMessagesRequest(request) {
+ const transportState = transportStateRef.current;
return {
body: {
id: rawChatId,
message: request.messages.at(-1),
hiddenPrompt: hiddenPromptRef.current || undefined,
- agentPresetId: selectedAgentPresetId || undefined,
- selectedChatModel: selectedModelId,
+ agentPresetId: transportState.selectedAgentPresetId || undefined,
+ selectedChatModel: transportState.selectedModelId,
selectedVisibilityType: "private",
- imageParams,
+ imageParams: transportState.imageParams,
},
};
},
diff --git a/components/agents/AgentGenerationWorkspaceDark.tsx b/components/agents/AgentGenerationWorkspaceDark.tsx
index 81addbbe9..f355c2cff 100644
--- a/components/agents/AgentGenerationWorkspaceDark.tsx
+++ b/components/agents/AgentGenerationWorkspaceDark.tsx
@@ -152,6 +152,24 @@ export function AgentGenerationWorkspaceDark({
() => selectableModels.find((model) => model.id === selectedModelId) || selectableModels[0],
[selectableModels, selectedModelId]
);
+ const transportStateRef = useRef<{
+ selectedAgentPresetId: string | null;
+ selectedModelId: string;
+ imageParams: ImageGenerationParams;
+ }>({
+ selectedAgentPresetId: null,
+ selectedModelId: "auto",
+ imageParams: {
+ aspectRatio: "auto",
+ imageSize: "2K",
+ imageCount: 1,
+ },
+ });
+ transportStateRef.current = {
+ selectedAgentPresetId: selectedAgentPresetId || null,
+ selectedModelId,
+ imageParams,
+ };
const { messages, setMessages, sendMessage, status } = useChat({
id: chatId,
@@ -162,15 +180,16 @@ export function AgentGenerationWorkspaceDark({
api: "/api/chat",
fetch: fetchWithErrorHandlers,
prepareSendMessagesRequest(request) {
+ const transportState = transportStateRef.current;
return {
body: {
id: rawChatId,
message: request.messages.at(-1),
hiddenPrompt: hiddenPromptRef.current || undefined,
- agentPresetId: selectedAgentPresetId || undefined,
- selectedChatModel: selectedModelId,
+ agentPresetId: transportState.selectedAgentPresetId || undefined,
+ selectedChatModel: transportState.selectedModelId,
selectedVisibilityType: "private",
- imageParams,
+ imageParams: transportState.imageParams,
},
};
},
diff --git a/components/agents/AgentGenerationWorkspaceDarkV2.tsx b/components/agents/AgentGenerationWorkspaceDarkV2.tsx
index 0651b3fa7..659d4b40d 100644
--- a/components/agents/AgentGenerationWorkspaceDarkV2.tsx
+++ b/components/agents/AgentGenerationWorkspaceDarkV2.tsx
@@ -759,6 +759,57 @@ export function AgentGenerationWorkspaceDarkV2({
const skuReplacementCandidates = skuReplacementState.candidates;
const skuReplacementSelectedCandidateId = skuReplacementState.selectedCandidateId;
const skuReplacementReferenceCards = skuReplacementState.references;
+ const transportStateRef = useRef<{
+ selectedAgentPresetId: string | null;
+ selectedAgentPresetType: AgentPreset["type"] | null;
+ selectedModelId: string;
+ imageParams: ImageGenerationParams;
+ isDetailReplacementPreset: boolean;
+ isSkuReplacementPreset: boolean;
+ detailReplacementQueryInput: string;
+ detailReplacementSelectedCandidateId: string | null;
+ detailReplacementReferenceCards: typeof detailReplacementReferenceCards;
+ skuReplacementQueryInput: string;
+ skuReplacementQueryType: typeof skuReplacementQueryType;
+ skuReplacementSelectedCandidateId: string | null;
+ skuReplacementReferenceCards: typeof skuReplacementReferenceCards;
+ selectedProductAttachmentCount: number;
+ }>({
+ selectedAgentPresetId: null,
+ selectedAgentPresetType: null,
+ selectedModelId: "auto",
+ imageParams: {
+ aspectRatio: "auto",
+ imageSize: "2K",
+ imageCount: 1,
+ },
+ isDetailReplacementPreset: false,
+ isSkuReplacementPreset: false,
+ detailReplacementQueryInput: "",
+ detailReplacementSelectedCandidateId: null,
+ detailReplacementReferenceCards: [],
+ skuReplacementQueryInput: "",
+ skuReplacementQueryType: "sku",
+ skuReplacementSelectedCandidateId: null,
+ skuReplacementReferenceCards: [],
+ selectedProductAttachmentCount: 0,
+ });
+ transportStateRef.current = {
+ selectedAgentPresetId: selectedAgentPresetId || null,
+ selectedAgentPresetType: selectedAgentPreset?.type || null,
+ selectedModelId,
+ imageParams,
+ isDetailReplacementPreset,
+ isSkuReplacementPreset,
+ detailReplacementQueryInput,
+ detailReplacementSelectedCandidateId: detailReplacementSelectedCandidateId || null,
+ detailReplacementReferenceCards,
+ skuReplacementQueryInput,
+ skuReplacementQueryType,
+ skuReplacementSelectedCandidateId: skuReplacementSelectedCandidateId || null,
+ skuReplacementReferenceCards,
+ selectedProductAttachmentCount: selectedProductAttachments.length,
+ };
const selectableModels = useMemo(() => {
const imageModels = (modelsData?.models || []).filter(
@@ -791,26 +842,27 @@ export function AgentGenerationWorkspaceDarkV2({
api: "/api/chat",
fetch: fetchWithErrorHandlers,
prepareSendMessagesRequest(request) {
+ const transportState = transportStateRef.current;
const replacementModePayload =
- selectedAgentPreset?.type === "image" &&
- (isDetailReplacementPreset || isSkuReplacementPreset)
+ transportState.selectedAgentPresetType === "image" &&
+ (transportState.isDetailReplacementPreset || transportState.isSkuReplacementPreset)
? {
- modeType: isDetailReplacementPreset
+ modeType: transportState.isDetailReplacementPreset
? ("detail_replacement" as const)
: ("sku_replacement" as const),
- query: isDetailReplacementPreset
- ? detailReplacementQueryInput.trim()
- : skuReplacementQueryInput.trim(),
- queryType: isDetailReplacementPreset
+ query: transportState.isDetailReplacementPreset
+ ? transportState.detailReplacementQueryInput.trim()
+ : transportState.skuReplacementQueryInput.trim(),
+ queryType: transportState.isDetailReplacementPreset
? ("spu" as const)
- : skuReplacementQueryType,
- selectedCandidateId: isDetailReplacementPreset
- ? detailReplacementSelectedCandidateId || null
- : skuReplacementSelectedCandidateId || null,
+ : transportState.skuReplacementQueryType,
+ selectedCandidateId: transportState.isDetailReplacementPreset
+ ? transportState.detailReplacementSelectedCandidateId || null
+ : transportState.skuReplacementSelectedCandidateId || null,
references: (
- isDetailReplacementPreset
- ? detailReplacementReferenceCards
- : skuReplacementReferenceCards
+ transportState.isDetailReplacementPreset
+ ? transportState.detailReplacementReferenceCards
+ : transportState.skuReplacementReferenceCards
)
.filter((item) => Boolean(String(item.imageUrl || "").trim()))
.map((item) => ({
@@ -820,10 +872,10 @@ export function AgentGenerationWorkspaceDarkV2({
candidateId: item.candidateId || null,
sortOrder: item.sortOrder ?? 0,
assignedProductIndex:
- selectedProductAttachments.length > 0
+ transportState.selectedProductAttachmentCount > 0
? Math.min(
item.assignedProductIndex ?? 0,
- Math.max(selectedProductAttachments.length - 1, 0)
+ Math.max(transportState.selectedProductAttachmentCount - 1, 0)
)
: null,
})),
@@ -834,10 +886,10 @@ export function AgentGenerationWorkspaceDarkV2({
id: rawChatId,
message: request.messages.at(-1),
hiddenPrompt: hiddenPromptRef.current || undefined,
- agentPresetId: selectedAgentPresetId || undefined,
- selectedChatModel: selectedModelId,
+ agentPresetId: transportState.selectedAgentPresetId || undefined,
+ selectedChatModel: transportState.selectedModelId,
selectedVisibilityType: "private",
- imageParams,
+ imageParams: transportState.imageParams,
agentModePayload: replacementModePayload,
},
};
diff --git a/components/agents/AgentGenerationWorkspaceNew.tsx b/components/agents/AgentGenerationWorkspaceNew.tsx
index d5c591a76..34d5e1dee 100644
--- a/components/agents/AgentGenerationWorkspaceNew.tsx
+++ b/components/agents/AgentGenerationWorkspaceNew.tsx
@@ -329,6 +329,24 @@ export function AgentGenerationWorkspaceNew({
() => selectableModels.find((model) => model.id === selectedModelId) || selectableModels[0],
[selectableModels, selectedModelId]
);
+ const transportStateRef = useRef<{
+ selectedAgentPresetId: string | null;
+ selectedModelId: string;
+ imageParams: ImageGenerationParams;
+ }>({
+ selectedAgentPresetId: null,
+ selectedModelId: "auto",
+ imageParams: {
+ aspectRatio: "auto",
+ imageSize: "2K",
+ imageCount: 1,
+ },
+ });
+ transportStateRef.current = {
+ selectedAgentPresetId: selectedAgentPresetId || null,
+ selectedModelId,
+ imageParams,
+ };
const { messages, setMessages, sendMessage, status } = useChat({
id: chatId,
@@ -339,15 +357,16 @@ export function AgentGenerationWorkspaceNew({
api: "/api/chat",
fetch: fetchWithErrorHandlers,
prepareSendMessagesRequest(request) {
+ const transportState = transportStateRef.current;
return {
body: {
id: rawChatId,
message: request.messages.at(-1),
hiddenPrompt: hiddenPromptRef.current || undefined,
- agentPresetId: selectedAgentPresetId || undefined,
- selectedChatModel: selectedModelId,
+ agentPresetId: transportState.selectedAgentPresetId || undefined,
+ selectedChatModel: transportState.selectedModelId,
selectedVisibilityType: "private",
- imageParams,
+ imageParams: transportState.imageParams,
},
};
},