Repository navigation
fix(browser): end downloads that are waiting for a manual resume Orca never offers - #28936
Conversation
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
🧹 Nitpick comments: 1
src/main/browser/browser-manager-downloads.test.ts: 1
387-426: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the interrupted-to-retry transition.
The added test keeps
getState()asinterrupteduntil the deferred check runs. It therefore covers only the manual-resume failure path. It does not detect a regression where Chromium changes the item toprogressingafter the interrupted event. Update the test to change the item state toprogressingbefore the deferred check, then assert thatitem.cancelis not called and no failed completion is reported.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
48340077-d6f5-4776-9dec-a041882a5acb
📒 Files selected for processing: 1
src/main/browser/browser-manager-downloads.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
|
A download waiting for a manual Resume could stay at “Downloading paused” forever because Electron never sends its final event in that state and Orca offers no Resume action. This PR makes the main process end that download with the existing “Download was interrupted.” failure, releasing its bookkeeping and requesting partial-file and remote-route cleanup. Chromium’s automatic retries retain their existing behavior. Review completed in two rounds, including independent architecture/correctness reviews and readiness/performance checks, with no proven production defect. The review change at Verified full PR workflow 38690420906 at exact head Fresh remote QA and a separate Windows targeted test were blocked by insufficient memory, and neither was started. Earlier macOS CDP screenshots/logs show an active real download reaching the existing interruption failure without a paused row. Those are historical branch evidence, accepted because production is unchanged; the running process SHA and a fresh same-input main comparison were not independently established. Normal completion, explicit Cancel, physical partial-file deletion, live record/route release, and the remote toast were not independently revalidated in this review. Deferred: the existing shared-connection policy remains—any unanswered request, including remote download abort, can fail the connection after 30 seconds and trigger reconnect. The coordinator reviewed this consequence and kept it out of scope; it is pre-existing transport policy. No open review decision remains, and the PR has not been merged. Historical whole-window macOS evidence, active download then final failure (not a main-versus-branch comparison): |


ELI5
When a download in Orca's built-in browser lost its connection and Chromium decided only a person could restart it, Orca had no "resume" button to offer. The download just sat there as "Downloading paused" with only a Cancel button, forever. Now Orca ends it as failed, like any other broken download, and throws away the half-written file.
What Changed
The problem. Electron reports a broken download in one of two ways. If it can't be resumed, it fires its final
doneevent and Orca shows "Download failed". If it could be resumed, it instead fires anupdatedevent with stateinterruptedand waits for someone to callresume(). Orca never offers a resume action, so that second kind never finished:Before / after for the user. Before: a dropped resumable download sat at "Downloading paused" indefinitely, and its partial file stayed on disk. After: it ends as failed with "Download was interrupted." (the same message a non-resumable interruption already shows), its partial file is removed, and the remote-workspace toast reaches its error state. Downloads that Chromium is still retrying on its own are unaffected and keep going.
The mechanism. The main process, which owns every download, now decides when one is over:
browser-manager-download-creation.ts: whenupdatedreportsinterruptedanditem.canResume()is true, the download is waiting for a person. Orca does not forward thatinterruptedprogress (so the shelf never flashes "paused") and schedules one check on the next turn of the event loop (setImmediate). Canceling inside Chromium's own update callback would nest a second update inside the first, which Chromium does not allow. The check re-reads the record and the item; if the download is still interrupted and still waiting for a manual resume, it is ended as failed.browser-manager-download-lifecycle.ts: the existing cancel path (cancelDownloadInternal) now takes the final status,canceledorfailed. It already does all the cleanup once: detaches the item's listeners, cancels the Chromium item (which deletes the partial file), releases the reserved file name, aborts any remote-workspace relay without waiting for it, and sends the one finished event. It does not use the client-hosted settle path that waits for the remote abort, so cleanup can't delay the result.browser-page-download-activity.ts: the "is this page still downloading?" tracker that keeps a page from being unloaded now just counts from start to finish. It no longer guesses at interruptions, because every download it sees now gets a finished event.This applies to every browser download: local ones, downloads from remote-workspace pages, and downloads that fell back to the local Downloads folder.
Why
The root cause was that whether a download is over depended on an event (
done) that never arrives for this case, so every consumer (shelf, page-unload veto, remote toast, main's own bookkeeping) was stranded or had to patch around it separately. Making the main process, the one owner of the download, decide when it ends fixes all of them at once and removes the renderer's workaround instead of adding another.The common pattern for an embedded browser with no resume UI is to wait only for
done, which strands these downloads the same way; nobody we looked at offers a manual resume for embedded-browser downloads either. Ending them is the honest state when there's no way to resume.Alternatives considered:
No wire format or message change: older and newer clients see the same
download-finishedevent they already handle.Linked Issue
N/A (maintainer change; no existing issue).
Visual Proof
N/A: the change is a download that used to sit at "Downloading paused" now shows the existing "Download was interrupted." failure row. No new UI.
Testing
src/main/browser/browser-manager-downloads.test.ts: one focused regression: a download waiting for manual resume is canceled once, sends no "paused" progress, sends exactly onefailedfinished event, drops its record and releases its file name. The fixture emits no nativedoneevent, so this checks the previously stranded case. The distinction from Chromium automatic retries was checked separately against the pinned native source; the earlier macOS run also recorded Range requests.browser-page-download-activity.test.ts: removed the interruption cases the tracker no longer handles.Ran the two test files above plus the client-hosted and destroyed-guest download suites on Linux; oxlint and oxfmt clean on the changed files; typecheck in CI.
Manual Electron check on macOS (built branch, hidden test copy of Orca, driven over the Chrome DevTools Protocol): a local server that sends part of a 50 MB file with
Accept-Rangesand then drops the connection.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)