Pake icon indicating copy to clipboard operation
Pake copied to clipboard

Show native download progress on Windows while preserving Linux and macOS compatibility

Open WavesMan opened this issue 1 month ago • 2 comments

Search before asking

  • [x] I searched in the issues and found nothing similar.

Motivation

Downloads in Pake on Windows can run silently without a visible progress panel or recent download list. Two download paths contribute to this behavior:

  • Browser downloads reach Tauri’s on_download callback, after which Wry sets WebView2’s Handled flag to true, hiding the default download UI.
  • Some file links and context-menu download actions use Rust reqwest, bypassing WebView2’s download manager. Users therefore have limited visibility into active, completed, or failed downloads. The implementation needs to address Windows visibility without introducing regressions in Linux and macOS.

Solution

Implement the change in platform-specific phases.

Phase 1: Windows — currently in progress

  • Register a Windows-specific WebView2 DownloadStarting handler and keep the default download panel visible.
  • Preserve the configured download directory, filename sanitization, and existing-file protection.
  • Install the handler before navigating to remote entry pages, including pages that immediately return attachments.
  • Route same-origin file links and context-menu download actions through native browser downloads.
  • Retain reqwest for cross-origin explicit downloads, where browsers may ignore the download attribute and preview or navigate instead.
  • Use WebView2’s built-in panel rather than introducing a custom download UI in this phase.

Linux and macOS — preserve existing behavior in Phase 1

Both platforms will retain their current combination of reqwest and native browser downloads:

  • Ordinary intercepted HTTP(S) downloads continue through reqwest.
  • Blob URLs, browser attachments, and other browser-managed downloads retain their existing native handling.
  • Existing download-directory rules, authentication handling, and completion/error feedback remain unchanged.
  • No new download panel or progress integration is introduced on these platforms in Phase 1.

Possible follow-up: native adapters with shared UI

A later, separately scoped change could connect WebKitGTK downloads on Linux and WKDownload on macOS to a shared Pake download panel and history page.

Unlike WebView2, these integrations do not automatically provide a Chrome-style download panel. They require platform-specific progress handling and application-provided UI. This follow-up is not part of the current Windows implementation.

Alternatives

  • Build a shared reqwest download manager: offers consistent progress and history UI, but cannot directly handle browser-local blob URLs or faithfully reproduce every browser request, including POST downloads and authentication contexts.
  • Move all platforms to native downloads immediately: preserves browser request semantics but requires three platform adapters, shared UI, and additional lifecycle testing.
  • Route all Windows downloads through temporary anchors: avoids some IPC work, but cross-origin files may open as previews instead of being saved.

Anything else?

Status: implementation is currently in progress. I am working on this task.

Development is on feature/windows-native-download, based on main commit 35bac8f2 (V3.17.5). Initial changes have been committed fork repo.

Validation completed:

  • 88 Rust unit tests passed.
  • 62 targeted JavaScript regression tests passed.
  • A real WebView2 probe verified same-origin files, blob downloads, and entry-page attachments.
  • The probe confirmed progress events, an open default download panel, correct file contents and destinations, existing-file protection, and session Cookie/Referer handling.

Compatibility boundaries and risks

  • Windows cross-origin explicit downloads still use reqwest and will not appear in WebView2’s native download panel.
  • Windows native downloads may use the server-provided attachment filename rather than the suggested anchor filename.
  • Linux and macOS retain their current visibility limitations; this phase does not add progress panels for them.
  • Preserving reqwest on Linux/macOS does not make it equivalent to browser networking. Existing authentication, redirect, referrer, and file-protection behavior must remain intact.
  • Future native adapters must identify tasks by download object rather than URL, since identical URLs can download concurrently.
  • macOS integration must cooperate with Wry’s existing download delegate and avoid synchronous save dialogs inside download callbacks.
  • Linux integration must handle WebKitGTK differences; a future floating panel must also accommodate Wayland positioning restrictions.
  • Cancellation, resume support, and behavior when the originating window closes require separate platform verification.
  • Linux/macOS behavior has not been validated on physical platform environments during this Windows-focused work. Shared-code regression tests do not substitute for that verification.

Further Windows compatibility review is planned before submitting a PR.

Are you willing to submit a PR?

  • [x] I'm willing to submit a PR!

WavesMan avatar Oct 14 '26 15:10 WavesMan

@WavesMan Thanks for the careful write-up and the branch, the phased plan made this easy to take in.

Your three commits are now on main with your authorship, rebased onto the current tree, so there is no need to open a separate PR. On a Windows 11 ARM64 machine the Rust tests and clippy pass, and your WebView2 probe reports three downloads started and completed, progress events, the default download panel open and every file in the right folder. Linux and macOS keep their current download paths, as you scoped it.

It is not in a published release yet. Windows apps will get the native download panel from the next pake-cli release, and I will close this issue once that version is on npm. The Linux and macOS panel stays out of scope for now.

tw93 avatar Oct 21 '26 08:10 tw93

@WavesMan thanks again for this one. pake-cli 3.17.7 is now on npm with your three commits, so Windows apps built with it show the native WebView2 download panel and progress.

Upgrade with npm install -g [email protected], then rebuild the app. Linux and macOS keep their current download paths. I am closing this, feel free to reopen if a download still runs silently on Windows.

tw93 avatar Oct 26 '26 13:10 tw93