Repository navigation
External media sources and app-side integration - #25623
crazytonyli wants to merge 2 commits into
Conversation
Generated by 🚫 Danger |
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 34022 | |
| Version | PR #25623 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | e7c0873 | |
| Installation URL | 42q74ejfmbrtg |
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 34022 | |
| Version | PR #25623 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | e7c0873 | |
| Installation URL | 6miqm5k66hls8 |
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
8e6e032 to
4666912
Compare
4666912 to
64a7b18
Compare
64a7b18 to
9aa7332
Compare
989a00e to
671677b
Compare
9d04372 to
a3cb5b6
Compare
a3cb5b6 to
9b8eb9e
Compare
9b8eb9e to
4136cb2
Compare
4136cb2 to
75209a7
Compare
75209a7 to
e7c0873
Compare
e7c0873 to
8fdbbd2
Compare
8fdbbd2 to
ace66bf
Compare
ace66bf to
df2a5e6
Compare
Tear down uploaders by observing Core Data blog deletions on the main context instead of hooking individual removal call sites. This covers every deletion path with one mechanism, including sync-driven cleanup of dead blogs and the account cascade on logout, and it keeps self-hosted uploaders alive through a WordPress.com-only logout.
Stock Photos, Tenor GIFs, and Image Playground as picker sheets that wrap the existing UIKit pickers, adapt their output to the module's external media model, and feed the M4 uploader. Wires the picker options into routing and adds the adapter and routing tests.
df2a5e6 to
98c4b93
Compare
wpmobilebot
left a comment
There was a problem hiding this comment.
Approve. I validated this on an iPhone 17 Pro simulator running iOS 26.5, Debug builds of both apps, signed in to the WordPress.com test account.
- Jetpack: Media → + now shows Free Photo Library. I searched, picked two photos and tapped Add. The banner showed "Uploading 2 items", and both photos landed at the top of the grid. On the site they are
pexels-photo-<id>.jpeg,image/jpeg, with the Pexels attribution caption kept. Cancel closes the sheet, and the menu still works afterwards. - WordPress app: the item is hidden, matching V1's
jetpackFeaturesEnabled()gate. - Tests: the PR's suites pass locally (
MediaUploaderRegistryTests,ExternalRemoteMediaAdapterTests,MediaLibraryRoutingExternalSourcesTests), and CI is green.
Gaps: Image Playground isn't available in the simulator, so I didn't exercise ImagePlaygroundPickerSheet. I checked the logout and site-removal teardown only with unit tests, not in the app (see the inline comment).
The inline comments are non-blocking.
| ) { | ||
| self.clientFactory = clientFactory | ||
| deletionObserver = NotificationCenter.default.addObserver( | ||
| forName: .NSManagedObjectContextObjectsDidChange, |
There was a problem hiding this comment.
Suggestion: Teardown misses blogs deleted on a background context when the main context no longer holds that Blog. That covers the two main paths the doc comment lists: BlogService.removeBlog and AccountService.removeDefaultWordPressComAccount both delete in performAndSave, as does sync cleanup (mergeBlogs).
automaticallyMergesChangesFromParent only reports a deletion in ObjectsDidChange / NSDeletedObjectsKey for an object registered in mainContext. The registry keeps only the object ID, so once the user leaves Media and the Blog is dropped from the main context, the uploader stays in the registry. Its uploads then fail with siteUnavailable, and staged files remain until the app relaunches.
I proved it with a test that vends an uploader, drops the Blog from mainContext, then deletes it via contextManager.performAndSave. The Blog row is gone from the store, but registry.hasUploader(blogID:) is still true. The same test with the Blog still referenced on main passes:
✔ Derived-context deletion tears down uploader while the Blog is still referenced on main
✘ Derived-context deletion tears down uploader after the main-context Blog was released
Expectation failed: !registry.hasUploader(blogID: id)
This isn't a regression, since trunk has no teardown, but the stated goal doesn't hold. A notification that carries deleted object IDs regardless of registration should close it, e.g. .NSManagedObjectContextDidSaveObjectIDs from any context on the same coordinator, or .NSManagedObjectContextDidMergeChangesObjectIDs on mainContext. Listening to saves or merges, not ObjectsDidChange, would also stop unsaved deletes from triggering teardown. It's worth adding a derived-context case to blogDeletionTearsDownUploader.
| // A nil api posts the fix-auth-token notification | ||
| // from the getter itself, which triggers the | ||
| // re-sign-in flow, so this is not a dead end. | ||
| return AnyView(EmptyView()) |
There was a problem hiding this comment.
Question (unverified): When the lookup fails here (token cleared or blog deleted while Media is open), activePicker is already set. The sheet would then present a blank EmptyView with no Cancel button, and didCancel() never fires. Separately, the blog.wordPressComRestApi != nil gate on line 55 runs when the screen is built. That getter posts .wpAccountRequiresShowingSigninForWPComFixingAuthToken when the token is empty, whereas V1 only touches it on tap. To prove either, open Media with an account whose authToken is empty (e.g. a Jetpack-connected self-hosted site with an application password) and screenshot the sheet or the unprompted sign-in. Returning a view that calls delegate.didCancel() and dismisses, and gating on blog.account?.authToken?.isEmpty == false, would avoid both.
| import WordPressMediaLibrary | ||
|
|
||
| extension ExternalRemoteMedia { | ||
| /// Stock Photos: prefer the asset's title (Pexels names are descriptive |
There was a problem hiding this comment.
Nit: This comment, and the "Sunset over the harbor" fixture in ExternalRemoteMediaAdapterTests, treat asset.name as a descriptive title. The live /meta/external-media/pexels response has name: "pexels-photo-31007138.jpeg"; the descriptive text is in title ("large container ship in hamburg harbor"). The behaviour is right and matches V1: uploads end up as pexels-photo-<id>.jpeg, and the deletingPathExtension is what makes that work. Consider rewording the comment and using a realistic name in the fixture so nobody later "fixes" this to use title.




Note
This PR will be merged after #25622.