README rewritten with engine features, not-available list and Apache-2.0 attribution (forked from TensorZero 2026.6.0). UI status indicator, logger prefix and warnings renamed to Relay (RELAY_UI_LOG_LEVEL with legacy alias). Help links resolve via docs-url.ts to pinned engine docs (VITE_RELAY_DOCS_URL override); fixed SFT link. /autopilot always shows the unavailable page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { useFetcher } from "react-router";
|
|
import { getTensorZeroClient } from "~/utils/tensorzero.server";
|
|
import { useEffect, useMemo } from "react";
|
|
import { logger } from "~/utils/logger";
|
|
import type { StatusResponse } from "~/types/tensorzero";
|
|
|
|
/**
|
|
* Loader that fetches the TensorZero Gateway status.
|
|
*/
|
|
export async function loader(): Promise<StatusResponse | undefined> {
|
|
try {
|
|
const status = await getTensorZeroClient().status();
|
|
return status;
|
|
} catch (error) {
|
|
logger.error("Failed to fetch Relay gateway status:", error);
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A hook that fetches the status of the TensorZero Gateway.
|
|
*/
|
|
export function useTensorZeroStatusFetcher() {
|
|
const statusFetcher = useFetcher();
|
|
const status = statusFetcher.data;
|
|
const isLoading = statusFetcher.state === "loading";
|
|
|
|
useEffect(() => {
|
|
if (statusFetcher.state === "idle" && !statusFetcher.data) {
|
|
statusFetcher.load("/api/tensorzero/status");
|
|
}
|
|
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
}, []); // Empty dependency array - only run on mount
|
|
|
|
return useMemo(() => ({ status, isLoading }), [status, isLoading]);
|
|
}
|