Skip to content

Show real download progress for Windows updates via a loopback proxy - #2468

Open
hahn-kev-bot wants to merge 1 commit into
developfrom
claude/windows-update-progress-a2f07d
Open

Show real download progress for Windows updates via a loopback proxy#2468
hahn-kev-bot wants to merge 1 commit into
developfrom
claude/windows-update-progress-a2f07d

Conversation

@hahn-kev-bot

Copy link
Copy Markdown
Collaborator

What & why

The Windows updater handed the GitHub .msixbundle URL straight to PackageManager.AddPackageByUriAsync, which fuses network download + staging + registration into one opaque operation. Its only feedback was an unreliable uint percentage the frontend distrusted (it hid 0 and had a "not sure if the % actually works" comment), and the op could appear to hang (the code races a 2-minute timeout).

This change runs a short-lived loopback reverse proxy (System.Net.HttpListener, BCL-only — no ASP.NET shipped in MAUI) between PackageManager and GitHub. Windows still owns the download/staging/install; we just sit in the byte path to report real progress.

How it works

  • UpdateDownloadProxy (new, Platforms/Windows): resolves GitHub's 302 redirect once to a terminal asset URL, binds a random http://localhost:{port}/{guid}/ prefix (no admin / no URL-ACL needed for a localhost prefix), forwards Range requests (echoing 206/Content-Range/Accept-Ranges), 404s unknown paths, reuses one keep-alive upstream connection, and reports the running byte total. Re-resolves + retries once on 401/403 (signed-URL expiry).
  • AppUpdateService.ApplyUpdate uses the proxy path and falls back to the previous direct AddPackageByUriAsync(release.Url) on any failure — update capability can't regress. Deployment options (DeferRegistrationWhenPackagesAreInUse, ForceUpdateFromAnyVersion, ForceAppShutdown) and the result mapping are unchanged.
  • AppUpdateProgressEvent now carries BytesDownloaded + BytesPerSecond (throttled to ~4/sec for the small JsEventListener channel) instead of the distrusted Percentage. The update dialog shows an honest Downloading update... 12.3 MB (2.1 MB/s) readout, falling back to Installing Update... when no byte events arrive (the direct-install fallback path).

Notes for reviewers

  • Differential download preserved: Windows issues Range requests through the proxy and only fetches the blocks it lacks (validated on real hardware: ~0.4% of a 164 MB bundle when a near-identical version was installed) — a real win on metered/slow connections. This is why the UI shows bytes/speed rather than a percent-of-total, which would finish early and mislead.
  • Content-Type rewrite was considered and rejected: prototyping showed AddPackageByUriAsync behavior is byte-identical with/without rewriting GitHub's application/octet-stream; the differential behavior comes from Range support, not MIME. (Content-Type only matters for the dormant .appinstaller path, which is out of scope here.)
  • IHttpClientFactory was intentionally not injected into AppUpdateService: the proxy owns a purpose-built HttpClient (AllowAutoRedirect=false + keep-alive), which fights a factory client.
  • HttpListener is Windows-only (http.sys) — fine, since this all lives under Platforms/Windows.

Test plan

  • ✅ MAUI Windows head builds (0 warnings, 0 errors); FwLiteShared regenerates the TS event type.
  • ✅ New UpdateDownloadProxyTests (3 tests, #if WINDOWS): full-download forwarding + byte total, Range → 206 + Content-Range passthrough, 404 for unknown paths. All pass.
  • ✅ Viewer svelte-check clean; eslint clean on changed files; i18n extracted (new Downloading update... string across 8 locales).
  • ⚠️ Manual (packaged, on-device): trigger an update from the dialog on an installed MSIX build, watch the live readout, confirm defer-registration applies on restart, and confirm a forced proxy failure falls back to a working direct install. The underlying mechanism was validated via a throwaway prototype on Windows hardware.

🤖 Generated with Claude Code

The Windows updater handed the GitHub .msixbundle URL straight to
PackageManager.AddPackageByUriAsync, which fuses download + staging +
registration into one opaque operation whose only feedback was an
unreliable percentage the UI distrusted.

Instead, run a short-lived loopback reverse proxy (System.Net.HttpListener,
BCL-only) between PackageManager and GitHub. Windows still owns the
download/staging/install, but we sit in the byte path to report real
progress. The proxy resolves GitHub's 302 once, forwards Range requests
(preserving Windows' differential download), and reports bytes streamed.
On any failure it falls back to the previous direct install so update
capability can't regress.

The progress event now carries bytes downloaded + speed (throttled to
~4/sec for the small JS event channel); the update dialog shows an honest
"Downloading update... X MB (Y MB/s)" readout instead of a fake percentage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@hahn-kev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 20 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 47448ea1-2d16-46db-a20b-29aa60f9c36a

📥 Commits

Reviewing files that changed from the base of the PR and between ccd29d0 and 8d6b66e.

📒 Files selected for processing (16)
  • backend/FwLite/FwLiteMaui.Tests/UpdateDownloadProxyTests.cs
  • backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs
  • backend/FwLite/FwLiteMaui/Platforms/Windows/UpdateDownloadProxy.cs
  • backend/FwLite/FwLiteShared/Events/AppUpdateProgressEvent.cs
  • frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Events/IAppUpdateProgressEvent.ts
  • frontend/viewer/src/lib/updates/UpdateDialog.svelte
  • frontend/viewer/src/lib/updates/UpdateDialogContent.svelte
  • frontend/viewer/src/locales/en.po
  • frontend/viewer/src/locales/es.po
  • frontend/viewer/src/locales/fr.po
  • frontend/viewer/src/locales/id.po
  • frontend/viewer/src/locales/ko.po
  • frontend/viewer/src/locales/ms.po
  • frontend/viewer/src/locales/sw.po
  • frontend/viewer/src/locales/vi.po
  • frontend/viewer/src/stories/updates/update-dialog-content.stories.svelte
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/windows-update-progress-a2f07d

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.

@github-actions github-actions Bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Jul 23, 2026
@argos-ci

argos-ci Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jul 23, 2026, 4:57 AM
e2e (Inspect) ✅ No changes detected - Jul 23, 2026, 5:04 AM

@hahn-kev

Copy link
Copy Markdown
Collaborator

In addition to gaining better update reporting, this also seems to have boosted update speed, from 10s, to less than 1s when tested via a prototype. Unfortunately it's really hard to test this kind of thing in production because it requires having this app installed and built, then getting that version to update.

@hahn-kev
hahn-kev requested a review from myieye July 23, 2026 05:06
@hahn-kev
hahn-kev marked this pull request as ready for review July 23, 2026 08:18

@myieye myieye left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wowee. Fancy stuff 🤓

{
var progress = new DownloadProgressReporter(eventBus, latestRelease);
await using var proxy = await UpdateDownloadProxy.StartAsync(latestRelease.Url, logger, progress.Report);
return await Deploy(proxy.LocalUri, latestRelease, quitOnUpdate);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Devin AI pointed out that Deploy runs for max 2 minutes due to:
var completedTask = await Task.WhenAny(updateTask, Task.Delay(TimeSpan.FromMinutes(2)));
at which point it simply does return UpdateResult.Started;

That then results in await using var proxy = being disposed, which presumably "cleans up"/cancels the download.

So, I think this needs some work.

downloadProgress
}: Props = $props();

function formatBytes(bytes: number): string {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should arguably share code with media-manager which currently has:

const BYTE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB'];

export function formatFileSize(bytes?: number): string | undefined {
  if (bytes == null) return undefined;
  let size = bytes;
  let unit = 0;
  while (size >= 1024 && unit < BYTE_UNITS.length - 1) {
    size /= 1024;
    unit++;
  }
  return `${formatNumber(size, {maximumFractionDigits: unit === 0 ? 0 : 1})} ${BYTE_UNITS[unit]}`;
}

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

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants