Skip to content

Render the AI builder preview in the sandboxed frame - #1427

Open
vytisbulkevicius wants to merge 2 commits into
developmentfrom
bugfix/pro/658
Open

vytisbulkevicius wants to merge 2 commits into
developmentfrom
bugfix/pro/658

Conversation

@vytisbulkevicius

Copy link
Copy Markdown
Contributor

The AI Chart Builder drew its preview directly in the admin page, while the front end and the block editor draw D3 charts in a sandboxed frame. The builder now uses the same frame for the preview and for its code check.

What changed

  • Builder preview — chart code runs in the sandboxed D3 frame (sandbox="allow-scripts"), not in the admin page. The builder no longer bundles its own copy of D3 and TopoJSON.

  • Code check — the check that runs before a chart is shown or saved uses a hidden sandboxed frame and waits for its result. A chart that gives no result in 10 seconds counts as failed.

  • D3 frame — after each render it reports the result to its parent as { type: 'render-result', error }.

Note

Tracked in Codeinwp/visualizer-pro#658.

QA

  1. Go to WP Admin → Visualizer → Chart Library. Click Add New Chart, select the AI builder, add data and generate a chart.

    Expect: the preview shows the chart, and the chart saves.

  2. In the library, click the edit control of that chart.

    Expect: the builder opens and the preview shows the saved chart.

  3. In the builder, ask for a change to the chart (for example, another colour).

    Expect: the preview updates, and a chart with broken code shows an error message, not an empty preview.

🤖 Generated with Claude Code

The builder preview and its code check now use the same sandboxed
frame as the front end and the block editor.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@pirate-bot

pirate-bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Plugin build for d034a1a is ready 🛎️!

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants