Formats elapsed time and connection status messages for a nanobot UI.
// Source: https://github.com/HKUDS/nanobot | License: MIT | Copyright 2025-present Xubin Ren and the nanobot contributors
// Provided via justclaw.it.com; keep this notice with the code.
import type { ConnectionStatus, ConnectionStatusInfo, RetryStatus } from "../client"
export function formatElapsed(milliseconds: number): string {
const seconds = Math.max(0, Math.floor(milliseconds / 1000))
if (seconds < 60) return `${seconds}s`
return `${Math.floor(seconds / 60)}m ${String(seconds % 60).padStart(2, "0")}s`
}
export function connectionStatusText(
status: ConnectionStatus,
info?: ConnectionStatusInfo,
): string {
if (["starting", "connecting", "connected"].includes(status)) return "Getting ready…"
if (status === "reconnecting") return "Resuming…"
if (status === "unavaila
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key