Skip to content

fix(windows): offer WebView2 runtime download when it is missing#18

Merged
Christian-Katzmann merged 2 commits into
Christian-Katzmann:mainfrom
Firnschnee:fix/windows-webview2-download-url
Jun 4, 2026
Merged

fix(windows): offer WebView2 runtime download when it is missing#18
Christian-Katzmann merged 2 commits into
Christian-Katzmann:mainfrom
Firnschnee:fix/windows-webview2-download-url

Conversation

@Firnschnee
Copy link
Copy Markdown
Contributor

@Firnschnee Firnschnee commented Jun 2, 2026

The third item from my real-hardware testing notes on #8: the WebView2-runtime-missing error message.

The problem

On a machine without the WebView2 Evergreen runtime (Windows LTSC/Server and some clean installs ship without it -- my test box was exactly this), OnLoaded hit the generic catch (Exception) and showed a developer-facing message pointing at docs/WINDOWS.md. Useless to an end user who just double-clicked a Start Menu shortcut and has no idea what a "maintainer checklist" is.

The fix

Catch WebView2RuntimeNotFoundException specifically and offer to open Microsoft's download page (Yes/No -> default browser via the existing OpenInDefaultBrowser helper). Kept separate from the generic handler on purpose: the installer is only suggested when the runtime is genuinely the problem, not for an arbitrary crash. The catch-all handler now also names the download URL as a hint.

Verification (Windows 11)

Couldn't uninstall my runtime, so I forced the failure by pointing WEBVIEW2_BROWSER_EXECUTABLE_FOLDER at a non-existent folder:

  • The not-found path triggers and shows the Yes/No dialog (<App> needs the Microsoft Edge WebView2 runtime...).
  • Clicking Yes opens the WebView2 download page in the default browser.
  • Compiles clean against the pinned WebView2 package (WebView2RuntimeNotFoundException is in Microsoft.Web.WebView2.Core, already imported); only the pre-existing DPI manifest warning remains.

Notes

  • Independent of fix(windows): bake app name into assembly so taskbar right-click shows it (#9) #17 -- touches only MainWindow.xaml.cs (+ changelog). Both edit the changelog near the same line, so whichever merges second will want a trivial conflict resolution.
  • The runtime-missing dialog itself can't be exercised by the windows-latest CI (the runner has the runtime), same as it can't be from macOS -- hence the manual hardware check above.

Summary by Sourcery

Improve Windows WebView2 runtime error handling to guide end users when the runtime is missing.

Bug Fixes:

  • Handle missing WebView2 runtime on Windows by detecting the specific runtime-not-found exception and offering to open Microsoft's download page so users can install it themselves.

Documentation:

  • Update the changelog to document the improved WebView2 runtime-missing behavior in the Windows beta scaffold.

A WebView2-less machine (Windows LTSC/Server and some clean installs
ship without the Evergreen runtime) hit the generic catch in OnLoaded,
which showed a developer-facing message pointing at docs/WINDOWS.md -
useless to an end user who just double-clicked a Start Menu shortcut.

Catch WebView2RuntimeNotFoundException specifically and offer to open
Microsoft's download page (Yes/No -> default browser). Kept separate
from the generic handler so the installer is only suggested when the
runtime is actually the problem; the catch-all now also names the URL
as a hint.

Validated on Windows 11: forcing a bogus runtime folder triggers the
not-found path, the Yes/No dialog shows, and Yes opens the download
page in the default browser. Compiles clean (only the pre-existing
DPI manifest warning).
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jun 2, 2026

Reviewer's Guide

Adds explicit handling for missing WebView2 runtime on Windows by prompting end users to install it from Microsoft’s download page, and updates the changelog to document the behavior change.

Sequence diagram for handling missing WebView2 runtime on window load

sequenceDiagram
    actor User
    participant MainWindow
    participant Web
    participant MessageBox
    participant DefaultBrowser

    User->>MainWindow: OnLoaded
    MainWindow->>Web: EnsureCoreWebView2Async
    alt WebView2 runtime missing
        Web-->>MainWindow: WebView2RuntimeNotFoundException
        MainWindow->>MessageBox: MessageBox.Show(YesNo Warning)
        MessageBox-->>MainWindow: MessageBoxResult.Yes
        opt User clicks Yes
            MainWindow->>DefaultBrowser: OpenInDefaultBrowser(WebView2DownloadUrl)
        end
    else Other WebView2 failure
        Web-->>MainWindow: Exception
        MainWindow->>MessageBox: MessageBox.Show(OK Error with WebView2DownloadUrl)
    end
Loading

File-Level Changes

Change Details Files
Handle missing WebView2 runtime explicitly and guide end users to install it.
  • Introduce a constant holding Microsoft’s canonical WebView2 Evergreen runtime download URL.
  • Add a dedicated catch block for WebView2RuntimeNotFoundException that shows a Yes/No dialog explaining the missing runtime and offering to open the download page in the default browser.
  • Adjust the generic exception handler message to reference the WebView2 download URL as a hint in addition to pointing maintainers at docs/WINDOWS.md.
plugins/app-it-windows/skills/app-it-windows/templates/wrapper-windows/MainWindow.xaml.cs
Document the Windows WebView2 runtime-missing behavior change.
  • Add a changelog entry describing the new behavior when the WebView2 runtime is missing, including the specific exception handled and the end-user flow.
CHANGELOG.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The WebView2 download URL is now hard-coded in MainWindow; consider centralizing it in a shared config or constants module so it can be reused or updated without touching UI code.
  • The new user-facing message strings are embedded directly in code and use explicit "\n" separators; consider using Environment.NewLine and a localization-friendly pattern (e.g., resource files) to make future translation or wording changes easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The WebView2 download URL is now hard-coded in MainWindow; consider centralizing it in a shared config or constants module so it can be reused or updated without touching UI code.
- The new user-facing message strings are embedded directly in code and use explicit "\n" separators; consider using `Environment.NewLine` and a localization-friendly pattern (e.g., resource files) to make future translation or wording changes easier.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Christian-Katzmann Christian-Katzmann merged commit 3a73650 into Christian-Katzmann:main Jun 4, 2026
4 checks passed
Christian-Katzmann added a commit that referenced this pull request Jun 4, 2026
…-runtime fixes (#17, #18)

He went from first real-hardware validator to the Windows beta's recurring
real-hardware tester — three fixes now, each traced and verified on Windows 11
(window title #8, taskbar right-click app name #17, WebView2-runtime-missing
path #18). Refresh his existing nudge line to reflect that arc.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Christian-Katzmann
Copy link
Copy Markdown
Owner

Merged — thank you, @Firnschnee. Catching WebView2RuntimeNotFoundException specifically, so the installer is only offered when the runtime is genuinely the problem (and not for an arbitrary crash), is the right call — and forcing the failure via WEBVIEW2_BROWSER_EXECUTABLE_FOLDER to test it without uninstalling your own runtime was resourceful.

Credited in the README's Community nudge alongside your other Windows fixes. Thanks again.

Christian-Katzmann added a commit that referenced this pull request Jun 4, 2026
…e landed (#17, #18)

The recruitment paragraph still framed #8 as the single real-hardware
milestone ("first run … window-title bug"). It's had a run of fixes since
(#17 taskbar app name, #18 WebView2-runtime-missing path), so update it to
"a run of fixes since — a real start, not a finish line." No overclaim — it
still says "needing more," the author still runs only macOS, and the concrete
fix-by-fix list stays in the README Community nudge.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants