fix(renderer): clear close debounce timers on unmount

This commit is contained in:
m4air
2026-09-15 20:28:47 -07:00
parent 07c7606fee
commit 86cd9f2ee1
@@ -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