fix(color-model): filter -dark source tokens consistently across Bricks/Gutenberg (PL-013/014/015) - #134
Conversation
…ks/Gutenberg PL-013/PL-014: classifyVar()/classify_color() exist in three near-identical implementations (Bricks JS, Gutenberg JS, Gutenberg PHP) that had silently drifted — only Gutenberg's JS correctly filtered both the `-light` and `-dark` source-duplicate suffixes; Bricks' JS and Gutenberg's PHP only filtered `-light`, so Bricks' color picker rendered a spurious duplicate swatch for every `-dark` token that Gutenberg correctly hid. Fixed both to match Gutenberg JS's already-correct behavior. Also ported Gutenberg filterModel's missing Array.isArray(group.sections)/Array.isArray(section .swatches) defensive guards into Bricks, which never had them. PL-015: added tests/color-model-cross-impl.test.js, a parametrized regression test running a shared fixture list against all three implementations to guarantee they can't silently re-diverge. The PHP side is exercised via tests/php-harness/classify-color.php, a small reflection- based harness (classify_color() is private and reads no instance state, so newInstanceWithoutConstructor() avoids needing a WordPress bootstrap) shelled out to via execFileSync, matching the plugin's existing lint-php.js convention. Left a TODO to migrate this into the PHPUnit suite once PR-A3 (Brain Monkey scaffold) lands, per the remediation plan. Rebuilt SLASHED-for-WP/integrations/bricks/assets/editor-app/app.js to include the source fix, matching this repo's existing built-asset commit convention. Verified: node --test tests/*.test.js (95/95, including the new 28-case cross-impl suite — confirmed it catches the original bug by temporarily reverting the Bricks fix and observing exactly the 4 expected subtest failures), php -l via npm run lint:php, npm run verify, and a full build:editor-app rebuild. composer phpstan/phpcs could not be run in this sandbox — composer install fails on all dev dependencies with "Could not authenticate against github.com" for both dist and source fallback downloads, a pre-existing environment network limitation unrelated to this change.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
PR Summary by QodoFix Bricks/Gutenberg color-token filtering drift and add cross-impl regression test
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
1 rule 1.
|
Matches scripts/lint-php.js's existing convention so a missing php binary fails with a clear message instead of an opaque ENOENT from execFileSync. Also caps the harness call with a timeout so a stuck php process can't hang the test runner.
…names SLASHED's SL-016 (codec.ts's `fa` → `generateCSS`) and SL-022 (lucide-svelte → @lucide/svelte) landed in main via #474. AppOverlay.svelte is plugin-specific and not vendored, so it kept referencing the old names and broke `vite build` as soon as CI's prebuild sync pulled the renamed exports from slashed@main — failing on every open plugin PR, not just the one that triggered it. Swaps the import/call site to generateCSS and updates package.json/ package-lock.json to depend on @lucide/svelte instead of the deprecated lucide-svelte package.
npm run check (svelte-check) had no equivalent of dev/build's predev/prebuild sync hook, so it type-checked whatever was already on disk. On a fresh checkout with the committed vendored src/ still predating the lucide-svelte rename, that meant a stale module-resolution error instead of an accurate check against the current framework source.
This branch predates the SL-016/SL-022 rename fix, so it inherited the same stale fa/lucide-svelte references breaking `vite build` in CI.
9f56144
into
claude/pr-469-audit-rebase-ggp0e4
Summary
First PR from SLASHED-Plugins' technical-debt audit remediation (Wave 0 — ships independently, no dependency on the SLASHED framework repo's own audit PRs). Targets this repo's integration branch
claude/pr-469-audit-rebase-ggp0e4, mirroring the same one-branch/multiple-PRs workflow used on the SLASHED side.classifyVar()/classify_color()exist in three near-identical implementations — Bricks JS, Gutenberg JS, Gutenberg PHP — that had silently drifted. Only Gutenberg's JS correctly filtered both the-lightand-darksource-duplicate token suffixes; Bricks' JS and Gutenberg's PHP only filtered-light, so Bricks' color picker rendered a spurious duplicate swatch for every-darktoken that Gutenberg correctly hid. Fixed both to match Gutenberg JS's already-correct behavior.filterModel's missingArray.isArray(group.sections)/Array.isArray(section.swatches)defensive guards into Bricks, which never had them (a second, smaller drift the audit flagged in the same finding).tests/color-model-cross-impl.test.js— a parametrized regression test running a shared fixture list against all three implementations, so they can't silently re-diverge again. The PHP side is exercised viatests/php-harness/classify-color.php, a small reflection-based harness (classify_color()is private and reads no instance state, sonewInstanceWithoutConstructor()avoids needing a full WordPress bootstrap), shelled out to viaexecFileSyncmatching this repo's existinglint-php.jsconvention. Left aTODOto migrate this into the PHPUnit suite once PR-A3 (Brain Monkey scaffold) lands, per the remediation plan.SLASHED-for-WP/integrations/bricks/assets/editor-app/app.jsto include the source fix, matching this repo's existing built-asset commit convention (confirmed the diff is a minimal 2-line change in the minified bundle, not a full rewrite).Test plan
node --test tests/*.test.js— 95/95 passed, including the new 28-case cross-impl suite-darkfixture vars × 2 assertions each), then restored the fixnpm run lint:php(php -lacross all 32 PHP files) — cleannpm run verify(version-metadata consistency) — cleannpm run build:editor-app— succeeds; rebuilt bundle committedNot verified here
composer phpstan/vendor/bin/phpcscould not be run in this sandbox —composer installfails on every dev dependency (both dist and source-fallback downloads) with "Could not authenticate against github.com," a pre-existing environment network limitation unrelated to this change.php -lsyntax-checked the modified PHP file successfully as a partial substitute.Generated by Claude Code