From c58a47c412484bdc0ee97b17356530ec8e67ed10 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 01:47:05 -0700 Subject: [PATCH] perf: guard SSH target card async state without effect (#3559) --- .../src/components/settings/SshTargetCard.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/renderer/src/components/settings/SshTargetCard.tsx b/src/renderer/src/components/settings/SshTargetCard.tsx index c1b0c1393..d794c64b9 100644 --- a/src/renderer/src/components/settings/SshTargetCard.tsx +++ b/src/renderer/src/components/settings/SshTargetCard.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from 'react' +import { useCallback, useRef, useState } from 'react' import { CircleStop, Loader2, @@ -87,11 +87,10 @@ export function SshTargetCard({ const removeInFlight = busyAction === 'remove' const mountedRef = useRef(true) - useEffect(() => { - mountedRef.current = true - return () => { - mountedRef.current = false - } + const handleCardRef = useCallback((node: HTMLDivElement | null): void => { + // Why: SSH target actions can resolve after the card is removed; the root + // ref gives async completions the same stale-write guard without an Effect. + mountedRef.current = node !== null }, []) const clearActionInFlight = (): void => { @@ -226,7 +225,10 @@ export function SshTargetCard({ ) return ( -
+