Skip to content

fix(browser): end downloads that are waiting for a manual resume Orca never offers - #28936

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/download-manual-resume-abandon
Oct 15, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/download-manual-resume-abandon

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​45 $\color{#cf222e}{\Huge{\mathbf{−}}}$​52 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​52 $\color{#cf222e}{\Huge{\mathbf{−}}}$​47 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

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 done event and Orca shows "Download failed". If it could be resumed, it instead fires an updated event with state interrupted and waits for someone to call resume(). Orca never offers a resume action, so that second kind never finished:

  • the download shelf showed "Downloading paused" with only Cancel, for the whole session;
  • the main process kept the download record, its listeners, its reserved file name in Downloads (and, for pages hosted on a paired remote workspace, the staging copy and relay to that workspace) until the app quit;
  • the browser page that started it had to invent its own "interrupted means no longer active" rule so it could still be unloaded to save memory;
  • for pages hosted on a remote workspace, the download toast kept spinning, because no finished event ever arrived.

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:

  1. browser-manager-download-creation.ts: when updated reports interrupted and item.canResume() is true, the download is waiting for a person. Orca does not forward that interrupted progress (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.
  2. browser-manager-download-lifecycle.ts: the existing cancel path (cancelDownloadInternal) now takes the final status, canceled or failed. 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.
  3. 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:

  • Add a Resume button. A bigger product change (new action, new wire message to older clients); nothing asks for it today. This change doesn't rule it out later.
  • Treat any interruption as failure. Wrong: Chromium retries network drops on its own (up to 5 times) and those retries look like progress, so they must be left alone. Only the "waiting for a person" state is ended.
  • End it in the renderer. The renderer only sees progress events and can't free main's resources; main owns the item, so main decides.

No wire format or message change: older and newer clients see the same download-finished event 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 one failed finished event, drops its record and releases its file name. The fixture emits no native done event, 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-Ranges and then drops the connection.

    • Clean mid-body close: Chromium made its 5 automatic resume attempts (seen in the server log); the shelf kept showing byte progress during them and never "Downloading paused"; about 0.1 s after the last attempt the row switched to "Download was interrupted." with the failed icon, stayed that way for over 150 s, and the partial file was deleted.
    • Connection reset (which Chromium does not retry): no retries, the row went straight to the same failure.
  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

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-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Cross-platform: Electron/Chromium behavior, no platform branches.
  • Remote / SSH: remote-workspace downloads go through the same end path; their relay is aborted without waiting, as on cancel.
  • Compatibility: no wire change.

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)
  • 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)

@brennanb2025
brennanb2025 marked this pull request as ready for review October 15, 2026 03:37
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The main process now checks whether an interrupted download remains resumable and reports it as failed if it does. The cancellation method accepts either a canceled or failed status. The renderer tracks active downloads from start to finish and no longer listens for progress events.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 443b3

A download that Chromium is retrying could regress without the new test noticing. The change appears mergeable, but the retry transition should be covered.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the primary change: ending browser downloads that are waiting for a manual resume that Orca does not provide.
Description check Passed The description is complete and directly matches the changes. It includes the user impact, mechanism, rationale, alternatives, maintainer-specific issue exception, testing evidence, compatibility cons…
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments: 1
src/main/browser/browser-manager-downloads.test.ts: 1

387-426: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the interrupted-to-retry transition.

The added test keeps getState() as interrupted until the deferred check runs. It therefore covers only the manual-resume failure path. It does not detect a regression where Chromium changes the item to progressing after the interrupted event. Update the test to change the item state to progressing before the deferred check, then assert that item.cancel is 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
📥 Commits

Reviewing files that changed from the base of the PR and between a8184b2 and 443b30b.

📒 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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

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 443b30b9cae9ba2045ce693f6cacf1d9b2e85cf3 trims the regression to the actual stranded-download case and removes an inaccurate mock-retry claim; gross test additions are 45 versus 52 production. Production code is unchanged from 4a366f1.

Verified full PR workflow 38690420906 at exact head 443b30b9cae9ba2045ce693f6cacf1d9b2e85cf3: .github/workflows/pr.yml completed successfully, including static analysis/typecheck, all five unit-test shards, relay integration, packaging and the verify aggregate (“PR checks passed”). The single CI watch exited 0; no failed job or rerun was needed.

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):

Historical branch download in progress

Historical branch interruption failure

@brennanb2025
brennanb2025 merged commit d771cf3 into main Oct 15, 2026
30 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/download-manual-resume-abandon branch October 15, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant