diff --git a/apps/desktop/src/ipc/methods/wsl.ts b/apps/desktop/src/ipc/methods/wsl.ts index 75a103d0ef..93c3434650 100644 --- a/apps/desktop/src/ipc/methods/wsl.ts +++ b/apps/desktop/src/ipc/methods/wsl.ts @@ -63,7 +63,20 @@ export const setWslDistro = makeIpcMethod({ handler: Effect.fn("desktop.ipc.wsl.setDistro")(function* (distro) { const appSettings = yield* DesktopAppSettings.DesktopAppSettings; const wslBackend = yield* DesktopWslBackend.DesktopWslBackend; - yield* appSettings.setWslDistro(distro); + const lifecycle = yield* DesktopLifecycle.DesktopLifecycle; + const change = yield* appSettings.setWslDistro(distro); + const settings = yield* appSettings.get; + // In wsl-only mode the pool's primary IS the WSL backend, and its distro + // is captured when that backend starts. reconcile only manages the + // dual-mode secondary (it skips registering one when wslOnly), so it can't + // swap the primary's distro — relaunch so the primary comes back up on the + // newly selected distro, same as the wsl-only toggle. In dual-backend mode + // the secondary wsl: instance is swapped by reconcile instead. + if (settings.wslOnly && change.changed) { + const state = yield* readWslState; + yield* lifecycle.relaunch(`wslDistro=${distro ?? "default"}`); + return state; + } yield* wslBackend.reconcile; return yield* readWslState; }), diff --git a/apps/web/src/components/settings/ConnectionsSettings.tsx b/apps/web/src/components/settings/ConnectionsSettings.tsx index f04025358d..636409d669 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.tsx +++ b/apps/web/src/components/settings/ConnectionsSettings.tsx @@ -2617,7 +2617,11 @@ export function ConnectionsSettings() { const defaultDistroName = desktopWslState.distros.find((distro) => distro.isDefault)?.name ?? null; if (value === BACKEND_VALUE_WSL_OFF) { - if (!desktopWslState.enabled) return; + // Match the recovery row's visibility (`enabled || wslOnly`): when WSL + // went unavailable while wsl-only was persisted, `enabled` can be false + // while `wslOnly` is true, and the "Switch to Windows" button must + // still clear that state instead of silently no-op'ing. + if (!desktopWslState.enabled && !desktopWslState.wslOnly) return; const wasWslOnly = desktopWslState.wslOnly; // Confirm when there's WSL state to lose, OR when wsl-only is // on (turning the only running backend off needs to switch @@ -2643,7 +2647,11 @@ export function ConnectionsSettings() { // the user re-picked the row that's already selected. const resolvedCurrent = desktopWslState.distro ?? defaultDistroName; if (resolvedCurrent === resolvedNext) return; - if (hasWslRegistrationToLose) { + // Confirm when there's WSL registration to lose, OR in wsl-only mode: + // there the primary IS the WSL backend, so a distro change relaunches + // the app (the IPC handler does this) rather than swapping a secondary, + // and the user should see that coming. + if (hasWslRegistrationToLose || desktopWslState.wslOnly) { setPendingWslChange({ kind: "distro", nextDistro }); return; }