You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(browser): Save to this computer for downloads from Server (streamed) pages - #48029
When a page that runs on a paired server (a Server (streamed) page) downloads a file, the file lands on the server, and Orca tells you where. Until now there was no way to get it onto the computer you're using. Now that toast has a Save to this computer button. It copies the file into this computer's Downloads folder, shows progress with Cancel, and then offers Show in Finder (Show in Folder on Windows and Linux). The server keeps its copy.
Files
Added
Deleted
Net
Test
2
$\color{#1a7f37}{\Huge{\mathbf{+}}}$152
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$152
Prod
22
$\color{#1a7f37}{\Huge{\mathbf{+}}}$795
$\color{#cf222e}{\Huge{\mathbf{−}}}$14
$\color{#1a7f37}{\Huge{\mathbf{+}}}$781
What Changed
Before: the toast said Saved to <path> on <server> and nothing else.
After (mockup 3 from the approved round-2 page, with its copy):
The finish toast keeps its message and adds Save to this computer. It stays up for 10 seconds (longer while hovered).
Clicking it turns the same toast into Downloading <name> to this computer… with Cancel, then Saved to <local path> with Show in Finder / Show in Folder.
A failure shows Couldn't save <name> to this computer. with the reason. Cancel removes the toast and leaves nothing in Downloads.
A name that's already taken gets (1), (2) and so on. Nothing is ever replaced.
Nothing goes into History. It's the toast action only.
How it works:
Host: a desktop stream now asks with downloadCopies: 1 (next to downloads: 1). When a download the host saved finishes, the host makes a one-time copy id for the device whose stream heard it, and sends it on that stream's downloadFinished event. The id remembers the file's path, device, inode, size and mtime. It's held for 2 minutes until the first read, then for 60 seconds between reads. There are at most 64 unread ids, and the oldest is dropped first.
New RPCs:browser.readDownloadCopy {copyId, offset} returns the next 512 KiB slice, in order, with one reader at a time. The last slice ends the copy. browser.releaseDownloadCopy drops it. Both refuse other devices and agents. Each read opens the file without following links and without blocking on a pipe, and refuses it if the inode, size or mtime changed since the download finished.
Desktop: the click calls a new IPC (browser:copyServerDownload) into the desktop's main process. Main reads the slices through the existing environment connection on the bulk-read lane, with one read in flight while the previous slice is written, and writes them to a temp file beside the destination in Downloads. It then hard-links the temp file to a free name. A link fails if a file with that name already exists, so nothing is overwritten. On a volume without hard links (FAT, exFAT, some shares) it exclusively creates the file and copies into it through that handle. Cancel, a failure, or the window closing deletes the temp file and releases the copy on the host.
File name: only the base name of the server's path is used. Separators, traversal and control characters are cleaned, leading dots and spaces are removed (so it can't be a hidden file), and reserved Windows names get a _ prefix on Windows. Free names go through the same reservations that local browser downloads use, so the two never collide.
Who can trigger it: only the person, by clicking the button on their own desktop's toast. The copy id goes only to the desktop stream that heard the download finish. The read RPC refuses agents (ownerOnly), other paired devices and local CLI callers: "Only a person at a desktop can copy a download to their computer." The server never gets a path from the desktop, and the desktop never takes a path from the server, only a cleaned name. A web page can't trigger a copy, and neither can a server RPC.
Why
This reuses what exists: the download events on the stream from #47177, the per-device one-time hand-out and release pattern of the streamed print from #47827, the pairing-revision fence, the bulk-read lane for byte-range reads, the browser download name reservations and file-name cleaner, and the existing reveal action.
The copy loop runs in the desktop's main process, not the renderer. A first version streamed the slices through the renderer, using the same path as remote file downloads. Its renderer working set grew by about 670 MB during a 500 MB copy. With main doing it, no bytes reach the renderer.
Linked Issue
No issue (remote browser parity, mockup 3: downloads from streamed pages, Save to this computer).
Visual Proof
Hidden dev desktop paired to a headless orca serve, both built from this branch (macOS). Both downloads folders point at scratch folders, so the paths in the shots are long.
Before (main): the server's path only. (screenshot removed: contained real product data)
After: same message, plus Save to this computer. (screenshot removed: contained real product data)
After: copying, with Cancel.
After: saved here, with Show in Finder. (screenshot removed: contained real product data)
After: the server's file was removed before the click.
Testing
A scratch Playwright probe (not committed) ran a headless orca serve paired to an Electron desktop, both built from this branch, with each side's downloads folder set to a scratch folder. The person clicked links in the streamed page.
Plain copy:q3-report.pdf copied with matching sha256. Show in Finder revealed the local path (stubbed).
Same name again: saved as q3-report (1).pdf. The first file was untouched.
Crafted names: the server's Chromium saved ../../x as _.._x and .bashrc as bashrc. Both landed in Downloads as is.
500 MB: the sha256 matched, and timing and memory are under Performance.
Cancel part-way (about 48 MB in): the temp file was gone, Downloads was unchanged, the toast closed, and the server copy stayed.
Server file deleted before the click: the failure toast appeared and nothing was left here.
An agent on the server calling browser.readDownloadCopy: refused with the sentence above.
Volume without hard links: on a scratch FAT32 disk image, link fails with ENOTSUP. The fallback saved to r (1).pdf next to an existing r.pdf, left r.pdf untouched, and a Cancel during the fallback copy removed its partial file.
Unit tests, each failing when its guard is removed:
browser-download-copy-offers.test.ts: only the offered device reads, in order and once. A replayed slice is refused, and the slices rejoin to the exact bytes. A file swapped in at the path is refused, and so is a symlink (the symlink case is skipped on Windows).
browser-download-incoming.test.ts: crafted names (../../x, ..\..\x, /etc/passwd, .bashrc, . .hidden, .., CON, .nul.txt) all land directly in Downloads under visible, unused names. A file that takes the name during the copy is never replaced, and the copy gets (1).
Codex release gate: NO P0 OR P1 on this head.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
There's no change for anyone who doesn't click the button. The only standing cost is one lstat on the host per finished download on a desktop-streamed page, plus a small held entry (at most 64, with timers that are unref'd).
Measured with a 500 MB copy on macOS over a loopback pairing (dev build):
Time: 16.9 s, about 30 MB/s. 512 KiB slices were as fast as 2 MiB ones.
Desktop renderer: no bytes pass through it. Working set went from 315 to 378 MB from normal UI work. The longest event-loop stall was 8 ms.
Desktop main: the JS heap peaked at 388 MB, all short-lived transport strings. It fell back to 101 MB once collected, with nothing retained. The longest event-loop stall was 4 ms.
Host main: the longest event-loop stall was 13 ms, with none over 50 ms. Each slice is one 512 KiB file read plus base64.
Memory bound: at most two slices are held at once on the desktop. The host holds none between reads.
Link sharing: reads use the bulk-read lane (two slots), so terminal and workspace calls keep their slots. A slice is one 512 KiB frame (about 4 s at 1 Mbit/s), close to the 384 KiB that file downloads use.
Size cap: 4 GiB, enforced by the host (no copy id for larger files) and by the desktop (stops writing past it).
Risk
The riskiest part is the new file write into Downloads. It never replaces a file (link, or exclusive create), it removes only its own partial files, and it shares name reservations with browser downloads. On volumes without hard links, the copy is written twice (temp, then final).
Mixed versions:
Older server: it strips downloadCopies, so no copy id is sent. The toast is the same as today, with no button.
Older desktop: it doesn't send downloadCopies, so the server makes no copy ids.
Phones and the web client: they don't opt in, and the web client's IPC stub refuses.
Level: Medium. A plain revert backs it out.
AI Disclosure
Review
Codex release-gate rounds until a clean one. Fixed along the way:
Copy reads moved to the bulk-read lane and use 512 KiB slices, so a slow link doesn't hold other replies for tens of seconds.
The host opens the file nonblocking (a pipe swapped in can't hang it) and without following links.
A volume without hard links copies through its own exclusively created handle, and on failure removes the file only if it's still the one it created.
Retry names stay reserved until the move.
Copy reads are marked as Orca's own UI calls, so they don't record browser-use interactions per slice.
Cancel is honoured during the final move.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
SSH workspaces don't have streamed pages, so they're unaffected. On Windows, O_NOFOLLOW and O_NONBLOCK don't exist, so the inode, size and mtime check is what refuses a swapped file there. The reveal label is "Show in Folder" on Windows and Linux, as the mockup shows.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
The server-saved download toast gets a Save to this computer action. The
desktop's main process copies the file over the existing connection into
Downloads, slice by slice straight to disk, under a free name, with
progress and Cancel. The server hands out only the file it saved, once,
to the device that heard the download finish.
Completed downloads saved by the host can now be offered to a paired device as readable copy IDs. The receiving client can read the file in ordered chunks and save it in Downloads without overwriting an existing file. Non-web remote-browser clients display a save offer with progress, cancellation, and completion actions. Paired web clients receive unavailable-operation stubs.
Merge Risk: Low · up to 23b54 · assessed changes only
Path filters excluded changed files. This rating applies only to the assessed changes.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: a Save to this computer action for downloads from Server (streamed) pages. The changeset adds the copy flow (offers, reads, release, IPC, renderer toast, and desktop c…
Description check
The description follows the repository template closely. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof with before and after images, Testing, Performance, Risk with a level, AI Discl…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: a Save to this computer action for downloads from Server (streamed) pages. The changeset adds the copy flow (offers, reads, release, IPC, renderer toast, and desktop copy) that matches this title. The title uses the conventional feat(browser) prefix and is specific, so a teammate scanning history can identify the primary change.
Full details: Description check
Explanation
The description follows the repository template closely. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof with before and after images, Testing, Performance, Risk with a level, AI Disclosure (left empty, which is acceptable for an internal contributor), Review, Agent skill upstream boundary, Notes, and Checklist. It explains the mechanism, the trust boundaries, mixed-version behavior, and the rollback path. The Linked Issue section does not reference a tracked issue, and the outside-contributor rule requires one. The final lint, typecheck, test, and build checklist item is unchecked, so validation status is not confirmed in the description.
Resolution
Optional improvements: link a tracked issue in the Linked Issue section if one exists, since the template asks for an actual issue. Confirm lint, typecheck, test, and build results, or state that CI covers them, and check that box.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Data Integrity & Integration · Quick win
Preserve exact file identity with BigInt stats.
Distinct inode values can become equal Numbers. For example, 9007199254740992 and 9007199254740993 have the same Number representation. If size and mtime also match, Lines 97–100 accept a different file.
Use { bigint: true } for both lstat and handle.stat, and retain exact identity fields. Node 24 supports BigInt stats. (nodejs.org)
Based on learnings, numeric Stats.dev and Stats.ino can lose file-identity precision.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Data Integrity & Integration · Quick win
Re-check the file identity after the read, before returning the slice.
The identity check runs once, before handle.read at line 109. Nothing checks the file after the read. If another writer changes the bytes and the mtime inside that window, the slice returns changed content and the desktop reports success. Add the same identity check after the read.
Suggested fix
handle = await open(offer.savePath, LOCAL_READ_OPEN_FLAGS | (constants.O_NOFOLLOW ?? 0))
- const stats = await handle.stat()- const { identity } = offer- if (- !stats.isFile() ||- stats.dev !== identity.dev ||- stats.ino !== identity.ino ||- stats.size !== identity.size ||- stats.mtimeMs !== identity.mtimeMs- ) {- throw new BrowserError(- 'browser_error',- 'The download changed on the server after it was saved. Download it again.'- )- }+ const { identity } = offer+ assertUnchangedSince(identity, await handle.stat())
const length = Math.min(COPY_READ_CHUNK_BYTES, identity.size - offer.nextOffset)
const chunk = Buffer.alloc(Math.max(0, length))
const { bytesRead } = await handle.read(chunk, 0, chunk.length, offer.nextOffset)
+ assertUnchangedSince(identity, await handle.stat())
if (bytesRead !== chunk.length) {
return { released: true }
}
+function assertUnchangedSince(identity: CopyOffer['identity'], stats: Stats): void {+ if (+ !stats.isFile() ||+ stats.dev !== identity.dev ||+ stats.ino !== identity.ino ||+ stats.size !== identity.size ||+ stats.mtimeMs !== identity.mtimeMs+ ) {+ throw new BrowserError(+ 'browser_error',+ 'The download changed on the server after it was saved. Download it again.'+ )+ }+}+
function expireOffer(copyId: string, ms: number): NodeJS.Timeout {
The reason will be displayed to describe this comment to others. Learn more.
Minor · Data Integrity & Integration · Quick win
Use BigInt stats in the fallback cleanup ownership check.
On a volume without hard-link support, numeric Stats can make two different file identifiers compare equal when they exceed Number.MAX_SAFE_INTEGER. If another file takes the target name after copyIntoNewFile creates it and the copy then fails, removeIfStillOurs can match that file and delete it. This needs a replacement at the same name inside a short cleanup window, so the likelihood is low. The impact is one file in Downloads.
Request BigInt stats at both points. BigIntStats compares the identifiers exactly, which removes the false match from rounding.
BigInt stats do not make the cleanup safe. removeIfStillOurs deletes by path after lstat, so a file that replaces the target between the lstat and the delete is still removed. Closing that window needs a different removal method, which this change does not provide.
Suggested fix
- let ours: Stats | null = null+ let ours: BigIntStats | null = null
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When a page that runs on a paired server (a Server (streamed) page) downloads a file, the file lands on the server, and Orca tells you where. Until now there was no way to get it onto the computer you're using. Now that toast has a Save to this computer button. It copies the file into this computer's Downloads folder, shows progress with Cancel, and then offers Show in Finder (Show in Folder on Windows and Linux). The server keeps its copy.
What Changed
Before: the toast said
Saved to <path> on <server>and nothing else.After (mockup 3 from the approved round-2 page, with its copy):
Downloading <name> to this computer…with Cancel, thenSaved to <local path>with Show in Finder / Show in Folder.Couldn't save <name> to this computer.with the reason. Cancel removes the toast and leaves nothing in Downloads.(1),(2)and so on. Nothing is ever replaced.How it works:
downloadCopies: 1(next todownloads: 1). When a download the host saved finishes, the host makes a one-time copy id for the device whose stream heard it, and sends it on that stream'sdownloadFinishedevent. The id remembers the file's path, device, inode, size and mtime. It's held for 2 minutes until the first read, then for 60 seconds between reads. There are at most 64 unread ids, and the oldest is dropped first.browser.readDownloadCopy {copyId, offset}returns the next 512 KiB slice, in order, with one reader at a time. The last slice ends the copy.browser.releaseDownloadCopydrops it. Both refuse other devices and agents. Each read opens the file without following links and without blocking on a pipe, and refuses it if the inode, size or mtime changed since the download finished.browser:copyServerDownload) into the desktop's main process. Main reads the slices through the existing environment connection on the bulk-read lane, with one read in flight while the previous slice is written, and writes them to a temp file beside the destination in Downloads. It then hard-links the temp file to a free name. A link fails if a file with that name already exists, so nothing is overwritten. On a volume without hard links (FAT, exFAT, some shares) it exclusively creates the file and copies into it through that handle. Cancel, a failure, or the window closing deletes the temp file and releases the copy on the host._prefix on Windows. Free names go through the same reservations that local browser downloads use, so the two never collide.Who can trigger it: only the person, by clicking the button on their own desktop's toast. The copy id goes only to the desktop stream that heard the download finish. The read RPC refuses agents (
ownerOnly), other paired devices and local CLI callers: "Only a person at a desktop can copy a download to their computer." The server never gets a path from the desktop, and the desktop never takes a path from the server, only a cleaned name. A web page can't trigger a copy, and neither can a server RPC.Why
This reuses what exists: the download events on the stream from #47177, the per-device one-time hand-out and release pattern of the streamed print from #47827, the pairing-revision fence, the bulk-read lane for byte-range reads, the browser download name reservations and file-name cleaner, and the existing reveal action.
The copy loop runs in the desktop's main process, not the renderer. A first version streamed the slices through the renderer, using the same path as remote file downloads. Its renderer working set grew by about 670 MB during a 500 MB copy. With main doing it, no bytes reach the renderer.
Linked Issue
No issue (remote browser parity, mockup 3: downloads from streamed pages, Save to this computer).
Visual Proof
Hidden dev desktop paired to a headless
orca serve, both built from this branch (macOS). Both downloads folders point at scratch folders, so the paths in the shots are long.Before (main): the server's path only.
(screenshot removed: contained real product data)
After: same message, plus Save to this computer.
(screenshot removed: contained real product data)
After: copying, with Cancel.

After: saved here, with Show in Finder.
(screenshot removed: contained real product data)
After: the server's file was removed before the click.

Testing
A scratch Playwright probe (not committed) ran a headless
orca servepaired to an Electron desktop, both built from this branch, with each side's downloads folder set to a scratch folder. The person clicked links in the streamed page.q3-report.pdfcopied with matching sha256. Show in Finder revealed the local path (stubbed).q3-report (1).pdf. The first file was untouched.../../xas_.._xand.bashrcasbashrc. Both landed in Downloads as is.browser.readDownloadCopy: refused with the sentence above.ENOTSUP. The fallback saved tor (1).pdfnext to an existingr.pdf, leftr.pdfuntouched, and a Cancel during the fallback copy removed its partial file.Unit tests, each failing when its guard is removed:
browser-download-copy-offers.test.ts: only the offered device reads, in order and once. A replayed slice is refused, and the slices rejoin to the exact bytes. A file swapped in at the path is refused, and so is a symlink (the symlink case is skipped on Windows).browser-download-incoming.test.ts: crafted names (../../x,..\..\x,/etc/passwd,.bashrc,. .hidden,..,CON,.nul.txt) all land directly in Downloads under visible, unused names. A file that takes the name during the copy is never replaced, and the copy gets(1).Codex release gate:
NO P0 OR P1on this head.Performance
There's no change for anyone who doesn't click the button. The only standing cost is one
lstaton the host per finished download on a desktop-streamed page, plus a small held entry (at most 64, with timers that are unref'd).Measured with a 500 MB copy on macOS over a loopback pairing (dev build):
Risk
The riskiest part is the new file write into Downloads. It never replaces a file (link, or exclusive create), it removes only its own partial files, and it shares name reservations with browser downloads. On volumes without hard links, the copy is written twice (temp, then final).
Mixed versions:
downloadCopies, so no copy id is sent. The toast is the same as today, with no button.downloadCopies, so the server makes no copy ids.Level: Medium. A plain revert backs it out.
AI Disclosure
Review
Codex release-gate rounds until a clean one. Fixed along the way:
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
SSH workspaces don't have streamed pages, so they're unaffected. On Windows,
O_NOFOLLOWandO_NONBLOCKdon't exist, so the inode, size and mtime check is what refuses a swapped file there. The reveal label is "Show in Folder" on Windows and Linux, as the mockup shows.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)