Repository navigation
The desktop app shows pictures, plays voice messages, and opens or saves files in chats - #181
Conversation
…ms are only saved; recordings stop when the sound output goes
|
Review findings and fixes (commit 1. Opened copies pile up and outlive their message: fixed.
2. Programs and scripts are never opened: fixed.
3. Direction and format characters in names: fixed. Control characters and Cf characters become 4. The media loader kept working on the old chat: fixed. Before each file it checks that the chat is the same ( 5. Opening went through GPUI's silent opener, which logs on Windows: fixed. The app now runs the opener itself, off the main thread:
The opener's own output is discarded, because it names the file. A failure shows "Couldn't open … : no app here opens this kind of file". Test (macOS): 6. Sound output gone mid-play: fixed.
7. Leftover copies when one is locked: fixed. Each copy's folder is removed on its own, and failures are logged (the error only).
8. Decode limits: done.
9. Picture memory is uncapped: stated, not capped. A real LRU needs pictures to load per drawn row, which is a rework (GPUI's 10. Playback: done.
11. One 12. Names: done.
13. Sticky failures: done.
14. Save As: done. The 15. Retry for files without a pointer or too large: left to your core issue, as asked. 16. Ids keyed by row index: nothing to change. Every file element and its right-click menu is keyed by the attachment id ( Owner's voice notes (one-off, uncommitted test, read-only, nothing copied or kept): all 9 decode, 4 ADTS AAC and 5 M4A. Durations: 5.7, 12.8, 15.3, 15.3 s (ADTS); 7.2, 3.3, 4.9, 8.1, 17.2 s (M4A). Checks:
|
What changed
A chat in the desktop app now shows its messages' files the way the Mac app's
AttachmentViews.swiftdoes. Before, every file showed as "📎 Attachment".Thumbnails, and EXIF rotation is applied. Clicking a picture opens it. A picture that won't decode shows as a file row, so it can still be opened.m:ss, tabular digits). The length is read from the recording's bytes in memory before it plays, for recordings up to 20 MB, as on the Mac. A recording that can't be decoded says "This recording can't be played", and it can still be opened from its menu.ByteCountFormatter: "1.2 MB", "340 KB". Clicking a row opens the file in the system's app for it.download_attachment).AttachmentChangedreloads the open chat's files.isFileDangerouslist, plus macOS and Linux ones such as.app,.command,.sh,.desktop,.deb) offer Save As… only, and clicking them saves. Save As… uses the system's save dialog (prompt_for_new_path). The copy is written beside the chosen file first, then renamed over it, so an existing file is only replaced by a complete copy.Files stay encrypted on disk
Client::file_bytes(decrypted in memory), and opened or saved copies fromClient::copy_file. A recording plays from memory, so unlike the Mac app it never needs a decrypted copy.<data folder>/open/<random>/. There is one copy per file, reused on later clicks, and it is deleted when its message expires or is deleted, or its chat is deleted. The data folder is the core's own (0700 on Unix), not the shared/tmp, and not the Mac app'sHush-open. All copies are also deleted at quit and at launch, once the core holds the data folder, likeFiles.clearLeftovers. Each copy's folder is removed on its own, so one that a program still holds open (Windows locks it) doesn't keep the others; a failure is logged and the next launch tries again.com.apple.quarantinemark, asFiles.quarantinewrites it.Zone.Identifier, Internet zone), which SmartScreen checks._, trailing dots and spaces are dropped (".." with them), Windows device names get a leading_, and long names are cut to 200 bytes keeping the extension. A file without a name gets "file" and its type's extension, unless that extension is a program's.New dependencies
rodio0.23 (playback only, with Symphonia's AAC/M4A, MP3, Vorbis, FLAC and WAV decoders). GPUI and gpui-component have no audio playback, and this is the smallest cross-platform option. It plays through cpal: CoreAudio on macOS, WASAPI on Windows, ALSA on Linux. Linux already needslibasound2-dev(it's in the README list), so no new system package is needed.image0.25: already in the tree through GPUI, with the same features. It is used directly to decode pictures small, because GPUI's ownImagedecoding keeps every pixel of a photo in its cache (about 48 MB for a 12 MP photo).libc, on macOS only, for the quarantine mark (already in the tree).tracing, already in the tree, sends warnings (file ids and errors only) to the core's log. rodio'stracingfeature sends sound-output errors there too.Where the code is
Everything lives in
core/desktop/src/app/files.rs(state and logic) andcore/desktop/src/app/files/view.rs(drawing).app/mod.rsandapp/view.rschange only to hook it in:Hush;client.detailscall as the reactions (actions::load_reactions), read again onAttachmentChanged;selectanddelete_chat, and deleting a message's opened copies onMessageChanged/MessageExpiredonce it is gone;render_rowtakes the window's handle for clicks.Different from the Mac app (say if you want it otherwise)
audio/ogg; codecs=opus) can't be decoded, because Symphonia has no Opus decoder. They say "This recording can't be played" and can still be opened or saved.shortcut:.How it was tested
cargo test -p hush-desktop: 37 pass. The new tests were written first and failed againsttodo!()stubs. They cover:../,..\,..,:,?, trailing dots,con.txt);cargo fmt --check, pluscargo clippy -p hush-desktop --all-targets -- -D warningswith and without--features snapshot: clean. The pre-commit hook's workspace clippy also passed.afconvert/ffmpeg/lame:afconvertADTS file that starts with an 11-byte frame (Symphonia stops on it).--snapshotscreen,files, renders Bogdan's chat. It has a voice message (0:42), Menu.pdf (1.2 MB), a photo still to download, Beach.mp4 downloading, Tickets.zip failed with Retry, a captioned photo and an outgoing photo, in light and dark. The pictures are inside the bubble with 12-point rounded corners. Uncaptioned files have their time under them on the right. The rows, download button, spinner and orange Retry look right in both modes. The existingchatscreen is unchanged.make checkwasn't run: it needs the signing certificate, which this Mac doesn't have.Not tested
AttachmentChangedevents, opening or saving with the real core, or sound output. Playing would make sound on this Mac, so it was checked only up to the decoded source.cfg, and rodio/cpal support all three systems.Closes #136
Part of #157