Add EditorCapabilityResolver to centralize editor-capability gating#22812
Open
Add EditorCapabilityResolver to centralize editor-capability gating#22812
Conversation
Add a new "Use Third-Party Blocks" toggle in Site Settings, gated behind GutenbergKit and editor assets support. Enhance the existing "Use Theme Styles" toggle with contextual warnings when the site lacks editor settings support or uses a non-block theme. Includes SiteSettingsProvider interface for injectable access to site settings from the local DB, replacing static SiteUtils calls for block editor default detection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gate the "Use Third-Party Blocks" toggle behind the remote gutenberg_kit_plugins feature flag in addition to the existing GutenbergKit and editor assets checks. Also simplify the summary string by removing "and styles" per reviewer feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tion Add ThemeRepository to fetch the active theme via WP API and determine if it is a block theme. Add EditorSettingsRepository to discover editor settings and editor assets route support via manifest/API root queries. Wire SiteSettingsFragment to use EditorSettingsRepository for gating theme styles and third-party blocks toggles. Also adds manifest route fetching methods to WpApiClientProvider for discovering available REST routes on WP.com and self-hosted sites. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove fetchWpComManifestRoutes and fetchSiteManifestRoutes from
WpApiClientProvider. EditorSettingsRepository now uses the standard
WpApiClient.request { it.apiRoot().get() } for all site types,
which already handles WP.com vs self-hosted URL resolution.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Call `EditorSettingsRepository.fetchEditorCapabilitiesForSite` when the user lands on My Site so the route-discovery and theme-detection results are available by the time they open Site Settings. On failure, a snackbar is shown and cached prefs retain their previous values so settings degrade to disabled rather than crashing.
12 tests covering pref delegation, route discovery persistence, theme detection, API errors, transport-level error isolation (one fetch failing doesn't block the other), and the both-fail case. Also fix MySiteViewModelTest for new constructor param.
Points at Automattic/wordpress-rs#1285 which fixes route discovery on WP.com simple sites so editor-assets and editor-settings routes appear in the API root response. Also adapts StatsDataSourceImpl to the new StatsUtmKeys API (String replaced with List<StatsUtmKey>).
Switch from hasRoute (exact path match) to hasRouteForEndpoint
(namespace + endpoint) so that WP.com sites — whose route keys
include a sites/{site_id} prefix — are correctly detected.
Requires wordpress-rs PR #1285 which adds hasRouteForEndpoint
to WpApiDetails and the ApiUrlResolver parameter.
Call fetchEditorCapabilitiesForSite during pull-to-refresh so editor settings prefs stay current without requiring a full screen resume. Show snackbar on failure in both paths.
Contributor
|
|
Contributor
|
|
Contributor
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
6968ec2 to
7af2cc5
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
`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.
7af2cc5 to
34887ae
Compare
4 tasks
adalpari
reviewed
May 5, 2026
Contributor
adalpari
left a comment
There was a problem hiding this comment.
It looks like there are some merge conflicts. Could you take a look at them?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
EditorCapabilityResolveras 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 remotegutenberg_kit_pluginsflag, the per-site capability cache (EditorSettingsRepository), and the user's per-site toggle (SiteSettingsProvider).Resolvedsealed 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 viashouldApplyInEditor.Available, not a gate — the pref stays enabled with an informational summary, matching today's behaviour.SiteSettingsFragmentthrough the resolver, replacing two inline conditional chains with pattern matches overResolved.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)experimental_block_editorfeature flag off — both prefs hiddenRelated