feat(plugin-chatbot): render AI data-query charts inline (data-chart)#1712
Merged
Conversation
Companion to the framework `visualize_data` tool. The data-query assistant can
now answer with a CHART: the tool emits a `data-chart` custom stream part and
the chat lifts it onto the message and renders it with the SDUI `<chart>`
component, right in the assistant bubble.
- mapMessages.ts: `extractCharts()` lifts every `data-chart` part into
`ChatMessage.charts` (defensive narrowing; keeps multiple charts in order).
Mirrors the existing `data-build-progress` → `buildProgress` path.
- ChatbotEnhanced.tsx: `ChatChart` type + `charts` field; renders each via
`<SchemaRenderer schema={{ type:'chart', … }}/>` (decoupled — no hard dep on
plugin-charts). Gives the chart a definite `width: min(520px, 80vw)` so
recharts' ResponsiveContainer measures a stable, non-zero width inside the
`w-fit` bubble (otherwise the circular width dependency leaves bars unpainted).
- mapMessages.test.ts: +3 tests (single chart lift, multi-chart order +
series-less drop, absent → undefined).
Verified end-to-end in the console against a live LLM: AI → visualize_data →
data-chart → a 5-bar chart renders in the chat bubble.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Companion to the framework
visualize_datatool (framework#1820). The data-query assistant can now answer with a chart rendered inline in the chat bubble, instead of only text/markdown.How
mapMessages.ts—extractCharts()lifts everydata-chartstream part (emitted byvisualize_dataviactx.onProgress) intoChatMessage.charts, with defensive narrowing and stable ordering for multiple charts. Mirrors the existingdata-build-progress→buildProgresspath.ChatbotEnhanced.tsx— adds theChatCharttype +chartsfield and renders each chart via<SchemaRenderer schema={{ type: 'chart', … }}/>(through theComponentRegistry'chart'component — no hard dependency onplugin-charts). The chart gets a definitewidth: min(520px, 80vw): the chat bubble isw-fitwhile recharts'ResponsiveContaineriswidth:100%, a circular dependency that otherwise leaves recharts measuring 0 and the bars unpainted; a viewport-relative width breaks the cycle.Testing
mapMessages.test.ts— +3 tests (single chart lift, multi-chart order + series-less drop, absent →undefined). Suite green (22 tests), typecheck clean.visualize_data→data-chartpart → a 5-bar chart (task counts by status) renders in the console chat bubble.🤖 Generated with Claude Code