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

Function startHookProgressInterval

src/utils/hooks/hookEvents.ts:124–151  ·  view source on GitHub ↗
(params: {
  hookId: string
  hookName: string
  hookEvent: string
  getOutput: () => Promise<{ stdout: string; stderr: string; output: string }>
  intervalMs?: number
})

Source from the content-addressed store, hash-verified

122}
123
124export function startHookProgressInterval(params: {
125 hookId: string
126 hookName: string
127 hookEvent: string
128 getOutput: () => Promise<{ stdout: string; stderr: string; output: string }>
129 intervalMs?: number
130}): () => void {
131 if (!shouldEmit(params.hookEvent)) return () => {}
132
133 let lastEmittedOutput = ''
134 const interval = setInterval(() => {
135 void params.getOutput().then(({ stdout, stderr, output }) => {
136 if (output === lastEmittedOutput) return
137 lastEmittedOutput = output
138 emitHookProgress({
139 hookId: params.hookId,
140 hookName: params.hookName,
141 hookEvent: params.hookEvent,
142 stdout,
143 stderr,
144 output,
145 })
146 })
147 }, params.intervalMs ?? 1000)
148 interval.unref()
149
150 return () => clearInterval(interval)
151}
152
153export function emitHookResponse(data: {
154 hookId: string

Callers 2

execCommandHookFunction · 0.85
registerPendingAsyncHookFunction · 0.85

Calls 2

shouldEmitFunction · 0.85
emitHookProgressFunction · 0.85

Tested by

no test coverage detected