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

Function useElapsedTime

src/hooks/useElapsedTime.ts:17–37  ·  view source on GitHub ↗
(
  startTime: number,
  isRunning: boolean,
  ms: number = 1000,
  pausedMs: number = 0,
  endTime?: number,
)

Source from the content-addressed store, hash-verified

15 * @returns Formatted duration string (e.g., "1m 23s")
16 */
17export function useElapsedTime(
18 startTime: number,
19 isRunning: boolean,
20 ms: number = 1000,
21 pausedMs: number = 0,
22 endTime?: number,
23): string {
24 const get = () =>
25 formatDuration(Math.max(0, (endTime ?? Date.now()) - startTime - pausedMs))
26
27 const subscribe = useCallback(
28 (notify: () => void) => {
29 if (!isRunning) return () => {}
30 const interval = setInterval(notify, ms)
31 return () => clearInterval(interval)
32 },
33 [isRunning, ms],
34 )
35
36 return useSyncExternalStore(subscribe, get, get)
37}
38

Callers 6

TeammateSpinnerLineFunction · 0.85
DreamDetailDialogFunction · 0.85
AsyncAgentDetailDialogFunction · 0.85
UltraplanSessionDetailFunction · 0.85
ReviewSessionDetailFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected