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