Skip to content

Integrate Gutenberg Preloading#22579

Open
jkmassel wants to merge 41 commits intotrunkfrom
integrate/gutenberg-preloading
Open

Integrate Gutenberg Preloading#22579
jkmassel wants to merge 41 commits intotrunkfrom
integrate/gutenberg-preloading

Conversation

@jkmassel
Copy link
Contributor

@jkmassel jkmassel commented Feb 10, 2026

Description

Adds background preloading of GutenbergKit editor dependencies so the block editor opens faster. When the My Site dashboard loads, GutenbergEditorPreloader fetches editor capabilities, theme styles, and third-party block settings on a background thread. If preloading completes before the editor is opened, the cached result is used immediately; otherwise the editor loads dependencies itself.

Key changes:

  • Editor dependency preloading — new GutenbergEditorPreloader singleton driven by MySiteViewModel that opportunistically warms EditorDependencyStore in the background. Supports idempotent preload, forced refresh (pull-to-refresh), and graceful cancellation.
  • Editor settings infrastructure — new EditorSettingsRepository and ThemeRepository for fetching editor capabilities and active theme data via WP API. Per-site preferences track whether the site supports editor settings and editor assets.
  • GutenbergKitSettingsBuilder refactor — converted from object to an injectable @Singleton class. Now reads "Use Theme Styles" and "Use Third-Party Blocks" from site settings to configure the editor. Builds an editor assets endpoint for both WP.com and self-hosted sites.
  • WpApiClient WP.com simple site supportWpApiClientProvider and SiteModel.getWpApiRestUrl() now handle WP.com simple sites that lack a self-hosted REST URL.

Testing instructions

Editor preloading on WP.com site:

  1. Open the app with a WP.com site selected
  2. Navigate to the My Site dashboard
  3. Open the block editor (create a new post)
  • Verify the editor opens without a visible loading delay for dependencies

Pull-to-refresh clears preloaded dependencies:

  1. Open the My Site dashboard
  2. Pull to refresh
  3. Open the block editor
  • Verify the editor still opens correctly with fresh dependencies

Editor configuration for self-hosted site with application password:

  1. Add a self-hosted site with an application password configured
  2. Open the block editor
  • Verify the editor loads with Basic auth and correct API root
  • Verify "Use Theme Styles" and "Use Third-Party Blocks" settings are respected

Theme styles and third-party blocks settings:

  1. Open Site Settings for a WP.com site
  2. Toggle "Use Theme Styles" off
  3. Open the block editor
  • Verify theme styles are not applied
  1. Toggle "Use Third-Party Blocks" on (if available)
  2. Open the block editor
  • Verify third-party block plugins are enabled

Local draft post ID handling:

  1. Create a new post (local draft)
  2. Open it in the block editor
  • Verify no remote post ID is sent to the editor for unsaved drafts

I tested against the following sites:

  • jetpack.wpmt.co (supports block assets and theme styles)
  • vanilla.wpmt.co (supports theme styles but not block assets)
  • cpt.wpmt.co (supports neither block assets nor theme styles)
  • wpmobile.wordpress.com (WP.com, supports both)

@jkmassel jkmassel changed the base branch from trunk to remove/login-lib February 10, 2026 16:29
@dangermattic
Copy link
Collaborator

dangermattic commented Feb 10, 2026

2 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ Class EditorServiceProviderImpl is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by 🚫 Danger

@jkmassel jkmassel changed the base branch from remove/login-lib to trunk February 10, 2026 16:31
@jkmassel jkmassel force-pushed the integrate/gutenberg-preloading branch from 2a49241 to 7d72605 Compare February 10, 2026 16:31
jkmassel and others added 9 commits February 10, 2026 09:32
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These are replaced by the simplified GutenbergKitSettingsBuilder and
the new GutenbergEditorPreloader in subsequent commits.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Inline the 18-parameter buildEditorConfiguration into
buildPostConfiguration, which now reads site/post fields directly from
SiteModel and PostImmutableModel. Also fixes a bug in shouldUsePlugins
where a stray `return false` made the method always return false.

Tests are updated to construct SiteModel objects instead of passing
individual primitives.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the old GutenbergKitConfig builder pattern with a simpler
buildEditorConfiguration that calls buildPostConfiguration and
customizes locale, cookies, plugins, theme styles, and network
logging via toBuilder().

Remove the ProgressBar from the editor layout since GutenbergView
manages its own loading visibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Preload editor dependencies (settings JSON, JS/CSS assets, API
preload data) in the background when the My Site screen loads, so
they are ready when the user opens the editor.

GutenbergEditorPreloader is a Dagger singleton that guards against
redundant work and caches results. The cache is cleared on
pull-to-refresh, which triggers a fresh preload.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire the fragment for Dagger injection via AppComponent so it can
read preloaded dependencies directly from GutenbergEditorPreloader
instead of receiving them through Bundle arguments.

Also use FrameLayout.LayoutParams when adding GutenbergView to
its container.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jkmassel jkmassel force-pushed the integrate/gutenberg-preloading branch from 7d72605 to e221a2a Compare February 10, 2026 16:32
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 10, 2026

Project dependencies changes

list
+ New Dependencies
org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3
org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.7.3

! Upgraded Dependencies
org.wordpress.gutenbergkit:android:316-34bc052ce3435b4189a4cbcec18d5d7b63ee34b3, (changed from v0.11.1)
tree
++--- androidx.navigation:navigation-compose:2.9.7
+|    \--- androidx.navigation:navigation-compose-android:2.9.7
+|         \--- androidx.activity:activity:1.8.0 -> 1.10.1
+|              \--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1 -> 2.10.0
+|                   \--- androidx.lifecycle:lifecycle-viewmodel-savedstate-android:2.10.0
+|                        \--- androidx.savedstate:savedstate:1.4.0
+|                             \--- androidx.savedstate:savedstate-android:1.4.0
+|                                  \--- org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.3
+|                                       \--- org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.7.3
+|                                            \--- org.jetbrains.kotlinx:kotlinx-serialization-bom:1.7.3
+|                                                 +--- org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.7.3 (c)
+|                                                 \--- org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3 (c)
 +--- project :libs:editor
-|    \--- org.wordpress.gutenbergkit:android:v0.11.1
-|         +--- org.jetbrains.kotlin:kotlin-parcelize-runtime:2.0.21 -> 2.2.21 (*)
-|         +--- androidx.core:core-ktx:1.13.1 -> 1.16.0 (*)
-|         +--- androidx.appcompat:appcompat:1.7.0 -> 1.7.1 (*)
-|         +--- com.google.android.material:material:1.12.0 (*)
-|         +--- androidx.webkit:webkit:1.11.0 -> 1.15.0 (*)
-|         +--- com.google.code.gson:gson:2.8.9 -> 2.13.2
-|         |    \--- com.google.errorprone:error_prone_annotations:2.41.0
-|         +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (*)
-|         \--- org.jetbrains.kotlin:kotlin-stdlib:2.0.21 -> 2.2.21 (*)
+|    \--- org.wordpress.gutenbergkit:android:316-34bc052ce3435b4189a4cbcec18d5d7b63ee34b3
+|         +--- org.jetbrains.kotlin:kotlin-parcelize-runtime:2.0.21 -> 2.2.21 (*)
+|         +--- androidx.core:core-ktx:1.13.1 -> 1.16.0 (*)
+|         +--- androidx.appcompat:appcompat:1.7.0 -> 1.7.1 (*)
+|         +--- com.google.android.material:material:1.12.0 (*)
+|         +--- androidx.webkit:webkit:1.11.0 -> 1.15.0 (*)
+|         +--- com.google.code.gson:gson:2.8.9 -> 2.13.2
+|         |    \--- com.google.errorprone:error_prone_annotations:2.41.0
+|         +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (*)
+|         +--- org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3
+|         |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.7.3
+|         |         +--- org.jetbrains.kotlinx:kotlinx-serialization-bom:1.7.3 (*)
+|         |         +--- org.jetbrains.kotlin:kotlin-stdlib:2.0.20 -> 2.2.21 (*)
+|         |         \--- org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.3 (*)
+|         +--- org.jsoup:jsoup:1.18.1 -> 1.22.1
+|         +--- com.squareup.okhttp3:okhttp:4.12.0 -> 5.3.2 (*)
+|         \--- org.jetbrains.kotlin:kotlin-stdlib:2.0.21 -> 2.2.21 (*)
-\--- org.wordpress.gutenbergkit:android:v0.11.1 (*)
+\--- org.wordpress.gutenbergkit:android:316-34bc052ce3435b4189a4cbcec18d5d7b63ee34b3 (*)

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 10, 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
FlavorJalapeno
Build TypeDebug
Versionpr22579-292aace
Build Number1484
Application IDorg.wordpress.android.prealpha
Commit292aace
Installation URL61va56bv4lndg
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 10, 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
FlavorJalapeno
Build TypeDebug
Versionpr22579-292aace
Build Number1484
Application IDcom.jetpack.android.prealpha
Commit292aace
Installation URL2d9u0719ac4tg
Note: Google Login is not supported on these builds.

