fix(chat): render chart artifacts
Build Push and Deploy / docker-image (push) Successful in 1m1s
Build Push and Deploy / deploy-fallback-log (push) Has been skipped

This commit is contained in:
2026-06-10 16:53:30 +08:00
parent 213a01ff7d
commit eee165c812
+18
View File
@@ -25,6 +25,7 @@ import {
import type { Message, SpeechState } from "./GlobalChatbox.types"; import type { Message, SpeechState } from "./GlobalChatbox.types";
import { stripMarkdown } from "./GlobalChatbox.utils"; import { stripMarkdown } from "./GlobalChatbox.utils";
import { AgentProgressTimeline } from "./AgentProgressTimeline"; import { AgentProgressTimeline } from "./AgentProgressTimeline";
import { AgentArtifactPanel } from "./AgentArtifactPanel";
import { ChatInlineChart } from "./ChatInlineChart"; import { ChatInlineChart } from "./ChatInlineChart";
import { ChatToolCallBlock } from "./ChatToolCallBlock"; import { ChatToolCallBlock } from "./ChatToolCallBlock";
import { MarkdownBlock, normalizeClipboardText } from "./AgentMarkdownBlock"; import { MarkdownBlock, normalizeClipboardText } from "./AgentMarkdownBlock";
@@ -92,6 +93,19 @@ export const AgentTurn = React.memo(
: [{ type: "text", content: answerContent }], : [{ type: "text", content: answerContent }],
[answerContent, isErrorMessage, isUser], [answerContent, isErrorMessage, isUser],
); );
const hasInlineChart = contentSegments.some(
(segment) =>
segment.type === "tool_call" &&
(segment.toolCall.tool === "chart" ||
segment.toolCall.tool === "show_chart"),
);
const visibleArtifacts = useMemo(
() =>
hasInlineChart
? message.artifacts?.filter((artifact) => artifact.kind !== "chart")
: message.artifacts,
[hasInlineChart, message.artifacts],
);
if (isUser) { if (isUser) {
return ( return (
@@ -275,6 +289,10 @@ export const AgentTurn = React.memo(
})} })}
</Stack> </Stack>
</Box> </Box>
{visibleArtifacts?.length ? (
<AgentArtifactPanel artifacts={visibleArtifacts} />
) : null}
</Stack> </Stack>
<AnimatePresence> <AnimatePresence>