Skip to content

feat: Implement LatestContentProvider for WebView recovery#22774

Merged
jkmassel merged 3 commits intojkmassel/gutenbergkit-settings-refactorfrom
feat/gutenberg-kit-pulls-content-rebased
Apr 8, 2026
Merged

feat: Implement LatestContentProvider for WebView recovery#22774
jkmassel merged 3 commits intojkmassel/gutenbergkit-settings-refactorfrom
feat/gutenberg-kit-pulls-content-rebased

Conversation

@dcalhoun
Copy link
Copy Markdown
Member

@dcalhoun dcalhoun commented Apr 7, 2026

Description

Ref CMM-1123.

This is a rebased version of #22493 (which was tested and approved). This now targets the jkmassel/gutenbergkit-settings-refactor branch (#22764) so it can be reviewed/tested on top of the GutenbergKit v0.15.0 upgrade.

Implements GutenbergKit's LatestContentProvider interface for pull-based content recovery.

When the WebView reinitializes (due to OS memory pressure or page refresh), the editor now requests the latest content from the app rather than using stale content from the initial WebView load. This ensures users don't lose their work during WebView recovery.

Changes:

  • Added getPersistedTitle() and getPersistedContent() methods to EditorFragmentListener interface
  • Set up LatestContentProvider on GutenbergView in GutenbergKitEditorFragment
  • Implemented the interface methods in GutenbergKitActivity returning content from EditPostRepository
  • Properly set the post status to avoid unexpectedly emptying post titles

Rebase notes:

  • Dropped 3 obsolete GutenbergKit version-bump commits (target branch already updates to v0.15.0)
  • Dropped the warmup-helper fix commit (warmup is a no-op stub on the new branch pending re-implementation against the v0.15.0 API)
  • Adapted EditorConfigurationBuilder to the new builder API: setStatus(...)setPostStatus(...) and removed the now-redundant setPostType(...) call (postType is a constructor argument)

Related PRs:

Testing instructions

WebView refresh recovery:

  1. Open a post with existing content in the GutenbergKit editor
  2. Make edits to the content (wait 2+ seconds for autosave to persist)
  3. Trigger a WebView refresh: press Cmd+R while the WebView is inspected via the Chrome Inspector at chrome://inspect
  • Verify the editor recovers with the edited content, not the original

dcalhoun added 2 commits April 7, 2026 15:59
Allow GutenbergKit to retrieve the latest content persisted in the host
app as needed. This is important for allowing GutenbergKit to display
the latest content after the WebView reloads or re-initializes from
memory pressure or backgrounding.
@dcalhoun dcalhoun added [Type] Enhancement Posting/Editing Gutenberg Editing and display of Gutenberg blocks. labels Apr 7, 2026
@dcalhoun dcalhoun added this to the 26.8 milestone Apr 7, 2026
@dcalhoun dcalhoun changed the title feat: Implement LatestContentProvider for WebView recovery (rebased on #22764) feat: Implement LatestContentProvider for WebView recovery Apr 7, 2026
@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented Apr 7, 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
Versionpr22774-700d23b
Build Number1488
Application IDcom.jetpack.android.prealpha
Commit700d23b
Installation URL4hkvmjvqrv1pg
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 7, 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
Versionpr22774-700d23b
Build Number1488
Application IDorg.wordpress.android.prealpha
Commit700d23b
Installation URL7v15g0tt64pp0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.40%. Comparing base (6cfa2a2) to head (700d23b).
⚠️ Report is 1 commits behind head on jkmassel/gutenbergkit-settings-refactor.

Files with missing lines Patch % Lines
...ss/android/ui/posts/GutenbergKitSettingsBuilder.kt 60.00% 2 Missing ⚠️
...ess/android/ui/posts/EditorConfigurationBuilder.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                           Coverage Diff                            @@
##           jkmassel/gutenbergkit-settings-refactor   #22774   +/-   ##
========================================================================
  Coverage                                    37.40%   37.40%           
========================================================================
  Files                                         2320     2320           
  Lines                                       123654   123658    +4     
  Branches                                     16793    16795    +2     
========================================================================
+ Hits                                         46256    46258    +2     
- Misses                                       73687    73689    +2     
  Partials                                      3711     3711           

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

Integrate an unrelated content loss fix that is necessary for testing
this branch's focus on content preservation.
gravatar = '2.5.0'
greenrobot-eventbus = '3.3.1'
gutenberg-kit = 'v0.15.0'
gutenberg-kit = '432-944fbfce704642cfe725dc69c03b3cf6d5018854'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This integrates the bug fix from wordpress-mobile/GutenbergKit#432, which is required for testing the LatestContentProvider's ability to preserve content persistence through WebView reloads.

Once wordpress-mobile/GutenbergKit#432 merges, this should be updated to point to a new release containing that fix.

@wpmobilebot
Copy link
Copy Markdown
Contributor

Project dependencies changes

list
! Upgraded Dependencies
org.wordpress.gutenbergkit:android:432-944fbfce704642cfe725dc69c03b3cf6d5018854, (changed from v0.15.0)
tree
 +--- project :libs:editor
-|    \--- org.wordpress.gutenbergkit:android:v0.15.0
+|    \--- org.wordpress.gutenbergkit:android:432-944fbfce704642cfe725dc69c03b3cf6d5018854
-\--- org.wordpress.gutenbergkit:android:v0.15.0 (*)
+\--- org.wordpress.gutenbergkit:android:432-944fbfce704642cfe725dc69c03b3cf6d5018854 (*)

@dcalhoun dcalhoun marked this pull request as ready for review April 8, 2026 15:42
@dcalhoun dcalhoun requested a review from a team as a code owner April 8, 2026 15:42
@dcalhoun dcalhoun requested review from adalpari and jkmassel and removed request for a team and adalpari April 8, 2026 15:42
Copy link
Copy Markdown
Contributor

@jkmassel jkmassel left a comment

Choose a reason for hiding this comment

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

Tested on-device, no data loss

* Returns the persisted post title for content recovery after WebView refresh.
* @return The most recently persisted title from autosave.
*/
String getPersistedTitle();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Because this is a Java file, we should have @ NonNull for this (and getPersistedContent)

@jkmassel jkmassel merged commit 0203851 into jkmassel/gutenbergkit-settings-refactor Apr 8, 2026
24 checks passed
@jkmassel jkmassel deleted the feat/gutenberg-kit-pulls-content-rebased branch April 8, 2026 16:40
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. Posting/Editing [Type] Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants