diff --git a/apps/web/src/components/settings/ConnectionsSettings.tsx b/apps/web/src/components/settings/ConnectionsSettings.tsx index 021919f43a..92727a2c6a 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.tsx +++ b/apps/web/src/components/settings/ConnectionsSettings.tsx @@ -2801,33 +2801,35 @@ export function ConnectionsSettings() { [desktopBridge], ); - // Seed the WSL backend state from the desktop bridge on mount (and when - // local-backend management becomes available). Without this, desktopWslState - // stays null and renderWslRow() bails, hiding the WSL settings UI entirely. - // The broader desktop access-management state is owned by desktopNetworkAccess - // upstream; this effect only owns the WSL picker's state. - useEffect(() => { - if (!canManageLocalBackend || !desktopBridge) { + // Load the WSL backend state from the desktop bridge. Clears any prior error + // up front so a stale failure message can't linger after a later success, and + // is reused by the retry control in renderWslRow. + const loadWslState = useCallback(() => { + if (!desktopBridge) { return; } - let cancelled = false; + setDesktopWslError(null); void desktopBridge .getWslState() .then((state) => { - if (!cancelled) { - setDesktopWslState(state); - } + setDesktopWslState(state); }) .catch((error: unknown) => { - if (cancelled) { - return; - } setDesktopWslError(error instanceof Error ? error.message : "Failed to load WSL state."); }); - return () => { - cancelled = true; - }; - }, [canManageLocalBackend, desktopBridge]); + }, [desktopBridge]); + + // Seed the WSL backend state on mount (and when local-backend management + // becomes available). Without this, desktopWslState stays null and + // renderWslRow() bails, hiding the WSL settings UI entirely. The broader + // desktop access-management state is owned by desktopNetworkAccess upstream; + // this only owns the WSL picker's state. + useEffect(() => { + if (!canManageLocalBackend) { + return; + } + loadWslState(); + }, [canManageLocalBackend, loadWslState]); // True when a desktop-local WSL backend is currently registered as an // environment on this machine. We use this as a proxy for "the user has work @@ -2957,7 +2959,26 @@ export function ConnectionsSettings() { }, [applyWslSettingChange, desktopBridge, pendingWslChange]); const renderWslRow = () => { - if (!desktopWslState) return null; + if (!desktopWslState) { + // The initial getWslState() load failed: surface the error with a retry + // rather than hiding the section silently. With no error we simply haven't + // loaded yet (or WSL management isn't available), so render nothing. + if (desktopWslError && canManageLocalBackend) { + return ( + {desktopWslError}} + control={ + + } + /> + ); + } + return null; + } // WSL went unavailable while the user still has the WSL backend persisted // (it may have been uninstalled or its distro removed). The desktop side // falls back to the Windows backend, but the normal distro picker needs a