Skip to content

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

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

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

Conversation

@vytisbulkevicius

@vytisbulkevicius vytisbulkevicius commented Nov 27, 2026 •

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.

  • Builder settings — the builder gets the address of the frame script in its own settings (vizAIBuilder.iframeJsUrl), on the library page and in the block editor. The preview does not depend on a D3 chart in the library.

  • Frame script address — every page that loads the frame script gets its address from Visualizer_Module::d3_iframe_js_url(), which adds the plugin version (?ver=). A browser does not answer with the script of an older version, which never reports its render result.

  • Older check results — a check result is ignored when it no longer applies:

    • A code save check is dropped when newer data arrives, the draft code changes or the code editor closes.
    • A data check is dropped when the chart code is replaced: a manual save, a generated chart or a fixed chart.
    • The data that a generated chart brings goes to the preview with the generated code. The preview reports a chart that fails with it, and the builder repairs that chart.
    • Data that arrives during a repair goes to the preview with the repaired code, also when its check with the old code failed first. An error of the repaired code stays visible with the Fix control.
    • Data that a generated chart brings is shown with any column headers. The header warning is for data that the user brings.
    • The builder is locked while a saved chart loads and while Publish chart runs. A late answer of the load or of the save cannot replace newer code or data.
    • Data uploads, the data of a generated chart and Publish chart run one after another, in one queue for the page. The server and the preview keep the rows of the last edit, also after the builder closes and opens again.
    • The data that a generated chart brings is not uploaded when the user started a data change that the generation did not get. At the click on Generate, the data source reports such a change: an upload of an edit or of an import that waits or runs, or editor text that differs from the rows of the builder, also after its upload failed. The change stays, with the generated code in the preview. The untouched sample data of a new chart is not a data change.
    • A closed builder starts no upload, and no repair starts while Publish chart runs.
    • The data source uploads an edit when its text differs from the text the server holds after the queued uploads. An import sets that text too.
    • The data source is locked while a file or URL import runs.
    • A builder that opens again on the library page loads the chart from the server, after the queued writes. It no longer shows the rows the page loaded with.
    • The load gets the row array for every stored source, also for a chart whose data came from a remote file.
    • The data source stays mounted behind the code editor, so it keeps its rows when Edit code closes.
  • D3 frame — after each render it reports the result to its parent as { type: 'render-result', error }.

Note

Tracked in Codeinwp/visualizer-pro#658.

Tests

New Playwright cases in tests/e2e/specs/ai-builder.spec.js:

  • the builder opened from the block editor renders in the sandbox;
  • code that throws shows Chart error: <message>;
  • a code save check is dropped when newer data arrives during it;
  • a data check is dropped when code saved with the newer data, or a generated chart, replaces the chart code;
  • the data a generated chart brings is shown with the generated code;
  • a generated chart that fails with the data it brings is repaired and shown with that data;
  • data that arrives during a repair is shown with the repaired code, and an error of that code stays visible;
  • data whose check failed before the repair finished is shown with the repaired code;
  • data that arrives during a generation is shown with the generated chart, and the data of the editor is shown when the data of that chart cannot be read;
  • data with other column headers that a generated chart brings is shown without the header warning;
  • the frame script address carries the plugin version, on the library page and in the block editor.

Each case fails with its fix reverted.

Two more cases cover the locks: the prompt is disabled until the saved chart loads, and Edit code does not open while the chart is published.

Four more cases cover the order of the requests: no repair during a publish, one upload at a time, no upload of a generation after the builder closes, and an edit after a generation that returned the data of the editor.
More cases cover the upload queue and the data source: an upload after the code editor closed, a data change that a generation did not get (an edit on a saved chart and on a new chart, an edit with a failed upload, text restored during an upload, an import on a new chart), the data of a generation after the user removed an edit, after a failed import or before the sample data loaded, text restored during an upload, the saved text after an import, the lock during an import, Publish chart behind an upload, a reopened builder that shows the rows of the last upload, and the data editor after Edit code closes. A PHPUnit case covers the rows of a remote file in the load.

The File import and the Spreadsheet source have no case. Playwright cannot match a request that carries a file, and the grid library of the Spreadsheet ships with the Pro plugin.

QA

  1. On a site with no AI chart in the library, 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.

  4. In a post, add a Visualizer block with that chart and click its edit control.

    Expect: the builder opens and the preview shows the chart. In Edit code, change the code and click Save: the preview shows the change.

Review responses

Answers to the points of the review of a941148 that have no inline thread:

  • Pro hooks that receive chart code (Module/Chart.php) — this PR does not change what reaches those hooks. Whether a Pro consumer runs chart code is a question for the Pro plugin, so it is out of scope here.
  • PHPUnit and Jest suites not run — CI runs PHPUnit on this branch. This round changes no Jest-covered file.
  • Block Edit control not clicked — the new block editor case calls window.vizOpenAIBuilderEdit, the function the control calls, as the review run did. The case covers the missing setting, which is what broke the block editor.

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 6fc2e8f is ready 🛎️!

vytisbulkevicius and others added 2 commits November 27, 2026 17:15
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
… checks

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

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The sandboxed preview works on the library page, but the block editor builder cannot render, and a save check can restore old data.

Validation details
  • Files reviewed: 4/4 changed files.
  • The new Playwright case passed at HEAD cd /workspace/head && sandbox-doctor.sh --plugin visualizer 2>&1 | grep -vE '^\s*$' | tail -8; export WP_BASE_URL=http:/… (run R9, exit 0) and failed with pr-base code cd /var/www/html && ln -sfn /workspace/base wp-content/plugins/visualizer && wp plugin deactivate visualizer >/dev/null … (run R10, exit 0).
  • Block editor vizAIBuilder lacks iframeJsUrl, and the builder showed the renderer error cat > /workspace/checks/C12/open.js <<'EOF' const { chromium } = require( 'playwright' ); const fs = require( 'fs' ); co… (run R13, exit 0).
  • Every other place that runs saved D3 code uses the sandboxed renderer frame.
  • The source check, the #chart container and the ready message of the frame match the builder.
Untested areas
  • Pro plugin hooks that receive chart code were not checked. Their source is not available.
  • The PHPUnit and Jest suites were not run.
  • The block Edit control was not clicked. The run called the function the control calls.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • classes/Visualizer/Module/Chart.php:82-92,426-437,876-884,978-982,1541-1567 — unverified: Whole chart records containing code reach Pro sidebar/resource hooks and the legacy Pro resource loader. Pro implementation and version are unavailable; whether those consumers exe…

🤖 Automated review · run code-review-agent_6b0b41f36e9e62.82123300.


🤖 Review agent — review posted ✅ on a9411487 · changes requested · 3 findings · 21 min

Run code-review-agent_6b0b41f36e9e62.82123300 · trail

Comment thread classes/Visualizer/Module/Admin.php Resolved
Comment thread tests/e2e/specs/ai-builder.spec.js Resolved
vytisbulkevicius and others added 6 commits December 1, 2026 12:12
…rseded code checks

The block editor localized vizAIBuilder without iframeJsUrl, so the builder
opened from a Visualizer block could not render or save code. New data now
drops a pending code save check, and a saved code drops a pending data check.

Adds E2E cases for the block editor preview, the error the chart code throws
and both superseded checks.
…ript

A generated or fixed chart now drops a pending data check of the code it
replaces, and the data a generated chart brings is checked with the generated
code. The address of the sandboxed frame script carries the plugin version, so
a browser does not answer the builder with the script of an older version that
never reports its render result.
…a with repaired code

Data that comes with a generated chart goes to the preview without a hidden
check, so a generated chart that fails is reported there and repaired.
When a repair replaces the chart code, data whose check was pending is
checked again with the repaired code.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…epaired code

The preview reports a failure of the repaired code with that data, so the
error and the Fix control stay. The repair test waits for both jobs.

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

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The three earlier findings are fixed, but data that reaches the builder during a repair or a generation can still miss the preview.

Validation details
  • Files reviewed: 8/8 changed files.
  • The repair order where the data check fails first was reproduced in the sandbox at 068cfa1: cd /workspace/checks/C7 && python3 - <<'EOF' import re p='specs/c7-order.spec.js' s=open(p).read() old="if ( body.includ… printed C7-A RESULT: preview=rows: 1 warning_shown=true (run R9).
  • The block editor case passed at HEAD cd /workspace/checks/C7 && export WP_BASE_URL=http://localhost:8080 WP_USERNAME=admin WP_PASSWORD=admin STORAGE_STATE_PA… (run R14, exit 0).
  • Every page that loads the frame script uses the versioned address. No builder path runs chart code outside the sandbox.
