Skip to content

Conversation

@dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Apr 9, 2025

Fetch and cache editor settings before providing them to the editor, as it
allows improving offline support. The changes also communicate the
background activity with an activity indicator.

Ref CMM-200.

Related:

To Test:

Important

Ensure the following experimental features are enabled:

  • Experimental block editor
  • Experimental block editor styles

1: Initial editor fallbacks to default settings

  1. Enable airplane mode.
  2. Open the post editor.
  3. Verify the editor loads, using default settings—e.g., white background with black text.

2: Editor fetches site-specific settings

  1. Disable airplane mode.
  2. Open the post editor.
  3. Verify the editor loads with site-specific settings—e.g., the theme's background and foreground colors.

3: Editor fallback to cached settings

  1. Enable airplane mode.
  2. Open the post editor.
  3. Verify the editor loads with site-specific settings—e.g., the theme's background and foreground colors.

Regression Notes

  1. Potential unintended areas of impact
    Regressions in Gutenberg Mobile or Aztec editors.
  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Manually smoke tested the editors.
  3. What automated tests I added (or what prevented me from doing so)
    Deemed unnecessary for the experimental editor.

PR Submission Checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing Checklist (strike-out the not-applying and unnecessary ones):

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • Talkback.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • Large and small screen sizes. (Tablet and smaller phones)
  • Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

@dangermattic
Copy link
Collaborator

dangermattic commented Apr 9, 2025

7 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ Class EditorSettings is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class EditorSettingsSqlUtils is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class EditorSettingsStore is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class FetchEditorSettingsPayload is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class EditorSettingsError is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@dcalhoun dcalhoun force-pushed the feat/provide-editor-settings branch from a2d6293 to 26d42ef Compare April 9, 2025 19:13
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 9, 2025

Project dependencies changes

list
! Upgraded Dependencies
org.wordpress.gutenbergkit:android:trunk-fa72e630203e7472d55f4abedfd5c462d2333584, (changed from trunk-a03e0dae10a404c88c215bfcee3176df951302f5)
tree
 +--- project :libs:editor
-|    \--- org.wordpress.gutenbergkit:android:trunk-a03e0dae10a404c88c215bfcee3176df951302f5
+|    \--- org.wordpress.gutenbergkit:android:trunk-fa72e630203e7472d55f4abedfd5c462d2333584
-\--- org.wordpress.gutenbergkit:android:trunk-a03e0dae10a404c88c215bfcee3176df951302f5 (*)
+\--- org.wordpress.gutenbergkit:android:trunk-fa72e630203e7472d55f4abedfd5c462d2333584 (*)

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 9, 2025

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr21791-d99dc81
Commitd99dc81
Direct Downloadwordpress-prototype-build-pr21791-d99dc81.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 9, 2025

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr21791-d99dc81
Commitd99dc81
Direct Downloadjetpack-prototype-build-pr21791-d99dc81.apk
Note: Google Login is not supported on these builds.

Comment on lines +3642 to +3649
if (editorFragment !is GutenbergKitEditorFragment) {
refreshEditorContent()
}
Copy link
Member Author

Choose a reason for hiding this comment

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

The timing of this content refresh is currently incompatible with/unnecessary for GutenbergKit.

annotation class AddOn