dcalhoun and others added 12 commits February 10, 2026 12:55
Local draft posts have remotePostId defaulting to 0, which was
passed directly to GutenbergKit's setPostId(). GBK expects null
for unsaved posts. Now check isLocalDraft and pass null instead.
…utenbergKitEditorFragment

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…pper

Per-site boolean preference that caches whether a site supports the
wp-block-editor/v1/settings endpoint, used by EditorSettingsRepository.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Enable the actual editor settings support check (was returning false)
and persist results to AppPrefs. Add logging at every key point for
debugging: cache hits, API fetch results, and persistence.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Inject EditorSettingsRepository so the builder can query editor settings
support when configuring theme styles. Extract buildCachedHosts and
buildEditorAssetsEndpoint into named methods. Update GutenbergKitActivity
to use the injected instance and remove redundant builder overrides.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GutenbergEditorPreloader now fetches editor settings support before
building the editor configuration, ensuring the config reflects the
latest server state. GutenbergKitEditorFragment uses the preloaded
dependencies instead of passing null.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Check for both wp-block-editor/v1/settings and wpcom/v2/editor-assets
routes in a single API root request via fetchEditorCapabilitiesForSite.
Add getSupportsEditorAssetsForSite for reading the cached result.

Change all new pref methods to take SiteModel instead of a raw ID to
prevent misuse of siteId vs local ID. The prefs key internally using
the local database ID which is always unique across site types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fetch current theme during editor capability detection to determine
if it is a block theme, persisting the result alongside editor
settings and editor assets support. In Site Settings, show contextual
messages under "Use Theme Styles" when the site lacks editor settings
support (disabled) or when the active theme is not a block theme.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Read the actual checkbox value from the local site settings DB
instead of just checking whether the site supports editor settings.
Falls back to false when editor settings are not supported.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a new site setting that lets users control whether third-party
blocks and styles from installed plugins are loaded in the editor.
The setting is gated behind GutenbergKit being enabled and the site
supporting editor assets. Includes DB migration, settings UI toggle,
and integration with GutenbergKitSettingsBuilder.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `isWPComSimpleSite()` to SiteModel and use it to route WP.com
simple sites through the public-api.wordpress.com proxy with bearer
token authentication. This enables the Rust WP API client to make
authenticated requests for WPCom sites that don't use application
passwords.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove the requirement for a non-empty namespace when building the
editor assets endpoint URL. Self-hosted sites have an empty namespace
but the wpcom/v2/editor-assets endpoint is still valid for them.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jkmassel jkmassel added Menus Themes Testing Part of a WIP Feature This label is used to disable milestone checks for PRs that are not against `develop` or `release`. and removed /My site labels Feb 11, 2026
jkmassel and others added 7 commits February 11, 2026 10:54
Replace direct SiteSettingsTable.getSettings() calls in
GutenbergKitSettingsBuilder with an injectable SiteSettingsProvider
that returns SiteSettingsModel directly, encapsulating cursor
lifecycle in the implementation. Also fixes three pre-existing
test failures: editor assets endpoint tests now expect a URL
for self-hosted sites, and the app-password test uses a
Jetpack-connected site (the realistic scenario).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unused dependencies field and read() method from
EditorDependencyStore. Add checkstyle suppression comments
for WpComDotOrgApiUrlResolver references in WpApiClientProvider.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
EditorDependencyStore was a stateless wrapper around EditorService
with a single call site. Inline the two calls directly and delete
the class.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace single-site fields with a ConcurrentHashMap of sealed
PreloadState entries (Loading | Ready) keyed by site local ID.
This fixes a bug where switching sites discarded previously
preloaded dependencies, and eliminates the need for
withContext(mainDispatcher) thread-hopping. Add @mainthread
annotations to all public methods so Android Lint flags any
call-site violations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Accept SiteModel instead of nothing, store the site local ID as
a fragment argument, and use it to look up preloaded dependencies
from the multi-site cache in GutenbergEditorPreloader.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jkmassel and others added 5 commits February 11, 2026 12:36
Inline the logic from SiteUtils.isBlockEditorDefaultForNewPost into
SiteSettingsProviderImpl so the preloader can use it via injection
rather than a static call. Deprecate the old static methods and
suppress warnings at the three remaining call sites.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wrap the static EditorService.create() + prepare() calls behind an
injectable interface so GutenbergEditorPreloader can be tested with
a mock.  Wire the binding through Hilt in PostModule.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
19 tests covering: feature gating, successful preload, failure
cleanup, deduplication (completed and in-flight), scope cancellation
recovery, multi-site caching, refresh, and clear semantics.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The custom DoNotMockDataClass lint rule flags mocking of data classes.
Construct real ThemeWithEditContext instances via a buildTheme() helper
instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Six tests covering the isBlockEditorDefault decision matrix: null/empty
editor, gutenberg editor, non-gutenberg on self-hosted, WPCom simple,
and WPCom Atomic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DoNotMockDataClass lint rule flagged the @mock annotation on
EditorDependencies. Use EditorDependencies.empty for the shared
field and construct a real instance for the refresh test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 48.67550% with 155 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.22%. Comparing base (e4d4571) to head (292aace).
⚠️ Report is 9 commits behind head on trunk.

