Menu ▾ ▴

#177 Clickable "Show in Finder / Show in folder" on the download toast

closed
nobody
2026-07-22
2026-07-22
Anonymous
No

Originally created by: kristofferR

Downloads finish with only a passive in-page toast. Make it actionable — macOS-motivated, but tauri-plugin-opener (already a dependency) exposes Rust-side reveal_item_in_dir on macOS (NSWorkspace activateFileViewerSelectingURLs), Windows (SHOpenFolderAndSelectItems), and Linux (FileManager1 D-Bus with portal fallback), so this ships cross-platform for the cost of a label string.

Two verified constraints shape the design:

  • DownloadEvent::Finished.path is always None on macOS, so the url→path mapping must be recorded at Requested time in on_download (window.rs), right after unique_path(...) resolves the destination.
  • The page is a remote origin and must never supply a filesystem path — it only echoes back the download URL as a lookup key into Rust-side state.

Rust side. In download.rs, a RECENT_DOWNLOADS map (pattern: NOTIFICATION_ROUTES in notifications.rs): cap ~32 with oldest-eviction, TTL ~10 min, remember_download(url, path) on Requested, forget_download on failed Finished, non-consuming lookup_download (user may click twice). New carrier:reveal-download listener in lib.rs ({url} payload): lookup → reveal_item_in_dir(path) via spawn_blocking (the Linux impl does blocking D-Bus); miss/error → warn log, no-op. No capability changes — capabilities gate webview IPC, and this call is made from Rust; the page only needs core:event:allow-emit, already granted.

Page side. __carrierToast (inject/src/panel/index.ts) gains an optional {label, onClick} action (inline button, pointerEvents: auto, ~6 s timeout; backward compatible). downloadSrc (context-menu.ts) resolves with the URL key on success; both callers (context menu + download-anchors.ts) show toast("Saved to Downloads", { label: revealLabel(), onClick: () => revealDownload(url) }). revealLabel() = "Show in Finder" when the UA contains "Mac" (the UA is set per-platform by the Rust shell, so this is reliable), else "Show in folder". revealDownload emits the event via the existing bridge.

Edge cases: file moved/deleted before click → plugin canonicalize fails, logged no-op; entry expired/evicted → silent no-op; failed download → entry forgotten, plain toast.

Testing. Unit: map cap/TTL/forget-on-failure (Rust); toast action rendering + downloadSrc key resolution (bun test). Manual: right-click image → Download → "Show in Finder" opens Finder with the file selected; same via the viewer's download anchor; spot-check once on Linux/Windows.

Part of [#179].

Related

Tickets: #179
Tickets: #188
Tickets: #252

Discussion

  • Anonymous

    Anonymous - 2026-07-22

    Originally posted by: kristofferR

    Implemented in [#188] and merged to main. Successful download toasts now include Show in Finder on macOS and Show in folder elsewhere, with reveal requests gated by a trusted user action.

     

    Related

    Tickets: #188

  • Anonymous

    Anonymous - 2026-07-22

    Ticket changed by: kristofferR

    • status: open --> closed
     

Log in to post a comment.