{message.role === "assistant" && message.parts.some((part) => part.type === "text" && part.text && part.text.trim().length > 0) && (
p.type === "text" && p.text?.trim()
),
"w-full":
(message.role === "assistant" &&
message.parts?.some(
(p) => p.type === "text" && p.text?.trim()
)) ||
mode === "edit",
"max-w-[calc(100%-2.5rem)] sm:max-w-[min(fit-content,80%)]":
message.role === "user" && mode !== "edit",
})}
>
{attachmentsFromMessage.length > 0 && (
{attachmentsFromMessage.map((attachment) => (
))}
)}
{message.parts?.map((part, index) => {
const { type } = part;
const key = `message-${message.id}-part-${index}`;
if (type === "reasoning" && part.text?.trim().length > 0) {
return (
);
}
if (type === "text") {
if (mode === "view") {
// 检查是否是图片处理的加载消息
if (part.text === "正在变清晰..." || part.text === "正在抠图..." || part.text === "正在图像拓展..." || part.text === "正在去水印...") {
let type: "enhance" | "rmbg" | "extend" | "watermark";
if (part.text === "正在变清晰...") {
type = "enhance";
} else if (part.text === "正在抠图...") {
type = "rmbg";
} else if (part.text === "正在去水印...") {
type = "watermark";
} else {
type = "extend";
}
return (
);
}
// 应用视频内容过滤
const routedFilteredText =
message.role === "assistant"
? filterAgentRoutingNoise(filterVideoContent(part.text))
: part.text;
const extractedModelName =
message.role === "assistant"
? extractModelBadgeName(routedFilteredText)
: "";
const contentWithoutBadge =
message.role === "assistant"
? stripModelBadgeLines(routedFilteredText)
: routedFilteredText;
const inferredFallbackModelName =
message.role === "assistant" &&
!extractedModelName &&
extractImageUrlsFromText(contentWithoutBadge).length > 0
? String(fallbackImageModelName || "").trim()
: "";
const displayModelName = extractedModelName || inferredFallbackModelName;
const filteredText =
message.role === "assistant"
? appendImageDoneSummary(contentWithoutBadge)
: contentWithoutBadge;
const useAssistantTypewriter =
message.role === "assistant" &&
!isLoading &&
shouldUseAssistantTypewriter(filteredText);
const textParts = parseAnnotations(filteredText);
return (
{message.role === "assistant" && displayModelName ? (
{displayModelName}
) : null}
{useAssistantTypewriter ? (
{(displayText) => (
{displayText}
)}
) : textParts.map((part, partIndex) => {
if (part.type === 'annotation') {
return (
{part.content}
);
}
// 使用处理状态作为 key 的一部分,确保状态变化时 Streamdown 重新渲染
const processingKey = `${isProcessingEnhance}-${isProcessingRmbg}-${isProcessingExtend}-${isProcessingAngleEdit}`;
return (
{sanitizeText(part.content)}
);
})}
);
}
if (mode === "edit") {
return (
);
}
}
if (type === "tool-getWeather") {
const { toolCallId, state } = part;
return (
{state === "input-available" && (
)}
{state === "output-available" && (
}
/>
)}
);
}
if (type === "tool-createDocument") {
const { toolCallId } = part;
if (part.output && "error" in part.output) {
return (
创建文档失败:{String(part.output.error)}
);
}
return (
);
}
if (type === "tool-updateDocument") {
const { toolCallId } = part;
if (part.output && "error" in part.output) {
return (
更新文档失败:{String(part.output.error)}
);
}
return (
);
}
if (type === "tool-requestSuggestions") {
const { toolCallId, state } = part;
return (
{state === "input-available" && (
)}
{state === "output-available" && (
错误:{String(part.output.error)}
)
}
/>
)}
);
}
return null;
})}
{!isReadonly && (