Skip to content

Add EditorCapabilityResolver to centralize editor-capability gating#22812

Open
jkmassel wants to merge 1 commit intojkmassel/site-settings-rustfrom
jkmassel/editor-capability-resolver
Open

Add EditorCapabilityResolver to centralize editor-capability gating#22812
jkmassel wants to merge 1 commit intojkmassel/site-settings-rustfrom
jkmassel/editor-capability-resolver

Conversation

@jkmassel
Copy link
Copy Markdown
Contributor

Summary

  • Introduces EditorCapabilityResolver as the single source of truth for whether the theme-styles and third-party-blocks capabilities apply to a site, combining the top-level GutenbergKit feature flag, the remote gutenberg_kit_plugins flag, the per-site capability cache (EditorSettingsRepository), and the user's per-site toggle (SiteSettingsProvider).
  • Returns a Resolved sealed hierarchy (Hidden / Unsupported(reason) / Available(userEnabled, advisory?)) that UI callers can branch on directly to pick the right visibility / disabled-with-reason / advisory-note treatment. Non-UI callers collapse the state via shouldApplyInEditor.
  • Models theme-not-a-block-theme as an advisory attached to Available, not a gate — the pref stays enabled with an informational summary, matching today's behaviour.
  • Wires SiteSettingsFragment through the resolver, replacing two inline conditional chains with pattern matches over Resolved.

Extracted from #22579 — the editor-side consumer (the GutenbergKit config builder) will land in that PR alongside its refactor to an injectable class, so the preloading PR only shows the editor-facing plumbing.

Test plan

  • ./gradlew :WordPress:testJetpackDebugUnitTest --tests "org.wordpress.android.ui.posts.EditorCapabilityResolverTest" passes (17 tests covering the decision tree for both capabilities)
  • Open a site's settings for a WP.com simple site — theme-styles pref visible and toggleable, third-party-blocks pref hidden or disabled per remote flag + capability cache
  • Open settings for a classic-theme site — theme-styles toggle still present, summary shows "not a block theme" advisory
  • Open settings with experimental_block_editor feature flag off — both prefs hidden

Related

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented Apr 22, 2026

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr22812-34887ae
Build Number1488
Application IDorg.wordpress.android.prealpha
Commit34887ae
Installation URL4oik3epaq4pkg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented Apr 22, 2026

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr22812-34887ae
Build Number1488
Application IDcom.jetpack.android.prealpha
Commit34887ae
Installation URL5ooql7e18t82g
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

@jkmassel jkmassel force-pushed the jkmassel/editor-capability-resolver branch 2 times, most recently from 6968ec2 to 7af2cc5 Compare April 22, 2026 18:35
@jkmassel jkmassel added Gutenberg Editing and display of Gutenberg blocks. Site Management Tech Debt labels Apr 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.20%. Comparing base (305ccc3) to head (34887ae).

Additional details and impacted files
@@                       Coverage Diff                       @@
##           jkmassel/site-settings-rust   #22812      +/-   ##
===============================================================
+ Coverage                        37.18%   37.20%   +0.02%     
===============================================================
  Files                             2317     2318       +1     
  Lines                           124468   124507      +39     
  Branches                         16896    16906      +10     
===============================================================
+ Hits                             46280    46321      +41     
+ Misses                           74444    74442       -2     
  Partials                          3744     3744              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

`SiteSettingsFragment` combined the top-level GutenbergKit feature
flag, the remote `gutenberg_kit_plugins` flag, the per-site capability
cache, and the user's toggle inline — a long conditional chain per
capability that's hard to share with other consumers and easy to drift
from when those consumers get added.

Introduces `EditorCapabilityResolver` as a single source of truth for
both theme styles and third-party blocks. Returns a `Resolved` sealed
result — `Hidden` / `Unsupported(reason)` / `Available(userEnabled,
advisory?)` — that UI callers branch on directly, and non-UI callers
collapse via `shouldApplyInEditor`. The theme-not-a-block-theme case
is modelled as an advisory, not a gate, matching today's behaviour
where the pref stays enabled with an informational summary.

Wires `SiteSettingsFragment` through the resolver. The editor-side
consumer (the GutenbergKit config builder) will land in a follow-up
alongside its refactor to an injectable class.
@jkmassel jkmassel force-pushed the jkmassel/editor-capability-resolver branch from 7af2cc5 to 34887ae Compare April 22, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gutenberg Editing and display of Gutenberg blocks. Site Management Tech Debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants