OS-file drop — progress UI, live refresh, cancel cleanup, CMO#237
Conversation
- Implemented a linear progress indicator with determinate and indeterminate modes. - Added support for customizable tones and inline labels with percentage display. - Created a floating upload-progress HUD to manage multiple file uploads. - Introduced live-refresh functionality for Media Library after file uploads. - Enhanced accessibility features with appropriate ARIA attributes. - Added comprehensive CSS styling and theming options via CSS variables. - Included unit tests to ensure correct rendering and behavior of the progress bar.
|
@claude can you review it for me? |
|
Claude finished @AllTerrainDeveloper's task in 3m 26s —— View job PR #237 Review — OS-file drop: progress UI, live refresh, cancel cleanup, CMOOverall: Solid, well-structured PR. The architecture is clean, the hook design matches the established event-driven pattern, and the late-cancel-cleanup logic is genuinely clever. I found a few real bugs and some smaller code-quality items to address before merging. Todo
Bugs1.
|
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
|
@claude ready for a next round!? |
|
Claude finished @AllTerrainDeveloper's task in 3m 18s —— View job PR #237 Review — Round 2Todo
Round 1 Scorecard — All items addressed ✅
What changed — notes per item1. File-identity matching (Bug 1) — 2. Late-cancel test (Bug 2) — The new test at 3. 4. Sequential loop comment (Item 4) — 5. ARIA on host (Item 5) — 6. Silent DELETE warnings (Item 6) — 7. Context-menu Nit — One new finding
|
…s lifecycle hooks
Builds on the drag-and-drop-from-desktop feature (#236) so the
upload flow has a real progress UI, refreshes the views the user is
looking at, and cleans up after itself when a user cancels.
Summary
<wpd-progress-bar>component — determinate / indeterminatelinear bar with tones, label + percent header, full CSS-variable
theming, ARIA wiring. Documented in
docs/examples/progress-bar.md.now uses
XMLHttpRequestsoupload.progressis observable.Two new hooks ride alongside the existing ones:
desktop-mode.drop.upload-started—{ file, fields, context, abort: () => void }fires once the request isopen()ed.desktop-mode.drop.upload-progress— per-tick{ loaded, total, indeterminate }, plus a synthetic 100%event on
upload.loadso a HUD can show "wrapping up".BEFORE_UPLOAD/AFTER_UPLOAD/UPLOAD_FAILEDsemantics areunchanged. New
UploadAbortedErrordistinguishes user-cancelfrom filter-cancel.
one row per file, with a
<wpd-progress-bar>and aCancel / Dismiss action. Auto-clears successful uploads after
2.5s, keeps failures around until dismissed. Suppressable via
data-desktop-mode-suppress-upload-hudon<body>so pluginscan take the same hook surface over with their own UI.
media-list.tssubscribes to
after-uploadand prepends the new attachment tothe visible grid via a single
wp/v2/media/{id}GET. Scrollposition and current selection are preserved.
pointing at
/wp-admin/upload.phpreloads when an uploadfinishes (URL preserved, so filters / pagination survive).
Suppressable via
data-desktop-mode-suppress-media-library-refresh.WordPress → Media for Navigate into, Open file in new tab,
Delete permanently. Delete confirms via
wpdConfirmandissues
DELETE wp/v2/media/{id}?force=true. Filterable via theexisting
desktop-mode.my-wordpress.tile-context-menuhook.single toast that summarises only the non-zero buckets:
Uploaded 2 files. Cancelled 1. Failed 1.Single-file batcheskeep their tight original toast (or the server error verbatim).
Cancel after the body had been fully sent, the server still
created the attachment. The uploader now detects that case
(via
xhr.upload.load) andDELETEs the attachment after theserver responds, so a cancelled upload never appears in the
Media Library, My WordPress, or anywhere else. The HUD shows
"Cancelling…" while it waits for the server.
cells were
96 × 92px around an88px-wide tile, leavingthe selected tile's background ring abutting adjacent ribbons.
Cell pitch bumped to
108 × 112so the inset selection hasbreathing room and 2-line labels don't bleed into the next
row.
Already-implemented (clarification)
Drops onto Gutenberg's drop zone, the classic media uploader, and
any
[data-drop-zone]are passed through to those handlers by thechromeless bridge (
includes/render/chromeless-bridge.php:1197).Gutenberg's own uploader handles upload + block insertion — the
OS-file-drop manager intentionally doesn't intercept those
surfaces. Only drops onto non-drop-zone areas escalate to the
shell's confirmation dialog.
Public API additions
JS hooks (
src/os-file-drop/hooks.ts)desktop-mode.drop.upload-started{ file, fields, context, abort }desktop-mode.drop.upload-progress{ file, fields, context, loaded, total, indeterminate }Also exposed via
wp.desktop.HOOKS.FILE_DROP_UPLOAD_STARTED/FILE_DROP_UPLOAD_PROGRESS.Exports
UploadAbortedErrorfromsrc/os-file-drop/upload.ts.WpdProgressBar,WpdProgressTonefromsrc/ui/components/wpd-progress-bar/.fetchMediaItem,deleteMediaItemfromsrc/my-wordpress/media-rest.ts.Body-attribute toggles (opt-out for plugins that want to own
the UI):
data-desktop-mode-suppress-upload-huddata-desktop-mode-suppress-media-library-refreshFiles
src/ui/components/wpd-progress-bar/{ts,styles,test}src/os-file-drop/progress-hud.ts,src/os-file-drop/library-refresher.tssrc/os-file-drop/{upload,hooks,dialog,index}.tssrc/my-wordpress/{media-list,media-rest}.ts,src/my-wordpress/index.tsassets/css/desktop-files.css(HUD)src/hooks.ts,src/ui/components/index.tsdocs/examples/progress-bar.md(new),docs/examples/os-file-drop.md,docs/examples/README.md,docs/hooks-reference.md,AGENTS.mdtests/vitest/os-file-drop-upload.test.ts(XHR fake),src/ui/components/wpd-progress-bar/wpd-progress-bar.test.ts(new)Test plan
npm run test:js— 1401/1401 pass.npm run lint— clean../node_modules/.bin/tsc --noEmit— clean.npm run build— both bundles emit cleanly.upload → HUD shows 0–100% → toast "Uploaded to Media
Library." → file appears in My WordPress → Media without F5.
mid-flight → HUD row goes "Cancelling…" → "Cancelled" →
summary toast reads "Uploaded 2 files. Cancelled 1." →
cancelled file is not present in Media Library.
upload.phpin a window, drop a file on thewallpaper → after upload, the Media Library iframe reloads
with the new attachment visible.
Delete permanently → confirm → tile disappears, count
decrements, no F5 needed.
detail view.
uploads and inserts the block (unchanged behavior).