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
fix(browser): Print on a streamed page saves a PDF on your desktop - #47827
On a page that runs on a paired server (a Server (streamed) page), clicking the site's own Print button did nothing you could see. Now Orca asks where to save the page as a PDF on your computer, then opens that PDF in your system's PDF viewer, where you can print it.
Files
Added
Deleted
Net
Test
2
$\color{#1a7f37}{\Huge{\mathbf{+}}}$123
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$123
Prod
16
$\color{#1a7f37}{\Huge{\mathbf{+}}}$439
$\color{#cf222e}{\Huge{\mathbf{−}}}$25
$\color{#1a7f37}{\Huge{\mathbf{+}}}$414
What Changed
Before: the page runs in a hidden window on the server, and Orca's print guard there either let print() open a print dialog on the server's own screen (nobody sees it) or, once an agent had driven the page, refused it and only told the agent. The person streaming the page got nothing.
After:
Host: server pages never open a print dialog on the host. When the guard holds a server page's print(), the host checks that the person's own input just reached the page. That is a short-lived print credit per tab, kept apart from the single-use credit that decides which viewer a popup follows. Any agent command that runs on the tab withdraws it. Input that arrives while an agent command runs on the tab or its popups isn't credited, and nothing is relayed during one.
The print: if that check passes, the host prints the frame that asked to PDF right away (the page, or just the iframe for iframe.contentWindow.print()). It sends a print event to that device's stream of the page, or of another page in the same tab when a popup prints itself as it opens. Only streams opened with prints: 1 hear it, and until the device starts reading, each new stream it opens on those pages is told again. Each device and page has at most one print at a time, up to 256 MiB, held until it is read to the end, released, or 5 minutes pass.
New RPCs:browser.readPrintPdf hands the print out in 2 MiB slices, and browser.releasePrintPdf drops it. Both work only for the device it was sent to.
Desktop: on a print event the pane fixes the pairing that sent it, opens the usual save dialog (<page title>.pdf), streams the slices into the chosen file through the existing remote-download path, then opens it with the system's default PDF app. Cancelling or a failure releases the print on the host, and failures show "Couldn't save the page as a PDF". Each print id is saved once (the last 64 handled ids are kept).
Agents: a print caused by an agent's click or script is still refused and reported as blockedPrint.
Who can trigger it: only the person, through their own click or key press on the streamed page from a paired desktop that opted in. Page script can call print(), but it reaches a desktop only within a second of that person's input to the same tab, and never while an agent command runs on it. Agents can't trigger it. Phones and the web client don't opt in. A re-paired or different host can't answer for an earlier print.
Why
This reuses what already exists: the local print guard, the page input credit that already decides which viewer a popup follows, the save-and-open flow used to open remote files in the default app, the pairing-revision fence used by granted file downloads, and the stream event opt-in pattern. The PDF is made when the page prints, not after the save dialog closes, so a page that navigates away while you pick a folder still saves what it printed.
Known limit: a local print dialog blocks the page's script until you close it, but on the server print() returns at once. So a page that changes itself in the same script right after print() (for example print(); document.body.innerHTML = …) saves the changed page. Locally Cmd+P is Go to File, not print, so that is unchanged here.
Linked Issue
No issue (remote browser parity gap M19: Print / Save as PDF on Server pages).
Visual Proof
Hidden dev desktop paired to a throwaway orca serve, both built from the branch (macOS). The page has Print, Print big, Print invoice (iframe), Print-then-leave and Print receipt (popup) buttons. The desktop's save dialog and shell.openPath were stubbed in its main process, so these show the page, the PDFs that were saved, and the error toast.
Before (main): click Print in the streamed page. The page called print(), and nothing appeared on the desktop.
After: the PDF saved from clicking Print (first page, rendered with sips):
After: "Print invoice" prints a hidden iframe, and only the invoice is saved:
After: "Print receipt" opens a popup that prints itself on load; the receipt is saved:
After: the toast when saving fails (the save dialog returned a folder that doesn't exist): (screenshot removed: contained real product data)
Testing
Ran a scratch Playwright probe (not committed) on macOS against a headless paired orca serve and a paired Electron desktop, both built from this branch.
Results:
Print: the save dialog was offered Print probe page.pdf. A valid PDF was written and passed to shell.openPath.
Big page: a 17.7 MB PDF arrived in 9 slices and matched browser.pdf for the same page in size.
iframe print: only the iframe's document was saved.
Popup that prints on load: saved as Receipt.pdf.
Cancel: nothing opened and no toast. The next print worked, because the cancelled one had been released.
Failed save: the error toast appeared.
Agent clicks Print (host CLI browser.mouseClick): no save dialog on the desktop, and the agent's result carried blockedPrint.
Viewer click, then an agent eval of setTimeout(() => print(), 100): no save dialog. The viewer's next Print still worked.
Before, on main: so that no real print panel could open on this Mac, the frames were told the agent leads them. The viewer's click ran print() and nothing reached the desktop.
Unit tests (each fails when its guard is removed):
browser-print-viewers.test.ts: a print goes only to the device whose input printed, and its slices rejoin to the exact bytes. 50 more prints while one waits render nothing. Release frees it. A print rendered between streams reaches the tab's next stream.
browser-page-input-credit.test.ts: opening a tab doesn't spend the print credit, an agent command withdraws it, an agent's input credits no one, and it lapses after a second.
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
None for anyone who doesn't print: nothing runs until a page prints from a person's input.
When a page does print:
Rendering: each device and page renders at most one PDF at a time. A page calling print() in a loop renders one, and the extra calls do no work.
Memory: a print holds at most 256 MiB on the host until it is read to the end, released, or 5 minutes pass.
Reads: each is a 2 MiB slice, base64 on the main thread, sent only when the desktop asks. A 17.7 MB PDF took 9 reads.
Cleanup: timers are unref'd and cleared, and the viewer registry empties when streams close.
Extra IPC: one more reply per document load on browser pages (the print answer next to the existing agent-lead answer).
Risk
The riskiest part is the guard change: print() now opens the host's native dialog only when main says the page isn't a server page. A local desktop page gets that answer together with the agent lead it already waited for, so it prints as before. A server page never prints natively, even from an older desktop.
Mixed versions:
An older desktop doesn't send prints: 1. On a new server, a print goes nowhere instead of to a hidden dialog on the server.
An older server strips prints. The desktop never gets a print event and never calls the new RPCs.
Phones and the web client don't opt in.
Level: Medium. A plain revert backs it out.
AI Disclosure
Review
One review round, then Codex release-gate rounds until a clean one. Fixed along the way:
PDF slices could splice two renders. Each print is one held snapshot with an id.
Rendering now happens when the page prints, so the PDF is what was printed.
iframe prints save the frame that asked.
Prints are refused while an agent command runs on the tab or its popups, and agent commands withdraw the viewer's credit.
Renders are bounded to one per device and page. A save waiting in its dialog can't be evicted, and a cancelled save releases its print.
A print stays readable across a stream reconnect, and an unread print is told again to the device's next stream, which covers a popup that prints as it opens.
Reads are pinned to the pairing that sent the print.
Opening a tab no longer spends the print credit, and a viewer's input that arrives while an agent command runs in the tab can't authorize a print.
The desktop remembers the last 64 handled print ids, so a retold print is saved once.
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 route popups and local pages are not server pages, so they keep native printing. Saving goes through the existing download flow, which cleans the file name and writes through a temp file.
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)
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
The change adds print handling for server pages and paired-device viewers. It registers viewers for print events, stores rendered PDFs, and serves them in bounded chunks through a browser RPC. Remote browser clients opt into print events, then save and open the PDF locally. The change also adds print-related contracts, input-credit lookup, and tests for device checks, chunked PDF reads, and viewer registration timing.
Merge Risk: Low · up to afcf5 · assessed changes only
Path filters excluded changed files. This rating applies only to the assessed changes.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Description check
The description is thorough and follows the repository template closely. It includes ELI5, What Changed, Why, Visual Proof with before/after screenshots, Testing with the checklist, Performance, Risk …
1) Linked Issue: the template says an actual issue must be linked, and it should always exist for outside contributors. The author wrote "No issue" and referred to a parity gap. Either link an existing issue with "Fixes #" or confir…
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title "fix(browser): Print on a streamed page saves a PDF on your desktop" matches the main change: print on a server-streamed page now saves a PDF to the desktop instead of printing on the unseen…
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 "fix(browser): Print on a streamed page saves a PDF on your desktop" matches the main change: print on a server-streamed page now saves a PDF to the desktop instead of printing on the unseen server screen. The raw summary covers the print guard, the print-viewer lifecycle, the new read and release RPCs, and the desktop save flow, all of which fit the title. The title is concise, specific, and free of file lists or vague terms.
Full details: Description check
Explanation
The description is thorough and follows the repository template closely. It includes ELI5, What Changed, Why, Visual Proof with before/after screenshots, Testing with the checklist, Performance, Risk with a level and rollback plan, Review, Agent skill upstream boundary, Notes, and Checklist. The Linked Issue section is filled with a note that no issue exists, which the template requires for outside contributors. The AI Disclosure section is empty. The final lint, typecheck, test, and build checklist item is unchecked, and the description does not say whether those commands passed. The author states that CI will cover them or that local runs are preferred, but no result is reported.
Resolution
Linked Issue: the template says an actual issue must be linked, and it should always exist for outside contributors. The author wrote "No issue" and referred to a parity gap. Either link an existing issue with "Fixes #<number>" or confirm the contributor is a maintainer who does not need one. 2) AI Disclosure: fill in this section, or state that it is not applicable because the author is a StablyAI team member. 3) Checklist: confirm whether pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass locally, or state that CI should cover them. Mark the item accordingly. 4) Visual Proof: two of the four attached images in the PR body are blank black images. Replace or remove them so the before and after views are readable.
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; 1 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Keep a print readable while its save is pending.
printForBrowserViewer drops the oldest held print when a device's page reaches three held prints. Its comment says a save in progress keeps its print, but the code does not track save state. If four prints complete for the same device and page before the first read, the first print is deleted. Its save then fails with "This print is no longer available" after the user chooses a destination.
The renderer guard in remote-browser-page-print.ts also contributes. It returns without reading later events, so those prints keep their slots until they expire or are evicted.
Require that a print whose save has started remains readable until its read finishes or its hold expires. Choose how excess prints are handled so that this print is not evicted and the three-print bound still holds.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Clear print credit that a viewer restores during an agent command before that command's print can use it.
A paired viewer's command on an owned popup can record print credit for the owner tab while an agent command on that tab still runs. The agent's withdrawal happens only when its command starts. If the agent calls print() and the command then settles, the print event can still find that credit. It then sends the PDF to the viewer's desktop, although the agent scheduled the print.
Prints scheduled by an agent command must stay blocked and reported, as the PR objective requires. Restored viewer credit must not authorize such a print. Choose the mechanism, for example by clearing print credit when the agent command settles, or by not recording print credit while an agent command runs on the tab.
A Server (streamed) page runs in a hidden window on the server, so its
print() either opened a print dialog on the server or, once an agent had
driven the page, was refused and only reported to the agent. Nothing ever
reached the person viewing the page.
Server pages now never open a print dialog on the host. When a viewer's
own click or key press makes the page print, the host prints the frame
that asked (the page or an iframe) to PDF right away and sends that
viewer a print event (opt-in with prints: 1). The desktop asks where to
save it, reads it in slices through browser.readPrintPdf, which only the
device it was sent to can read, and opens it in the system PDF viewer,
where it can be printed. An agent's print is still refused and reported
to it.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Minor · Report refused prints caused by an active popup command. · browser-manager-visibility.ts:215-216
src/main/browser/guest-lifecycle/manager/browser-manager-visibility.ts:215-216 Minor · Functional Correctness · Quick win
Report refused prints caused by an active popup command.
If an agent command in an ordinary same-origin popup calls opener.print(), the owner tab can still be unled. The tab-wide execution check rejects viewer printing, but this guard returns because only the printing guest's lead is checked. No refusal event reaches the popup command.
Include active popup commands in refusal detection and event routing. Preserve the early return after successful viewer printing. The PR objectives require prints during popup agent activity to be refused and reported.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 4a455bda-f2df-4132-804b-e842533b845b
Commits
Reviewing files that changed from the base of the PR and between bdc8d3b and afcf5a8.
Files ignored due to path filters: 1
src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
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
On a page that runs on a paired server (a Server (streamed) page), clicking the site's own Print button did nothing you could see. Now Orca asks where to save the page as a PDF on your computer, then opens that PDF in your system's PDF viewer, where you can print it.
What Changed
Before: the page runs in a hidden window on the server, and Orca's print guard there either let
print()open a print dialog on the server's own screen (nobody sees it) or, once an agent had driven the page, refused it and only told the agent. The person streaming the page got nothing.After:
print(), the host checks that the person's own input just reached the page. That is a short-lived print credit per tab, kept apart from the single-use credit that decides which viewer a popup follows. Any agent command that runs on the tab withdraws it. Input that arrives while an agent command runs on the tab or its popups isn't credited, and nothing is relayed during one.iframe.contentWindow.print()). It sends aprintevent to that device's stream of the page, or of another page in the same tab when a popup prints itself as it opens. Only streams opened withprints: 1hear it, and until the device starts reading, each new stream it opens on those pages is told again. Each device and page has at most one print at a time, up to 256 MiB, held until it is read to the end, released, or 5 minutes pass.browser.readPrintPdfhands the print out in 2 MiB slices, andbrowser.releasePrintPdfdrops it. Both work only for the device it was sent to.printevent the pane fixes the pairing that sent it, opens the usual save dialog (<page title>.pdf), streams the slices into the chosen file through the existing remote-download path, then opens it with the system's default PDF app. Cancelling or a failure releases the print on the host, and failures show "Couldn't save the page as a PDF". Each print id is saved once (the last 64 handled ids are kept).blockedPrint.Who can trigger it: only the person, through their own click or key press on the streamed page from a paired desktop that opted in. Page script can call
print(), but it reaches a desktop only within a second of that person's input to the same tab, and never while an agent command runs on it. Agents can't trigger it. Phones and the web client don't opt in. A re-paired or different host can't answer for an earlier print.Why
This reuses what already exists: the local print guard, the page input credit that already decides which viewer a popup follows, the save-and-open flow used to open remote files in the default app, the pairing-revision fence used by granted file downloads, and the stream event opt-in pattern. The PDF is made when the page prints, not after the save dialog closes, so a page that navigates away while you pick a folder still saves what it printed.
Known limit: a local print dialog blocks the page's script until you close it, but on the server
print()returns at once. So a page that changes itself in the same script right afterprint()(for exampleprint(); document.body.innerHTML = …) saves the changed page. Locally Cmd+P is Go to File, not print, so that is unchanged here.Linked Issue
No issue (remote browser parity gap M19: Print / Save as PDF on Server pages).
Visual Proof
Hidden dev desktop paired to a throwaway
orca serve, both built from the branch (macOS). The page has Print, Print big, Print invoice (iframe), Print-then-leave and Print receipt (popup) buttons. The desktop's save dialog andshell.openPathwere stubbed in its main process, so these show the page, the PDFs that were saved, and the error toast.Before (main): click Print in the streamed page. The page called

print(), and nothing appeared on the desktop.After: the PDF saved from clicking Print (first page, rendered with

sips):After: "Print invoice" prints a hidden iframe, and only the invoice is saved:

After: "Print receipt" opens a popup that prints itself on load; the receipt is saved:

After: the toast when saving fails (the save dialog returned a folder that doesn't exist):
(screenshot removed: contained real product data)
Testing
Ran a scratch Playwright probe (not committed) on macOS against a headless paired
orca serveand a paired Electron desktop, both built from this branch.Results:
Print probe page.pdf. A valid PDF was written and passed toshell.openPath.browser.pdffor the same page in size.Receipt.pdf.browser.mouseClick): no save dialog on the desktop, and the agent's result carriedblockedPrint.setTimeout(() => print(), 100): no save dialog. The viewer's next Print still worked.Before, on main: so that no real print panel could open on this Mac, the frames were told the agent leads them. The viewer's click ran
print()and nothing reached the desktop.Unit tests (each fails when its guard is removed):
browser-print-viewers.test.ts: a print goes only to the device whose input printed, and its slices rejoin to the exact bytes. 50 more prints while one waits render nothing. Release frees it. A print rendered between streams reaches the tab's next stream.browser-page-input-credit.test.ts: opening a tab doesn't spend the print credit, an agent command withdraws it, an agent's input credits no one, and it lapses after a second.Codex release gate:
NO P0 OR P1on this head.Performance
None for anyone who doesn't print: nothing runs until a page prints from a person's input.
When a page does print:
print()in a loop renders one, and the extra calls do no work.Risk
The riskiest part is the guard change:
print()now opens the host's native dialog only when main says the page isn't a server page. A local desktop page gets that answer together with the agent lead it already waited for, so it prints as before. A server page never prints natively, even from an older desktop.Mixed versions:
prints: 1. On a new server, a print goes nowhere instead of to a hidden dialog on the server.prints. The desktop never gets aprintevent and never calls the new RPCs.Level: Medium. A plain revert backs it out.
AI Disclosure
Review
One review round, then 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 route popups and local pages are not server pages, so they keep native printing. Saving goes through the existing download flow, which cleans the file name and writes through a temp file.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)