Text chat 26: Upload tray, drop overlay, attachment modals, paste (#276) #413
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-26-ui-upload-tray"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Text chat 26: the upload tray, the drop overlay, the attachment modals and image paste (spec §3.3, §8, §9.2).
Stacked on: textchat-25-ui-composer (already merged into textchat; its only extra commit, a merge of textchat, was resolved to the textchat side).
What I built
screens/main/composer/attachments.rs,ChannelAttachmentArea.{tsx,module.css}): a row of 12.5 rem tiles inside the composer box, above the text, in send order (selectors::upload_tray). Each tile shows thegetFileIconicon, the name, the size and the extension (getFileExtension, 1 to 4 characters). Each also has the spoiler / edit / remove bar (Phosphor fill icons, tooltips). A spoiler tile is covered until you click it. You can drag a tile to reorder: press, move, then release on another tile. A 2 px line shows which side it will land on, and the drop sendsMoveAttachmentatdrop_index, which follows the original'shandleAttachmentDropformula. The Send button is now enabled when the tray has files and there is no text.modals/attachment_edit.rs): file name (up to 512 characters), alt text for images and videos only (up to 4096, with ann/4,096counter), and "Mark as spoiler". Cancel or Save; Save sendsEditAttachment.modals/upload_errors.rs): "File size too large", "Whoa, this is heavy" and "Can't upload files here", shown fromchat.uploads.refusal. As on desktop in the original, there is a header X and no footer. Closing an alert sends the newUserAction::DismissUploadRefusal.modals/drop_overlay.rs,UploadDropModal): "Upload to #general", or "Upload directly to #general" while Shift is held. During slowmode, Shift does not send directly. Escape hides the card, but the drop still attaches the files, as in the original. The dropped paths go to the store asCoreEvent::FileswithAttachorAttachAndSend.MessageUploadProgress): the pending message of an upload job shows one card per file with its name, size, a progress bar (red once the job fails) and "Cancel upload" (CancelUpload).ClipboardImages::read_imagefirst. If there is an image, it goes toAddFilesasimage.png. Otherwise the text from iced's clipboard is pasted. Pasted text over the message limit becomesmessage.txt(the store gets the pasted text, thenPasteLongText, then the draft back), and the draft is left unchanged. The inline edit box keeps the editor's own paste.widgets::modal: a general modal (backdrop, centred card, Escape) with the standard header, content and footer card (Modal.module.css, small: 27.5 rem).Deviations and cross-crate changes (please review)
UserAction::DismissUploadRefusal(one variant, one arm inuploads.rs, a test and a README line). Without it the refusal stays until a later add succeeds, so the UI cannot reopen the alert for a second, identical refusal.files::LocalFiles(describe(paths) -> BoxFuture<Vec<FileRef>>,keep_pasted(png) -> FileRef). It is implemented byapps/fluxer'sDesktop: a dropped file's size and type are read on a plain thread, and pasted PNGs are kept inPastedImagesunderFileSource::Clipboard. This was needed because the UI cannot hold the runtime's types (#365).fluxer_ui::runtakes it as a newlocal_filesargument. CLAUDE.md's list of sanctioned injected traits now names it, and the READMEs are updated.widgets/message_row.rsandscreens/main/messages.rsfor the progress cards andCancelUpload, andscreens/main/mod.rsto draw the modals.Testing
crates/fluxer-ui/tests/uploads.rs(7 tests, no GPU):tray_tiles_and_actions_emit,drag_reorder_emits_move,edit_modal_limits,refusal_opens_matching_modal,drop_overlay_shift_sends_directly,paste_image_becomes_file,progress_row_cancel. Influxer-core:dismissing_the_refusal_clears_it.upload_tray,upload_drop_overlay,attachment_edit_modalandupload_progress. The goldens were made on lavapipe in the Ubuntu 22.04 image (fluxer-native-shots:u2204). All 55fluxer-uiscreenshot tests pass there. The app's view comes from the fork's CSS files named in each test; I have no Electron reference image.cargo xtask ciis green on the host.FLUXER_SCREENSHOT_TESTS=1could not run the whole workspace inside the 22.04 image, because its libspa is too old forfluxer-capture. So the ignored tests ran withcargo test -p fluxer-ui -- --ignoredin that image instead.apps/fluxer --libsometimes aborts at exit with a futex error after all its tests pass. This is the known #338, which also happens without this change.Closes #276
🤖 Generated with Claude Code
Independent review: Text chat 26 (upload tray, drop overlay, attachment modals, paste)
Reviewed
git diff 2e03927e..origin/textchat-26-ui-upload-tray(head4e32a4c), read cold.Plan checks
crates/fluxer-ui/tests/uploads.rs(tray_tiles_and_actions_emit,drag_reorder_emits_move,edit_modal_limits,refusal_opens_matching_modal,drop_overlay_shift_sends_directly,paste_image_becomes_file,progress_row_cancel), and all 4 goldens are there (upload_tray,upload_drop_overlay,attachment_edit_modal,upload_progress). They check the spec's values: filename limit 512, alt text limit 4096, the original's strings, Shift sends at once, Escape, message.txt over 2000 UTF-16 units, Cancel upload.AttachmentEditModal, the two refusal modals (plusNoPermission), the drop overlay, the progress row with "Cancel upload" and Ctrl+V readingClipboardImages::read_imagefirst are all present.drop_indexcopiesChannelAttachmentArea.handleAttachmentDropexactly, quirk included. Thewidgets::modalis generic.UserAction::DismissUploadRefusal, with a core test, and no new dependency.LocalFilesis injected, called only throughTask::perform/Task::future, and implemented inapps/fluxer. CLAUDE.md's exception list is updated to match. No paths, URLs or file contents are logged:upload_files::openerrors carry no path. No new fixtures.cargo xtask ciin the review worktree: green (exit 0).Findings
composer::paste_textincrates/fluxer-ui/src/screens/main/composer/mod.rssends three actions:ComposerEdited { text: <pasted> }, thenPasteLongText, thenComposerEdited { text: <old draft> }.adjust_spans(fluxer-core/src/chat/composer.rs:1190), which drops every span the replaced text covers.text_to_filethen callsdraft.mentions.clear().@alice, not<@id>, so nobody is pinged. The original'shandlePasteExceedsLimitleaves the draft alone.LocalFiles/the UI builds aFileRef { source: FileSource::Text(text), name: "message.txt", .. }and sends it withAddFiles, or core gets an action that carries the text.paste_image_becomes_fileso the draft holds a mention span and still has it after the long paste.FileHoveredsetsdrop.hoveringwhenever settings and the soundboard upload are closed.FileDroppedonly clears it (State::dropped) whenmessages.channel()isSome. A drop with no channel open (winit sends noFilesHoveredLeftafter a drop) leaveshovering == true. The next text channel opened then shows theopaqueoverlay, which blocks input until Escape. Fix: calldrop.left()(or reset) in theFileDroppedbranch that does not take the file, and when settings are open.DropsEndedis queued withTask::doneon the firstFileDropped. This relies on everyFileDroppedof the same drop being handled before the queued message. If iced splits them across batches, the rest form a second drop, and with Shift held that sends two messages. Worth a comment or a check on a real X11/Windows drop; no change is required.Verdict: changes requested. One blocking finding (1). CI is green locally; findings 2 and 3 are optional.
Review round 1 addressed in
05d722a:composer/mod.rspaste_text loses mention spans: fixed. Text pasted over the length limit is now oneUserAction::AddFileswith amessage.txtFileRef(FileSource::Text,text/plain, ids in a range of their own, bit 62, which neither the runtime's counter nor core's text files (bit 63) reach). The draft is not touched, so its text, cursor and mention spans stay, and no typing event or draft save of the pasted text goes out. Test first:paste_image_becomes_filenow autocompletes@adainto the draft, does the long paste, and checks there is exactly oneAddFiles, the draft's text, cursor andmentionsare unchanged, and a second long paste gets a different id. It failed on the old code with the three-action detour. "Upload your message as a file" still usesPasteLongText, which is right there because the draft is what becomes the file. README updated.app.rshover stuck after a drop with no channel: fixed. AFileDroppedthat no composer takes (no channel open, or the settings shown) now callsdrop.left(), so the overlay does not come up with the next channel. The shell'supdatecannot be built in tests (Shellis private), so this one has no test of its own. The state change it uses is covered bydrop_overlay_shift_sends_directly.app.rsDropsEnded with split batches: deferred to #416 (follow-up). winit 0.30 sends all of a drop's paths from one platform callback, beforeAboutToWaitand before any proxy message, so nothing splits today. A real fix needs a debounce timer, and fluxer-ui has none without I/O (iced is built without tokio/smol).tests/uploads.rsTDD order: no action needed, as the finding says.Local
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green.Independent review: Text chat 26 (upload tray, drop overlay, attachment modals, paste)
Reviewed the task's own commits on
origin/textchat-26-ui-upload-tray@05d722a(df5c99c,4e32a4c,05d722a; the merged Text chat 25 code is out of scope).Tests named by the plan. All seven are present in
crates/fluxer-ui/tests/uploads.rsand assert what the plan says:tray_tiles_and_actions_emit,drag_reorder_emits_move(drop_indexmatchesChannelAttachmentArea.handleAttachmentDropline for line),edit_modal_limits(512 and 4096),refusal_opens_matching_modal(the original's three titles and texts),drop_overlay_shift_sends_directly(UploadDropModalstrings),paste_image_becomes_file,progress_row_cancel. The four goldens areupload_tray,upload_drop_overlay,attachment_edit_modalandupload_progress.Interfaces. The tray (spoiler, edit and remove bar; drag →
MoveAttachment),AttachmentEditModal, the TooLarge, TooMany and NoPermission alerts, the drop overlay (Shift, Escape), the progress row with "Cancel upload" →CancelUpload, and Ctrl+V readingClipboardImages::read_imagefirst are all present.Invariants. fluxer-core gets no new dependency, and file bytes stay out of it: pasted images are
FileSource::Clipboard(handle), kept by the runtime. fluxer-ui does no I/O of its own. No paths or URLs are logged: thedescribeerror path logs theFileErroronly, which carries no path. No Cargo changes. Server data cannot panic the client: every index goes throughgetor a bounds check.Local gate.
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green (EXIT 0). The four screenshot tests ran and passed.Findings
files::LocalFiles, and amends CLAUDE.md's sanctioned-I/O list to name it. Neither the plan nor the review checklist lists that trait.describeis called throughTask::future.keep_pastedis a synchronous call inside aTask::thenclosure and does no I/O: it is an in-memory store in the runtime. The shape matches the other traits, but the contract change needs Charles's explicit OK.UserAction::DismissUploadRefusalto fluxer-core (with a test) and wiresLocalFilesinapps/fluxer, but the plan lists fluxer-ui files only. The change is additive. Other open branches with exhaustiveUserActionmatches, or with anevery_chat_actionlist, may need a one-line merge fix.attachment_editcaps the filename and alt text by Unicode scalar values (chars()). HTMLmaxLengthcounts UTF-16 units, so text with astral characters (emoji) can be up to about twice the original's length in UTF-16 units. Worth checking against the server's validator.useChannelComposerPaste).paste_textdoes not, so the threshold differs slightly for tabbed text.FileDroppedarriving before theTask::done(DropsEnded)it queues. If a later file arrives after the take, it becomes a secondCoreEvent::Files. With Shift held, that means a second message. Shift is also only known throughModifiersChanged, which an unfocused window may not receive while an external drag is in progress.None of these break another task's interface, lose data or leak anything.
Verdict: approve. Nothing blocks. CI is green locally. Findings 1 and 2 need Charles's acknowledgement of the CLAUDE.md change.