Skip to content

Add EditorCapabilityResolver to centralize editor-capability gating#22812

Open
jkmassel wants to merge 1 commit into
trunkfrom
jkmassel/editor-capability-resolver
Open

Add EditorCapabilityResolver to centralize editor-capability gating#22812
jkmassel wants to merge 1 commit into
trunkfrom
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-d5911f3
Build Number1488
Application IDorg.wordpress.android.prealpha
Commitd5911f3
Installation URL1cc7vt316ofc8
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-d5911f3
Build Number1488
Application IDcom.jetpack.android.prealpha
Commitd5911f3
Installation URL2gogrrn8esgm0
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.22%. Comparing base (57acb95) to head (d5911f3).

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #22812      +/-   ##
==========================================
+ Coverage   37.20%   37.22%   +0.02%     
==========================================
  Files        2317     2318       +1     
  Lines      124509   124548      +39     
  Branches    16907    16917      +10     
==========================================
+ Hits        46324    46365      +41     
+ Misses      74438    74436       -2     
  Partials     3747     3747              

☔ 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.

@jkmassel jkmassel force-pushed the jkmassel/editor-capability-resolver branch from 7af2cc5 to 34887ae Compare April 22, 2026 18:59
Base automatically changed from jkmassel/site-settings-rust to trunk May 4, 2026 15:04
@jkmassel jkmassel requested a review from a team as a code owner May 4, 2026 15:04
@jkmassel jkmassel requested review from adalpari and removed request for a team May 4, 2026 15:04
Copy link
Copy Markdown
Contributor

@adalpari adalpari left a comment

Choose a reason for hiding this comment

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

It looks like there are some merge conflicts. Could you take a look at them?

`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 34887ae to d5911f3 Compare May 5, 2026 23:23
@dangermattic
Copy link
Copy Markdown
Collaborator

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

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.

4 participants