Skip to content

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

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

vytisbulkevicius wants to merge 29 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.
    • 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, also 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, the data of a generation behind an earlier upload, 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 8054e9b 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.

@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 load lock works, but repairs, uploads and closed-builder generations can still overwrite newer chart state, and one generated CSV can drop the next edit.

  • classes/Visualizer/ChartBuilder/src/AIBuilder/index.js:573-579 — correctness Async work still writes builder or chart state after a newer action. The new lock does not reach these places: - index.js:317-319, 521-524, 573-579, 891-895: Fix, or a late preview error, starts a repair during Publish. The shortcode then shows for the older stored code. - DataSource.js:216-271: overlapping uploads apply in response order. Older rows replace newer rows. - index.js:447-479: a generation continues after the builder closes. It uploads its CSV over newer data of the reopened chart. Tie each result to the newest action and the open builder, or lock each path. Add ai-builder.spec.js cases that hold each request, act, release it, and expect the newer state.
  • classes/Visualizer/ChartBuilder/src/AIBuilder/DataSource.js:208-239 — correctness A generated CSV that equals the current text drops the next data edit. handleGenerate() passes the job's CSV as initialCsvText (index.js:478). The effect at lines 209-214 then arms skipUploadRef and sets csvText. The text does not change, so the manual effect at lines 217-239 does not run, and the skip stays armed. The next edit consumes it at line 220 and returns without an upload. The preview and the stored chart keep the old rows. Arm the skip only for text that differs from the current csvText. Add a case to ai-builder.spec.js where a generation returns the current CSV, the user makes one edit, and the new rows show. This assumes that a generation can return CSV identical to the current text.
Validation details
  • Files reviewed: 3/3 files changed since the prior review. The other 5 changed files are unchanged since then.
  • The edit-mode load is fixed. The prompt, data inputs and code editor stay locked until the chart loads.
  • The code editor can no longer save during Publish.
  • The upload skip of loaded data no longer drops the next edit while the builder is locked.
  • All checks were source reads. No Playwright case was run.
Untested areas
  • A Publish request survives a closed builder. Whether it can overwrite a newer publication of the same chart was not settled.
  • 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.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • not reached: Pro filter implementation behind classes/Visualizer/Module/Chart.php:1228 is unavailable

🤖 Automated review · run code-review-agent_6b0ff55a939806.02692000.


🤖 Review agent — review posted ✅ on 4da8b327 · changes requested · 2 findings · 18 min

Run code-review-agent_6b0ff55a939806.02692000 · trail

vytisbulkevicius and others added 4 commits December 2, 2026 12:59
…west action

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>
…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

setInitialCsvText( trimmedCsv );
handleDataReady( parsed.series, parsed.data );
// The data of the job waits for the uploads of the data source, so the server keeps the rows of the job.
const parsed = await queueWrite( () => openRef.current && 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 can replace a data edit that was still waiting to upload. Generate stays enabled while an upload waits in the queue. generateChart() then sends the older series and data (index.js:445). When the job returns data_csv, this upload runs after the waiting edit and replaces its rows (index.js:468-483). latestDataRef protects only a job without data. This assumes the generation service can return data_csv derived from the rows it receives. Fix: send a generation the rows of every edit made before the click, or keep edits the job did not see. Add an ai-builder.spec.js case: hold an upload, click Generate, return data_csv, and expect the edit to stay.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not in this PR. A click on Generate comes after the edit, and a job that returns data replaces the rows of the chart by design, on development too. Whether the job must also receive an edit that is still on its way to the server is a question for the generation flow, and the finding itself depends on what the service returns. This PR orders the writes; it does not change which rows a generation sends or returns. I will raise it with the owner as a follow-up, with the two-tab case.

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.

Still open at 8054e9b. This PR promises that the server keeps the rows of the last edit. Generate still sends the series and data of the click (index.js:445) while DataSource owes an upload (DataSource.js:228-248). When the job returns data_csv, its upload runs after that edit and replaces it (index.js:468-483). This assumes that the service derives data_csv from the rows it receives. Fix: send a generation the rows of every edit made before the click. If you open a follow-up issue for this exact place, link it here. That settles this thread.

…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

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