Skip to content

Conversation

@jkmassel
Copy link
Contributor

Summary

  • Use API to determine theme style support by querying the WordPress REST API for editor capabilities
  • Add some initial tests for WordPressClient feature detection and caching behaviour – there's more to do here, but that'll be a future PR.

Changes

WordPressClient Feature Detection

  • Added WordPressClientAPI protocol to abstract WordPress API access for testing
  • Added supports(_:forSiteId:) method to check API route availability for features
  • Results are cached internally using a single Task to avoid redundant API calls. In the future, we'll want a way to invalidate this, but we'll do that later.

Editor Capability Fetching

  • EditorDependencyManager now fetches and caches editor capabilities on My Site load
  • GutenbergSettings stores feature support per-blog using WordPressClient.Feature.stringValue as stable keys
  • Theme styles toggle visibility is now determined by API capability rather than hardcoded logic

Testing Instructions

  • Ensure CI passes
  • Add cpt.wpmt.co to the app. Ensure the editor loads as expected. Ensure that theme styles toggle cannot be activated in Site Settings.
  • Add jetpack.wpmt.co to the app. Ensure the editor loads. Ensure that theme styles toggle can be activated.
  • Add a WP.com simple site to the app. Ensure the editor loads. Ensure that theme styles toggle can be activated.

@jkmassel jkmassel requested a review from dcalhoun January 22, 2026 19:36
@jkmassel jkmassel added this to the 26.6 milestone Jan 22, 2026
@jkmassel jkmassel added the Gutenberg Editing and display of Gutenberg blocks. label Jan 22, 2026
@dangermattic
Copy link
Collaborator

2 Warnings
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ This PR is assigned to the milestone 26.6. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 22, 2026

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number30571
VersionPR #25160
Bundle IDorg.wordpress.alpha
Commitbc417dc
Installation URL0h1hafhl0cem8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 22, 2026

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number30571
VersionPR #25160
Bundle IDcom.jetpack.alpha
Commitbc417dc
Installation URL1o58gg3jp2lr0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 22, 2026

🤖 Build Failure Analysis

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

async let currentUserTask = try await api.users.retrieveMeWithEditContext().data
async let activeThemeTask = try await api.themes.listWithEditContext(
params: ThemeListParams(status: .active)
).data.first(where: { $0.status == .active })
Copy link
Contributor

Choose a reason for hiding this comment

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

If one of the requests fails, the whole loadSiteInfoTask fails, which means we won't get any of the "site info". That's probably not something we'd want here?

case .blockTheme: isBlockTheme
case .plugins: apiRoot.hasRoute(route: "/wp/v2/plugins")
case .applicationPasswordExtras: apiRoot.hasRoute(route: "/application-password-extras/v1/admin-ajax")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: using the urlResolver property in WordPressAPI to find the URL should work on both self-hosted and WP.com sites, so we can merge the two similar branches into one.

let key = blog.locallyUniqueId + "-capabilities"

// Don't allow more than one concurrent invalidation
if self.prefetchTasks[key] != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to this PR: you can use OSAllocatedUnfairLock in LockingHashMap, which is Sendable, to get rid of the @unchecked declaration, which means it's impossible (as long as we continue to have the Swift compiler check in place) to forget use the lock.withLock.

@dcalhoun
Copy link
Member

dcalhoun commented Jan 22, 2026

Noting some early testing results:

  • Theme styles correctly loaded for WPCOM Simple sites.
  • With theme styles enabled, theme styles were missing from the editor for WoW/Atomic sites and jetpack.wpmt.co. WoA correctly showed (presumably cached) theme styles before I logged out and back in; then theme styles were missing.
  • The Use theme styles toggle resets when navigating away from the Site Settings view or toggling an adjacent setting.
  • The Use theme styles toggle was correctly disabled for cpt.wpmt.co.
Theme styles settings reset

theme-styles-settings.MP4

@jkmassel jkmassel force-pushed the add/conditional-editor-theme-styles branch from 36bd1c1 to cfc334e Compare January 22, 2026 23:00
@jkmassel jkmassel force-pushed the add/conditional-editor-theme-styles branch from cfc334e to bc417dc Compare January 22, 2026 23:11
@sonarqubecloud
Copy link

@wpmobilebot wpmobilebot modified the milestones: 26.6, 26.7 Jan 23, 2026
@wpmobilebot
Copy link
Contributor

Version 26.6 has now entered code-freeze, so the milestone of this PR has been updated to 26.7.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants