Skip to content

Studio: confirm browser downloads, choose the download folder - #12832

Merged
danielhanchen merged 18 commits into
mainfrom
studio-download-approval
Oct 7, 2026
Merged

danielhanchen merged 18 commits into
mainfrom
studio-download-approval

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Pages in the browser panel could save files without asking. In the desktop app's native views a page could start a download with no click and it went straight into Downloads, limited only by the rate cap. This adds a confirmation for files from websites and lets desktop users choose where downloads go.

Download confirmation

  • Saving a file that came from a website shows Download this file? with the site and file name, a Remember for next time checkbox, and Cancel or Download. Screenshots and files from chat don't ask.
  • With Remember checked, the answer is kept per site: later downloads from it are always allowed, or always blocked with a short notice.
  • Several downloads waiting at once are asked about one at a time.
  • Clicking outside the prompt cancels, like Cancel or Escape.
  • Opening a file the panel can't show (an installer, an archive) starts its download through the prompt, as a browser would. Before, the page only said it can't be shown. Coming back to the tab doesn't ask again.
  • Desktop app, page started downloads: the download handler can't wait for an answer, so the file lands in a staging folder in the app cache while the prompt is up. Allowed, it moves to the download folder (or a save dialog when Ask where to save is on), gets the usual quarantine mark and is recorded in Download history. Cancelled, it is deleted once it finishes. Staging is emptied on first use after launch, so a quit mid-download leaves nothing behind. Blob and form downloads work, since nothing is fetched twice.
  • Download events no longer carry the file's path to the webview.

Download location (desktop app)

  • Settings > Browser > Downloads > Location shows the System Downloads folder or the chosen one, with Change and Reset.
  • The folder is picked in the system folder dialog and stored on the Rust side (browser-download-folder.json in app data). The webview never sends a path, so a page can't point downloads at another folder. A chosen folder that no longer exists falls back to Downloads.
  • New commands: browser_download_decide, browser_download_folder, browser_download_folder_pick and browser_download_folder_reset.

Other settings

  • Ask before downloading (on by default) turns the confirmation off.
  • Site download permissions lists remembered sites, each switchable between Always allow and Always block, or removable.
  • Ask where to save each file now works in the desktop app: off saves straight to the download folder, on shows the save dialog starting there. Before, the desktop app always showed the dialog for panel saves.
  • Location, Ask before downloading and Site download permissions are in the settings search (Location only on desktop), and every new string is translated in all locales.

Module scripts in the web panel

  • Pages load in a sandbox with an opaque origin, so module scripts (always fetched with CORS) fail on hosts that don't allow any origin. google.com/chrome is one: its Download Chrome button is a custom element defined in a module, so it never showed.
  • The backend now fetches a page's module scripts through the same SSRF-guarded fetcher and inlines the self-contained ones. Ones with imports keep their src, since inlining would break their relative URLs. At most 6 per page, 2 MB each, 8 s in all; a failed fetch leaves the tag as it was.

Testing

  • tsc -b, npm run i18n:check:strict and npm run bundle:check pass, with no new eslint findings in the touched files. Browser and settings tests pass (46), including a new test for remembering, changing and forgetting a site's answer.
  • pytest tests/test_browser_routes.py passes (31), with new tests for inlining and for each case that keeps the tag. A live fetch of google.com/chrome comes back with simplify-download defined inline.
  • cargo check --tests passes. cargo test for browser_downloads, native_file_dialogs and browser_webview passes, with a new test for moving a staged file to its target.
  • Checked the web build in a running Studio: the new Downloads rows render, Location is hidden on the web, and the site list switches and removes entries. Opening a Firefox installer URL shows the prompt on its own, an outside click cancels it, and a plain text file still opens with no prompt. The confirmation dialog, the staging flow and the folder picker were not run in a desktop build.

Screenshots

Settings > Browser > Downloads, before and after: the new Ask before downloading and Site download permissions rows (Location is desktop only, so it is hidden on the web build).

Settings > Browser downloads rows, before and after

