From 86cd9f2ee1ad92ecc559993fdf92e08407c31c75 Mon Sep 17 00:00:00 2001 From: m4air Date: Tue, 15 Sep 2026 20:28:47 -0700 Subject: [PATCH] fix(renderer): clear close debounce timers on unmount --- .../use-terminal-editor-close-foundation.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/use-terminal-editor-close-foundation.ts b/src/renderer/src/components/use-terminal-editor-close-foundation.ts index 2aceced683d..627f0a3d1f0 100644 --- a/src/renderer/src/components/use-terminal-editor-close-foundation.ts +++ b/src/renderer/src/components/use-terminal-editor-close-foundation.ts @@ -1,4 +1,4 @@ -import { useCallback, useRef, useState } from 'react' +import { useCallback, useEffect, useRef, useState } from 'react' import { CLOSE_DIALOG_DEBOUNCE_MS } from './terminal-workspace-model' import { assessWindowCloseRunningWork, @@ -27,6 +27,15 @@ export function useTerminalEditorCloseFoundation( }, CLOSE_DIALOG_DEBOUNCE_MS) closeDialogDebounceTimersRef.current.add(timer) }, []) + useEffect(() => { + const debounceTimers = closeDialogDebounceTimersRef.current + return () => { + for (const timer of debounceTimers) { + window.clearTimeout(timer) + } + debounceTimers.clear() + } + }, []) const [windowCloseDialogOpen, setWindowCloseDialogOpen] = useState(false) // Why: "running" and "could not reach the host" are different claims, and telling the user // processes are running when the truth is that a host went quiet is the fabricated certainty