Files with missing lines Patch % Lines
...s/android/repositories/EditorSettingsRepository.kt 0.00% 73 Missing ⚠️
...fluxc/network/rest/wpapi/rs/WpApiClientProvider.kt 0.00% 19 Missing ⚠️
.../java/org/wordpress/android/ui/prefs/AppPrefs.java 0.00% 12 Missing ⚠️
...ss/android/ui/posts/GutenbergKitSettingsBuilder.kt 87.50% 4 Missing and 6 partials ⚠️
...press/android/datasets/SiteSettingsProviderImpl.kt 35.71% 9 Missing ⚠️
...i/navmenus/screens/ObserveScrollDirectionForFab.kt 0.00% 6 Missing ⚠️
...ress/android/ui/posts/EditorServiceProviderImpl.kt 0.00% 6 Missing ⚠️
.../org/wordpress/android/ui/prefs/AppPrefsWrapper.kt 0.00% 6 Missing ⚠️
...rg/wordpress/android/models/SiteSettingsModel.java 0.00% 4 Missing ⚠️
.../wordpress/android/repositories/ThemeRepository.kt 83.33% 2 Missing ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #22579      +/-   ##
==========================================
+ Coverage   38.18%   38.22%   +0.04%     
==========================================
  Files        2238     2241       +3     
  Lines      111772   111864      +92     
  Branches    15585    15598      +13     
==========================================
+ Hits        42680    42762      +82     
- Misses      65551    65553       +2     
- Partials     3541     3549       +8     

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

Point to GutenbergKit PR #316 build artifact for WP Android
integration support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link

@jkmassel jkmassel marked this pull request as ready for review February 12, 2026 19:22
@jkmassel jkmassel requested a review from a team as a code owner February 12, 2026 19:22
@jkmassel jkmassel requested review from adalpari and dcalhoun and removed request for a team February 12, 2026 19:22
@jkmassel jkmassel added this to the 26.6 milestone Feb 12, 2026
Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

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

Thank you for implementing this! 🙇🏻‍♂️

I was unable to fully test the implementation due to the issues noted in inline comments and in wordpress-mobile/GutenbergKit#316 (review). They kept me from truly experiencing the intended functionality.

In addition to the inline comments here, I was unable to upload new media or attach Media Library items to block. When I attempted to do so, the media never displayed in the block editor canvas, the block remained as a placeholder. There were no logs in the Android Studio or Chrome console. 😕

Hopefully we can identify the root cause for some of these foundational problems and I can perform deeper testing afterwards.

)
} else {
WpAuthenticationProvider.staticWithUsernameAndPassword(
username = site.apiRestUsernamePlain,
Copy link
Member

Choose a reason for hiding this comment

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

I encountered a crash when opening the editor for the time with a Wow/Atomic site. GBK and plugins features were enabled. Before opening the editor, I created an application password for the site via tapping the prompt atop the My Site view.

Stack trace
FATAL EXCEPTION: DefaultDispatcher-worker-6 (Fix with AI)
Process: com.jetpack.android.beta, PID: 3797
java.lang.NullPointerException: getApiRestUsernamePlain(...) must not be null
	at org.wordpress.android.fluxc.network.rest.wpapi.rs.WpApiClientProvider.getWpApiClient(WpApiClientProvider.kt:43)
	at org.wordpress.android.fluxc.network.rest.wpapi.rs.WpApiClientProvider.getWpApiClient$default(WpApiClientProvider.kt:32)
	at org.wordpress.android.repositories.ThemeRepository$fetchCurrentTheme$2.invokeSuspend(ThemeRepository.kt:27)
	at org.wordpress.android.repositories.ThemeRepository$fetchCurrentTheme$2.invoke(Unknown Source:8)
	at org.wordpress.android.repositories.ThemeRepository$fetchCurrentTheme$2.invoke(Unknown Source:4)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndspatched(Undispatched.kt:66)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:43)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1)
	at org.wordpress.android.repositories.ThemeRepository.fetchCurrentTheme(ThemeRepository.kt:26)
	at org.wordpress.android.repositories.EditorSettingsRepository.fetchThemeBlockStyleSupport(EditorSettingsRepository.kt:162)
	at org.wordpress.android.repositories.EditorSettingsRepository.access$fetchThemeBlockStyleSupport(EditorSettingsRepository.kt:19)
	at org.wordpress.android.repositories.EditorSettingsRepository$fetchEditorCapabilitiesForSite$2$1$2.invokeSuspend(EditorSettingsRepository.kt:110)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:124)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@4908726, Dispatchers.IO]

This did not occur in the prototype build, only a local build. After it occurred, I app continued to crash on launch, presumably the same site remains selected on My Site.

Comment on lines +1045 to +1047
mUseThirdPartyBlocksPref =
(WPSwitchPreference) getChangePref(R.string.pref_key_use_third_party_blocks);
mUseThirdPartyBlocksPref.setChecked(mSiteSettings.getUseThirdPartyBlocks());
Copy link
Member

Choose a reason for hiding this comment

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

This was unexpectedly disabled for my WP.com Simple site.

Disabled third-party plugins toggle

Image

Copy link
Member

Choose a reason for hiding this comment

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

Additionally, when I enabled this option for a newly added jetpack.wpmt.co site, I encountered a crash.

Stack trace
FATAL EXCEPTION: main (Fix with AI)
Process: com.jetpack.android.beta, PID: 30058
java.lang.AssertionError: Cannot get asset path from empty bundle
	at org.wordpress.gutenberg.model.EditorAssetBundle.assetDataPath(EditorAssetBundle.kt:137)
	at org.wordpress.gutenberg.model.EditorAssetBundle.hasAssetData(EditorAssetBundle.kt:120)
	at org.wordpress.gutenberg.CachedAssetRequestInterceptor.handleRequest(CachedAssetRequestInterceptor.kt:48)
	at org.wordpress.gutenberg.GutenbergView$initializeWebView$1.shouldInterceptRequest(GutenbergView.kt:395)
	at WV.og.a(chromium-SystemWebViewGoogle6432.aab-stable-755913303:101)
	at org.chromium.android_webview.ShouldInterceptRequestMediator.shouldInterceptRequestFromNative(chromium-SystemWebViewGoogle6432.aab-stable-755913303:18)

Using the pull-to-refresh gesture on My Site seems to address it. I was able to then open the editor and see Jetpack blocks.

Comment on lines +441 to +444
if (isWPComSimpleSite()) {
return "https://public-api.wordpress.com/wp/v2/sites/"
+ mSiteId;
}
Copy link
Member

Choose a reason for hiding this comment

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

I asked Claud to assess if this might introduce unexpected behavior elsewhere if existing callers expect a null value. It seems to think it is OK.

Claude's findings
  Summary

  ┌──────────┬────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────┐
  │ Severity │              File              │                                    Issue                                    │
  ├──────────┼────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────┤
  │ Medium   │ CookieNonceAuthenticator       │ Null-check-based discovery/retry logic broken for WP.com simple sites       │
  ├──────────┼────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────┤
  │ Medium   │ ReactNativeStore               │ Same null-check-based discovery/retry logic broken                          │
  ├──────────┼────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────┤
  │ Low      │ WpApiClientProvider.buildUrl() │ Intentional change, but affects getWpApiClientCookiesNonceAuthentication()  │
  ├──────────┼────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────┤
  │ None     │ All other callers              │ Either write-only, guarded by isUsingSelfHostedRestApi, or in the PR itself │
  └──────────┴────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────┘

  Recommendation

  The practical risk is low because CookieNonceAuthenticator and ReactNativeStore are only used for self-hosted/cookie-nonce auth flows, and WP.com simple
  sites shouldn't reach those code paths. However, the semantic change to the getter is a landmine for future code — anyone writing if (site.wpApiRestUrl !=
  null) as a guard for "has a real persisted REST URL" will silently get wrong behavior for WP.com simple sites.

  Consider either:
  1. Adding a separate method like getEffectiveWpApiRestUrl() for the synthesized URL and leaving getWpApiRestUrl() as a pure field accessor, or
  2. Adding a hasPersistedWpApiRestUrl() method that checks the raw field, so callers that need to distinguish "synthesized" from "persisted" can do so
  explicitly.

Comment on lines +160 to +168
private fun getUseThirdPartyBlocks(site: SiteModel): Boolean {
if (!editorSettingsRepository
.getSupportsEditorAssetsForSite(site)
) {
return false
}
return siteSettingsProvider
.getSettings(site)?.useThirdPartyBlocks ?: false
}
Copy link
Member

Choose a reason for hiding this comment

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

Should we have this continue to respect the remote gutenberg_kit_plugins feature flag?

Comment on lines +1110 to +1114
// hide third-party blocks preference if GutenbergKit is not enabled
if (!mGutenbergKitFeatureChecker.isGutenbergKitEnabled()) {
WPPrefUtils.removePreference(
this, R.string.pref_key_site_editor, R.string.pref_key_use_third_party_blocks
);
Copy link
Member

Choose a reason for hiding this comment

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

Should we also hide this if the remote gutenberg_kit_plugins feature flag is disabled?

<string name="site_settings_use_theme_styles_unsupported">Install the Gutenberg Plugin on your site to activate theme style support.</string>
<string name="site_settings_use_theme_styles_not_block_theme">Your site isn\'t using a Block Theme, so the editor might not match your content correctly. If things aren\'t looking right, you can disable editor styles.</string>
<string name="site_settings_use_third_party_blocks">Use Third-Party Blocks (Beta)</string>
<string name="site_settings_use_third_party_blocks_summary">Load third-party blocks and styles from plugins installed on your site.</string>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe styles is superfluous? Blocks include the styles. Are there editor plugins that load styles without blocks? Does it impact GBK?

Suggested change
<string name="site_settings_use_third_party_blocks_summary">Load third-party blocks and styles from plugins installed on your site.</string>
<string name="site_settings_use_third_party_blocks_summary">Load third-party blocks from plugins installed on your site.</string>

Comment on lines +222 to +229
gutenbergView.setLatestContentProvider(
object : GutenbergView.LatestContentProvider {
override fun getLatestContent():
GutenbergView.LatestContent? {
return null
}
}
}
)
Copy link
Member

Choose a reason for hiding this comment

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

Is this a non-functioning placeholder for integrating #22493?

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. Menus Part of a WIP Feature This label is used to disable milestone checks for PRs that are not against `develop` or `release`. Performance Testing Themes unit-tests-exemption

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments