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>
92 lines
3.0 KiB
TypeScript
92 lines
3.0 KiB
TypeScript
import { useTensorZeroStatusFetcher } from "~/routes/api/tensorzero/status";
|
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
|
|
import { useMemo } from "react";
|
|
|
|
interface RelayStatusIndicatorProps {
|
|
collapsed?: boolean;
|
|
}
|
|
|
|
/**
|
|
* A component that displays the status of the Relay gateway.
|
|
*/
|
|
export default function RelayStatusIndicator({
|
|
collapsed = false,
|
|
}: RelayStatusIndicatorProps) {
|
|
const { status, isLoading } = useTensorZeroStatusFetcher();
|
|
const uiVersion = __APP_VERSION__;
|
|
|
|
// Extract server version from status if available
|
|
const serverVersion = status?.version || "";
|
|
|
|
// Check if versions match (ignoring patch version) - memoized to prevent re-renders
|
|
const versionsMatch = useMemo(() => {
|
|
if (!serverVersion) return true; // No data yet, don't show warning
|
|
// We can do an exact match for now
|
|
return uiVersion === serverVersion;
|
|
}, [uiVersion, serverVersion]);
|
|
|
|
const statusColor = useMemo(() => {
|
|
if (isLoading || status === undefined) return "bg-gray-300"; // Loading or initial state
|
|
if (!status) return "bg-red-500"; // Could not connect (explicit null/failed state)
|
|
if (!versionsMatch) return "bg-yellow-500"; // Version mismatch
|
|
return "bg-green-500"; // Everything is good
|
|
}, [isLoading, status, versionsMatch]);
|
|
|
|
const statusText = isLoading
|
|
? "Checking status..."
|
|
: status === undefined
|
|
? "Connecting to Gateway..."
|
|
: status
|
|
? `Relay Gateway ${serverVersion}`
|
|
: "Gateway Unavailable";
|
|
|
|
const statusDot = (
|
|
<div className="flex h-4 w-4 shrink-0 items-center justify-center">
|
|
<div className={`h-2 w-2 rounded-full ${statusColor}`} />
|
|
</div>
|
|
);
|
|
|
|
const content = (
|
|
<div className="text-fg-muted flex flex-col gap-1 overflow-hidden p-2 text-xs">
|
|
<div className="flex items-center gap-2">
|
|
{statusDot}
|
|
<span className="whitespace-nowrap transition-opacity duration-200 group-data-[collapsible=icon]:opacity-0">
|
|
{statusText}
|
|
</span>
|
|
</div>
|
|
{status && !versionsMatch && !collapsed && (
|
|
<div className="ml-6 transition-opacity duration-200 group-data-[collapsible=icon]:opacity-0">
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<span className="text-[10px] whitespace-nowrap text-yellow-600">
|
|
Version mismatch: UI {uiVersion}
|
|
</span>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="right" align="center">
|
|
You may experience compatibility issues
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
|
|
if (collapsed) {
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>{content}</TooltipTrigger>
|
|
<TooltipContent side="right" align="center">
|
|
{statusText}
|
|
{status && !versionsMatch && (
|
|
<div className="text-yellow-600">
|
|
Version mismatch: UI {uiVersion}
|
|
</div>
|
|
)}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
);
|
|
}
|
|
|
|
return content;
|
|
}
|