Untested areas
  • The new cases were not run with each fix reverted. At pr-base they fail because the sandbox preview is missing.
  • The output of the external chart generator was not captured.
  • The block Edit control was not clicked. The PHPUnit suite was not run.
  • Pro plugin hooks that receive chart code remain unchecked. Their source is not available.

🤖 Automated review · run code-review-agent_6b0f1e508a4217.85342430.


🤖 Review agent — review posted ✅ on 068cfa11 · changes requested · 3 findings · 30 min

Run code-review-agent_6b0f1e508a4217.85342430 · trail

Comment thread tests/e2e/specs/ai-builder.spec.js Resolved
vytisbulkevicius and others added 3 commits December 1, 2026 22:24
…code

Data whose check failed, or whose column headers changed, goes to the
preview when a repair or a generation replaces the chart code. Data that a
generated chart brings is shown with any column headers. The spec opens a
saved chart through one helper.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…at arrives during a generation

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

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The three earlier findings are fixed, but data that arrives during a generation can still miss the preview, and a late preview error can overwrite a generated chart.

  • classes/Visualizer/ChartBuilder/src/AIBuilder/DataSource.js:216-238 — note Not blocking: another place of the cause this PR fixes, in a file the PR does not change. Overlapping uploads apply in the order their responses arrive. When the user edits the CSV again while the first upload runs, two uploads are in flight. Nothing ties a response to the newest request before onDataReady(). When the older response arrives last, handleDataReady() gives it the newest check token, and it replaces the newer data. Invalidate a running upload whenever the input changes, also when the input returns to the last uploaded CSV. Apply only a response that matches the current input. Add a case to ai-builder.spec.js that holds two uploads, releases them in reverse order, and expects the newer rows.
