perf: guard SSH target row async state without effect (#3556)

This commit is contained in:
Neil
2026-05-30 01:36:59 -07:00
committed by GitHub
parent 5ef97d581c
commit 7eb0148e86
@@ -4,7 +4,7 @@
* Why extracted: keeps AddRepoSteps.tsx under the 400-line oxlint limit
* while isolating the inline-connect interaction logic.
*/
import React, { useEffect, useRef, useState } from 'react'
import React, { useCallback, useRef, useState } from 'react'
import { Loader2 } from 'lucide-react'
import type { SshTarget, SshConnectionState } from '../../../../shared/ssh-types'
@@ -57,15 +57,15 @@ export function SshTargetRow({
})
}
useEffect(() => {
mountedRef.current = true
return () => {
mountedRef.current = false
}
const handleRowRootRef = useCallback((node: HTMLDivElement | null): void => {
// Why: SSH connects can resolve after this row is removed; the row ref
// gives the async completion the same guard without a mount-only Effect.
mountedRef.current = node !== null
}, [])
return (
<div
ref={handleRowRootRef}
role={isConnected ? 'button' : undefined}
tabIndex={isConnected ? 0 : undefined}
className={`w-full flex items-center gap-2 px-3 py-2 rounded-md border text-xs transition-colors ${