The web browser panel opening an installer (7-zip.org): before, the page only says the file can't be shown; after, it asks Download this file? with Remember for next time, naming the site that was asked for rather than the host it redirected to.

Download prompt for a file the panel can't show, before and after

@chatgpt-codex-connector

This comment has been minimized.

Base automatically changed from studio-download-history to studio-browser-settings October 6, 2026 06:38
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@shimmyshimmer
shimmyshimmer force-pushed the studio-download-approval branch from e365af5 to 1d33f86 Compare October 6, 2026 08:39
Base automatically changed from studio-browser-settings to main October 6, 2026 10:55
@shimmyshimmer
shimmyshimmer force-pushed the studio-download-approval branch from 1d33f86 to e92aebc Compare October 6, 2026 10:58
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

This comment has been minimized.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@shimmyshimmer shimmyshimmer reopened this Oct 6, 2026
@shimmyshimmer
shimmyshimmer force-pushed the studio-download-approval branch from 944eb17 to 4b7fa78 Compare October 6, 2026 12:16
Files from websites now ask before they are saved, with a Remember
for next time checkbox that always allows or blocks the site. In the
desktop app a page download lands in a staging folder until it is
allowed, then moves to the download folder; cancelled ones are deleted.

Settings > Browser > Downloads adds Location (desktop app), Ask before
downloading and Site download permissions. Ask where to save each file
now works in the desktop app too.
@shimmyshimmer
shimmyshimmer force-pushed the studio-download-approval branch from 706a614 to da5cf2b Compare October 6, 2026 12:36
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex security review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Unsloth and others added 3 commits October 6, 2026 06:53
Downloads
- Quarantine files saved from the panel with their source URL, so
  Gatekeeper/SmartScreen check them; they now skip the save dialog by default.
- Keep a site's download answer for the page that started it. blob: and data:
  downloads have no host, and one answer for "" covered them on every site.
- Escape or an outside click cancels once; only the Cancel button remembers.
- Answer every native download prompt: deny when the tab is gone, catch
  decide failures, refuse past 3 unanswered per tab, and deny after 10 minutes.
- Hold a lock from picking a free name to taking it, so two saves can't pick
  the same one.

Module inlining
- Check integrity metadata before inlining, since the attribute is dropped.
- Leave modules alone that any origin may load (Access-Control-Allow-Origin *).
- Cache answers per module URL (bounded, 10 min), so a site's pages don't
  refetch the same bundles.
- Count inlined code toward the page size limit; one failing fetch leaves
  the page as it was.
- Read script attributes with a start-tag tokenizer, so "src" or "type"
  inside another attribute's value (onerror="this.src='x'") isn't taken
  for the tag's own; repeated attributes keep the first.
- Keep remembered download answers per account (their own store named with
  accountDatabaseName), like history and bookmarks.
- A remembered answer also settles the site's other downloads still waiting.
- Copy across volumes into a temp file beside the target and rename it in
  place, so a failed copy never truncates the file being replaced.
- Report a download location that can't be saved, and keep it only once it
  is on disk.
- Make website file names safe on every platform (Windows-reserved
  characters and device names, trailing dots, 240-byte limit), for panel
  saves and page downloads alike.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Unsloth and others added 2 commits October 6, 2026 07:57
- Keep remembered download answers per origin (scheme, host, port), as
  browsers scope site permissions; the short host is only the label.
- With "Ask where to save" on in the web build, a download that finishes
  after the click expired waits for a Save click instead of saving without
  the dialog (showSaveFilePicker needs a recent click).
- Cache fetched modules only as long as Cache-Control allows (max-age,
  s-maxage less Age, at most 10 min), and never for no-store, no-cache or
  private: a deploy at the same URL shows on the next load.
- Treat a comment between "import"/"from" and the specifier as an import,
  so lazy chunks (import /* name */ ("./a.js")) stay external.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 7, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 7, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 7, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 7, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: a0a9be014f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

affects UI# important# new-feature# security# Moves a security boundary: sandbox, allowlist, permission or network guard >3000#

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants