From 527151c1c086818eb833eec0cf9eb247d1feec83 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 01:32:07 -0700 Subject: [PATCH] fix: guard resource kill async state (#3554) --- .../status-bar/ResourceUsageStatusSegment.tsx | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx b/src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx index a79869011fd..2e1b6f0eaaf 100644 --- a/src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx +++ b/src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx @@ -1080,19 +1080,21 @@ export function ResourceUsageStatusSegment({ } catch { /* already dead — fall through */ } finally { - setKilling(false) - setKillConfirm(null) - // Why: after the killed row unmounts, focus would otherwise drop to - // . Park focus on the popover body so keyboard users land back - // in the list rather than outside the popover. - cancelPopoverBodyFocusFrame() - if (popoverBodyRef.current) { - popoverBodyFocusFrameRef.current = requestAnimationFrame(() => { - popoverBodyFocusFrameRef.current = null - popoverBodyRef.current?.focus() - }) + if (mountedRef.current) { + setKilling(false) + setKillConfirm(null) + // Why: after the killed row unmounts, focus would otherwise drop to + // . Park focus on the popover body so keyboard users land back + // in the list rather than outside the popover. + cancelPopoverBodyFocusFrame() + if (popoverBodyRef.current) { + popoverBodyFocusFrameRef.current = requestAnimationFrame(() => { + popoverBodyFocusFrameRef.current = null + popoverBodyRef.current?.focus() + }) + } + void refreshSessions() } - void refreshSessions() } }, [cancelPopoverBodyFocusFrame, killConfirm, refreshSessions])