/** Availability of saved servers; one monitor in the Rust Core, the state is shared by the whole UI. */ import { call, subscribe } from "../transport"; export type AvailabilityStatus = "checking" | "online" | "offline" | "unknown" | "unverified"; export interface ServerAvailability { id: string; status: AvailabilityStatus; latencyMs: number | null; lastSuccessAt: number | null; lastAttemptAt: number | null; failures: number; reason: string | null; via: "direct" | "jump"; } export interface AvailabilityChange { servers: ServerAvailability[]; removed?: string[]; reset?: boolean } export const availability = Object.freeze({ list: () => call("core_availability_list", "availability:list"), refresh: () => call<{ refreshing: boolean }>("core_availability_refresh", "availability:refresh"), onChanged: (callback: (event: AvailabilityChange) => void) => subscribe("availability:changed", callback) });