Repository navigation
The desktop app sends pictures and files - #187
Conversation
Files chosen with the + button or Attach Files (Shift-Cmd-A, Ctrl elsewhere), dropped on the chat or pasted wait in a tray above the composer and go with the next message, its text as their caption. A pasted picture is written as a PNG into the data folder and removed once the core has its copy, once it leaves the tray, and at launch and quit. A failed send puts the files back in the tray.
…files The send keeps formatted text's words, styles and drafts, and passes the styles as the files' caption's. The picker's answer leaves a dialog opened meanwhile its keys. The send button hides while editing without words. A return pressed while files are being added waits for them. A failed send says the core's words, and that its files weren't sent once another chat is open.
|
Review findings and fixes, in 7c16f9b (merged with main after #186, test-first: each new test failed before its fix). Merge with #186. Rulings applied
1 (Important), the picker's answer took the keys from a dialog opened meanwhile. Fixed. The composer gets the focus back only if 2, "Save edit" showed and did nothing while editing with files and no words. Fixed. 3, a caption could go without a file still being added. Fixed. 4, a failed send after a chat switch dropped its files silently. Fixed. 5,
The window test
Observation (#186's code, not changed here). In the headless tests, a simulated Enter puts "\n" into the field before Checks: |
What changed
The desktop app can send pictures and files, as the Mac app does (
ComposerView.swift'sFileTray,AppStore.addFilesandsend,Composer.pastedFiles):Pasted image xxxxxxxx.pngand attached. GPUI's clipboard gives files on macOS and Windows, and pictures on all three systems. On Linux, files copied in a file manager paste as their paths' text, because GPUI doesn't read them there (ashortcut:comment inpaste); dropping them or using "+" works.send_attachmentswith the text and its styles as the caption (none if it's empty), and the reply's quote goes with it. Pressing ↩ while a dropped or pasted file is still being read waits for it, so a caption never goes without its picture. If the send fails, the files and the words go back. The error is the core's text, as on the Mac: "Menu.pdf is larger than 100 MB". If another chat was opened meanwhile, the error also says that the files weren't sent. A failed upload is an ordinary failed message, so the existing Retry handles it.Hush Desktop/paste, which only we can read; never the Mac app's). They're deleted once the core has its encrypted copy, when they leave the tray, and at launch and quit. The user's own files are never touched.The code is in its own module,
core/desktop/src/app/attach.rs. It hooks intosend,select/delete_chat, the composer row, the chat view and the menu. It reusesfiles::thumbnailfor the tray's pictures.New direct dependency:
mime_guess(default features off), to get a file's type from its extension. It's already built in this tree through reqwest with the same features, so nothing new is compiled, and it is pure Rust on all three systems.Why
Closes #137. Part of #157.
How it was tested
Unit tests in
attach.rs:paste/../xpath that only looks like oneWindow tests (headless GPUI,
--features snapshot) using real keys and real drop events:I broke each hook in turn (no drop handler, no paste capture, no clearing on select, edits allowed) and confirmed its test fails.
Window tests from the review:
Unit tests for what ↩ sends (text, files with or without a caption, an edit only, waiting) and for the error after a chat switch.
cargo fmt --check,cargo clippy -p hush-desktop --all-targets -- -D warnings(with and without--features snapshot),cargo test -p hush-desktop(90) and--features snapshot(106) all pass.I checked the snapshots (light and dark). The "files" screen now has a pasted screenshot and a PDF waiting in the tray, the "+" button and the send button. The "chat" and "reply" screens show the "+" beside the field, with the reply bar spanning the full width above.
Not tested
send_attachmentscall is the Mac app's.make checkneeds a signing certificate this Mac doesn't have. The core is unchanged.