Skip to content

Delete plan-11 Phase D legacy site-editor code (#434) - #455

Merged
ViewFromTheBox merged 6 commits into
release/1.0from
feature/434-delete-phase-d-legacy
May 16, 2026
Merged

ViewFromTheBox merged 6 commits into
release/1.0from
feature/434-delete-phase-d-legacy

Conversation

@ViewFromTheBox

@ViewFromTheBox ViewFromTheBox commented May 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #434. Final Phase H deliverable before umbrella #406 can close.

Walks through the per-system cutover described in the issue, with each step landing in its own commit inside this PR for chronological review. Net result: the plan-11 Phase D legacy is gone — six models, five policies, eight migrations, three resolver/inliner classes, two services, plus a drop-migration to retire orphan tables on existing installs.

Commit-by-commit walkthrough

Commit Step What it does
2d51d51 3 + 4 EntitySearchController + MenuLocationsController rewired against cms-framework resolvers / MenuLocationAssignment under class_exists guards. Both return empty data without cms-framework (Phase H install gate is the user-facing surface). Tests rewritten to cover the no-cms-framework branch.
(this commit) 1 Delete GlobalStylesCssProvider + GlobalStylesCacheInvalidator + the orphaned GlobalStylesCompiler. Renderer-blade's <x-ve-blocks> / <x-ve-template> now use a new GlobalStylesEmissionResolver that delegates to cms-framework's GlobalStylesEmitter under class_exists.
(this commit) 2 Rewrite TemplatePartInliner + PatternInliner to consume cms-framework's TemplatePartResolver + BlockPattern. Delete legacy visual-editor TemplateResolver; TemplateComponent walks the WP-style fallback chain itself and calls cms-framework's TemplateResolver per candidate.
(this commit) 5 + 6 Delete the 6 plan-11 Phase D models + 5 policies + orphaned MenuLocationResolver. Remove imports, container bindings, and Gate::policy registrations from VisualEditorServiceProvider. Drop the 8 plan-11 visual_editor_* migrations. Add a drop-migration that retires the orphan tables on existing installs.
289a235 docs Mark plan-14 §4.5.1 shipped.

What's gone

  • Models (src/Models/): VisualEditorTemplate, VisualEditorTemplatePart, VisualEditorPattern, VisualEditorPatternCategory, VisualEditorGlobalStyles, VisualEditorNavigation
  • Policies (src/Policies/): all 5 corresponding policies
  • Resolvers / inliners (src/Resources/): legacy TemplateResolver (the new H5-aware SiteEditor\Resolution\TemplateResolver stays)
  • Services (src/Services/): GlobalStylesCssProvider, GlobalStylesCacheInvalidator, GlobalStylesCompiler (orphan), MenuLocationResolver
  • Migrations (database/migrations/): 8 create_visual_editor_* files
  • Tests: VisualEditorTemplateTest, MenuLocationResolverTest, GlobalStylesCssProviderTest, GlobalStylesCompilerTest, TemplateResolverTest, TemplatePartInlinerTest, PatternInlinerTest, and three renderer-blade feature tests (TemplateComponentTest, TemplatePartRenderingTest, SyncedPatternRenderingTest) — all exercised legacy DB-fixture behavior that no longer applies.

What's new

  • packages/visual-editor-renderer-blade/src/Services/GlobalStylesEmissionResolver.php — thin facade over cms-framework's GlobalStylesEmitter, with a class_exists short-circuit.
  • database/migrations/2026_05_15_000000_drop_legacy_visual_editor_tables.php — drops all 8 legacy tables. dropIfExists so fresh installs and partially-cleaned envs both run cleanly. Irreversible by design.

What changed in place

  • TemplatePartInliner + PatternInliner — same public API, same cycle / depth guards. The findPart / findPattern lookup methods now resolve through cms-framework. Block-markup theme attributes are preserved on output but no longer drive the lookup (cms-framework scopes by active theme implicitly).
  • EntitySearchController — template / template-part search hits cms-framework's resolvers; resources-config sources (pages, posts) still use direct Eloquent query.
  • MenuLocationsController — reads theme.json menus.locations via ThemeManager + assignments via MenuLocationAssignment. is_fallback always false in the response (cms-framework has no config fallback chain — that was a Phase D concept).
  • TemplateComponent — walks the WP fallback chain itself, calls cms-framework's TemplateResolver per candidate. The theme prop is preserved but no longer drives the resolver (same reasoning as the inliners).
  • BlocksComponent + TemplateComponent — swap GlobalStylesCssProvider for GlobalStylesEmissionResolver. The defaultTheme prop on <x-ve-blocks> is preserved but no longer drives global-styles theme selection (cms-framework's emitter uses the active theme).

Behavioral notes

  • Without cms-framework, the package's site-editor surface no-ops gracefully: empty pattern lookups, empty template lookups, no global-styles CSS emitted. The Phase H install gate (H7 — Site-editor shell wiring + install gate (rescope plan 11 Phase D UI) #432) is the user-facing surface for the missing-package case at the SPA mount; these endpoints stay defensive for direct-API callers.
  • MenuLocation.is_fallback field stays in the response shape for backwards compatibility with the existing JS contract, but it's always false. The JS-side MenuLocation type comment mentions the fallback hint; that hint is now decorative — the renderer should treat unassigned locations as plainly empty.
  • No Gate::authorize calls left in EntitySearchController / MenuLocationsController. Route middleware (['api', 'auth'] per config/visual-editor.php) still gates access.

Test plan

  • ./vendor/bin/pest --compact — 505 passed (down from 576; the deletions removed legacy-model-backed tests, replaced with smaller no-cms-framework-branch tests)
  • npm test — 1031 passed across 110 test files
  • Manual: confirmed src/VisualEditorServiceProvider.php parses cleanly, no leftover imports for deleted classes
  • Manual smoke against a Keystone-mounted dev environment (deferred — the consuming-app side will exercise the populated cms-framework paths)

Drop-migration deployment notes

The new migration 2026_05_15_000000_drop_legacy_visual_editor_tables.php drops the 8 visual_editor_* tables on existing installs. Fresh v1.x installs never create them. The migration is irreversible by design — Phase H replaced the schema, there's no migration path back. Apps that need the old tables should pin to a pre-v1 release.

Closes the Phase H umbrella

After this lands, #406 (Phase H umbrella) has no open deliverables. visual-editor v1.0.0 can tag from release/1.0.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • Retired legacy Visual Editor database tables and Eloquent models; added a drop-migration to retire orphaned tables.
    • Removed legacy global-styles compilation/cache and menu resolver; global-styles emission and menu assignments now defer to cms-framework when available.
    • Simplified service provider wiring and authorization registrations.
  • Bug Fixes

    • Search and menu endpoints now gate behavior on cms-framework availability and fall back safely when absent.
  • Documentation

    • Updated plan doc to reflect the legacy cleanup and new delegation approach.
  • Tests

    • Adjusted/removed tests to align with the retired legacy components and new cms-framework delegation.

Review Change Stack

Rewire EntitySearchController and MenuLocationsController against cms-framework's resolvers + assignment models under class_exists guards. Both return empty data when cms-framework isn't installed (Phase H install gate is the user-facing surface for that condition). Drops the legacy Gate::authorize(VisualEditorNavigation::class) — route middleware already enforces auth. Tests rewritten to cover the no-cms-framework branch; the populated path is exercised by consuming-app tests where a real cms-framework env is wired.
Delete GlobalStylesCssProvider + GlobalStylesCacheInvalidator (parent package). Renderer-blade's <x-ve-blocks> / <x-ve-template> now use a new GlobalStylesEmissionResolver that delegates to cms-framework's GlobalStylesEmitter under a class_exists guard — Phase H install gate is the user-facing surface for the no-cms-framework case; the resolver returns '' so the renderer doesn't emit a <style> block. Cache busting is event-driven inside cms-framework, no more per-request invalidator. GlobalStylesCompiler was the deleted provider's last consumer, so it goes too along with its test.
Rewrite TemplatePartInliner + PatternInliner to consume cms-framework's TemplatePartResolver + BlockPattern under class_exists guards. Legacy visual-editor TemplateResolver (src/Resources/TemplateResolver.php) deleted entirely; TemplateComponent now walks the WP-style fallback chain itself and calls cms-framework's TemplateResolver per candidate. Tests that exercised the legacy model-backed inliner internals are deleted — the cycle/depth coverage moves with the inliner logic, which now sits behind cms-framework's resolvers and is covered by their tests + consuming-app integration tests.
Delete the 6 plan-11 Phase D models (VisualEditorTemplate, VisualEditorTemplatePart, VisualEditorPattern, VisualEditorPatternCategory, VisualEditorGlobalStyles, VisualEditorNavigation) + their 5 policies + the orphaned MenuLocationResolver service. Remove their imports, container bindings, and Gate::policy registrations from VisualEditorServiceProvider. Drop the 8 plan-11 visual_editor_* migrations and ship a single drop-migration (2026_05_15_000000_drop_legacy_visual_editor_tables.php) so existing installs cleanly retire the orphan tables. Delete the model + service unit/feature tests that exercised the deleted code (VisualEditorTemplateTest, MenuLocationResolverTest). 505 pest tests pass.
@coderabbitai

coderabbitai Bot commented May 15, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ee3f58d1-6d94-412b-a442-f613055265c7

📥 Commits

Reviewing files that changed from the base of the PR and between 289a235 and 11fb5b8.

📒 Files selected for processing (1)
  • src/Http/Controllers/EntitySearchController.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Http/Controllers/EntitySearchController.php

📝 Walkthrough

Walkthrough

This PR removes Phase D visual-editor models, policies, creation migrations and related services; it reworks renderers and controllers to delegate template/template-part/pattern/global-styles/navigation resolution to cms-framework under runtime guards, registers a GlobalStylesEmissionResolver, and adds a migration to drop orphaned visual_editor_* tables.

Changes

Plan 11 Phase D Legacy Cleanup and cms-framework Migration

Layer / File(s) Summary
Database migrations: remove legacy schema, add drop migration
database/migrations/2026_04_23_*.php, database/migrations/2026_05_15_000000_drop_legacy_visual_editor_tables.php
Seven Phase D table-creation migrations are removed and a new drop-migration is added to safely drop orphaned visual_editor_* tables on installs that ran the old migrations.
Plan documentation update
docs/plans/14-cms-framework-site-editor-integration.md
Updates the plan note to mark the Phase D cleanup as shipped via #434 and documents the removals and cms-framework cutovers.
Global styles: new emission resolver and Blade wiring
packages/visual-editor-renderer-blade/src/Services/GlobalStylesEmissionResolver.php, packages/visual-editor-renderer-blade/src/View/Components/BlocksComponent.php, packages/visual-editor-renderer-blade/src/View/Components/TemplateComponent.php, packages/visual-editor-renderer-blade/src/VisualEditorRendererBladeServiceProvider.php, tests under packages/visual-editor-renderer-blade/tests/Feature/*
Introduces GlobalStylesEmissionResolver that conditionally delegates to cms-framework's GlobalStylesEmitter; replaces the old GlobalStylesCssProvider usage in Blade components to call emit() and adapt to empty-string short-circuiting; wires the resolver as a singleton and updates tests to expect no CSS emitted when cms-framework is absent.
TemplateComponent: fallback chain & runtime resolver
packages/visual-editor-renderer-blade/src/View/Components/TemplateComponent.php
TemplateComponent now builds a deterministic WordPress-style fallback slug chain and resolves templates via a runtime-resolved TemplateResolver (when available), returning the first matched block tree or an explicit failure ([null,null]), and uses GlobalStylesEmissionResolver for CSS emission.
Model and policy removal, service provider cleanup
src/Models/VisualEditor*.php, src/Policies/VisualEditor*.php, src/VisualEditorServiceProvider.php
Deletes Phase D Eloquent models and authorization policies; removes GlobalStylesCssProvider, GlobalStylesCacheInvalidator, MenuLocationResolver bindings; updates VisualEditorServiceProvider to reduce policy registrations and provide GlobalStylesEmissionTracker.
Inliners and template resolution: migrate to cms-framework
src/Resources/PatternInliner.php, src/Resources/TemplatePartInliner.php
PatternInliner and TemplatePartInliner now resolve blocks through cms-framework (BlockPattern / TemplatePartResolver) under class-exists guards, returning null/matching not-found markers when resolvers or records are missing; cycle and depth guards preserved.
Controller rewrites: EntitySearchController and MenuLocationsController
src/Http/Controllers/EntitySearchController.php, src/Http/Controllers/MenuLocationsController.php
EntitySearchController now calls searchCmsFrameworkEntities() for template/template-part (returns empty data if cms-framework absent) and resolves other types via resolveResourceSource()/searchResourceModel(); MenuLocationsController returns empty data when cms-framework is missing and reads ThemeManager/MenuLocationAssignment when available, with is_fallback always false.
Test coverage updates and cleanup
packages/visual-editor-renderer-blade/tests/Feature/*.php, tests/Feature/VisualEditor/*.php, tests/Unit/VisualEditor/*.php
Removes test suites for deleted models/services/resolvers; updates GlobalStylesEmissionTest, BlocksComponentTest, EntitySearchControllerTest, and MenuLocationsControllerTest to assert cms-framework delegation behaviors (no CSS emitted or empty data when cms-framework is absent).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • ArtisanPack-UI/visual-editor#364: Related — removes the VisualEditorGlobalStyles stack that this PR also replaces with cms-framework emission.
  • ArtisanPack-UI/visual-editor#362: Related — previously added the VisualEditor templates stack that this PR deletes and replaces with runtime resolver delegation.
  • ArtisanPack-UI/visual-editor#392: Related — touched the Blade global-styles rendering path; this PR replaces the provider-based flow with GlobalStylesEmissionResolver.

Poem

🐰 Away with tables old and worn,
The models fade like breaking dawn,
cms-framework hums a tidy tune,
Resolvers rise beneath the moon,
Clean code hops on—spring’s coming soon!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% 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 PR title 'Delete plan-11 Phase D legacy site-editor code (#434)' directly and clearly summarizes the main objective of removing Phase D legacy code, matching the primary scope of changes.
Linked Issues check ✅ Passed The PR comprehensively addresses all coding requirements from #434: removes all Phase D models/policies/migrations, retargets EntitySearchController and MenuLocationsController to cms-framework, replaces global-styles providers with cms-framework delegation, rewires inliners for cms-framework resolvers, and deletes orphaned legacy services and tests.
Out of Scope Changes check ✅ Passed All changes are directly scoped to Phase D cleanup as specified in #434; no net-new functionality, renderer architecture changes, or cms-framework modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feature/434-delete-phase-d-legacy

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

@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

🤖 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 `@src/Http/Controllers/EntitySearchController.php`:
- Around line 106-132: The loop in EntitySearchController collects matches and
stops once count($matches) >= self::MAX_RESULTS, which causes the selection to
depend on resolver->all() iteration order; instead gather all candidate matches
into the $matches array, then sort them using the existing usort (static fn
(array $a, array $b): int => strcasecmp(...)), and only after sorting slice the
array to self::MAX_RESULTS (mirroring searchResourceModel() behavior) so the
returned set is the alphabetically-first results regardless of iteration order.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4a9b0b4d-c4a5-47bf-a7a2-96a1f2f452ee

📥 Commits

Reviewing files that changed from the base of the PR and between f1ff7bc and 289a235.

📒 Files selected for processing (49)
  • database/migrations/2026_04_23_000000_create_visual_editor_templates_table.php
  • database/migrations/2026_04_23_100000_create_visual_editor_template_parts_table.php
  • database/migrations/2026_04_23_200000_create_visual_editor_global_styles_table.php
  • database/migrations/2026_04_23_300000_create_visual_editor_navigations_table.php
  • database/migrations/2026_04_23_400000_create_visual_editor_patterns_table.php
  • database/migrations/2026_04_23_500000_create_visual_editor_pattern_categories_table.php
  • database/migrations/2026_04_23_600000_create_visual_editor_pattern_category_table.php
  • database/migrations/2026_04_24_000000_add_location_to_visual_editor_navigations_table.php
  • database/migrations/2026_05_15_000000_drop_legacy_visual_editor_tables.php
  • docs/plans/14-cms-framework-site-editor-integration.md
  • packages/visual-editor-renderer-blade/src/Services/GlobalStylesEmissionResolver.php
  • packages/visual-editor-renderer-blade/src/View/Components/BlocksComponent.php
  • packages/visual-editor-renderer-blade/src/View/Components/TemplateComponent.php
  • packages/visual-editor-renderer-blade/src/VisualEditorRendererBladeServiceProvider.php
  • packages/visual-editor-renderer-blade/tests/Feature/BlocksComponentTest.php
  • packages/visual-editor-renderer-blade/tests/Feature/GlobalStylesEmissionTest.php
  • packages/visual-editor-renderer-blade/tests/Feature/SyncedPatternRenderingTest.php
  • packages/visual-editor-renderer-blade/tests/Feature/TemplateComponentTest.php
  • packages/visual-editor-renderer-blade/tests/Feature/TemplatePartRenderingTest.php
  • src/Http/Controllers/EntitySearchController.php
  • src/Http/Controllers/MenuLocationsController.php
  • src/Models/VisualEditorGlobalStyles.php
  • src/Models/VisualEditorNavigation.php
  • src/Models/VisualEditorPattern.php
  • src/Models/VisualEditorPatternCategory.php
  • src/Models/VisualEditorTemplate.php
  • src/Models/VisualEditorTemplatePart.php
  • src/Policies/VisualEditorGlobalStylesPolicy.php
  • src/Policies/VisualEditorNavigationPolicy.php
  • src/Policies/VisualEditorPatternPolicy.php
  • src/Policies/VisualEditorTemplatePartPolicy.php
  • src/Policies/VisualEditorTemplatePolicy.php
  • src/Resources/PatternInliner.php
  • src/Resources/TemplatePartInliner.php
  • src/Resources/TemplateResolver.php
  • src/Services/GlobalStylesCacheInvalidator.php
  • src/Services/GlobalStylesCompiler.php
  • src/Services/GlobalStylesCssProvider.php
  • src/Services/MenuLocationResolver.php
  • src/VisualEditorServiceProvider.php
  • tests/Feature/VisualEditor/EntitySearchControllerTest.php
  • tests/Feature/VisualEditor/GlobalStylesCssProviderTest.php
  • tests/Feature/VisualEditor/MenuLocationResolverTest.php
  • tests/Feature/VisualEditor/MenuLocationsControllerTest.php
  • tests/Unit/VisualEditor/GlobalStylesCompilerTest.php
  • tests/Unit/VisualEditor/PatternInlinerTest.php
  • tests/Unit/VisualEditor/TemplatePartInlinerTest.php
  • tests/Unit/VisualEditor/TemplateResolverTest.php
  • tests/Unit/VisualEditor/VisualEditorTemplateTest.php
💤 Files with no reviewable changes (34)
  • database/migrations/2026_04_23_500000_create_visual_editor_pattern_categories_table.php
  • src/Models/VisualEditorPatternCategory.php
  • database/migrations/2026_04_23_200000_create_visual_editor_global_styles_table.php
  • database/migrations/2026_04_23_300000_create_visual_editor_navigations_table.php
  • src/Policies/VisualEditorGlobalStylesPolicy.php
  • src/Models/VisualEditorGlobalStyles.php
  • tests/Unit/VisualEditor/TemplateResolverTest.php
  • database/migrations/2026_04_23_400000_create_visual_editor_patterns_table.php
  • tests/Unit/VisualEditor/GlobalStylesCompilerTest.php
  • packages/visual-editor-renderer-blade/tests/Feature/TemplatePartRenderingTest.php
  • src/Policies/VisualEditorTemplatePartPolicy.php
  • src/Models/VisualEditorTemplate.php
  • database/migrations/2026_04_23_100000_create_visual_editor_template_parts_table.php
  • tests/Unit/VisualEditor/TemplatePartInlinerTest.php
  • src/Policies/VisualEditorTemplatePolicy.php
  • src/Services/GlobalStylesCompiler.php
  • src/Policies/VisualEditorNavigationPolicy.php
  • tests/Unit/VisualEditor/VisualEditorTemplateTest.php
  • database/migrations/2026_04_23_600000_create_visual_editor_pattern_category_table.php
  • src/Policies/VisualEditorPatternPolicy.php
  • database/migrations/2026_04_24_000000_add_location_to_visual_editor_navigations_table.php
  • src/Services/GlobalStylesCssProvider.php
  • src/Services/GlobalStylesCacheInvalidator.php
  • src/Models/VisualEditorTemplatePart.php
  • tests/Feature/VisualEditor/GlobalStylesCssProviderTest.php
  • database/migrations/2026_04_23_000000_create_visual_editor_templates_table.php
  • src/Resources/TemplateResolver.php
  • src/Models/VisualEditorNavigation.php
  • src/Models/VisualEditorPattern.php
  • tests/Unit/VisualEditor/PatternInlinerTest.php
  • src/Services/MenuLocationResolver.php
  • tests/Feature/VisualEditor/MenuLocationResolverTest.php
  • packages/visual-editor-renderer-blade/tests/Feature/TemplateComponentTest.php
  • packages/visual-editor-renderer-blade/tests/Feature/SyncedPatternRenderingTest.php

Comment thread src/Http/Controllers/EntitySearchController.php Outdated
@ViewFromTheBox ViewFromTheBox moved this from Backlog to Done in ArtisanPack UI Overview May 16, 2026
@ViewFromTheBox ViewFromTheBox moved this from Done to In Review in ArtisanPack UI Overview May 16, 2026
@ViewFromTheBox
ViewFromTheBox marked this pull request as ready for review May 16, 2026 00:50
CR flagged that the template / template-part search branch in EntitySearchController short-circuited the gather loop at MAX_RESULTS, then sorted what it had — meaning the returned 20 depended on the resolver's iteration order rather than being the alphabetically-first matches. Gather all candidates, sort, then slice — mirrors searchResourceModel()'s orderBy + limit semantics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant