Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

720 B
Raw Blame
import * as React from 'react';

const CLOCK_TICK_MS = 60_000;

export const useDeadlineClock = (deadlineValue?: string | null): number => {
  const [now, setNow] = React.useState(() => Date.now());
  const deadline = deadlineValue ? Date.parse(deadlineValue) : Number.NaN;

  React.useEffect(() => {
    let timer: ReturnType<typeof setTimeout> | null = null;
    const tick = () => {
      const current = Date.now();
      setNow(current);
      if (Number.isFinite(deadline) && current < deadline) {
        timer = setTimeout(tick, Math.min(CLOCK_TICK_MS, deadline - current));
      }
    };

    tick();
    return () => {
      if (timer !== null) clearTimeout(timer);
    };
  }, [deadline]);

  return now;
};