override fun getDbVersion(): Int {
return 204
Copy link
Member Author

Choose a reason for hiding this comment

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

Noting that a 204 migration did not exist. I do not believe this is a problem, but noting it just in case.

Copy link
Member Author

Choose a reason for hiding this comment

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

This store was built based on the existing EditorThemeStore.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dcalhoun I'm curious why we have this duplication with EditorThemeStore? Do we need two separate stores for editor settings?

Copy link
Member Author

Choose a reason for hiding this comment

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

@nbradbury it's an attempt to mitigate regressions.

When the GutenbergKit implementation first began, we colocated much of the new logic with existing editor logic; this included introducing a good amount of branching logic to exiting code. In retrospect, we deemed this misguided, as every change we made in the advancement of GutenbergKit meant the possibility of a regression in the Gutenberg Mobile and Aztec editors. We ultimately separated a good amount of the logic in #21493.

Duplicating EditorThemeStore to EditorSettings felt appropriate for continuing that separation practice, it also allowed for a simpler implementation for GutenbergKit.

@dcalhoun dcalhoun changed the title refactor: Provide GutenbergKit editor settings refactor: Fetch and cache GutenbergKit editor settings Apr 11, 2025
@codecov
Copy link

codecov bot commented Apr 11, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 39.32%. Comparing base (ad0b027) to head (d99dc81).
Report is 1 commits behind head on trunk.

Files with missing lines Patch % Lines
...rdpress/android/fluxc/persistence/WellSqlConfig.kt 25.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #21791   +/-   ##
=======================================
  Coverage   39.32%   39.32%           
=======================================
  Files        2125     2125           
  Lines       99871    99871           
  Branches    15385    15385           
=======================================
  Hits        39277    39277           
  Misses      57114    57114           
  Partials     3480     3480           

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

@dcalhoun dcalhoun marked this pull request as ready for review April 12, 2025 01:14
@dcalhoun dcalhoun requested a review from nbradbury April 12, 2025 01:15
@nbradbury nbradbury self-assigned this Apr 14, 2025
@nbradbury
Copy link
Contributor

nbradbury commented Apr 14, 2025

@dcalhoun This isn't something that needs to be addressed here, especially since EditorThemeStore already does this, but I wanted to caution against storing raw JSON in the database. I think it was with WCAndroid where we encountered users getting SQLiteBlobTooBigException due to plugins adding a ton of baggage to JSON responses.

Semi-related, we may want to make use of the fields parameter to limit the response to just the fields we use. The response is only ~5KB in this case so it's not huge, but it would be more efficient for storage.

response

@dcalhoun
Copy link
Member Author

This isn't something that needs to be addressed here, especially since EditorThemeStore already does this, but I wanted to caution against storing raw JSON in the database. I think it was with WCAndroid where we encountered users getting SQLiteBlobTooBigException due to plugins adding a ton of baggage to JSON responses.

@nbradbury thank you for the feedback. This is a great point. I believe the WP-Android app suffers from similar exceptions in certain contexts.

Semi-related, we may want to make use of the fields parameter to limit the response to just the fields we use. The response is only ~5KB in this case so it's not huge, but it would be more efficient for storage.

Leveraging the _fields parameter may be a good option. I have not reviewed which fields are applicable to GutenbergKit at this time; doing so is a good optimization opportunity to pursue later.

Is there an alternative persistence layer to SQLite that makes sense for this specific feature? Or is SQLite the best choice? For context, the data is site-specific and should likely persist at least a few days.

@nbradbury
Copy link
Contributor

Is there an alternative persistence layer to SQLite that makes sense for this specific feature? Or is SQLite the best choice?

I recommend sticking with SQLite, especially for this feature since the data isn't unreasonably large. I've heard other devs recommend storing the data in a separate file and write the filename to the database, but I've never felt the need to do that.

Copy link
Contributor

@nbradbury nbradbury left a comment

Choose a reason for hiding this comment

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

Looks good! :shipit:

@dcalhoun
Copy link
Member Author

@nbradbury thank you for the review. Did you have time to also review the sibling PR: wordpress-mobile/GutenbergKit#114?

@dcalhoun dcalhoun force-pushed the feat/provide-editor-settings branch from bf0f0ca to 234d290 Compare April 21, 2025 15:09
Communicate active background work to the user.
Improve offline support and performance.
@dcalhoun dcalhoun force-pushed the feat/provide-editor-settings branch from 234d290 to 6064d99 Compare April 24, 2025 20:05
dcalhoun added 13 commits April 24, 2025 16:08
Match caching strategy for other FluxC stores.
This is the expected ID value for the Gutenberg editor.
Now that we await the editor settings, we should postpone starting the
editor. This means we only start the editor once.
Ensure the editor continues launching if retrieving site-specific editor
settings fails.
Apply the cached settings rather than the default settings, if
available.
@dcalhoun dcalhoun force-pushed the feat/provide-editor-settings branch from 6064d99 to d99dc81 Compare April 24, 2025 20:08
@sonarqubecloud
Copy link

@dcalhoun dcalhoun merged commit 19e4ecd into trunk Apr 24, 2025
24 of 26 checks passed
@dcalhoun dcalhoun deleted the feat/provide-editor-settings branch April 24, 2025 20:33
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. [Type] Enhancement unit-tests-exemption

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants