Skip to content

Migrate from legacy section-based tokens to flat override map - #95

Merged
jackgranatowski merged 3 commits into
mainfrom
claude/frontend-panel-configurator-bugs-r2zv01
Jun 29, 2026
Merged

Migrate from legacy section-based tokens to flat override map#95
jackgranatowski merged 3 commits into
mainfrom
claude/frontend-panel-configurator-bugs-r2zv01

Conversation

@jackgranatowski

@jackgranatowski jackgranatowski commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR completes the migration from the legacy section-based token storage system (slashed_tokens option with per-section maps) to the new flat override map system (slashed_overrides option with CSS custom property names as keys).

Key changes:

  • Remove all legacy token section handling from Slashed_CSS_Generator — the class now only reads from the flat override map via generate_flat_override_declarations()
  • Delete Slashed_Token_Sanitizer class (legacy section sanitization no longer needed)
  • Delete Slashed_Tab_Registry class (legacy tab/section registry no longer needed)
  • Remove legacy REST endpoints (POST /tokens, POST /tokens/validate, POST /tokens/reset, GET /tokens/export, POST /tokens/import) — only the flat override endpoints remain
  • Remove viewport min/max constants and all per-section declaration generators from CSS generator
  • Update Slashed_Token_Store to remove legacy settings methods; keep only the flat override map and plugin settings
  • Update admin color override resolution to read from flat override map instead of legacy section structure
  • Simplify Svelte components to remove legacy ratio preset tracking logic

The configurator SPA now exclusively uses the flat override map (POST /tokens/overrides) for all design token customization. Framework defaults remain untouched when no override is set.

Type

  • feat
  • fix
  • docs
  • chore / tooling

Checklist

  • Conventional Commit messages
  • npm test passes
  • npm run lint passes
  • npm run verify passes
  • Generated artifacts not hand-edited
  • CHANGELOG.md updated under ## [Unreleased]
  • Built SPA assets committed (admin-app source changed)

Notes

This is a breaking change for any external code that directly accessed Slashed_Token_Store::get_settings() or the legacy REST endpoints. All token customization now flows through the flat override map, which is simpler and more maintainable.

The migration is transparent to end users — the configurator UI continues to work identically, just backed by the new storage format.

https://claude.ai/code/session_01A96n1MkdCboCtqEuYQhAdP

Summary by CodeRabbit

  • New Features

    • Spacing and typography controls now show separate min/max ratio inputs with preset selection and manual fine-tuning.
    • Ratio controls now support clearer breakpoint-specific customization.
  • Bug Fixes

    • Overlay panels now correctly hide inert behavior when open.
    • Improved handling of override values so supported settings are preserved more reliably.
    • Added accessibility labels to ratio controls for better screen reader support.

… legacy token system

Frontend panel was fully non-interactive: AppOverlay bound `inert={!isOpen}`,
but `inert` is a boolean attribute so `inert="false"` (rendered when open) kept
the panel disabled. Bind `inert={!isOpen || undefined}` so the attribute is
absent when open — clicks, keyboard, and all inputs work again.

Modular scale (Mobile -> Desktop): ratio presets hid the custom inputs and forced
mobile and desktop to share one ratio. Redesign ClampField's ratio block into two
always-visible per-breakpoint rows (Mobile/Desktop), each with its own preset
selector and editable number input, writing the independent --sf-*-ratio-min and
--sf-*-ratio-max tokens. Wire TypographyPanel and SpacingPanel to per-side handlers.

Remove the dead legacy section-based token system (slashed_tokens) so the flat
override map is the single source of truth:
- css-generator now emits only the validated flat overrides
- rest-controller drops /tokens, /tokens/validate|reset|export|import handlers
- token-store drops the section read/write API and legacy option constants
- inventory reads admin-chrome colors from the flat overrides (-source-light/-dark)
- token-page stops hydrating settings/tabs/defaults
- delete class-tab-registry.php and class-token-sanitizer.php

Also fix a temporal-dead-zone error in SliderRow (state declared after the
derived that read it). Rebuild the committed admin-app bundle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A96n1MkdCboCtqEuYQhAdP
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c628455f-c224-47c6-bf2e-69061bd50c82

📥 Commits

Reviewing files that changed from the base of the PR and between 6f4c5e7 and 98c6814.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • SLASHED-for-WP/admin-app/src/components/inputs/ClampField.svelte
  • SLASHED-for-WP/assets/admin-app/app.js
  • SLASHED-for-WP/includes/class-css-generator.php
  • SLASHED-for-WP/includes/class-rest-controller.php
  • SLASHED-for-WP/integrations/bricks/slashed-bricks.php
  • SLASHED-for-WP/integrations/gutenberg/slashed-gutenberg.php
💤 Files with no reviewable changes (3)
  • SLASHED-for-WP/integrations/bricks/slashed-bricks.php
  • SLASHED-for-WP/integrations/gutenberg/slashed-gutenberg.php
  • SLASHED-for-WP/includes/class-rest-controller.php
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • SLASHED-for-WP/admin-app/src/components/inputs/ClampField.svelte
  • SLASHED-for-WP/includes/class-css-generator.php

📝 Walkthrough

Walkthrough

Removes legacy section-based token storage, REST endpoints (/tokens save/validate/reset/export/import), Slashed_Token_Sanitizer, and Slashed_Tab_Registry classes. Replaces the storage layer with a flat slashed_overrides map and slashed_bricks_settings options. Updates the CSS generator, inventory color resolver, admin-app data contract, and ClampField ratio UI accordingly.

Changes

PHP: Flat override model and legacy removal

Layer / File(s) Summary
Token store: flat override and plugin-settings API
SLASHED-for-WP/includes/class-token-store.php
Removes OPTION_NAME/LEGACY_OPTION_NAME constants and all section-based get/update/delete methods; adds SETTINGS_OPTION_NAME, OVERRIDES_OPTION_NAME, ALLOWED_CSS_BUNDLES, PLUGIN_SETTING_DEFAULTS, and new get_overrides/update_overrides/delete_overrides/get_plugin_settings/update_plugin_settings methods.
CSS generator: flat override path only
SLASHED-for-WP/includes/class-css-generator.php
Removes legacy section-based declaration builders, flat_has_any(), and format_float(); rewires has_overrides() and get_override_css() to the flat map only; expands validate_override_value() with timing-function and scroll-timeline range validators.
Inventory: color override resolution from flat map
SLASHED-for-WP/includes/class-inventory.php
Rewrites get_admin_color_overrides() to read --sf-color-{family}-source-light/-source-dark entries from the flat override map and map them to -light/-dark resolver keys; removes brand/status array iteration and dark_overrides_enabled gating.
REST controller and deleted-class bootstrap cleanup
SLASHED-for-WP/includes/class-rest-controller.php, SLASHED-for-WP/slashed.php, SLASHED-for-WP/integrations/bricks/slashed-bricks.php, SLASHED-for-WP/integrations/gutenberg/slashed-gutenberg.php
Removes legacy /tokens section-based REST routes and handlers (save_section, validate_section, reset_section, export_tokens, import_tokens, is_known_section); removes require_once entries for deleted class-token-sanitizer.php and class-tab-registry.php from all bootstrap files.
Admin-app data contract: pluginSettings payload
SLASHED-for-WP/includes/class-token-page.php
Changes wp_localize_script payload to remove tabs, defaults, and settings fields and supply a single pluginSettings object merged with CONFIGURATOR_URL.

Svelte admin app: ratio UI and minor fixes

Layer / File(s) Summary
ClampField: per-breakpoint ratio select UI
SLASHED-for-WP/admin-app/src/components/inputs/ClampField.svelte
Adds ratioMin_bound/ratioMax_bound props, clampRatio() helper, and activeRatioMin/activeRatioMax derived values; replaces the preset-button grid with two independent rows each containing a preset <select> and numeric <input> wired to onRatioMinChange/onRatioMaxChange.
SpacingPanel and TypographyPanel: drop activeRatio wiring
SLASHED-for-WP/admin-app/src/components/panels/SpacingPanel.svelte, SLASHED-for-WP/admin-app/src/components/panels/TypographyPanel.svelte
Removes activeRatio derived values from both panels and updates ClampField props to pass ratioMin/ratioMax and bound props directly, dropping activeRatioValue/onRatioPreset.
SliderRow initialization order and AppOverlay inert fix
SLASHED-for-WP/admin-app/src/components/inputs/SliderRow.svelte, SLASHED-for-WP/admin-app/src/AppOverlay.svelte
Moves rawDraft and isEditing declarations before showRaw in SliderRow; changes AppOverlay inert binding to !isOpen || undefined to omit the attribute when open.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: migrating from legacy section-based tokens to a flat override map.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/frontend-panel-configurator-bugs-r2zv01

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Resolves PSR2.Classes.ClassDeclaration.CloseBraceAfterBody — the class
closing brace must follow the last method body with no intervening blank
line. Left over from removing the legacy section/export/import handlers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A96n1MkdCboCtqEuYQhAdP
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Migrate token customization to flat override map and remove legacy section APIs

✨ Enhancement 🐞 Bug fix 🕐 40+ Minutes

Grey Divider

AI Description

• Remove legacy section-based token storage and REST endpoints; keep only flat override map.
• Simplify CSS generation and admin preview color resolution to read slashed_overrides.
• Fix configurator panel interactivity and improve modular-scale ratio editing per breakpoint.
Diagram

graph TD
  A["Admin configurator SPA"] --> B["REST: /tokens/overrides"] --> C["Token Store (slashed_overrides)"] --> D["CSS Generator"] --> E["Emitted override CSS"]
  C --> F["Inventory color preview"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep legacy endpoints/options with deprecation window
  • ➕ Avoids breaking external integrations immediately
  • ➕ Allows gradual migration of third-party callers
  • ➖ Ongoing maintenance burden across REST, storage, and CSS generation
  • ➖ Higher risk of inconsistent behavior between legacy and flat paths
2. Provide one-time migration from slashed_tokens to slashed_overrides
  • ➕ Preserves existing saved customizations automatically
  • ➕ Reduces support burden for upgrades
  • ➖ Requires robust mapping logic for all legacy sections/fields
  • ➖ Can be hard to validate safely for arbitrary stored values
3. Expose a compatibility shim endpoint that translates legacy payloads
  • ➕ Minimizes client changes while still persisting flat overrides
  • ➕ Lets server enforce validation uniformly
  • ➖ Still keeps legacy surface area alive
  • ➖ Adds translation complexity and test matrix

Recommendation: The PR’s approach (single flat override map as the only source of truth) is the simplest long-term design and aligns storage, REST, and CSS emission. If backward compatibility is important, consider a follow-up that adds either (a) a documented deprecation window or (b) a one-time migration path so existing installations/clients don’t lose customizations or break silently.

Files changed (13) +155 / -1050

Enhancement (3) +47 / -46
ClampField.svelteRedesign modular-scale ratio UI for independent mobile/desktop editing +47/-34

Redesign modular-scale ratio UI for independent mobile/desktop editing

• Reworks the optional ratio block to render two always-visible rows (min/mobile and max/desktop), each with its own preset selector and number input. Computes active preset matches per side and clamps ratio values within bounds before emitting changes.

SLASHED-for-WP/admin-app/src/components/inputs/ClampField.svelte

SpacingPanel.svelteRemove shared ratio preset coupling; use per-breakpoint ratio handlers +0/-6

Remove shared ratio preset coupling; use per-breakpoint ratio handlers

• Deletes the derived "activeRatio" logic that required min/max ratios to match. Stops bulk-setting both ratio tokens from a single preset and instead wires separate min/max handlers to match the new ClampField behavior.

SLASHED-for-WP/admin-app/src/components/panels/SpacingPanel.svelte

TypographyPanel.svelteDecouple modular-scale ratio presets for min/max typography ratios +0/-6

Decouple modular-scale ratio presets for min/max typography ratios

• Removes legacy active-ratio detection that assumed a single shared ratio value. Drops the preset bulk update path and relies on separate ratio min/max updates for independent breakpoint control.

SLASHED-for-WP/admin-app/src/components/panels/TypographyPanel.svelte

Bug fix (2) +6 / -5
AppOverlay.svelteFix overlay interactivity by conditionally omitting 'inert' +1/-1

Fix overlay interactivity by conditionally omitting 'inert'

• Updates the 'inert' binding so the attribute is absent when the panel is open. This prevents browsers from treating 'inert="false"' as still inert, restoring clicks/keyboard/input interaction.

SLASHED-for-WP/admin-app/src/AppOverlay.svelte

SliderRow.sveltePrevent raw-mode typing interruptions by stabilizing local draft state +5/-4

Prevent raw-mode typing interruptions by stabilizing local draft state

• Moves 'rawDraft'/'isEditing' state declarations earlier so derived 'showRaw' can safely reference them. Keeps the local draft model intact so re-renders don’t interrupt in-progress user edits.

SLASHED-for-WP/admin-app/src/components/inputs/SliderRow.svelte

Refactor (6) +34 / -935
class-css-generator.phpDrop legacy section token emission; emit only validated flat overrides +8/-490

Drop legacy section token emission; emit only validated flat overrides

• Removes all section-based settings reading, viewport constants, and per-section declaration generators. The CSS generator now exclusively produces override declarations from the flat 'slashed_overrides' map via 'generate_flat_override_declarations()'.

SLASHED-for-WP/includes/class-css-generator.php

class-inventory.phpResolve admin preview colors from flat override source tokens +22/-56

Resolve admin preview colors from flat override source tokens

• Replaces legacy 'get_settings()['colors']' reads with 'get_overrides()' lookups for '--sf-color-*-source-light/dark'. Translates those source tokens into the resolver’s '--sf-color-*-light/dark' preview keys so admin previews match emitted CSS.

SLASHED-for-WP/includes/class-inventory.php

class-rest-controller.phpRemove legacy /tokens endpoints; keep only /tokens/overrides APIs +1/-295

Remove legacy /tokens endpoints; keep only /tokens/overrides APIs

• Deletes the legacy section-based REST routes and handlers (save/validate/reset/export/import). The controller now exposes only the flat override map endpoints under '/tokens/overrides', reducing surface area and enforcing the new storage model.

SLASHED-for-WP/includes/class-rest-controller.php

class-token-page.phpStop hydrating SPA with legacy tabs/defaults/settings payload +0/-3

Stop hydrating SPA with legacy tabs/defaults/settings payload

• Removes legacy boot payload fields ('tabs', 'defaults', 'settings') that were tied to the section-based token system. The page now primarily passes the flat overrides and plugin settings needed by the configurator.

SLASHED-for-WP/includes/class-token-page.php

class-token-store.phpRemove legacy slashed_tokens API; retain flat overrides + plugin settings +3/-89

Remove legacy slashed_tokens API; retain flat overrides + plugin settings

• Drops the section-based option constants and read/write helpers ('get_settings', 'update_section', etc.). Clarifies that 'slashed_overrides' is the single source of truth for design token customization and keeps only the flat override and plugin settings APIs.

SLASHED-for-WP/includes/class-token-store.php

slashed.phpRemove legacy token class wiring from plugin bootstrap +0/-2

Remove legacy token class wiring from plugin bootstrap

• Stops requiring legacy classes that were only needed for the section-based token system. Keeps bootstrap aligned with the new flat override-only architecture.

SLASHED-for-WP/slashed.php

Other (2) +68 / -64
app.cssRebuild admin SPA CSS bundle +1/-1

Rebuild admin SPA CSS bundle

• Updates the committed built CSS artifact to reflect the latest SPA source changes. This keeps the shipped WP admin assets in sync with the Svelte code.

SLASHED-for-WP/assets/admin-app/app.css

app.jsRebuild admin SPA JS bundle +67/-63

Rebuild admin SPA JS bundle

• Updates the committed built JavaScript artifact corresponding to the SPA source changes (UI fixes and token API migration). Ensures the distributed plugin includes the latest compiled admin app.

SLASHED-for-WP/assets/admin-app/app.js

@qodo-code-review

qodo-code-review Bot commented Jun 29, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Standalone bootstrap fatal requires ✓ Resolved 🐞 Bug ☼ Reliability
Description
The standalone Bricks/Gutenberg bootstrap code still require_onces
includes/class-token-sanitizer.php and includes/class-tab-registry.php, but this PR deletes
those files. In standalone mode (when Slashed_Token_Store isn't already loaded), those
require_once calls will fatal-error on missing files and prevent the integration plugin from
loading.
Code

SLASHED-for-WP/includes/class-token-sanitizer.php[L1-25]

-<?php
-/**
- * Pure sanitization helpers for SLASHED token submissions.
- *
- * Stateless: every public method takes inputs and returns outputs.
- * No DB access, no option reads — pure data transforms.
- *
- * @package SLASHED
- */
-
-if ( ! defined( 'ABSPATH' ) ) {
-	exit;
-}
-
-/**
- * Class Slashed_Token_Sanitizer
- */
-class Slashed_Token_Sanitizer {
-
-	/**
-	 * Sanitize a single section's raw input map.
-	 *
-	 * Dispatches to sanitize_color_section() for the colors tab and falls
-	 * back to a generic flat-map sanitizer for everything else.
-	 *
Relevance

⭐⭐⭐ High

Team has accepted fixes preventing standalone-mode fatals (guarding undefined constants); missing
require_once files would similarly fatal.

PR-#27

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Both standalone integration entrypoints still require the legacy files in their standalone bootstrap
blocks; since the PR deletes those files, those require statements will fatal when executed.

SLASHED-for-WP/integrations/bricks/slashed-bricks.php[40-52]
SLASHED-for-WP/integrations/gutenberg/slashed-gutenberg.php[54-65]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
This PR deletes `includes/class-token-sanitizer.php` and `includes/class-tab-registry.php`, but the standalone integration entrypoints still attempt to load these files via `require_once` when running without the unified plugin. `require_once` on a missing file causes a fatal error, breaking standalone activation/runtime.

### Issue Context
In standalone mode, `integrations/bricks/slashed-bricks.php` and `integrations/gutenberg/slashed-gutenberg.php` execute their "load shared infrastructure" block (guarded by `! class_exists('Slashed_Token_Store')`). That block still includes the deleted legacy files.

### Fix Focus Areas
- SLASHED-for-WP/integrations/bricks/slashed-bricks.php[40-52]
- SLASHED-for-WP/integrations/gutenberg/slashed-gutenberg.php[54-65]

### What to change
- Remove the `require_once $slashed_shared . 'class-token-sanitizer.php';` line.
- Remove the `require_once $slashed_shared . 'class-tab-registry.php';` line.
- Double-check no other standalone bootstrap code paths reference the removed classes/files.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Legacy slashed_tokens dropped 🐞 Bug ≡ Correctness
Description
Slashed_CSS_Generator::get_override_css() now only emits declarations from the flat
slashed_overrides map, and Slashed_Token_Store no longer exposes any read/migration path for the
legacy slashed_tokens section map. Any existing installs that still have overrides stored only in
slashed_tokens will stop applying those overrides after upgrade.
Code

SLASHED-for-WP/includes/class-css-generator.php[55]

+		$declarations = self::generate_flat_override_declarations();
Relevance

⭐⭐⭐ High

Team previously added transparent read-time migrations for legacy options (essential→optimal) to
avoid upgrade breakage.

PR-#77

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new CSS generator emits only flat overrides, and the token store now only supports the flat
overrides option; therefore legacy section-based overrides can no longer be read/applied by the
runtime.

SLASHED-for-WP/includes/class-css-generator.php[45-100]
SLASHED-for-WP/includes/class-token-store.php[22-70]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The PR removes all legacy section-based token handling (`slashed_tokens`) and emits CSS only from `slashed_overrides`. If an upgraded site still has customizations stored in the legacy option, they will no longer affect emitted override CSS.

### Issue Context
Post-PR, there is no `Slashed_Token_Store::get_settings()` (or similar) and `Slashed_CSS_Generator` no longer merges legacy section declarations.

### Fix Focus Areas
- SLASHED-for-WP/includes/class-token-store.php[22-70]
- SLASHED-for-WP/includes/class-css-generator.php[30-100]

### What to change
Implement a one-time migration path that preserves existing user customizations:
- On plugin load or on first `get_overrides()` call, if `slashed_overrides` is empty, check for legacy option(s) (e.g., `slashed_tokens` and any older names).
- If legacy data exists, convert it into the flat override map keys (`--sf-*`) and store it in `slashed_overrides`.
- Optionally delete the legacy option after successful migration.
- Ensure the conversion uses the same validation rules as the REST override sanitizer (`Slashed_CSS_Generator::validate_override_value`) so only safe values are migrated.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

// (Design Settings → POST /tokens/overrides). Appended last so a value
// set there wins over a legacy section override of the same property.
$declarations = array_merge( $declarations, self::generate_flat_override_declarations() );
$declarations = self::generate_flat_override_declarations();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

2. Legacy slashed_tokens dropped 🐞 Bug ≡ Correctness

Slashed_CSS_Generator::get_override_css() now only emits declarations from the flat
slashed_overrides map, and Slashed_Token_Store no longer exposes any read/migration path for the
legacy slashed_tokens section map. Any existing installs that still have overrides stored only in
slashed_tokens will stop applying those overrides after upgrade.
Agent Prompt
### Issue description
The PR removes all legacy section-based token handling (`slashed_tokens`) and emits CSS only from `slashed_overrides`. If an upgraded site still has customizations stored in the legacy option, they will no longer affect emitted override CSS.

### Issue Context
Post-PR, there is no `Slashed_Token_Store::get_settings()` (or similar) and `Slashed_CSS_Generator` no longer merges legacy section declarations.

### Fix Focus Areas
- SLASHED-for-WP/includes/class-token-store.php[22-70]
- SLASHED-for-WP/includes/class-css-generator.php[30-100]

### What to change
Implement a one-time migration path that preserves existing user customizations:
- On plugin load or on first `get_overrides()` call, if `slashed_overrides` is empty, check for legacy option(s) (e.g., `slashed_tokens` and any older names).
- If legacy data exists, convert it into the flat override map keys (`--sf-*`) and store it in `slashed_overrides`.
- Optionally delete the legacy option after successful migration.
- Ensure the conversion uses the same validation rules as the REST override sanitizer (`Slashed_CSS_Generator::validate_override_value`) so only safe values are migrated.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@@ -1,146 +0,0 @@
<?php

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Standalone bootstrap fatal requires 🐞 Bug ☼ Reliability

The standalone Bricks/Gutenberg bootstrap code still require_onces
includes/class-token-sanitizer.php and includes/class-tab-registry.php, but this PR deletes
those files. In standalone mode (when Slashed_Token_Store isn't already loaded), those
require_once calls will fatal-error on missing files and prevent the integration plugin from
loading.
Agent Prompt
### Issue description
This PR deletes `includes/class-token-sanitizer.php` and `includes/class-tab-registry.php`, but the standalone integration entrypoints still attempt to load these files via `require_once` when running without the unified plugin. `require_once` on a missing file causes a fatal error, breaking standalone activation/runtime.

### Issue Context
In standalone mode, `integrations/bricks/slashed-bricks.php` and `integrations/gutenberg/slashed-gutenberg.php` execute their "load shared infrastructure" block (guarded by `! class_exists('Slashed_Token_Store')`). That block still includes the deleted legacy files.

### Fix Focus Areas
- SLASHED-for-WP/integrations/bricks/slashed-bricks.php[40-52]
- SLASHED-for-WP/integrations/gutenberg/slashed-gutenberg.php[54-65]

### What to change
- Remove the `require_once $slashed_shared . 'class-token-sanitizer.php';` line.
- Remove the `require_once $slashed_shared . 'class-tab-registry.php';` line.
- Double-check no other standalone bootstrap code paths reference the removed classes/files.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
SLASHED-for-WP/includes/class-css-generator.php (2)

30-43: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep has_overrides() aligned with the emitter.

Line 37 treats any non-empty value as an override, but generate_flat_override_declarations() later drops values that fail validate_override_value(). A stored invalid value can make has_overrides() return true while get_override_css() emits nothing.

Proposed fix
 		foreach ( Slashed_Token_Store::get_overrides() as $name => $value ) {
 			if ( ! is_string( $name ) || ! preg_match( '/^--sf-[a-z0-9-]+$/', $name ) ) {
 				continue;
 			}
-			if ( '' !== (string) $value && null !== $value ) {
+			if ( false !== self::validate_override_value( $value ) ) {
 				return true;
 			}
 		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@SLASHED-for-WP/includes/class-css-generator.php` around lines 30 - 43, Keep
has_overrides() consistent with generate_flat_override_declarations() by using
the same value validation before returning true. Update the override check in
Slashed_CSS_Generator::has_overrides() so it only counts entries that would
actually be emitted by get_override_css(), either by reusing
validate_override_value() or matching its exact acceptance rules, and keep the
existing key filtering aligned with the emitter.

150-174: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Accept the token syntaxes the flat UI now saves.

The shared flat validator rejects current admin-app values such as cubic-bezier(...), linear(...), and scroll timeline ranges like entry 0%; sanitize_overrides() then silently drops those overrides before storage. Add explicit timing-function and timeline-range branches before falling through to font-family parsing.

Proposed fix
 	public static function validate_override_value( $value ) {
 		$candidate = self::valid_color( $value );
 		if ( false !== $candidate ) {
 			return $candidate;
 		}
 		$candidate = self::valid_dimension( $value );
 		if ( false !== $candidate ) {
 			return $candidate;
 		}
+		$candidate = self::valid_timing_function( $value );
+		if ( false !== $candidate ) {
+			return $candidate;
+		}
+		$candidate = self::valid_timeline_range( $value );
+		if ( false !== $candidate ) {
+			return $candidate;
+		}
 		return self::valid_font_family( $value );
 	}
+
+	private static function valid_timing_function( $value ) {
+		$v = trim( (string) $value );
+		if ( ! self::is_css_safe( $v ) ) {
+			return false;
+		}
+		if ( preg_match( '/^(linear|ease|ease-in|ease-out|ease-in-out|step-start|step-end)$/i', $v ) ) {
+			return $v;
+		}
+		if ( preg_match( '/^(cubic-bezier|linear|steps)\s*\(/i', $v )
+			&& preg_match( '#^[a-z0-9\s.,%()+-]+$#i', $v ) ) {
+			return $v;
+		}
+		return false;
+	}
+
+	private static function valid_timeline_range( $value ) {
+		$v = trim( (string) $value );
+		if ( ! self::is_css_safe( $v ) ) {
+			return false;
+		}
+		if ( preg_match( '/^(normal|entry|exit|cover|contain)(\s+-?(\d+\.?\d*|\.\d+)(%|px|rem|em|vh|vw)?)?$/i', $v ) ) {
+			return $v;
+		}
+		return false;
+	}

Also applies to: 232-237

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@SLASHED-for-WP/includes/class-css-generator.php` around lines 150 - 174,
`validate_override_value()` is missing support for the token syntaxes the flat
UI now emits, so `sanitize_overrides()` drops valid override values before they
are stored. Update `Slashed_CSS_Generator::validate_override_value` to try
explicit timing-function and scroll timeline-range validation branches before
falling back to `valid_font_family()`, alongside the existing `valid_color()`
and `valid_dimension()` checks, so values like `cubic-bezier(...)`,
`linear(...)`, and `entry 0%` are accepted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@SLASHED-for-WP/admin-app/src/components/inputs/ClampField.svelte`:
- Around line 151-172: The ratio controls in ClampField.svelte are currently
unlabeled for assistive tech because the side text is only rendered as a span;
add accessible names to both the select and number input, either by wiring them
to real labels or by adding clear aria-labels. Update the controls in the row
render block that uses row.side, ratioPresets, and row.onChange so each input
has a unique, descriptive label tied to its purpose.

---

Outside diff comments:
In `@SLASHED-for-WP/includes/class-css-generator.php`:
- Around line 30-43: Keep has_overrides() consistent with
generate_flat_override_declarations() by using the same value validation before
returning true. Update the override check in
Slashed_CSS_Generator::has_overrides() so it only counts entries that would
actually be emitted by get_override_css(), either by reusing
validate_override_value() or matching its exact acceptance rules, and keep the
existing key filtering aligned with the emitter.
- Around line 150-174: `validate_override_value()` is missing support for the
token syntaxes the flat UI now emits, so `sanitize_overrides()` drops valid
override values before they are stored. Update
`Slashed_CSS_Generator::validate_override_value` to try explicit timing-function
and scroll timeline-range validation branches before falling back to
`valid_font_family()`, alongside the existing `valid_color()` and
`valid_dimension()` checks, so values like `cubic-bezier(...)`, `linear(...)`,
and `entry 0%` are accepted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6a25253b-fa72-42fd-a9ad-78f5a99a8f6c

📥 Commits

Reviewing files that changed from the base of the PR and between 1e1d92d and 6f4c5e7.

📒 Files selected for processing (15)
  • SLASHED-for-WP/admin-app/src/AppOverlay.svelte
  • SLASHED-for-WP/admin-app/src/components/inputs/ClampField.svelte
  • SLASHED-for-WP/admin-app/src/components/inputs/SliderRow.svelte
  • SLASHED-for-WP/admin-app/src/components/panels/SpacingPanel.svelte
  • SLASHED-for-WP/admin-app/src/components/panels/TypographyPanel.svelte
  • SLASHED-for-WP/assets/admin-app/app.css
  • SLASHED-for-WP/assets/admin-app/app.js
  • SLASHED-for-WP/includes/class-css-generator.php
  • SLASHED-for-WP/includes/class-inventory.php
  • SLASHED-for-WP/includes/class-rest-controller.php
  • SLASHED-for-WP/includes/class-tab-registry.php
  • SLASHED-for-WP/includes/class-token-page.php
  • SLASHED-for-WP/includes/class-token-sanitizer.php
  • SLASHED-for-WP/includes/class-token-store.php
  • SLASHED-for-WP/slashed.php
💤 Files with no reviewable changes (6)
  • SLASHED-for-WP/includes/class-token-sanitizer.php
  • SLASHED-for-WP/includes/class-tab-registry.php
  • SLASHED-for-WP/slashed.php
  • SLASHED-for-WP/admin-app/src/components/panels/TypographyPanel.svelte
  • SLASHED-for-WP/admin-app/src/components/panels/SpacingPanel.svelte
  • SLASHED-for-WP/includes/class-token-page.php

Comment thread SLASHED-for-WP/admin-app/src/components/inputs/ClampField.svelte
- Remove require_once of deleted class-token-sanitizer.php and
  class-tab-registry.php from standalone Bricks/Gutenberg bootstraps to
  avoid a fatal error on standalone activation.
- Accept easing (cubic-bezier()/linear()/steps()) and scroll-timeline
  range (entry 0%, cover 30%) values in validate_override_value() so
  motion-panel overrides are no longer silently dropped on save/emit.
- Align has_overrides() with the emitter by reusing validate_override_value().
- Add aria-labels to the modular-scale ratio select and number input in
  ClampField.svelte; rebuild admin SPA assets.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Snqr6gnsRqsXFgxB9zo991
@jackgranatowski
jackgranatowski merged commit 3f600bb into main Jun 29, 2026
9 checks passed
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