fix: persist composer mode during send
This commit is contained in:
parent
1a6a1a8d6e
commit
a4abda497c
@ -2999,6 +2999,7 @@ export function CanvasChatPanel({
|
|||||||
return [] as string[];
|
return [] as string[];
|
||||||
}, [isVideoModel, videoParams]);
|
}, [isVideoModel, videoParams]);
|
||||||
const activeComposerMode = composerModeOverride || computedComposerMode;
|
const activeComposerMode = composerModeOverride || computedComposerMode;
|
||||||
|
const activeComposerModeRef = useRef(activeComposerMode);
|
||||||
const agentUploadSlots = useMemo(() => {
|
const agentUploadSlots = useMemo(() => {
|
||||||
if (
|
if (
|
||||||
activeComposerMode !== "agent" ||
|
activeComposerMode !== "agent" ||
|
||||||
@ -3240,6 +3241,10 @@ export function CanvasChatPanel({
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 默认选择模型(根据系统设置)
|
// 默认选择模型(根据系统设置)
|
||||||
|
useEffect(() => {
|
||||||
|
activeComposerModeRef.current = activeComposerMode;
|
||||||
|
}, [activeComposerMode]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectedModelId && siteSettings) {
|
if (!selectedModelId && siteSettings) {
|
||||||
currentModelIdRef.current = "auto";
|
currentModelIdRef.current = "auto";
|
||||||
@ -3456,6 +3461,7 @@ export function CanvasChatPanel({
|
|||||||
(mode: "agent" | "image" | "video" | "detail") => {
|
(mode: "agent" | "image" | "video" | "detail") => {
|
||||||
hiddenPromptRef.current = null;
|
hiddenPromptRef.current = null;
|
||||||
autoContextRef.current = null;
|
autoContextRef.current = null;
|
||||||
|
activeComposerModeRef.current = mode;
|
||||||
setComposerModeOverride(mode);
|
setComposerModeOverride(mode);
|
||||||
|
|
||||||
if (mode === "agent") {
|
if (mode === "agent") {
|
||||||
@ -3891,10 +3897,12 @@ export function CanvasChatPanel({
|
|||||||
console.log("[CanvasChat] Preparing request:", {
|
console.log("[CanvasChat] Preparing request:", {
|
||||||
id: rawId,
|
id: rawId,
|
||||||
modelId: currentModelIdRef.current,
|
modelId: currentModelIdRef.current,
|
||||||
|
composerMode: activeComposerModeRef.current,
|
||||||
imageParams: imageParamsRef.current,
|
imageParams: imageParamsRef.current,
|
||||||
contextPayload: buildContextPayload(),
|
contextPayload: buildContextPayload(),
|
||||||
lastMessage: request.messages.at(-1),
|
lastMessage: request.messages.at(-1),
|
||||||
});
|
});
|
||||||
|
const effectiveComposerMode = activeComposerModeRef.current || activeComposerMode;
|
||||||
const hiddenPrompt = hiddenPromptRef.current || undefined;
|
const hiddenPrompt = hiddenPromptRef.current || undefined;
|
||||||
const autoContext = autoContextRef.current || undefined;
|
const autoContext = autoContextRef.current || undefined;
|
||||||
const contextPayload = buildContextPayload();
|
const contextPayload = buildContextPayload();
|
||||||
@ -3915,11 +3923,11 @@ export function CanvasChatPanel({
|
|||||||
id: rawId,
|
id: rawId,
|
||||||
message: request.messages.at(-1),
|
message: request.messages.at(-1),
|
||||||
agentPresetId:
|
agentPresetId:
|
||||||
activeComposerMode === "agent" && selectedAgentPreset?.id
|
effectiveComposerMode === "agent" && selectedAgentPreset?.id
|
||||||
? selectedAgentPreset.id
|
? selectedAgentPreset.id
|
||||||
: undefined,
|
: undefined,
|
||||||
selectedChatModel: currentModelIdRef.current,
|
selectedChatModel: currentModelIdRef.current,
|
||||||
composerMode: activeComposerMode,
|
composerMode: effectiveComposerMode,
|
||||||
selectedVisibilityType: "private",
|
selectedVisibilityType: "private",
|
||||||
deepThinkingEnabled: requestIsConversationModel
|
deepThinkingEnabled: requestIsConversationModel
|
||||||
? false
|
? false
|
||||||
@ -4936,7 +4944,8 @@ export function CanvasChatPanel({
|
|||||||
|
|
||||||
if (imageNodes.length === 0) return undefined;
|
if (imageNodes.length === 0) return undefined;
|
||||||
|
|
||||||
const shouldIsolateDirectModeContext = activeComposerMode !== "agent";
|
const effectiveComposerMode = activeComposerModeRef.current || activeComposerMode;
|
||||||
|
const shouldIsolateDirectModeContext = effectiveComposerMode !== "agent";
|
||||||
if (shouldIsolateDirectModeContext && selectedImageNodes.length === 0) {
|
if (shouldIsolateDirectModeContext && selectedImageNodes.length === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -7084,6 +7093,8 @@ export function CanvasChatPanel({
|
|||||||
if (!textContent && hasWorkflowContext && workflowContext?.summaryText) {
|
if (!textContent && hasWorkflowContext && workflowContext?.summaryText) {
|
||||||
textContent = `请基于当前工作流设定生成方案:${workflowContext.summaryText}`;
|
textContent = `请基于当前工作流设定生成方案:${workflowContext.summaryText}`;
|
||||||
}
|
}
|
||||||
|
const effectiveComposerMode = activeComposerModeRef.current || activeComposerMode;
|
||||||
|
|
||||||
if (!textContent && hasAgentUploadSlots && selectedAgentPreset) {
|
if (!textContent && hasAgentUploadSlots && selectedAgentPreset) {
|
||||||
textContent = `请按「${selectedAgentPreset.name}」智能体配置顺序处理产品图1、产品图2和模特图。`;
|
textContent = `请按「${selectedAgentPreset.name}」智能体配置顺序处理产品图1、产品图2和模特图。`;
|
||||||
}
|
}
|
||||||
@ -7104,7 +7115,7 @@ export function CanvasChatPanel({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
activeComposerMode === "agent" &&
|
effectiveComposerMode === "agent" &&
|
||||||
selectedAgentPreset?.type === "text" &&
|
selectedAgentPreset?.type === "text" &&
|
||||||
selectedAgentPreset.slots?.length
|
selectedAgentPreset.slots?.length
|
||||||
) {
|
) {
|
||||||
@ -7166,7 +7177,7 @@ export function CanvasChatPanel({
|
|||||||
text: textContent,
|
text: textContent,
|
||||||
attachments: normalizedAttachmentKeys,
|
attachments: normalizedAttachmentKeys,
|
||||||
skillTagId: selectedSkillTag?.id || null,
|
skillTagId: selectedSkillTag?.id || null,
|
||||||
mode: activeComposerMode,
|
mode: effectiveComposerMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (shouldBlockDuplicateSend(activeChatId, sendSignature)) {
|
if (shouldBlockDuplicateSend(activeChatId, sendSignature)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user