fix: preserve canvas context for chat image results
This commit is contained in:
parent
979c960359
commit
166cc184d1
@ -2066,6 +2066,7 @@ export function CanvasChatPanel({
|
||||
const detailModeSwitchRef = useRef(false);
|
||||
const hiddenPromptRef = useRef<string | null>(null);
|
||||
const autoContextRef = useRef<string | null>(null);
|
||||
const contextPayloadRef = useRef<any>(null);
|
||||
const lastWorkflowAutofillSignatureRef = useRef<string | null>(null);
|
||||
const lastWorkflowAutofillUrlsRef = useRef<string[]>([]);
|
||||
const pendingLaunchRef = useRef<CanvasLaunchPayload | null>(null);
|
||||
@ -4561,25 +4562,27 @@ export function CanvasChatPanel({
|
||||
? request.id.replace('canvas-', '')
|
||||
: request.id;
|
||||
|
||||
const capturedContextPayload = contextPayloadRef.current ?? buildContextPayload();
|
||||
console.log("[CanvasChat] Preparing request:", {
|
||||
id: rawId,
|
||||
modelId: currentModelIdRef.current,
|
||||
composerMode: activeComposerModeRef.current,
|
||||
agentEntryMode: agentEntryModeRef.current,
|
||||
imageParams: imageParamsRef.current,
|
||||
contextPayload: buildContextPayload(),
|
||||
contextPayload: capturedContextPayload,
|
||||
lastMessage: request.messages.at(-1),
|
||||
});
|
||||
const effectiveComposerMode = activeComposerModeRef.current || activeComposerMode;
|
||||
const effectiveAgentEntryMode = agentEntryModeRef.current;
|
||||
const hiddenPrompt = hiddenPromptRef.current || undefined;
|
||||
const autoContext = autoContextRef.current || undefined;
|
||||
const contextPayload = buildContextPayload();
|
||||
const contextPayload = capturedContextPayload;
|
||||
const requestModel = allModels.find((model) => model.id === currentModelIdRef.current);
|
||||
const requestIsVideoModel = isCanvasVideoModel(requestModel);
|
||||
const requestIsConversationModel = isCanvasConversationOnlyModel(requestModel);
|
||||
hiddenPromptRef.current = null;
|
||||
autoContextRef.current = null;
|
||||
contextPayloadRef.current = null;
|
||||
return {
|
||||
body: {
|
||||
id: rawId,
|
||||
@ -8284,6 +8287,7 @@ export function CanvasChatPanel({
|
||||
const autoContext = buildAutoContext();
|
||||
autoContextRef.current =
|
||||
clampChatRequestText(autoContext, MAX_CHAT_AUTO_CONTEXT_LENGTH) || null;
|
||||
contextPayloadRef.current = buildContextPayload() || null;
|
||||
|
||||
if (textContent) {
|
||||
parts.push({ type: "text" as const, text: textContent });
|
||||
@ -8328,6 +8332,7 @@ export function CanvasChatPanel({
|
||||
});
|
||||
} catch (error) {
|
||||
releaseSendGuard(activeChatId);
|
||||
contextPayloadRef.current = null;
|
||||
console.error("[CanvasChat] sendMessage failed:", error);
|
||||
toast.error("发送失败,请重试");
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user