Support uploading files/images as attachments (desktop only)#784
Conversation
…into image_upload_2.0
|
Hi @alanpoon, sorry just getting around to reviewing things after my bonanza of makepad fixes. Is this PR ready to merge in? (just wondering since you hadn't yet requested a review from me or assigned the if so, lmk and i'll review it asap. |
|
hi @alanpoon, friendly bump on this. Is this ready? (aside from the conflicts) No real rush, but i'm planning to do an alpha release soon and it'd be great to have this feature included! Plus I'd hate to see all your hard work go to waste. |
|
Working on it. |
kevinaboos
left a comment
There was a problem hiding this comment.
Thanks Alan, i appreciate the contribution here, especially updating it for Makepad 2.0.
I left a few initial comments about the major issues that stuck out to me. I may add more in the future, but these are a good set of requests for you to get started on.
|
I had Claude max do a thorough review, just out of curiosity. I was aware of some of these things and think they can be left for later, but some of them do need to be addressed now. You don't have to fully implement replies, though I think it's basically just a one-line fix, so you might as well since it's quite trivial. But you definitely need to address points 1-5 below, as well as 6 and 7. Note that point 3, 6, 7 are all things i brought up already, related to the TimelineKind usage. Points 9, 10, 12, 13, 14 are also pretty important to address. 🚨 Critical — real behavior bugs1. Replies are silently dropped on every attachment send. // For now, we'll just send the attachment without reply support
// TODO: Add proper reply support for attachments
let _ = replied_to; // Suppress unused warning for now
Worse: 2. Cancel button does nothing to actually abort the upload. let _send_attachment_task = Handle::current().spawn(async move { ... });The Fix: grab 3. Attachment can be sent to the WRONG room. Some(FilePreviewerAction::UploadConfirmed(file_data)) => {
if let Some(selected_room) = &self.app_state.selected_room {
if let Some(timeline_kind) = selected_room.timeline_kind() {
if let Some(sender) = get_timeline_update_sender(&timeline_kind) {
let _ = sender.send(TimelineUpdate::FileUploadConfirmed(file_data.clone()));The target room is resolved from
Result: the file uploads to Room B silently. This is the most dangerous issue in the PR — user data goes to the wrong conversation. 4. if let Some(selected_file_path) = dialog.pick_file() {
5. Progress updates race with completion/error and can overwrite the error UI. Two independent tasks write to the same
No ordering between them. A late 🔴 High — architectural6.
UI modal → Half of this indirection exists only to fetch 7. Already noted in the first review. Related: the RoomScreen retry guard 🟠 Medium — correctness8. No file-size limit. A user picks a 4 GB video. The entire file is 9. The generated thumbnail is dead code.
Lanczos3 resize on a large image is CPU-expensive and currently wasted. Either wire the thumbnail into 10. 11. 12. No duplicate upload prevention. While a file is being read in the background thread, clicking the attach button again overwrites 13. 14. 🟡 Low — code quality15. 16. 17. Double 18. 19. Debug 20. ✅ Things that look fine
Suggested priorityBlock on #1–#6. Those six are user-visible data-safety, liveness, or correctness bugs. #7 is a natural companion to #6 and they're best fixed together with the routing redesign. |
|
Also, if you're busy with other things, I can have Claude take a stab at fixing these things, they're not too complicated so it ought to be doable. Just let me know. |
|
If I recall correctly, rfd::FileDialog::pick_file cannot by asynchronous for macOS. If it blocks UI thread, then point 12: No duplicate upload prevention, won't happen. |
|
FYI, i'm working on this PR now since it's the next feature I want to tackle before we publish the beta release, so i'll address these issues myself. I'm starting from your PR here and will push to this branch, so no need to do anything. |
* Uploads now preserve thread context by using timeline kind and `timeline.send_attachment(...)` instead of at the room level * Reply metadata is preserved throughout the first upload action, any error states, and any subsequet retry attemps * Cancellation works properly and actually aborts the background task * Use the async `rfd` dialog instead of blocking the main thread. It just needs to be *created* on the main UI thread, not actually opened.
* Ensure the room and reply that the attachment are for get properly preserved * Add upload attempt IDs so that we don't mistakenly treat one upload session's updates as relevant to a different upload session * Implement proper cancellation via the upload's abort handle * Don't load the full file/image into memory until we need it for a preview thumbnail * Allow the user to edit the file caption before uploading * Warn on large files (but allow them, of course)
Simplifies older logic that had a bunch of unnecessary actions everywhere other misc/small fixes for file upload logic
kevinaboos
left a comment
There was a problem hiding this comment.
Thanks Alan! Appreciate your initial work on this. I did a series of major redesigns that you guys might want to apply to robrix2, your choice.
Migration to 2.0
Supersedes/closes #674