Skip to content

Defer Charts docs runtime until interaction - #1131

Merged
tannerlinsley merged 1 commit into
mainfrom
agent/defer-charts-doc-runtime
Aug 9, 2026
Merged

Defer Charts docs runtime until interaction#1131
tannerlinsley merged 1 commit into
mainfrom
agent/defer-charts-doc-runtime

Conversation

@tannerlinsley

@tannerlinsley tannerlinsley commented Aug 9, 2026

Copy link
Copy Markdown
Member

What changed

  • Keep Charts docs examples on their static SVG preview until Run or Edit is selected.
  • Remove viewport-triggered client loading and automatic expanded-editor startup.
  • Preserve Run-only activation when source is intentionally hidden.
  • Cover the passive document controls in the focused embed test.

Evidence and impact

Charts docs currently contain 89 chart examples across 29 pages. Before this change, approaching each example loaded its workspace and browser compiler automatically. The production esbuild WASM asset is 13.5 MB raw / 3.6 MB gzip, before example modules.

A browser check on the Lines and Areas docs page confirmed that scrolling through four passive examples made no Charts example client, esbuild-wasm, or esm.sh requests. Run then loaded the live chart and compiler; Edit loaded the workbench.

Validation

  • pnpm test: 108 passed, one existing environment-gated smoke test skipped; TypeScript and lint clean
  • pnpm build
  • Rendered Chrome checks for passive, Run, and Edit states

Risk

Low. The live runtime and editor are unchanged after activation. The behavior change is limited to requiring explicit intent before loading them.

Closes #1130

Summary by CodeRabbit

  • New Features
    • Added Edit and Run controls to chart examples.
    • Chart examples now activate explicitly and preserve the selected editing mode.
  • Bug Fixes
    • Improved chart example loading and editing-state synchronization.
  • Tests
    • Updated chart embedding coverage to verify the new Edit and Run controls.

@tannerlinsley tannerlinsley added the source-audit Tracked by the automated source audit label Aug 9, 2026
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Chart examples no longer load from viewport visibility. The fallback displays explicit Edit and Run controls. Selecting a control activates the current example and passes the selected editing mode to the client component.

Changes

Chart example activation

Layer / File(s) Summary
Activation controls and fallback rendering
src/components/charts/ChartsCatalogDocExample.tsx, tests/charts-catalog-frame-embedding.test.ts
The example uses explicit activation state. The fallback renders Edit and Run buttons. The rendering test verifies both controls.
Client editing-state synchronization
src/components/charts/ChartsCatalogDocExample.client.tsx
ChartsCatalogDocExampleClient accepts an edit prop and synchronizes its editing state when caseId or edit changes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Reader
  participant ChartsCatalogDocExample
  participant ChartsCatalogDocExampleClient
  Reader->>ChartsCatalogDocExample: Select Edit or Run
  ChartsCatalogDocExample->>ChartsCatalogDocExample: Activate current example
  ChartsCatalogDocExample->>ChartsCatalogDocExampleClient: Load with edit mode
  ChartsCatalogDocExampleClient->>ChartsCatalogDocExampleClient: Synchronize editing state
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes deferring Charts documentation runtime loading until the reader interacts.
Linked Issues check ✅ Passed The changes satisfy #1130 by deferring live client loading until Run or Edit while preserving the static preview and updating coverage.
Out of Scope Changes check ✅ Passed The changes remain focused on interaction-based Charts documentation activation and its related test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/defer-charts-doc-runtime

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com 301b31f Commit Preview URL

Branch Preview URL
Aug 09 2026, 02:51 PM

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/charts-catalog-frame-embedding.test.ts`:
- Around line 166-167: Extend the chart catalog embedding tests around the
existing HTML assertions with an interactive client-component test: verify
passive rendering does not load the live client, then trigger the Run and Edit
controls separately and verify each loads the client with its corresponding
selected mode. Use the existing test setup and client-loading symbols rather
than relying on renderToStaticMarkup for activation behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 42cf3ea5-c0de-42b0-bb87-f76e11b61a1b

📥 Commits

Reviewing files that changed from the base of the PR and between 9ab7a51 and 301b31f.

📒 Files selected for processing (3)
  • src/components/charts/ChartsCatalogDocExample.client.tsx
  • src/components/charts/ChartsCatalogDocExample.tsx
  • tests/charts-catalog-frame-embedding.test.ts

Comment on lines +166 to +167
assert.match(html, />Edit</)
assert.match(html, />Run</)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Add an interactive activation test.

renderToStaticMarkup cannot execute these controls. It does not verify that passive rendering avoids loading the live client. It does not verify that Run or Edit activates the client with the selected mode.

Add a client-side component test that confirms passive rendering performs no client load, then confirms each explicit action activates the client. The PR objective requires this behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/charts-catalog-frame-embedding.test.ts` around lines 166 - 167, Extend
the chart catalog embedding tests around the existing HTML assertions with an
interactive client-component test: verify passive rendering does not load the
live client, then trigger the Run and Edit controls separately and verify each
loads the client with its corresponding selected mode. Use the existing test
setup and client-loading symbols rather than relying on renderToStaticMarkup for
activation behavior.

@tannerlinsley
tannerlinsley merged commit b24c97a into main Aug 9, 2026
7 checks passed
@tannerlinsley
tannerlinsley deleted the agent/defer-charts-doc-runtime branch August 9, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

source-audit Tracked by the automated source audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid passive esbuild-wasm loads in Charts docs

1 participant