fix: restore canvas generation placeholders

This commit is contained in:
134 2026-06-22 10:36:08 +08:00
parent 39b4bd5983
commit ef89ab1aeb
2 changed files with 28 additions and 3 deletions

View File

@ -7631,6 +7631,10 @@ export function CanvasChatPanel({
textContent = `请按「${selectedSkillTag.name}」标签的要求处理。`; textContent = `请按「${selectedSkillTag.name}」标签的要求处理。`;
} }
textContent = clampChatRequestText(textContent, MAX_CHAT_TEXT_PART_LENGTH); textContent = clampChatRequestText(textContent, MAX_CHAT_TEXT_PART_LENGTH);
const requestModel = allModels.find((model) => model.id === effectiveModelId);
const shouldShowOptimisticImageGeneration =
effectiveComposerMode === "image" &&
Boolean(requestModel && isCanvasImageModel(requestModel));
// 🆕 隐藏提示词(不在 UI 中展示) // 🆕 隐藏提示词(不在 UI 中展示)
const hiddenSegments: string[] = []; const hiddenSegments: string[] = [];
@ -7728,6 +7732,16 @@ export function CanvasChatPanel({
inFlightRawChatIdRef.current = rawChatId; inFlightRawChatIdRef.current = rawChatId;
clearStreamImageGenerationStateForChat(activeChatId); clearStreamImageGenerationStateForChat(activeChatId);
clearAgentProgressStateForChat(activeChatId); clearAgentProgressStateForChat(activeChatId);
if (shouldShowOptimisticImageGeneration) {
const imageParamSnapshot = imageParamsRef.current || imageParams;
setStreamImageGenerationStateForChat(activeChatId, {
phase: "processing",
providerType: requestModel?.providerType,
modelName: getAgentSafeModelName(requestModel?.displayName),
imageCount:
Math.max(1, Math.round(Number(imageParamSnapshot?.imageCount || 1))) || 1,
});
}
// 使用与 multimodal-input 相同的格式发送消息 // 使用与 multimodal-input 相同的格式发送消息
try { try {
@ -7737,6 +7751,9 @@ export function CanvasChatPanel({
}); });
} catch (error) { } catch (error) {
releaseSendGuard(activeChatId); releaseSendGuard(activeChatId);
if (shouldShowOptimisticImageGeneration) {
clearStreamImageGenerationStateForChat(activeChatId);
}
if (inFlightChatIdRef.current === activeChatId) { if (inFlightChatIdRef.current === activeChatId) {
inFlightChatIdRef.current = null; inFlightChatIdRef.current = null;
inFlightRawChatIdRef.current = null; inFlightRawChatIdRef.current = null;
@ -7778,10 +7795,13 @@ export function CanvasChatPanel({
clearSelection, clearSelection,
buildAutoContext, buildAutoContext,
buildContextPayload, buildContextPayload,
allModels,
isVideoModel, isVideoModel,
isCanvasImageModel,
videoParams, videoParams,
videoFrameSlots.length, videoFrameSlots.length,
currentModel?.providerType, currentModel?.providerType,
imageParams,
selectedImageNodes, selectedImageNodes,
isDetailGenerationMode, isDetailGenerationMode,
canUseDetailGeneration, canUseDetailGeneration,
@ -7790,6 +7810,7 @@ export function CanvasChatPanel({
getSendGuard, getSendGuard,
clearStreamImageGenerationStateForChat, clearStreamImageGenerationStateForChat,
clearAgentProgressStateForChat, clearAgentProgressStateForChat,
setStreamImageGenerationStateForChat,
computedComposerMode, computedComposerMode,
releaseSendGuard, releaseSendGuard,
setSendGuard, setSendGuard,

View File

@ -191,18 +191,22 @@ export function ImageParamsBar({
a.watermark === b.watermark && a.watermark === b.watermark &&
a.seed === b.seed; a.seed === b.seed;
const buildBaseParams = (source?: Partial<ImageGenerationParams>) => const buildBaseParams = (source?: Partial<ImageGenerationParams>) => {
clampParamsByProvider({ const hasSourceAspectRatio =
typeof source?.aspectRatio === "string" && source.aspectRatio.trim().length > 0;
return clampParamsByProvider({
aspectRatio: inlineTheme === "minimal" ? "1:1" : "auto", aspectRatio: inlineTheme === "minimal" ? "1:1" : "auto",
imageSize: "2K", imageSize: "2K",
imageCount: 1, imageCount: 1,
promptExtend: true, promptExtend: true,
watermark: false, watermark: false,
...source, ...source,
...(inlineTheme === "minimal" && (!source?.aspectRatio || source.aspectRatio === "auto") ...(inlineTheme === "minimal" && !hasSourceAspectRatio
? { aspectRatio: "1:1" } ? { aspectRatio: "1:1" }
: {}), : {}),
}); });
};
const [params, setParams] = useState<ImageGenerationParams>({ const [params, setParams] = useState<ImageGenerationParams>({
...buildBaseParams(initialParams), ...buildBaseParams(initialParams),