Skip to content

Conversation

@jkmassel
Copy link
Contributor

What?

Fixes namespace handling for native REST API requests and improves asset bundle validation robustness.

Why?

Native REST API requests (editor settings, active theme, site settings, post types, editor assets) were not properly applying the site namespace from EditorConfiguration.siteApiNamespace. This caused requests to fail for sites that require namespaced endpoints (e.g., /wp/v2/sites/123/posts instead of /wp/v2/posts).

Additionally, the asset bundle validation was too fragile—if a bundle directory existed but was incomplete (missing editor-representation.json), it would be incorrectly treated as valid, causing editor initialization failures.

How?

  1. Namespace support for REST API URLs (RESTAPIRepository.swift): Added buildNamespacedURL() helper that inserts the namespace after the version segment of API paths. Applied this to all native API requests: editor settings, active theme, site settings, post types, and individual post/type lookups.

  2. Namespace support for editor assets (EditorAssetLibrary.swift): Updated editorAssetsUrl() to apply the namespace when building the editor-assets endpoint URL.

  3. Robust bundle validation (EditorAssetBundle.swift, EditorAssetLibrary.swift):

    • hasBundle() now verifies both manifest.json AND editor-representation.json exist
    • EditorAssetBundle.init(url:) validates editor-representation.json exists before parsing
    • Changed listBundles() to use compactMap with try? to skip invalid bundles instead of failing
  4. Editor loading view timing (EditorViewController.swift): Moved hideActivityView() from a defer block to when the editor is actually ready, ensuring the loading indicator remains visible during WebView initialization.

  5. Optional progress callback (EditorService.swift): Made the progress parameter in prepare() optional for simpler API usage when progress monitoring isn't needed.

Testing Instructions

  1. Configure a site that uses namespaced API endpoints (e.g., WordPress.com site with siteApiNamespace set to ["sites/12345/"])
  2. Open the editor for a post on that site
  3. Verify the editor loads successfully without API errors
  4. Verify the loading indicator remains visible until the editor is ready
  5. Test with an incomplete asset bundle (delete editor-representation.json from a cached bundle) and verify it's properly skipped

Accessibility Testing Instructions

N/A - These changes are internal API/loading improvements with no UI changes.

Screenshots or screencast

N/A - Internal changes only.

dcalhoun and others added 5 commits January 14, 2026 16:54
Native requests should respect the site API namespace configuration.
Mitigate partial bundles resulting in editor load failures.
Ensure required files are present when consider bundle existence. Avoids
unexpected errors from missing editor representation files.
@jkmassel jkmassel requested a review from dcalhoun January 20, 2026 19:51
@dcalhoun dcalhoun changed the title Fix/namespace default editor settings endpoint fix: Improve preloading robustness Jan 20, 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.

Changes LGTM.

I tested a WoW site in the iOS Demo app and things functioned as expected. Therefore, I believe these changes are ready to merge. I did not test manually deleting a editor-representation.json file.

Once we have a sibling WordPress-iOS integration PR open, we can further validate the success of these changes. At the present, the preloading is not working in WordPress-iOS with the latest feat/preload-gutenberg-kit-dependencies branch. I presume that is not due to these changes, but lack of full integration in WordPress-iOS.

@jkmassel please merge at your discretion.

@jkmassel jkmassel merged commit 189ff57 into trunk Jan 20, 2026
12 checks passed
@jkmassel jkmassel deleted the fix/namespace-default-editor-settings-endpoint branch January 20, 2026 23:31
@jkmassel
Copy link
Contributor Author

The failures in wordpress-mobile/WordPress-iOS#25151 were unrelated to this PR, so I've merged it and will cut a new release.

@dcalhoun dcalhoun restored the fix/namespace-default-editor-settings-endpoint branch January 21, 2026 15:27
@dcalhoun dcalhoun deleted the fix/namespace-default-editor-settings-endpoint branch January 21, 2026 15: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.

3 participants