Files
site-builder/craft/scripts/e2e-sitesmith-review-backend.php
shadowdaoandClaude Opus 5.5 4177e5015a fix(sitesmith): summarize nested (linkedNodes) nodes, explain dropped review ops, truly label-free bg placeholders
1. summarizeCanvas() walked only node.nodes, so everything inside Section/ColumnLayout/forms
   (linkedNodes) was missing and live self-reviews could only name top-level sections. It now
   walks nodes + linked slots (stable key order) and lists id, type and key props (text first,
   links, main style values as style.<key>, colour-like props) as key="value", within a
   documented budget (150 nodes, 6000 chars, 300 chars of props per line; detail is dropped
   before nodes; cuts happen at line boundaries -- a mid-line cut used to make the server
   refuse the whole review). HtmlBlock code is no longer summarised.
   applyPatch no longer counts an op with nothing left to set as a change; ops that did nothing
   are counted per reason. The self-review note and console say why ops were dropped (server
   and editor reasons, counts only). Real-browser test 8n builds a nested page, sends the real
   summary through the real WHP review lockdown (php) and checks the nested edit takes effect
   while link/text edits, unknown ids and deletes are dropped.
3. Background placeholders use ?text=%E2%80%8B (measured: placehold.co then draws no glyphs;
   the same-colour label left a 4-colour ghost in its PNG); the capture draws no <text> for a
   zero-width or same-colour label. Pixel test on the case-4 hero markup in both browsers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXgk6UunFCKyXqLe2Cq
2026-11-01 20:40:09 -08:00

18 lines
1.0 KiB
PHP

<?php
/**
* Used by scripts/e2e-sitesmith.mjs (scenario 8n): runs the REAL WHP review lockdown on what the editor sent.
* stdin {summary, proposed:[ops with alias ids]} -> stdout {summary: server-rebuilt summary | null, alias, ops, dropped}
* (api/sitesmith.php sitesmith_review_rebuild_summary + Sitesmith::reviewFilterOps). Offline, no model call.
* Usage: php e2e-sitesmith-review-backend.php <backend repo dir>
*/
ob_start();
define('SITESMITH_API_LIBRARY_ONLY', true);
$dir = rtrim($argv[1], '/');
require_once $dir . '/web-files/libs/Sitesmith.php';
require $dir . '/web-files/api/sitesmith.php';
ob_end_clean();
$in = json_decode(stream_get_contents(STDIN), true);
$rb = sitesmith_review_rebuild_summary((string)($in['summary'] ?? ''));
$f = $rb === null ? ['ops' => [], 'dropped' => []] : Sitesmith::reviewFilterOps((array)($in['proposed'] ?? []), $rb['alias']);
echo json_encode(['summary' => $rb['summary'] ?? null, 'alias' => $rb['alias'] ?? null, 'ops' => $f['ops'], 'dropped' => (object)$f['dropped']], JSON_UNESCAPED_SLASHES);