fix(chat): render chart artifacts
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
import type { Message, SpeechState } from "./GlobalChatbox.types";
|
||||
import { stripMarkdown } from "./GlobalChatbox.utils";
|
||||
import { AgentProgressTimeline } from "./AgentProgressTimeline";
|
||||
import { AgentArtifactPanel } from "./AgentArtifactPanel";
|
||||
import { ChatInlineChart } from "./ChatInlineChart";
|
||||
import { ChatToolCallBlock } from "./ChatToolCallBlock";
|
||||
import { MarkdownBlock, normalizeClipboardText } from "./AgentMarkdownBlock";
|
||||
@@ -92,6 +93,19 @@ export const AgentTurn = React.memo(
|
||||
: [{ type: "text", content: answerContent }],
|
||||
[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) {
|
||||
return (
|
||||
@@ -275,6 +289,10 @@ export const AgentTurn = React.memo(
|
||||
})}
|
||||
</Stack>
|
||||
</Box>
|
||||
|
||||
{visibleArtifacts?.length ? (
|
||||
<AgentArtifactPanel artifacts={visibleArtifacts} />
|
||||
) : null}
|
||||
</Stack>
|
||||
|
||||
<AnimatePresence>
|
||||
|
||||
Reference in New Issue
Block a user