Validation details
  • Files reviewed: 2/2 files changed since the prior review, and 8/8 files of the PR.
  • The passed-check order during a generation was run in the sandbox at 91884d5: cd /workspace/checks/C2 && ln -sfn /workspace/head/node_modules node_modules && export WP_BASE_URL=http://localhost:8080… printed C2 RESULT preview=rows: 1 (run R9).
  • The existing case for data that arrives during a generation passed cd /workspace/checks/C2 && export WP_BASE_URL=http://localhost:8080 WP_USERNAME=admin WP_PASSWORD=admin STORAGE_STATE_PA… (run R10, exit 0).
  • A late preview error during a generation started a repair that replaced the generated code cd /workspace/checks/C5 && python3 - <<'EOF' p='specs/ai-builder-c5.spec.js' s=open(p).read() s=s.replace("const BUSY_CO… (run R20, exit 0).
Untested areas
  • The new cases were not run with each fix reverted.
  • The late-error case ran only with the generation finishing first.
  • The output of the external chart generator was mocked. The PHPUnit suite was not run.
  • Pro plugin hooks that receive chart code remain unchecked. Their source is not available.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • classes/Visualizer/Module/Chart.php:82-92,426-437,876-884,978-982,1541-1571 — unverified: Whole records containing D3 code reach Pro sidebar/resource hooks. Pro implementation source is unavailable, so whether those consumers execute code or asynchronously apply stale c…

🤖 Automated review · run code-review-agent_6b0fb36b2fb680.63507608.


🤖 Review agent — review posted ✅ on 91884d51 · changes requested · 3 findings · 25 min

Run code-review-agent_6b0fb36b2fb680.63507608 · trail

…its render

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

Copy link
Copy Markdown
Contributor Author

Review note F10 (overlapping uploads in DataSource.js) is not changed here. That file is outside this PR, and the order of two uploads is a separate behaviour from the code and data checks that this PR changes. It needs its own change.

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The three earlier findings are fixed, but late responses can still undo user actions in the builder: an edit-mode load and a Publish response.

  • classes/Visualizer/ChartBuilder/src/AIBuilder/DataSource.js:216-238 — note Not blocking: another place of the cause this PR fixes, in a file the PR does not change. Overlapping CSV, file and URL uploads still apply in the order their responses arrive (lines 216-268). Nothing ties a response to the newest request before onDataReady(). An older response that arrives last gets the newest check token in handleDataReady() and is stored in latestDataRef (index.js:376-379). It replaces the newer rows. Give the uploads one shared request-generation guard, and apply only the response of the newest input. Add cases to ai-builder.spec.js that hold two CSV, file or URL uploads, release them in reverse order, and expect the newer rows.
  • classes/Visualizer/ChartBuilder/src/AIBuilder/index.js:252-287 — correctness Actions taken before an existing chart finishes loading are undone by the load. Edit mode sets chartId before fetchChart() resolves, and Edit code and Generate stay enabled. When the user saves code in the editor first, the late load replaces it with existing.code (lines 273-275). When the user generates first, the fallback at lines 479-481 uses the empty arrays captured at the click. The generated chart then shows without the loaded rows. Block editing and generating until the load completes. Add a case to ai-builder.spec.js that holds the chart fetch, saves code or generates, releases the fetch, and expects the newer code and the loaded rows.
  • classes/Visualizer/ChartBuilder/src/AIBuilder/index.js:570-582 — correctness A late Publish response marks the chart as published after the editor replaced its code. handleSave() sends code from the click and then sets shortcode without a check (lines 575-576). Edit code stays enabled while publishing (line 927). The user can save new code before the response arrives. The shortcode then shows and Publish chart hides (line 1049), while the stored chart keeps the older code. Lock code changes while publishing, or show the shortcode only when the published code is still the current code. Add a case to ai-builder.spec.js that holds the save request, saves new code, releases the request, and expects Publish to stay available.
Validation details
  • Files reviewed: 8/8 changed files. Two PR files changed since the prior review. The other changed files came from the merged development branch.
  • The fixes for the three earlier threads were confirmed from source. No Playwright or PHPUnit case was run.
  • Every requirement in the PR body was checked against the source and met.
  • The upload-order finding reuses the evidence of run code-review-agent_6b0fb36b2fb680.63507608, not rerun.
Untested areas
  • The new cases were not run, with or without their fixes.
  • The QA step for a library without an AI chart was not run.
  • Pro plugin hooks that receive chart data remain unchecked. Their source is not available.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • classes/Visualizer/Module/Chart.php:1223-1228 — unverified: Pro table/excel handling delegates to visualizer_pro_handle_chart_data; its implementation is unavailable, so freshness behavior remains unknown.

🤖 Automated review · run code-review-agent_6b0fe471644f18.81741555.


🤖 Review agent — review posted ✅ on ca376315 · changes requested · 2 findings · 15 min

Run code-review-agent_6b0fe471644f18.81741555 · trail

vytisbulkevicius and others added 3 commits December 2, 2026 11:44
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@vytisbulkevicius

Copy link
Copy Markdown
Contributor Author

Review of ca37631:

  • D1 (actions before the saved chart loads) — fixed in 1462120. A new loading state is part of isLocked until the load settles, so the prompt, the data source, Edit code and Generate wait for it. Case: "locks the builder until the saved chart loads".
  • D3 (late Publish response) — fixed in 1462120. saving is part of isLocked, so the code cannot change while the save request runs. Case: "locks the code while the chart is published".
  • The lock showed an older fault in DataSource.js: the upload skip of the loaded CSV stayed set during a lock and dropped the next edit. 4da8b32 takes the skip before the disabled check.
  • F10 (order of overlapping uploads) — not in this PR, as answered before: it is in DataSource.js upload code that this PR does not change, and the note is not blocking.

…is open

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

Copy link
Copy Markdown
Contributor Author

Review of 4da8b32:

  • Repair during Publish — fixed in ad22e4c. handleSave() sets busyRef, so neither Fix nor a late preview error starts a repair while the save request runs. Case: "does not repair the chart while it is published".
  • Overlapping uploads — fixed in 6915cac. runUpload() in DataSource.js runs the CSV, file and URL uploads one after another. Applying only the newest answer was not enough: the server keeps the rows of the request that it handles last. Case: "starts an upload after the upload before it answered".
  • Generation after the builder closes — fixed in ad22e4c and e31d268. A closed builder uploads neither the CSV of a generation nor a queued upload. Case: "does not upload the data of a generation after the builder closes".
  • Generated CSV that equals the current text — fixed in ad22e4c. The upload skip is set only for text that differs from the current text. Case: "uploads an edit after a generation returned the data that the editor has".

Known and not changed: when the first preview error of a chart arrives during a Publish that then fails, no automatic repair starts and Fix is not offered until the code or the data changes.

vytisbulkevicius and others added 2 commits December 2, 2026 17:13
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The earlier findings are fixed, but late uploads, imports and requests that survive a close can still replace the newest chart data.

Validation details
  • Files reviewed: 3/3 files changed since the prior review. The other 5 changed files are unchanged since then.
  • The six new Playwright cases pass at HEAD in the sandbox site: cd /workspace/head && set -o pipefail; WP_BASE_URL=http://localhost:8080 WP_USERNAME=admin WP_PASSWORD=admin timeout 900… printed 6 passed (6.2m) (run R9).
  • Repair during Publish chart, overlapping uploads, the generation upload after a close and the generated CSV skip are fixed.
  • The builder mounts in its own root without StrictMode, so the openRef cleanup does not run while it is open.
Untested areas
  • The six cases also fail at pr-base and at 4da8b32. Most fail before their own assertion, so these runs do not show that each fix is needed.
  • The new findings were traced in the source only. No case was run for them.
  • The unchanged PHP files and iframe.js were not read again in this run.

🤖 Automated review · run code-review-agent_6b103a8e593fc9.07916110.


🤖 Review agent — review posted ✅ on 74916fe9 · changes requested · 3 findings · 24 min

Run code-review-agent_6b103a8e593fc9.07916110 · trail

vytisbulkevicius and others added 2 commits December 2, 2026 18:03
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The three earlier findings are fixed, but a reopened builder shows older rows, and Publish from a second tab can replace newer code.

Validation details
  • Files reviewed: 4/4 files changed since the prior review. The other 6 changed files are unchanged since then.
  • A held-upload reopen case ran in the sandbox site (WordPress 7.1.5, PHP 8.3.37): cd /workspace/checks/R1 && rm -rf test-results/*; set -o pipefail; NODE_PATH=/workspace/head/node_modules WP_BASE_URL=ht… printed 1 passed (run R8). The reopened preview kept rows: 1, and a reload showed rows: 2.
  • A reopen after a finished upload ran too: `set -e; cd /workspace/checks/R1; F=specs/ai-builder.spec.js; head -n -1 $F > specs/tmp.js; cat >> specs/tmp.js <<'EOF'

…printed1 passed(run R10). The reopened preview showedrows: 1`.

  • Run R9 of code-review-agent_6b103a8e593fc9.07916110 passed six cases at 74916fe. It was not rerun.
Untested areas
  • The new cases of this round were not run. Their fixes were checked in the source.
  • The two-tab Publish race was traced in the source only.
  • iframe.js and the PHP files were not read again. They are unchanged since the prior review.

🤖 Automated review · run code-review-agent_6b1049a5db0575.02480147.


🤖 Review agent — review posted ✅ on 53970514 · changes requested · 2 findings · 29 min

Run code-review-agent_6b1049a5db0575.02480147 · trail

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

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The reopen fix works, but the library page now fails to open URL-imported charts, and older rows can still replace newer edits.

Validation details
  • Files reviewed: 2/2 files changed since the prior review. The other 8 changed files are unchanged since then.
  • Sandbox site, WordPress 7.1.5, PHP 8.3.37: the three changed cases pass at 6049f16 [R10]. With the index.js of 53970514, the two reopen cases fail: set -o pipefail; cd /workspace/head && git -C /repo show 53970514f65a8191dd8af9a8b14fe6d8ca4bd338:classes/Visualizer/Cha… printed Received (run R12).
  • A URL-imported chart opened from the library shows (t || []).map is not a function at HEAD [R18]. The same chart shows rows: 2 with the index.js of 53970514 [R20].
Untested areas
  • The data shape of JSON, database and third-party sources in the chart load was not traced.
  • The editor remount and the generation order were traced in the source only.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • not reached: Classic renderer consumers in js/preview.js, js/render-chartjs.js, js/render-datatables.js and js/render-google.js
    • not reached: existing review replies truncated in threads.md were not recovered

🤖 Automated review · run code-review-agent_6b1060e40fe258.53317730.


🤖 Review agent — review posted ✅ on 6049f16b · changes requested · 3 findings · 22 min

Run code-review-agent_6b1060e40fe258.53317730 · trail

…or mounted

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

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The two fixes of the last round work, but a generation can still replace an edit that waits to upload; see the open thread.

Validation details
  • Files reviewed: 4/4 files changed since the prior review. The other 6 changed files are unchanged since then.
  • Sandbox site, WordPress 7.1.5, PHP 8.3.37. A URL-imported chart opened from the library shows cd /repo && git archive HEAD classes/Visualizer/ChartBuilder/src/AIBuilder/index.js classes/Visualizer/Module/AIBuilder.… printed rowsText ['rows: 2'] (run R15).
  • The new data editor case passes at HEAD: cat > /workspace/pw.c3b.config.js <<'EOF' // C3 (b): the new HEAD case of tests/e2e/specs/ai-builder.spec.js on the sand… printed 1 passed (run R13). With the code of 6049f16, it fails at toHaveValue [R14].
  • The new PHPUnit case passes at HEAD: cd /workspace/head && grep -n "WP_TESTS_DIR\|plugins/\|PLUGIN\|require.*index.php\|visualizer" tests/bootstrap.php 2>/de… printed OK (1 test, 2 assertions) (run R16). It fails with the pr-base code [R17].
Untested areas
  • Source handlers of the Pro plugin and of other plugins are not in the checkout. Their rows in the chart load were not traced.
  • The Pro spreadsheet grid was not checked while it is hidden behind the code editor.
  • The standards pass was skipped. This is the ninth review of the PR.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • not reached: Wizard’s direct decoder beyond its fixed local CSV source (classes/Visualizer/Module/Wizard.php:217-246)

🤖 Automated review · run code-review-agent_6b10723894f945.38328578.


🤖 Review agent — review posted ✅ on 8054e9b8 · changes requested · 0 findings · 15 min

Run code-review-agent_6b10723894f945.38328578 · trail

vytisbulkevicius and others added 2 commits December 4, 2026 10:19
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…new chart

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

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The fix keeps an edit on a saved chart, but a new chart's first edit and a failed upload are still replaced by generated data.

Validation details
  • Files reviewed: 2/2 files changed since the prior review. The other 8 changed files are unchanged since then. One question row was not settled: handleDataReady() signature and return changed.
  • Sandbox site, WordPress 7.1.5, PHP 8.3.37. The three changed cases pass at HEAD [R11]. With the 8054e9b code, the case for a kept edit fails [R10].
  • A new chart whose pasted rows waited behind the sample upload ended with python3 - <<'PY' from pathlib import Path p=Path('/workspace/checks/C2/ai-builder.spec.js') s=p.read_text().replace("pre… printed "uploads":3,"previewRows":"rows: 3" (run R15).
Untested areas
  • The failed-upload case is traced in source only. It was not run.
  • The question row "handleDataReady() signature and return changed" stays unchecked. Its code is unchanged since the prior review.
  • The standards pass was skipped. This is the tenth review of the PR.
  • Source handlers and the spreadsheet grid of the Pro plugin are not in the checkout.

🤖 Automated review · run code-review-agent_6b127cb396a8d0.05688838.


🤖 Review agent — review posted ✅ on 6b00350d · changes requested · 1 finding · 16 min

Run code-review-agent_6b127cb396a8d0.05688838 · trail

vytisbulkevicius and others added 3 commits December 4, 2026 11:00
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

Both earlier edit fixes work, but a Pro import on a new chart can still be replaced by generated data.

Validation details
  • Files reviewed: 3/3 files changed since the prior review. The other 7 changed files are unchanged since then. One question row was not settled: Usage logger crashes when chart settings meta is a string.
  • Sandbox site, WordPress 7.1.5, PHP 8.3.37. The five generation and edit cases pass at HEAD: cd /workspace/checks/R1 && set -o pipefail; timeout 600 node head/node_modules/@playwright/test/cli.js test -c pw.r1.con… printed 5 passed (25.4s) (run R11)
  • A URL import on a new chart, with Generate clicked before any upload answered, ended with mkdir -p /workspace/checks/R2 && cd /workspace/checks/R2 && cat > pw.r2.config.js <<'EOF' // R2 runner: scratch spec und… printed R2 final preview .rows: ["rows: 3"] (run R17)
Untested areas
  • The File import path was traced in source only. Playwright cannot match a file request.
  • The question row "Usage logger crashes when chart settings meta is a string" stays unchecked. Its code is unchanged since an earlier review.
  • The Pro plugin source is not in the checkout.

🤖 Automated review · run code-review-agent_6b1287d3d82084.22438223.


🤖 Review agent — review posted ✅ on 15b88e9e · changes requested · 1 finding · 25 min

Run code-review-agent_6b1287d3d82084.22438223 · trail

vytisbulkevicius and others added 3 commits December 4, 2026 12:06
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The import fix works, but an edit can still be lost on Publish and Done, and a generation in another tab can replace newer rows.

Validation details
  • Files reviewed: 3/3 files changed since the prior review. The other 7 changed files are unchanged since then.
  • Sandbox site, WordPress 7.1.5, PHP 8.3.37. The three new cases pass: cd /workspace/checks/C1 && set -o pipefail; export C1_GREP='keeps text restored while the upload of an edit waits|keeps … printed 3 passed (run R6)
  • The earlier import scenario keeps the imported rows at this head: cd /workspace/checks/C1/r2 && set -o pipefail; timeout 280 node /workspace/checks/C1/head/node_modules/@playwright/test/… printed R2 uploads total: 1 (run R8)
  • The generation and upload cases of the spec pass except one sandbox fixture failure: cd /workspace/checks/C1 && export C1_GREP='^(?!.*(keeps text restored while the upload of an edit waits|keeps an import … (run R7, exit 0)
Untested areas
  • An open spreadsheet cell editor at the Generate click was not traced. Its grid ships with the Pro plugin.
  • Closing the builder while a second edit waits in the upload queue was not checked.
  • The block editor case could not run. The sandbox nonce request returned 400.
  • No base-branch runs of the new cases were made.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • not reached: Complete registration/configuration traces for competing classic-editor, abilities and background-refresh writers: classes/Visualizer/Module/Chart.php:254-278,1417-1438,1693-1718
    • not reached: classes/Visualizer/Module/Abilities.php:1255-1265
    • not reached: classes/Visualizer/Module/Setup.php:415-463

🤖 Automated review · run code-review-agent_6b129763a6b800.89773291.


🤖 Review agent — review posted ✅ on 6fc2e8fa · changes requested · 2 findings · 45 min

Run code-review-agent_6b129763a6b800.89773291 · trail

Comment on lines +245 to 257
const t = setTimeout( () => {
const userData = ! isSample( trimmed );
lastCsvRef.current = trimmed;
runUpload( () => uploadCsvString( chartId, uploadNonce, trimmed ).catch( ( e ) => {
// The server does not hold this text, so the editor can upload it again.
if ( lastCsvRef.current === trimmed ) lastCsvRef.current = null;
throw e;
} ), ( r ) => {
appliedCsvRef.current = trimmed;
onDataReady( r.series, r.data );
lastCsvRef.current = trimmed;
} catch ( e ) { setError( e.message ); }
finally { setLoading( false ); }
}, userData );
}, 700 );
return () => clearTimeout( t );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

correctness A data edit is lost when the user publishes and closes the builder within 700 ms of typing. The edit uploads only when the debounce fires (DataSource.js:245-256). Publish saves only the title and code (index.js:588) and does not wait for the edit. When Publish answers first, Done closes the builder and return () => clearTimeout( t ) cancels the upload. The published chart keeps the older rows, and the reopened builder shows them. This path was already in the code the earlier review saw. Fix: report Publish as done only when the server holds the editor's data: wait for a pending edit and its queued upload, and report an edit whose upload failed. Add an ai-builder.spec.js case that edits, publishes, clicks Done at once, reopens and expects the edit.

setInitialCsvText( trimmedCsv );
handleDataReady( parsed.series, parsed.data );
// The data of the job waits for the uploads of the data source. A data change that the job did not get stays.
const parsed = await queueWrite( () => openRef.current && ! owedAtClick && uploadCsvString( chartId, uploadNonce, trimmedCsv ) );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

correctness A generation in one tab replaces a newer data edit made in another tab of the same chart. owedAtClick reads only the data source of this page (index.js:432,476), and the write queue is page-local (api.js:32-46). Open one chart in tabs A and B. Click Generate in A, then edit the rows in B. When A's job returns data_csv, A uploads it after B's edit, and the chart loses B's rows. This path was already in the code the earlier review saw. Fix: refuse a data write whose base is older than the chart's current data, and tell the user the generated data was not applied. Add a two-page case to ai-builder.spec.js.

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