refactor: share viz footer assets across R and Python#227
Merged
cpsievert merged 10 commits intofeat/ggsql-integration-r-v2from May 1, 2026
Merged
refactor: share viz footer assets across R and Python#227cpsievert merged 10 commits intofeat/ggsql-integration-r-v2from
cpsievert merged 10 commits intofeat/ggsql-integration-r-v2from
Conversation
1192362 to
6beedc1
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Centralizes the visualization footer JS/CSS into a shared js/ source, then generates package-local artifacts for both the R and Python runtimes. This reduces divergence between implementations and adds stronger guarantees that committed web assets match the sources.
Changes:
- Introduce shared
js/src/viz-core.ts+ thin runtime entrypoints and generateviz.js/viz.cssintopkg-randpkg-py. - Update R/Python footer markup to use
data-querychat-actionand resolve Shiny DOM widget IDs for export behavior. - Add
web-build/web-checktargets and Playwright coverage for “Save as PNG/SVG” downloads in Python.
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg-r/inst/htmldep/viz.js | Replace inline footer logic with generated bundle sourced from shared viz-core. |
| pkg-r/inst/htmldep/viz.css | Add generated-file header; CSS now sourced from shared js/src/viz.css. |
| pkg-r/R/querychat_viz.R | Add data-querychat-action attributes and ensure DOM widget ID is passed for exports. |
| pkg-py/src/querychat/static/js/viz.js | Replace runtime-specific implementation with generated bundle sourced from shared viz-core. |
| pkg-py/src/querychat/static/css/viz.css | Add generated-file header; keep in sync with shared CSS source. |
| pkg-py/src/querychat/_viz_tools.py | Resolve Shiny DOM widget IDs via resolve_id; add data-querychat-action attributes in footer markup. |
| pkg-py/tests/test_viz_footer.py | Add unit tests asserting resolved DOM widget IDs are used in rendered footer markup. |
| pkg-py/tests/playwright/test_11_viz_footer.py | Add real download assertions for PNG/SVG export via the Save menu. |
| js/src/viz-core.ts | New shared footer event delegation + export adapter interface. |
| js/src/viz-r.ts | New R entrypoint wiring shared core + Vega action adapter. |
| js/src/viz-py.ts | New Python entrypoint wiring shared core + Vega action adapter. |
| js/src/viz.css | New shared CSS source for viz container/footer styling. |
| js/build.mjs | New build pipeline to stage and copy generated assets into R/Python package locations. |
| js/check.mjs | New “stale output” check to fail when committed generated assets diverge from sources. |
| js/package.json | New private JS workspace for shared asset build/check scripts. |
| js/package-lock.json | Lockfile for shared JS tooling (esbuild, typescript). |
| js/tsconfig.json | New TS config for typechecking shared sources (no emit). |
| Makefile | Add web-setup, web-build, web-check targets for shared asset workflows. |
| .gitignore | Ignore js/node_modules/. |
Files not reviewed (1)
- js/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Stacked on #224.
Summary
Centralize the visualization footer assets under
js/and generate the package-local artifacts for both runtimes from a single shared source.This branch now does four concrete things:
js/and copies generatedviz.js/viz.cssintopkg-randpkg-pyviz-core.tsand makesweb-buildatomic while makingweb-checkfail on stale generated assetsThe browser-side result is that the shared logic now owns:
The runtime-specific surface is much smaller than where this branch started.
Verification
make web-buildmake web-checkRscript -e "devtools::test('pkg-r', filter = '^(viz-tool|querychat-viz)$', reporter = 'summary')"uv run pytest pkg-py/tests/test_viz_footer.py -vuv run pytest pkg-py/tests/playwright/test_11_viz_footer.py -k 'click_save_opens_menu or click_outside_closes_menu or toggle_save_menu' -vuv run pytest pkg-py/tests/playwright/test_11_viz_footer.py -k 'save_as_png_downloads_png or save_as_svg_downloads_svg' -vRepro Chart.png/Repro Chart.svgdownloads