Skip to content

Integrate GutenbergKit remote editor asset caching#24639

Merged
crazytonyli merged 5 commits intotrunkfrom
try-gbk-remote-editor
Jun 30, 2025
Merged

Integrate GutenbergKit remote editor asset caching#24639
crazytonyli merged 5 commits intotrunkfrom
try-gbk-remote-editor

Conversation

@crazytonyli
Copy link
Contributor

@crazytonyli crazytonyli commented Jun 27, 2025

Description

Close CMM-509. This PR uses wordpress-mobile/GutenbergKit#148.

To try it out locally:

  1. Checkout Support caching remote assets GutenbergKit#148 in your local GutenbergKit repo.
  2. Update the Package.swift to reference your local GutenbergKit repo.
  3. Build & run to launch the Jetpack app.
  4. Log in with your a8c account and open a post.

Testing instructions

@crazytonyli crazytonyli requested a review from dcalhoun June 27, 2025 03:02
@dangermattic
Copy link
Collaborator

dangermattic commented Jun 27, 2025

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

Generated by 🚫 Danger

GutenbergKit.EditorViewController.warmup()
GutenbergKit.EditorViewController.warmup(
configuration: blog.flatMap(EditorConfiguration.init(blog:)) ?? .default
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can move/copy this code to "warm up" the GBK editor after switching sites, which pre-fetches the remote editor assets.

editorAssetsEndpoint.appendPathComponent("editor-assets")
self.editorAssetsEndpoint = editorAssetsEndpoint
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This if statement is new. The rest are moved from the view controller initializer above.

siteApiNamespace.append("sites/\(siteId)")
} else {
siteApiNamespace.append("sites/\(siteDomain)")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I lied. This if statement is also changed. The siteApiNamespace should not be ["sites/<site-id>", "sites/<mysite.wordpress.com>"], right? It should contain either the id or the domain?

Here is the original code, for easier review:

        if isWPComSite {
            if let siteId {
                siteApiNamespace.append("sites/\(siteId)")
            }
            siteApiNamespace.append("sites/\(siteDomain)")
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wait... I see the code comment now. I'll revert this change.

Copy link
Member

Choose a reason for hiding this comment

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

Correct, we need to retain this. Third-party blocks can utilize either namespace. So, we need both for proper matching, otherwise we may mistakenly add a duplicative namespace to a path already containing a namespace.

@dcalhoun dcalhoun changed the title Integrate GutenbergKit remote editor Integrate GutenbergKit remote editor asset caching Jun 27, 2025
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.

This works well from my testing. 🎉 Aside from the noted GBK release requirement, this seems good to merge.

Comment on lines 57 to 58
//.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.3.0"),
.package(path: "../../../GutenbergKit"),
Copy link
Member

Choose a reason for hiding this comment

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

Friendly note: we need to replace the local path with a new GBK release before merging this PR.

FYI I have a open wordpress-mobile/GutenbergKit#151 for documenting and automating the GBK release process.

siteApiNamespace.append("sites/\(siteId)")
} else {
siteApiNamespace.append("sites/\(siteDomain)")
}
Copy link
Member

Choose a reason for hiding this comment

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

Correct, we need to retain this. Third-party blocks can utilize either namespace. So, we need both for proper matching, otherwise we may mistakenly add a duplicative namespace to a path already containing a namespace.

@crazytonyli crazytonyli force-pushed the try-gbk-remote-editor branch from b702cb5 to bd6fccd Compare June 30, 2025 00:54
@sonarqubecloud
Copy link

@crazytonyli crazytonyli marked this pull request as ready for review June 30, 2025 00:57
@crazytonyli
Copy link
Contributor Author

⬆️ Rebased with one change: replacing the GBK local path ref to the 0.4.0 release tag.

@crazytonyli crazytonyli enabled auto-merge June 30, 2025 00:59
@wpmobilebot
Copy link
Contributor

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 Number28066
VersionPR #24639
Bundle IDorg.wordpress.alpha
Commitbd6fccd
Installation URL64rev0fg6oum0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

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 Number28066
VersionPR #24639
Bundle IDcom.jetpack.alpha
Commitbd6fccd
Installation URL1vbvsep3g39ug
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@crazytonyli crazytonyli added this pull request to the merge queue Jun 30, 2025
Merged via the queue into trunk with commit 2908eae Jun 30, 2025
32 of 34 checks passed
@crazytonyli crazytonyli deleted the try-gbk-remote-editor branch June 30, 2025 01:45
@dcalhoun dcalhoun restored the try-gbk-remote-editor branch August 18, 2025 20:25
@dcalhoun dcalhoun deleted the try-gbk-remote-editor branch August 18, 2025 20:28
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.

4 participants