{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") {
// 应用视频内容过滤
const filteredText = filterVideoContent(part.text);
const textParts = parseAnnotations(filteredText);
return (
{textParts.map((part, partIndex) => {
if (part.type === 'annotation') {
return (
{part.content}
);
}
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 && (