From 2a3cdd5aa58f433455cf0eeb704c8ae345a6ad25 Mon Sep 17 00:00:00 2001 From: Josh Gratton Date: Fri, 19 Jun 2026 17:59:23 -0400 Subject: [PATCH] fix(settings): keep the WSL recovery row visible during retry Addresses a Cursor Bugbot finding: loadWslState() cleared the error up front, so clicking Retry made the error/retry row vanish (renderWslRow only shows it when !desktopWslState and desktopWslError) until the IPC settled. Clear the error only on success instead, so it persists across an in-flight retry, and add a loading flag so the Retry button shows "Retrying..." and is disabled while in flight. --- .../settings/ConnectionsSettings.tsx | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/apps/web/src/components/settings/ConnectionsSettings.tsx b/apps/web/src/components/settings/ConnectionsSettings.tsx index 92727a2c6a..f023996d4d 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.tsx +++ b/apps/web/src/components/settings/ConnectionsSettings.tsx @@ -2013,6 +2013,7 @@ export function ConnectionsSettings() { const [desktopWslState, setDesktopWslState] = useState(null); const [isUpdatingWslBackend, setIsUpdatingWslBackend] = useState(false); const [desktopWslError, setDesktopWslError] = useState(null); + const [isLoadingWslState, setIsLoadingWslState] = useState(false); // Pending WSL setting change waiting on user confirmation. Set when // the user tries a destructive change (disable, switch distro, // toggle wsl-only) while the WSL backend has saved-env state on this @@ -2801,21 +2802,26 @@ export function ConnectionsSettings() { [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. + // Load the WSL backend state from the desktop bridge. Clears the error only on + // success, so a failed load's message stays visible (including across an + // in-flight retry, rather than the row flickering away), and tracks a loading + // flag for the retry control. Reused by the retry control in renderWslRow. const loadWslState = useCallback(() => { if (!desktopBridge) { return; } - setDesktopWslError(null); + setIsLoadingWslState(true); void desktopBridge .getWslState() .then((state) => { setDesktopWslState(state); + setDesktopWslError(null); }) .catch((error: unknown) => { setDesktopWslError(error instanceof Error ? error.message : "Failed to load WSL state."); + }) + .finally(() => { + setIsLoadingWslState(false); }); }, [desktopBridge]); @@ -2960,9 +2966,11 @@ export function ConnectionsSettings() { const renderWslRow = () => { 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. + // A load failed: keep a recovery row (with retry) visible instead of + // silently hiding the section. The error persists across an in-flight + // retry so the row doesn't flicker away, and the button reflects the + // loading state. With no error we simply haven't loaded yet (or WSL + // management isn't available), so render nothing. if (desktopWslError && canManageLocalBackend) { return ( {desktopWslError}} control={ - } />