History

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.

Josh Gratton committed 4 months ago

Commit 2a3cdd51 parent 72a648a1 file · +22 −9Browse files

Unified · Split

apps/web/src/components/settings/ConnectionsSettings.tsx+22−9
@@ -2013,6 +2013,7 @@ export function ConnectionsSettings() { · 2012 unmodified lines
20132013 const [desktopWslState, setDesktopWslState] = useState<DesktopWslState | null>(null);
20142014 const [isUpdatingWslBackend, setIsUpdatingWslBackend] = useState(false);
20152015 const [desktopWslError, setDesktopWslError] = useState<string | null>(null);
2016+ const [isLoadingWslState, setIsLoadingWslState] = useState(false);
20162017 // Pending WSL setting change waiting on user confirmation. Set when
20172018 // the user tries a destructive change (disable, switch distro,
20182019 // toggle wsl-only) while the WSL backend has saved-env state on this
@@ -2801,21 +2802,26 @@ export function ConnectionsSettings() { · 782 unmodified lines
28012802 [desktopBridge],
28022803 );
28032804
2804− // Load the WSL backend state from the desktop bridge. Clears any prior error
2805− // up front so a stale failure message can't linger after a later success, and
2806− // is reused by the retry control in renderWslRow.
2805+ // Load the WSL backend state from the desktop bridge. Clears the error only on
2806+ // success, so a failed load's message stays visible (including across an
2807+ // in-flight retry, rather than the row flickering away), and tracks a loading
2808+ // flag for the retry control. Reused by the retry control in renderWslRow.
28072809 const loadWslState = useCallback(() => {
28082810 if (!desktopBridge) {
28092811 return;
28102812 }
2811− setDesktopWslError(null);
2813+ setIsLoadingWslState(true);
28122814 void desktopBridge
28132815 .getWslState()
28142816 .then((state) => {
28152817 setDesktopWslState(state);
2818+ setDesktopWslError(null);
28162819 })
28172820 .catch((error: unknown) => {
28182821 setDesktopWslError(error instanceof Error ? error.message : "Failed to load WSL state.");
2822+ })
2823+ .finally(() => {
2824+ setIsLoadingWslState(false);
28192825 });
28202826 }, [desktopBridge]);
28212827
@@ -2960,9 +2966,11 @@ export function ConnectionsSettings() { · 138 unmodified lines
29602966
29612967 const renderWslRow = () => {
29622968 if (!desktopWslState) {
2963− // The initial getWslState() load failed: surface the error with a retry
2964− // rather than hiding the section silently. With no error we simply haven't
2965− // loaded yet (or WSL management isn't available), so render nothing.
2969+ // A load failed: keep a recovery row (with retry) visible instead of
2970+ // silently hiding the section. The error persists across an in-flight
2971+ // retry so the row doesn't flicker away, and the button reflects the
2972+ // loading state. With no error we simply haven't loaded yet (or WSL
2973+ // management isn't available), so render nothing.
29662974 if (desktopWslError && canManageLocalBackend) {
29672975 return (
29682976 <SettingsRow
@@ -2970,8 +2978,13 @@ export function ConnectionsSettings() { · 1 unmodified line
29702978 description="Couldn't load the WSL backend state."
29712979 status={<span className="block text-destructive">{desktopWslError}</span>}
29722980 control={
2973− <Button size="xs" variant="outline" onClick={loadWslState}>
2974− Retry
2981+ <Button
2982+ size="xs"
2983+ variant="outline"
2984+ onClick={loadWslState}
2985+ disabled={isLoadingWslState}
2986+ >
2987+ {isLoadingWslState ? "Retrying…" : "Retry"}
29752988 </Button>
29762989 }
29772990 />

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t