Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(windows): make sure the WebView2 Runtime is there for the user who starts LU (D10)

purple86cf7306d8da
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b5925aa2..07410063 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -785,6 +785,29 @@ jobs:
rm -f "$RUNNER_TEMP/lu-dry-run/dry-run-updater.key"
node scripts/release-dry-run.mjs check-binaries "$RUNNER_TEMP/lu-dry-run/receipt.json" src-tauri/target/release
+ # D10: the NSIS installer now carries Microsoft's WebView2 bootstrapper
+ # (bundle.windows.webviewInstallMode embedBootstrapper). tauri build
+ # fetches it from go.microsoft.com and checks nothing, because the file
+ # has no fixed version or hash. What can be checked is Microsoft's
+ # Authenticode signature on the copy that went into the installer.
+ - name: "Dry run: the embedded WebView2 bootstrapper is signed by Microsoft"
+ if: ${{ inputs.dry_run }}
+ shell: pwsh
+ timeout-minutes: 5
+ run: |
+ # The condition stays `inputs.dry_run` alone (release-dry-run.test.ts);
+ # Linux has no NSIS installer and so nothing to check.
+ if (-not $IsWindows) { 'no NSIS installer on this platform'; exit 0 }
+ $found = @(Get-ChildItem -Path src-tauri/target, "$env:LOCALAPPDATA\tauri" -Recurse -Filter MicrosoftEdgeWebview2Setup.exe -ErrorAction SilentlyContinue)
+ if ($found.Count -eq 0) { throw "no MicrosoftEdgeWebview2Setup.exe after the build" }
+ foreach ($f in $found) {
+ $sig = Get-AuthenticodeSignature $f.FullName
+ "{0} {1:N0} bytes {2} {3}" -f $f.FullName, $f.Length, $sig.Status, $sig.SignerCertificate.Subject
+ if ($sig.Status -ne 'Valid' -or $sig.SignerCertificate.Subject -notmatch 'O=Microsoft Corporation') {
+ throw "$($f.FullName) is not validly signed by Microsoft"
+ }
+ }
+
# ── Windows code signing, only with the secrets of one lane ──────────
# Two lanes, and at most one of them signs a release:
# - Azure Artifact Signing signs inside `tauri build`.
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index cb75199e..50f7575e 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -57,6 +57,8 @@ mod runtime_root;
mod storage_move;
mod system_tray;
mod tray_menu;
+#[cfg(any(windows, test))]
+mod webview2_check;
mod state;
// Test-only OS helpers (a shell, a sleeper, "is this pid alive"), shared by
// the process tests in state.rs, commands/engine.rs and commands/bg_tasks.rs
@@ -616,6 +618,11 @@ pub fn run() {
"LU starting"
);
+ // Before any window: without the WebView2 Runtime for this Windows user
+ // Tauri can only show a raw error and end (webview2_check.rs).
+ #[cfg(windows)]
+ webview2_check::ensure_runtime();
+
let app_state = AppState::new();
let builder = tauri::Builder::default();
diff --git a/src-tauri/src/webview2_check.rs b/src-tauri/src/webview2_check.rs
new file mode 100644
index 00000000..a4e71039
--- /dev/null
+++ b/src-tauri/src/webview2_check.rs
@@ -0,0 +1,165 @@
+//! The window on Windows is a WebView2, and the runtime behind it has to be
+//! there for the Windows user who starts LU.
+//!
+//! 2026-11-03, a fresh Windows install: right after setup LU showed only
+//! Tauri's own dialog, "Could not find the WebView2 Runtime ... You may have it
+//! installed on another user account, but it is not available for this one",
+//! and ended. The installer is the first line (installer-hooks.nsh,
+//! LU_ENSURE_WEBVIEW2, says when the stock section skips the runtime). This is
+//! the second, for whatever still slips through: a runtime that exists only
+//! for another account, a setup that failed, a runtime removed later.
+//!
+//! Before any window is built LU asks WebView2 itself, the same question
+//! Tauri asks. Without an answer it says in plain words what is missing and
+//! offers to install it for this user with the Microsoft bootstrapper the
+//! installer left in the install folder. That runs without admin rights. Where
+//! the bootstrapper is missing or the install fails, it opens Microsoft's
+//! download page instead of leaving the user with an error.
+
+use std::path::{Path, PathBuf};
+
+/// Microsoft's page for the runtime, the one the installer names too.
+pub(crate) const DOWNLOAD_PAGE: &str = "https://developer.microsoft.com/microsoft-edge/webview2/";
+
+/// The file the installer keeps next to the app (installer-hooks.nsh).
+pub(crate) const BOOTSTRAPPER: &str = "MicrosoftEdgeWebview2Setup.exe";
+
+/// What LU offers when the runtime is missing.
+#[derive(Debug, PartialEq, Eq)]
+pub(crate) enum Offer {
+ /// Run Microsoft's bootstrapper from the install folder.
+ Install(PathBuf),
+ /// Nothing to run here: open Microsoft's download page.
+ DownloadPage,
+}
+
+pub(crate) fn offer(exe_dir: Option<&Path>) -> Offer {
+ match exe_dir.map(|d| d.join(BOOTSTRAPPER)) {
+ Some(p) if p.is_file() => Offer::Install(p),
+ _ => Offer::DownloadPage,
+ }
+}
+
+pub(crate) fn missing_text(offer: &Offer) -> String {
+ let head = "LU needs the Microsoft Edge WebView2 Runtime to show its window, \
+ and it is not available for this Windows user. It may be installed \
+ only for another account on this PC.";
+ match offer {
+ Offer::Install(_) => format!(
+ "{head}\n\nInstall it for this user now? It comes from Microsoft and \
+ needs no admin rights.\n\nYes: install it, then LU starts.\n\
+ No: open Microsoft's download page instead:\n{DOWNLOAD_PAGE}"
+ ),
+ Offer::DownloadPage => format!(
+ "{head}\n\nPress OK to open Microsoft's download page, install the \
+ Evergreen runtime there and start LU again:\n{DOWNLOAD_PAGE}"
+ ),
+ }
+}
+
+pub(crate) fn still_missing_text() -> String {
+ format!(
+ "The WebView2 Runtime is still not available for this Windows user.\n\n\
+ Press OK to open Microsoft's download page, install the Evergreen \
+ runtime there and start LU again:\n{DOWNLOAD_PAGE}"
+ )
+}
+
+/// Runs before the Tauri builder. Returns when the runtime is there; ends the
+/// process when it is not and could not be installed.
+#[cfg(windows)]
+pub(crate) fn ensure_runtime() {
+ if tauri::webview_version().is_ok() {
+ return;
+ }
+ tracing::warn!("WebView2 runtime not available for this user");
+ let exe_dir = std::env::current_exe().ok().and_then(|p| p.parent().map(Path::to_path_buf));
+ let offer = offer(exe_dir.as_deref());
+ match &offer {
+ Offer::Install(setup) => {
+ if ask_yes_no(&missing_text(&offer)) {
+ // Not silent on purpose: the user just said yes and should
+ // see Microsoft's progress, not a frozen nothing.
+ let status = std::process::Command::new(setup).arg("/install").status();
+ tracing::info!(?status, "WebView2 bootstrapper finished");
+ if tauri::webview_version().is_ok() {
+ return;
+ }
+ tell(&still_missing_text());
+ }
+ }
+ Offer::DownloadPage => tell(&missing_text(&offer)),
+ }
+ let _ = std::process::Command::new("explorer").arg(DOWNLOAD_PAGE).spawn();
+ std::process::exit(1);
+}
+
+#[cfg(windows)]
+fn wide(s: &str) -> Vec<u16> {
+ s.encode_utf16().chain(std::iter::once(0)).collect()
+}
+
+#[cfg(windows)]
+fn message_box(text: &str, style: u32) -> i32 {
+ use windows_sys::Win32::UI::WindowsAndMessaging::{MessageBoxW, MB_SETFOREGROUND};
+ let (text, title) = (wide(text), wide("LU"));
+ // SAFETY: both pointers are NUL-terminated UTF-16 buffers that outlive
+ // the call; a null owner window is allowed.
+ unsafe { MessageBoxW(std::ptr::null_mut(), text.as_ptr(), title.as_ptr(), style | MB_SETFOREGROUND) }
+}
+
+#[cfg(windows)]
+fn ask_yes_no(text: &str) -> bool {
+ use windows_sys::Win32::UI::WindowsAndMessaging::{IDYES, MB_ICONWARNING, MB_YESNO};
+ message_box(text, MB_YESNO | MB_ICONWARNING) == IDYES
+}
+
+#[cfg(windows)]
+fn tell(text: &str) {
+ use windows_sys::Win32::UI::WindowsAndMessaging::{MB_ICONWARNING, MB_OK};
+ message_box(text, MB_OK | MB_ICONWARNING);
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn the_bootstrapper_next_to_the_app_is_offered() {
+ let dir = std::env::temp_dir().join(format!("lu-wv2-{}", std::process::id()));
+ std::fs::create_dir_all(&dir).unwrap();
+ assert_eq!(offer(Some(&dir)), Offer::DownloadPage);
+ std::fs::write(dir.join(BOOTSTRAPPER), b"x").unwrap();
+ assert_eq!(offer(Some(&dir)), Offer::Install(dir.join(BOOTSTRAPPER)));
+ std::fs::remove_dir_all(&dir).unwrap();
+ assert_eq!(offer(None), Offer::DownloadPage);
+ }
+
+ #[test]
+ fn every_text_names_the_runtime_and_microsofts_page() {
+ for t in [
+ missing_text(&Offer::Install(PathBuf::from("x"))),
+ missing_text(&Offer::DownloadPage),
+ still_missing_text(),
+ ] {
+ assert!(t.contains("WebView2 Runtime"), "{t}");
+ assert!(t.contains(DOWNLOAD_PAGE), "{t}");
+ }
+ assert!(DOWNLOAD_PAGE.starts_with("https://developer.microsoft.com/"));
+ }
+
+ #[test]
+ fn the_check_runs_before_the_builder() {
+ let src = include_str!("lib.rs");
+ let run = &src[src.find("\npub fn run() {").expect("run exists")..];
+ let check = run.find("webview2_check::ensure_runtime()").expect("run calls the check");
+ let builder = run.find("tauri::Builder::default()").expect("run builds");
+ assert!(check < builder, "the check must come before any window exists");
+ }
+
+ #[test]
+ fn the_installer_leaves_the_file_the_app_looks_for() {
+ let hooks = include_str!("../windows/installer-hooks.nsh");
+ assert!(hooks.contains(&format!("$INSTDIR\\{BOOTSTRAPPER}")));
+ }
+}
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index a90382ee..5ee56443 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -73,6 +73,10 @@
"signingIdentity": "-"
},
"windows": {
+ "webviewInstallMode": {
+ "type": "embedBootstrapper",
+ "silent": true
+ },
"wix": {
"upgradeCode": "a32db5c6-2c3c-5e92-a20a-2464954554f9"
},
diff --git a/src-tauri/windows/installer-hooks.nsh b/src-tauri/windows/installer-hooks.nsh
index 62f37aff..cc02bd53 100644
--- a/src-tauri/windows/installer-hooks.nsh
+++ b/src-tauri/windows/installer-hooks.nsh
@@ -220,3 +220,87 @@
lu_wix_done:
!endif
!macroend
+
+; The window needs the Microsoft Edge WebView2 Runtime, and it has to be there
+; for the Windows user who starts LU, not just somewhere on the machine.
+;
+; 2026-11-03, a fresh Windows install: right after setup LU opened only
+; Tauri's "Could not find the WebView2 Runtime ... You may have it installed
+; on another user account, but it is not available for this one". The stock
+; WebView2 section (tauri-bundler 2.11, installer.nsi) has the gaps that let
+; that happen without a word:
+; - it counts the runtime as present as soon as a "pv" value exists, and
+; EdgeUpdate leaves "0.0.0.0" behind after a broken or removed runtime;
+; Microsoft's own detection rule says that value means not installed;
+; - it also counts a per-user runtime in HKCU, and an install for all users
+; that a standard user starts with an admin's password runs under the
+; admin's account, so it reads the admin's HKCU and skips the install for
+; the person who will actually use the app;
+; - it skips everything on an update (/UPDATE);
+; - with the default downloadBootstrapper a blocked download ends the setup.
+; The bootstrapper is now embedded (bundle.windows.webviewInstallMode), and
+; this check runs after the stock section with Microsoft's rule. When it still
+; finds no runtime it runs the same bootstrapper itself.
+;
+; A copy of the bootstrapper stays in the install folder: the app runs it at
+; start (webview2_check.rs) for a Windows user who has no runtime even though
+; the install went fine, the "another user account" case. NSIS stores the
+; identical file once, so the copy costs no installer size.
+!macro LU_READ_WEBVIEW2 ROOT KEY
+ ${If} $R1 == ""
+ ReadRegStr $R1 ${ROOT} "${KEY}\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" "pv"
+ ${If} $R1 == "0.0.0.0"
+ StrCpy $R1 ""
+ ${EndIf}
+ ${EndIf}
+!macroend
+
+!macro LU_ENSURE_WEBVIEW2
+ Push $R1
+ Push $R2
+ StrCpy $R1 ""
+ !insertmacro LU_READ_WEBVIEW2 HKLM "SOFTWARE\WOW6432Node"
+ !insertmacro LU_READ_WEBVIEW2 HKLM "SOFTWARE"
+ ; A per-user runtime counts only for a per-user install, the one case where
+ ; this HKCU belongs to the person who starts the app.
+ StrCpy $R2 "CurrentUser"
+ !if "${INSTALLMODE}" == "perMachine"
+ StrCpy $R2 "AllUsers"
+ !else if "${INSTALLMODE}" == "both"
+ StrCpy $R2 $MultiUser.InstallMode
+ !endif
+ ${If} $R2 != "AllUsers"
+ !insertmacro LU_READ_WEBVIEW2 HKCU "SOFTWARE"
+ ${EndIf}
+
+ !if "${INSTALLWEBVIEW2MODE}" == "embedBootstrapper"
+ File "/oname=$INSTDIR\MicrosoftEdgeWebview2Setup.exe" "${WEBVIEW2BOOTSTRAPPERPATH}"
+ ${If} $R1 == ""
+ DetailPrint "$(installingWebview2)"
+ ExecWait '"$INSTDIR\MicrosoftEdgeWebview2Setup.exe" ${WEBVIEW2INSTALLERARGS} /install' $R2
+ ${If} $R2 = 0
+ DetailPrint "$(webview2InstallSuccess)"
+ ${Else}
+ DetailPrint "$(webview2InstallError)"
+ ; Not an abort: LU itself is installed fine, and at its start it
+ ; offers the runtime again with Microsoft's download page as the
+ ; fallback. Silent updates show nothing here.
+ ${IfNot} ${Silent}
+ MessageBox MB_OK|MB_ICONEXCLAMATION "LU is installed, but the Microsoft Edge WebView2 Runtime it needs for its window could not be installed (code $R2).$\r$\n$\r$\nLU offers it again when it starts. You can also get it from Microsoft:$\r$\nhttps://developer.microsoft.com/microsoft-edge/webview2/"
+ ${EndIf}
+ ${EndIf}
+ ${EndIf}
+ !endif
+ Pop $R2
+ Pop $R1
+!macroend
+
+!macro NSIS_HOOK_POSTINSTALL
+ !insertmacro LU_ENSURE_WEBVIEW2
+!macroend
+
+; The stock uninstaller removes only the files it copied itself and then the
+; folder if it is empty, so the bootstrapper copy above would keep it alive.
+!macro NSIS_HOOK_PREUNINSTALL
+ Delete "$INSTDIR\MicrosoftEdgeWebview2Setup.exe"
+!macroend
diff --git a/src/lib/__tests__/installer-webview2.test.ts b/src/lib/__tests__/installer-webview2.test.ts
new file mode 100644
index 00000000..c4ea0210
--- /dev/null
+++ b/src/lib/__tests__/installer-webview2.test.ts
@@ -0,0 +1,68 @@
+/**
+ * The Windows installer has to leave a WebView2 Runtime that the person who
+ * starts LU can use.
+ *
+ * 2026-11-03, a fresh Windows install: LU opened only Tauri's "Could not find
+ * the WebView2 Runtime ... installed on another user account". The stock
+ * section counts a "pv" of 0.0.0.0 as installed, counts the HKCU of whoever
+ * ran the setup (an admin, for an install for all users), skips updates, and
+ * with the default download mode a blocked download ends the setup. The
+ * reasons are written out in installer-hooks.nsh (LU_ENSURE_WEBVIEW2); this
+ * pins the parts that a later edit could quietly undo.
+ *
+ * Run: npx vitest run src/lib/__tests__/installer-webview2.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import { dirname, resolve } from 'node:path'
+
+const here = dirname(fileURLToPath(import.meta.url))
+const root = resolve(here, '../../..')
+const read = (rel: string) => readFileSync(resolve(root, rel), 'utf8')
+
+const hooks = read('src-tauri/windows/installer-hooks.nsh')
+const conf = JSON.parse(read('src-tauri/tauri.conf.json')) as {
+ bundle?: { windows?: { webviewInstallMode?: { type?: string; silent?: boolean } } }
+}
+const ensure = hooks.slice(
+ hooks.indexOf('!macro LU_ENSURE_WEBVIEW2'),
+ hooks.indexOf('!macro NSIS_HOOK_POSTINSTALL'),
+)
+
+describe('the installer leaves a WebView2 Runtime for this user', () => {
+ it('embeds the bootstrapper, so a blocked download cannot end the setup', () => {
+ expect(conf.bundle?.windows?.webviewInstallMode).toEqual({ type: 'embedBootstrapper', silent: true })
+ })
+
+ it('runs its own check after the files are in place', () => {
+ const post = hooks.slice(hooks.indexOf('!macro NSIS_HOOK_POSTINSTALL'))
+ expect(post).toMatch(/^!macro NSIS_HOOK_POSTINSTALL\s+!insertmacro LU_ENSURE_WEBVIEW2\s+!macroend/)
+ })
+
+ it('treats a pv of 0.0.0.0 as missing, as Microsoft says', () => {
+ const read = hooks.slice(hooks.indexOf('!macro LU_READ_WEBVIEW2'), hooks.indexOf('!macro LU_ENSURE_WEBVIEW2'))
+ expect(read).toContain('${If} $R1 == "0.0.0.0"')
+ expect(read).toContain('StrCpy $R1 ""')
+ })
+
+ it("does not count the HKCU of an install for all users", () => {
+ const hkcu = ensure.indexOf('LU_READ_WEBVIEW2 HKCU')
+ const guard = ensure.lastIndexOf('${If} $R2 != "AllUsers"', hkcu)
+ expect(hkcu).toBeGreaterThan(-1)
+ expect(guard).toBeGreaterThan(-1)
+ expect(ensure.slice(guard, hkcu)).not.toContain('${EndIf}')
+ })
+
+ it('never aborts the setup over the runtime', () => {
+ expect(ensure).not.toMatch(/\bAbort\b/)
+ expect(ensure).toContain('https://developer.microsoft.com/microsoft-edge/webview2/')
+ })
+
+ it('removes its bootstrapper copy on uninstall, or the folder stays behind', () => {
+ const copy = ensure.match(/File "\/oname=(\$INSTDIR\\[^"]+)"/)
+ expect(copy).not.toBeNull()
+ const pre = hooks.slice(hooks.indexOf('!macro NSIS_HOOK_PREUNINSTALL'))
+ expect(pre).toContain(`Delete "${copy![1]}"`)
+ })
+})
diff --git a/src/lib/__tests__/release-dry-run.test.ts b/src/lib/__tests__/release-dry-run.test.ts
index 59068e46..39fd9659 100644
--- a/src/lib/__tests__/release-dry-run.test.ts
+++ b/src/lib/__tests__/release-dry-run.test.ts
@@ -126,7 +126,9 @@ describe('release.yml, a dry run step and a release step are never the same step
const dry = buildSteps.filter((s) => stepIf(s) === DRY)
it('has its own steps for key, endpoint, build, check, collection and artifact', () => {
- expect(dry).toHaveLength(6)
+ // Seven since D10: the signature check of the embedded WebView2
+ // bootstrapper, which only a build can reach.
+ expect(dry).toHaveLength(7)
// No third kind of condition on the new input: a step is in the dry run
// by exactly `inputs.dry_run`, or out of it by `!inputs.dry_run`.
for (const step of buildSteps) {