fix(desktop): apply WSL distro changes in wsl-only mode + unblock recovery button
Two WSL-mode edge cases from review: Medium (cursor) — WSL-only distro change ignored: in wsl-only mode the pool's primary IS the WSL backend and its distro is captured when that backend starts. setWslDistro only persisted + reconciled, but reconcile deliberately skips the secondary in wsl-only mode, so nothing restarted the primary — the old distro kept serving while labels/IPC showed the new one. setWslDistro now relaunches (like the wsl-only toggle) when wslOnly && the distro actually changed; dual-backend mode still swaps the secondary via reconcile. The renderer routes wsl-only distro changes through the existing "Switch WSL distro?" confirm so the relaunch isn't a surprise. High (macroscope) — recovery button non-functional: the "Switch to Windows" recovery row in renderWslRow is shown when `enabled || wslOnly`, but handleSelectWslMode's WSL-off path returned early on `!enabled` alone, so when WSL went unavailable with wsl-only persisted (enabled false, wslOnly true) the button did nothing. The guard is now `!enabled && !wslOnly`, matching the row's visibility; the disable flow then clears wslOnly and relaunches onto Windows.
This commit is contained in:
1 parent
43187e6416
commit
2afae370fc
2 files changed
+24
-3
No files matched your search
@@ -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:<distro> 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;
|
||||
}),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user