Repository navigation
Conversation
This branch has not been deployed
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.
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
Closes #6791.
Renders
```viscode blocks as data charts using GPT-Vis (@antv/gpt-vis, MIT), following the existing mermaid pattern inPreCode: the code block stays visible and the chart is shown below it.app/components/vis-chart.tsx: newVisChartcomponent. It loads@antv/gpt-viswith a dynamicimport()only when a vis block is present, renders the block, destroys the chart on unmount or re-render, and hides itself (leaving the plain code block) if the syntax is invalid or rendering fails.app/utils/vis.ts: dependency-freeisVisSyntax()(so detection never pulls in the library) andgetVisTheme(), which maps the app theme (light / dark / auto +prefers-color-scheme) to the GPT-Visdefault/darktheme. Switching the theme re-renders the chart.app/components/markdown.tsx: detectcode.language-visin the same debouncedrenderArtifactspass as mermaid.app/styles/markdown.scss: give the chart container a usable width (600px, capped at 100%) so it does not collapse to the width of a short code block.Bundle size: the first-load JS is unchanged (
/stays at 626 kB / 716 kB first load inyarn build). GPT-Vis and its G2/G6 dependencies are split into lazy chunks (~2.5 MB raw, ~710 kB gzip) that are fetched only the first time a vis block is rendered.📝 补充信息 | Additional Information
Tested locally (Node 22.17, yarn 1.22.19):
yarn test:ci: 38 suites, 182 tests passed (addstest/vis.test.tsandtest/vis-chart.test.tsx, which mocks@antv/gpt-visand covers render, theme, destroy on unmount, error fallback and non-vis input).npx tsc --noEmit -p .: passed.npx eslintandnpx prettier --checkon the changed files: no errors (the only warning is the existingexhaustive-depswarning onPreCode).yarn build: passed, route sizes as above.next start: avis lineblock renders a chart in light and dark theme and follows a live theme switch; an invalid block (vis notachart) shows only the code block and logs[Vis] Unsupported chart type.Pre-existing on
main, unchanged by this PR:yarn lint(next lint) crashes inunused-imports/no-unused-importsonapp/constant.ts, andyarn exportfails with "Server Actions are not supported with static export".