Files
openconcho/packages/web/src/hooks/useHealthStatus.ts
Claude 38e76d33de feat: add health indicator and localhost auto-detect
Surfaces live connection health for the active instance in the sidebar
and probes localhost:8000 on the first-run choose-type screen so users
running Honcho locally can connect in one tap.

- useHealthStatus hook polls checkConnection every 30s via TanStack Query
- HealthDot component renders a colored status dot with tooltip
- choose-type screen silently probes http://localhost:8000 once; on
  success it surfaces a "Detected Honcho at localhost:8000 — tap to
  connect" banner that opens the self-hosted form
2026-05-14 23:50:03 +00:00

21 lines
611 B
TypeScript

import { useQuery } from "@tanstack/react-query";
import { useInstances } from "@/hooks/useInstances";
import { checkConnection } from "@/lib/config";
const POLL_INTERVAL_MS = 30_000;
export function useHealthStatus() {
const { active } = useInstances();
return useQuery({
queryKey: ["health", active?.id, active?.baseUrl, active?.token],
queryFn: async () => {
if (!active) throw new Error("No active instance");
return checkConnection(active.baseUrl, active.token || undefined);
},
enabled: !!active,
refetchInterval: POLL_INTERVAL_MS,
refetchOnWindowFocus: true,
staleTime: 0,
});
}