()
| 90 | } |
| 91 | |
| 92 | function onFocusChange(): void { |
| 93 | const state = getTerminalFocusState() |
| 94 | if (state === 'blurred') { |
| 95 | clearTimer() |
| 96 | timerRef.current = setTimeout(onBlurTimerFire, BLUR_DELAY_MS) |
| 97 | } else if (state === 'focused') { |
| 98 | clearTimer() |
| 99 | abortInFlight() |
| 100 | pendingRef.current = false |
| 101 | } |
| 102 | // 'unknown' → no-op |
| 103 | } |
| 104 | |
| 105 | const unsubscribe = subscribeTerminalFocus(onFocusChange) |
| 106 | // Handle the case where we're already blurred when the effect mounts |
no test coverage detected