Skip to content

feat(desktop): multi-select in the paperclip file picker#551

Merged
tlongwell-block merged 1 commit into
mainfrom
dawn/file-picker-multi-select
May 12, 2026
Merged

feat(desktop): multi-select in the paperclip file picker#551
tlongwell-block merged 1 commit into
mainfrom
dawn/file-picker-multi-select

Conversation

@tlongwell-block
Copy link
Copy Markdown
Collaborator

Why

Drag-drop and paste already handle multiple files (handleDrop /
handlePaste in useMediaUpload.ts), but the 📎 paperclip button
opens pick_file (singular) so users can only attach one at a time.
Mentioned on the May 12 standup.

What

Switch the Tauri file dialog to pick_files (plural — already
available in tauri-plugin-dialog v2.7) and process each picked path
through the existing TOCTOU-safe pipeline.

Rust (desktop/src-tauri/src/commands/media.rs)

  • Extract the per-file pipeline into process_picked_path so
    pick_and_upload_media can call it once per selected path. The
    fd-pinning / transcode / poster-upload behaviour is preserved
    verbatim per file.
  • Command return type is now Vec<BlobDescriptor> (empty on
    cancellation). Uploads run sequentially; if one fails, the command
    returns the error for that file and earlier successes are not rolled
    back — they're already content-addressed on the relay.

TS

  • desktop/src/shared/api/tauri.tspickAndUploadMedia returns
    BlobDescriptor[].
  • desktop/src/features/messages/lib/useMediaUpload.ts
    handlePaperclip appends each returned descriptor through the
    existing slot system. Spinner count is incremented once at click and
    decremented once when uploads return, matching the previous UX.

Verification

  • just desktop-tauri-check — passes.
  • just desktop-tauri-fmt-check — passes.
  • just desktop-check (Biome + file-size guard) — passes (media.rs
    is 719 lines, override is 720).
  • just desktop-typecheck — passes.
  • just desktop-build — passes.
  • node --test useMediaUpload.test.mjs — 10/10 pass.

Risk

Moderate. The Rust API surface for pick_and_upload_media changes
shape (Option → Vec); the only TS caller is updated in the same
PR. The security-critical fd-pinning pattern is preserved per file.
Sequential upload semantics keep the error-handling model simple.

The 📎 paperclip button only accepted one file at a time even though
drag-drop and paste already handle multi-file uploads. Switch the Tauri
file dialog from `pick_file` to `pick_files` and process each picked
path through the existing TOCTOU-safe pipeline (fd pin → sniff →
transcode-or-passthrough → MIME validation → upload).

Rust:
- Extract the per-file pipeline into `process_picked_path` so
  `pick_and_upload_media` can call it once per selected path. The
  fd-pinning / transcode / poster-upload behaviour is preserved
  verbatim per file.
- Command return type is now `Vec<BlobDescriptor>` (empty on
  cancellation). Uploads run sequentially; if one fails, the command
  returns its error and earlier uploads are not rolled back (they're
  already content-addressed on the relay).

TS:
- `pickAndUploadMedia` returns `BlobDescriptor[]`.
- `handlePaperclip` appends each descriptor through the existing
  slot system. Spinner count is incremented once at click time and
  decremented once when the dialog + uploads return, matching the
  previous UX.

Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com>
@tlongwell-block tlongwell-block force-pushed the dawn/file-picker-multi-select branch from 93baca5 to 97ad60a Compare May 12, 2026 18:26
@tlongwell-block tlongwell-block merged commit 61c30ad into main May 12, 2026
15 checks passed
@tlongwell-block tlongwell-block deleted the dawn/file-picker-multi-select branch May 12, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants