Repository navigation
Consolidate the Spotlight open path - #25991
crazytonyli wants to merge 4 commits into
Conversation
Generated by 🚫 Danger |
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 34374 | |
| Version | PR #25991 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 4d8ee7c | |
| Installation URL | 7taeb88e14s7g |
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 34374 | |
| Version | PR #25991 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 4d8ee7c | |
| Installation URL | 26pum17qb0tkg |
|
Version |
|
Version |
4d8ee7c to
5d2f861
Compare
| return | ||
| // A cached copy opens immediately; the network fetch covers posts | ||
| // that are indexed but no longer cached locally. | ||
| if let post = identifier.post(in: coreDataStack.mainContext) { |
There was a problem hiding this comment.
Finding from Claude:
Tapping a draft in Spotlight can open an out-of-date copy of it. If the draft was changed on the web since the app last synced it, the editor shows the old content.
What happens
fetchPost now returns the post saved on the device whenever there is one, and only asks the server when there isn't. Before this PR, the app always fetched the post from the server first (PostRepository.getPost), which also updated the saved copy.
Who is affected
Anyone who changes a draft on the web or on another device, then opens it from Spotlight before the app syncs it. Spotlight skips the post list, so the app gets no chance to sync first.
What they see
The editor opens with the old content. The app also picks the screen from the saved status, so a draft that was published on the web should open in the editor instead of the preview. That status case was not reproduced; it goes through the same lookup.
How this was checked
PR head 5d2f861, WordPress app, iPhone 18 Pro simulator on iOS 27.0, local self-hosted site.
- Created a draft, signed in, and opened Posts → Drafts, so the draft was saved on the device and indexed in Spotlight.
- Changed the draft's body through the REST API, standing in for a web edit.
- Searched Spotlight for the draft and tapped the result.
| Body | |
|---|---|
| Server, after the edit | NEW body edited on the web |
| Editor, opened from Spotlight | OLD draft body from before the web edit |
Not checked: trunk on the simulator (that trunk refreshes the post comes from reading the code), the status-change cases, and what happens if the stale draft is saved.
Worth fixing in this PR: fetch the post from the server first, and fall back to the saved copy only when that fails, for example when offline. That keeps this PR's offline improvement, and the trash check would then see the server's status too.
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
…ifier type Identifiers arrive from the system through Spotlight activities, so the composite format cannot be assumed. Decomposition now returns nil for a malformed identifier or an unknown item type instead of indexing past the end of the components. A post identifier type parses a post's composite identifier into its site domain and post ID, and resolves the site by WP.com ID or xmlrpc URL and the cached post from it.
Route every Spotlight tap through one async open method that resolves the identifier, fetches the post from the cache first and the network second, refuses trashed posts, and reports whether anything was put on screen. The activity handler validates the identifier up front and dispatches the open, so a malformed identifier is rejected instead of misrouted. Post and page navigation share one method, and the Reader helpers return a result instead of taking failure closures.
Opening the saved copy first showed edits made on the web only after the next sync, and chose the screen and the trash check from a stale status. The server copy is fetched first again; the saved copy is the fallback when the server can't be reached, and a post deleted on the server opens nothing.
9a02d26 to
54769e2
Compare
|
Version |



Description
Opening a Spotlight result currently uses separate callback-based paths for WP.com and self-hosted posts, with duplicate navigation logic for posts and pages.
This PR:
SearchIdentifierGenerator.decomposeFromUniqueIdentifier(_:)reject malformed and unknown identifiers.AbstractPost.SearchIdentifierto resolve the exact site and post for WP.com and self-hosted sites.openItem(withUniqueIdentifier:), with shared post and page navigation. It opens cached posts immediately, fetches missing posts, and rejects trashed posts.Testing instructions