Skip to content

build: update GutenbergKit to v0.20.0-alpha.1 - #26267

Merged
dcalhoun merged 17 commits into
trunkfrom
build/update-gutenberg-kit
Oct 30, 2026
Merged

dcalhoun merged 17 commits into
trunkfrom
build/update-gutenberg-kit

Conversation

@dcalhoun

@dcalhoun dcalhoun commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Description

Close CMM-2554.

Updates GutenbergKit to 0.20.0-alpha.1 and adopts its breaking and new host APIs:

  • Editor crashes: implements the now-required unavailable callback. Undo, redo and Code Editor are disabled until the editor reloads. Custom posts reload from their last saved content and can be closed without the editor's content.
  • Media uploads: saving while the editor locks saving (e.g. during a media upload) asks for confirmation first, since the content may be incomplete. The user stays in control, so a plugin that never releases its lock can't block saving. Closing mid-upload also asks, since the upload stops with the editor. Leaving then runs the normal close flow.
  • Translations: localizes GutenbergKit's new crash and media error strings.

Media upload server setup is handled separately.

Known gaps (deferred):

  • Saving mid-upload: choosing Continue, or Save Draft from the close sheet after Leave, saves an empty Image block or a Cover or Media & Text blob: URL. Trunk saved these without asking.
  • Crash mid-upload: a crash clears the save lock, but the local copy can still hold a blob: URL, which a later save sends without asking. The fix likely belongs in GutenbergKit, which knows when a block's media is temporary.
  • Multi-file upload failure: Gutenberg uses one save lock per upload call and releases it when any file fails, while the other files keep uploading. Core blocks upload one file per call, but Jetpack's Slideshow uploads several in one call, so a failed file means saving and closing skip the alerts. The fix belongs in Gutenberg; the host only gets a boolean.
  • Lock reasons: Gutenberg core's only public selector, isPostSavingLocked(), returns a boolean, so GutenbergKit can't report why saving is locked. A plugin's lock (e.g. a Jetpack Donations block whose Stripe fetch failed) gets the same "like a media upload" confirmation.
  • Custom post Save Draft after a crash: with changed post settings, Save Draft is still offered after a crash and fails with an error. Nothing is lost. Trunk does the same.
  • Tests: the save and Leave alerts are unit tested, but the close and Leave flows that show them aren't.

Testing instructions

Use the Jetpack app on a site with the block editor enabled. The editor's web view is inspectable in debug builds.

Steps that run JavaScript use Safari's Develop menu: choose the device or simulator, then the editor page, and run the snippet in the console.

To crash the editor:

wp.data.select( 'core/editor' ).getEditorMode = () => { throw new Error( 'Test crash' ); };
wp.data.dispatch( 'core/editor' ).updateEditorSettings( {} );

Autofocus:

  1. Open an existing post.
  • Verify the keyboard stays hidden.
  1. Close it, then create a new post.
  • Verify the caret is in the title.

Editor crash and reload:

  1. Open an existing post and type some text.
  • Verify undo is enabled.
  1. Crash the editor with the snippet above.
  • Verify the editor shows "The editor stopped working" with a Reload Editor button.
  • Verify undo and redo are disabled.
  • Verify Code Editor in the "…" menu is disabled.
  1. Tap Reload Editor.
  • Verify the editor reloads with the text you typed.
  • Verify Code Editor is enabled again, and undo becomes enabled after the next edit.
  1. Close the post without saving your changes to the server.

Save lock during media uploads:

  1. Create a new post and insert an Image block. Throttle the network (e.g. Network Link Conditioner) and upload a large image.
  2. While it uploads, tap Publish, then Save Draft and Preview in the "…" menu, tapping Keep Editing each time.
  • Verify each asks "Your post isn't ready yet", and Keep Editing does nothing else.
  1. Tap Publish again, then Continue.
  • Verify the publishing sheet opens. Dismiss it.
  1. Wait for the upload to finish, then tap Publish.
  • Verify the publishing sheet opens without asking. Dismiss it.

To test without a real upload, run wp.data.dispatch( 'core/editor' ).lockPostSaving( 'test' ) before step 2, and unlockPostSaving( 'test' ) before step 4.

  1. Repeat step 2 in a page.
  • Verify the alert says "Your page isn't ready yet".

Closing during an upload:

  1. Open a published post, make an edit, then start an image upload as above (or lock saving). While it uploads, tap Close.
  • Verify a "Your post isn't ready yet" alert appears, offering Keep Editing and Leave.
  1. Tap Keep Editing.
  • Verify the editor stays open.
  1. Tap Close again, then Leave.
  • Verify the close sheet offers Discard Changes but not Save Draft. Tap Discard Changes.
  1. Reopen the post.
  • Verify your edit is gone.
  1. Repeat steps 1 and 3 with a draft.
  • Verify the close sheet offers Discard Changes and Save Draft.
  1. Make an edit and tap Close with saving unlocked.
  • Verify the close sheet appears instead of the alert.

Custom post types

  1. Create a new custom post, make an edit, and lock saving with lockPostSaving as above.
  • Verify Publish, Save Draft in the "…" menu, and Save Draft on the close sheet each ask "Your post isn't ready yet" first.
  1. Tap Close.
  • Verify a "Your post isn't ready yet" alert offers Keep Editing and Leave, and Leave shows the close sheet, whose Save Draft doesn't ask again.
  1. Unlock saving.
  • Verify Publish opens the publishing sheet without asking.
  1. Crash the editor, then close it.
  • Verify Publish is disabled and closing offers only Discard Changes.

AI-generated details

Integrates GutenbergKit v0.20.0-alpha.1 (previously 0.19.0). Setting up GutenbergKit's media upload server is out of scope and handled separately.

Host changes

  • Implements the required editorDidBecomeUnavailable(_:) (fix!: reset host readiness when the editor crashes GutenbergKit#638, feat: surface editor crashes natively and offer a reload GutenbergKit#642). Undo, redo and the editor mode toggle are disabled until the editor reloads, and custom posts can't be saved meanwhile.
  • Custom posts reload from their last saved content. They can be closed even when the editor can't report its content.
  • Localizes GutenbergKit's crash notice and block inserter media error strings.
  • Save availability (feat: report save availability to the host GutenbergKit#792): while the editor locks saving (e.g. during a media upload), a GBK-only alert asks before saving, with Keep Editing and Continue:
    • posts: Publish, Update, Submit for Review, Save Draft and Preview. The shared isUploadingMedia guards no longer apply to GBK, so Aztec and Gutenberg Mobile are unchanged. Closing asks too, because the editor's uploads stop when it closes. Leaving refreshes the content and runs the normal close flow, so published posts still offer only Discard Changes, as on trunk and in Gutenberg Mobile.
    • custom posts: Publish, Update and both Save Draft actions. Closing shows the same Leave alert as posts, so replacing a block's media (which doesn't change the saved markup) can't be dropped silently.
    • Pages say "Your page isn't ready yet"; posts and custom post types say "post", as "Post Settings" does.
    • A lock is advisory rather than blocking, unlike core on the web, because GutenbergKit doesn't report a lock's reason and a plugin can hold one for the whole session. Jetpack's Donations block does this when its Stripe status fetch fails (donations/edit.jsx:147-149).

Why the blob: gaps are deferred

While uploading, Image, Video, Audio and File blocks keep their blob: URL in an attribute that isn't saved. Cover and Media & Text blocks do save it. Gutenberg Mobile avoids this because the host uploads media natively and PostCoordinator waits for uploads before syncing. GutenbergKit uploads in the web view, so the host can't wait for them.

Two host-side fixes were considered and rejected:

  • Skipping Core Data autosaves while saving is locked would lose edits made during an upload if the editor crashes. Crashes are most likely during large uploads.
  • Blocking saves when the content contains a blob: URL relies on matching URLs in the content, which is brittle.

After a reload, the Cover block shows a spinner forever for a blob: URL without a media ID. GutenbergKit could flag those blocks instead.

Verified

  • Build and the PostGBKEditorViewControllerTests, CustomPostEditorServiceTests and CustomPostSettingsViewModelTests suites (33 tests) under the WordPress scheme. The Jetpack scheme has no test plan.
  • Smoke test in the Jetpack app on a WP Cloud site, against the GutenbergKit trunk dev server:
    • An existing draft opens without autofocus, and a new post autofocuses the title.
    • A forced crash shows the localized notice and disables undo, redo and the code editor. Reload restores the latest content.
  • Smoke test of the final changes in the Jetpack app (iOS 27.0 simulator, WP Cloud site), locking saving with lockPostSaving:
    • New post: Publish, Save Draft and Preview each asked "Your post isn't ready yet". Keep Editing did nothing else, and Continue opened the publishing sheet. Once unlocked, Publish opened the sheet without asking.
    • Closing while locked showed the Leave alert. Keep Editing stayed, and Leave showed the close sheet with Discard Draft and Save Draft.
    • Published post: Update asked first. After Leave, the close sheet offered only Discard Changes, and reopening showed the edit was gone.
    • Custom post (Book): Publish (then Continue to the publishing sheet), the "…" menu's Save Draft and the close sheet's Save Draft each asked first. After a crash, Publish was disabled and closing offered only Discard Changes.
    • Not smoke tested yet: the custom post Leave alert and the page title, both added after this run.
  • The Jetpack app builds against 0.20.0-alpha.1, and its packaged web bundle is identical to a local build of GutenbergKit trunk.

🤖 Generated with Claude Code

https://claude.ai/code/session_017NCdQuHPbc49BP1ZshDSE8

@dangermattic

Copy link
Copy Markdown
Collaborator
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@dcalhoun dcalhoun changed the title build: integrate the latest GutenbergKit trunk build: update GutenbergKit to v0.20.0-alpha.1 Oct 28, 2026
@dcalhoun
dcalhoun force-pushed the build/update-gutenberg-kit branch from aa066c5 to df52238 Compare October 28, 2026 17:35
dcalhoun and others added 17 commits October 29, 2026 14:29
Pins the pr-build/839 snapshot, which has trunk's Swift sources and a prebuilt web bundle that trunk revisions lack, until a GutenbergKit prerelease is published.
GutenbergKit now requires delegates to implement editorDidBecomeUnavailable(_:), with no default, so a subclass override is never silently skipped.
GutenbergKit added strings for its editor crash notice and block inserter media errors, which otherwise appear in English.
After a crash, GutenbergKit refuses calls into the editor until it reloads, so undo, redo, the editor mode toggle, and custom post saving would silently do nothing.
GutenbergKit restarts a reloaded editor from the host's latest content, or from the content it opened with when there is none, which would discard drafts saved earlier in the session.
Closing read the content from the editor and gave up when it couldn't, so an editor that was still loading, failed to load, or crashed couldn't be closed.
…saving

GutenbergKit now reports when saving is locked, e.g. during its media uploads, whose temporary URLs would otherwise be saved. Saves show the existing media-uploading alert, and closing keeps the changes in the local revision.
Custom posts save straight to the server, so saving during GutenbergKit's media uploads would persist their temporary URLs.
Separates the formatter's changes from the strings added next.
GutenbergKit's uploads run in the editor's web view and stop when it closes, so closing mid-upload loses the media. Unlike the app's own uploads, they can't finish in the background.
Replaces the temporary pr-build snapshot pin with the published prerelease.
Leaving kept the local revision without asking, so a later Update could
publish abandoned edits. Refreshing first also covers an upload that
finished while the alert was shown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017NCdQuHPbc49BP1ZshDSE8
A plugin can hold a save lock for the whole session, e.g. Jetpack's
Donations block when its Stripe fetch fails, which blocked updating
published posts and custom posts. Asking keeps the user in control.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017NCdQuHPbc49BP1ZshDSE8
… saving

Closing ends the editor's uploads, and replacing a block's media doesn't
change the saved markup, so the close flow dismissed without a prompt.
Posts and pages already ask.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017NCdQuHPbc49BP1ZshDSE8
The Page editor showed "Your post isn't ready yet", unlike its other
page-specific strings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017NCdQuHPbc49BP1ZshDSE8
The titles already said page, but the messages still said post.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017NCdQuHPbc49BP1ZshDSE8
@dcalhoun
dcalhoun force-pushed the build/update-gutenberg-kit branch from de12e0b to 8bcbb4e Compare October 29, 2026 18:36
@dcalhoun
dcalhoun marked this pull request as ready for review October 29, 2026 18:47
@dcalhoun
dcalhoun requested a review from crazytonyli October 29, 2026 18:47
@dcalhoun
dcalhoun added this pull request to the merge queue Oct 30, 2026
Merged via the queue into trunk with commit c5c9c45 Oct 30, 2026
23 checks passed
@dcalhoun
dcalhoun deleted the build/update-gutenberg-kit branch October 30, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants