Repository navigation
Add upload UI and wire the uploader into the grid - #25622
crazytonyli wants to merge 15 commits into
Conversation
Generated by 🚫 Danger |
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
1e1fa49 to
90df03b
Compare
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 34024 | |
| Version | PR #25622 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 5bc6594 | |
| Installation URL | 5t4622h4lmc70 |
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 34007 | |
| Version | PR #25622 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 2afa80c | |
| Installation URL | 2m1vlndtdk8f0 |
90df03b to
362fcbe
Compare
362fcbe to
14694c9
Compare
14694c9 to
5db0706
Compare
80dac4b to
3206ce1
Compare
3206ce1 to
9e91167
Compare
9e91167 to
019a63c
Compare
019a63c to
8384343
Compare
8384343 to
8682318
Compare
cb78b3b to
2afa80c
Compare
2afa80c to
5bc6594
Compare
bc45542 to
b918305
Compare
The folder symbol's built-in accessibility label is "move", which the filter menu exposed for documents. The doc symbol also matches the grid's document tile.
Fit as many tiles of at least 96 pt as the width allows, with a minimum of 4 columns, instead of a fixed 4 or 5. Tiles now stay about the size they are on a portrait iPhone in iPad split views, landscape, and full-width layouts.
Pending and failed entries carry the materialized temp file URL so the Uploads screen can render a thumbnail. It is nil until materialization completes and stays nil for non-retryable failures.
The registry caches one MediaUploader per blog so in-flight uploads survive navigation, and pushes a freshly built policy into a cached uploader on every vend so changed media settings apply to new enqueues. The factory derives the policy from the blog's allowed types and the user's media settings.
Add an add-menu with photo library, camera, file, and app-supplied external pickers; a banner above the grid summarizing pending and failed uploads; and an Uploads sheet with per-row cancel, retry, and remove plus bulk actions. The view model observes the uploader's state publisher and maps snapshots into row items. The routing vends the site's uploader from the registry into the hosting controller.
The uploader drops entries as soon as they finish, so the open Uploads screen switched to "No Uploads" right after a success. It now shows "All uploaded" unless the user cancelled or removed the last rows.
The file name next to the icon already identifies the row. VoiceOver read the icon as a separate element with its symbol's built-in label.
Use a new key: the bundled English strings file maps the old key to the old text, which overrides the value in code until the next release regenerates it, and translators need to see the new text.
b918305 to
f52092c
Compare
|
Version |
wpmobilebot
left a comment
There was a problem hiding this comment.
Approve. The upload flow works end to end. I found no Blockers, but please address the registry lifecycle suggestion before mediaLibraryV2 ships.
Tested on an iPhone 17 Pro simulator (iOS 26.5), Debug build of feb2737, signed in to the WordPress.com test site:
- Add menu → Photo Library with 2 and then 6 photos. The banner showed "Uploading N items", the Uploads sheet showed live progress with thumbnails, and it switched to "All uploaded" when the queue drained while open. New items appeared at the top of the grid.
- Choose File (security-scoped
.fileImporterURL) with a file the server rejects. Checked the "1 upload failed" banner, the failed row, Retry, Remove (→ "No Uploads"), and the bulk menu, in light and dark mode. No layout, truncation, or color problems.
I also ran MediaUploaderRegistryTests, MediaUploaderTests and UploadsEmptyStateTrackerTests; the PR's tests all pass. Not covered: the camera items (no camera in the simulator), the pre-iOS 26 close button, self-hosted sites, and logging out mid-upload. External picker options aren't wired up in this PR.
| // Blog on its main managed object context; only the Sendable policy | ||
| // value crosses into the update Task below. | ||
| let policy = MediaUploadPolicyFactory.make(from: blog) | ||
| if let existing = uploaders[id] { |
There was a problem hiding this comment.
Suggestion: A cached uploader keeps the WordPressClient it was first built with. WordPressClientFactory keys clients on blog and transport/credentials, and swaps them when a token or application password rotates or a WP.com site moves to direct access. #25852 also evicts them on logout and site removal. This registry keys on the blog only, and tearDown(blogID:) / tearDownAll() have no callers. After an in-place token refresh (AccountService.createOrUpdateAccountWithUserDetails sets account.authToken on the existing account), the grid uses the new client, but uploads keep sending the old credentials until the app relaunches. Uploaders for removed sites or logged-out accounts are also never cleaned up.
This test, added to MediaUploaderRegistryTests, fails on feb2737 with Expectation failed: uploadClient === current. The 3 existing registry tests pass.
@Test func uploaderFollowsRotatedCredentials() throws {
let blog = makeBlog(siteId: 1)
let registry = MediaUploaderRegistry()
_ = try registry.uploader(for: blog)
// Same Blog/WPAccount, new token (what the authtoken fixer in
// AccountService.createOrUpdateAccountWithUserDetails does).
blog.account?.authToken = "rotated-token"
contextManager.saveContextAndWait(mainContext)
let current = WordPressClientFactory.shared.instance(for: try WordPressSite(blog: blog))
let uploader = try registry.uploader(for: blog)
let transport = Mirror(reflecting: uploader).descendant("transport")
let uploadClient = transport.flatMap { Mirror(reflecting: $0).descendant("client") } as? WordPressClient
#expect(uploadClient === current)
}Possible fix: rebuild the uploader, or swap its transport, when clientFactory.instance(for:) returns a different client. Then call tearDown/tearDownAll from the places that already call evictInstance/reset. I filed this as a Suggestion rather than a Blocker only because mediaLibraryV2 is debug-only today. It should be fixed before the flag ships.
|
|
||
| switch item.mode { | ||
| case .uploading: | ||
| Button(action: onCancel) { |
There was a problem hiding this comment.
Suggestion: This cancel button has no accessibility label, so VoiceOver reads the symbol's built-in name. On the simulator, each in-progress row's button is announced as "Close" (identifier: 'xmark.circle.fill', label: 'Close'), the same as the sheet's own Close button two elements earlier. The Retry and Remove buttons already have labels, so please add a localized one here too (e.g. "Cancel upload").
| .buttonStyle(.plain) | ||
| case .failed(_, let isRetryable): | ||
| HStack(spacing: 16) { | ||
| if isRetryable { |
There was a problem hiding this comment.
Suggestion: Retry (and "Retry all failed") is offered for permanent server rejections. I uploaded a text file named .pdf through Choose File, and WordPress.com rejected it with "Sorry, you are not allowed to upload this file type." The row still shows Retry, and tapping it fails again within a second with the same error:
The root cause is MediaUploader.markFailed, which keeps the retry payload for any upload-stage error. This PR is the first place users can see it. Consider marking 4xx/permission rejections non-retryable so only Remove is offered.
| // V2 uploads stage into persistent storage; clear anything a | ||
| // prior crash/force-quit orphaned there (no in-flight uploads | ||
| // survive process termination). | ||
| MediaUploader.sweepOrphanedStagingFiles() |
There was a problem hiding this comment.
Nit: This sweep is already called on trunk, synchronously, near the top of didFinishLaunchingWithOptions (line 234), and its doc says to call it once. The second call is harmless because the cutoff is captured on the first call, but it looks like a leftover from before that call landed. It can be removed.




Note
This PR will be merged after #25621.