MCPcopy Index your code
hub / github.com/codeaashu/claude-code / useNotifyAfterTimeout

Function useNotifyAfterTimeout

src/hooks/useNotifyAfterTimeout.ts:38–65  ·  view source on GitHub ↗
(
  message: string,
  notificationType: string,
)

Source from the content-addressed store, hash-verified

36 * @param timeout - The timeout in milliseconds (defaults to 6000ms)
37 */
38export function useNotifyAfterTimeout(
39 message: string,
40 notificationType: string,
41): void {
42 const terminal = useTerminalNotification()
43
44 // Reset interaction time when hook is called to make sure that requests
45 // that took a long time to complete don't pop up a notification right away.
46 // Must be immediate because useEffect runs after Ink's render cycle has
47 // already flushed; without it the timestamp stays stale and a premature
48 // notification fires if the user is idle (no subsequent renders to flush).
49 useEffect(() => {
50 updateLastInteractionTime(true)
51 }, [])
52
53 useEffect(() => {
54 let hasNotified = false
55 const timer = setInterval(() => {
56 if (shouldNotify(DEFAULT_INTERACTION_THRESHOLD_MS) && !hasNotified) {
57 hasNotified = true
58 clearInterval(timer)
59 void sendNotification({ message, notificationType }, terminal)
60 }
61 }, DEFAULT_INTERACTION_THRESHOLD_MS)
62
63 return () => clearInterval(timer)
64 }, [message, notificationType, terminal])
65}
66

Callers 3

PermissionRequestFunction · 0.85
ElicitationFormDialogFunction · 0.85
ElicitationURLDialogFunction · 0.85

Calls 4

useTerminalNotificationFunction · 0.85
shouldNotifyFunction · 0.85
sendNotificationFunction · 0.50

Tested by

no test coverage detected