import { Tooltip } from "@opencode-ai/ui/tooltip" import { JSXElement, ParentProps, Show, createEffect, createSignal, onCleanup, onMount } from "solid-js" import { serverDisplayName } from "@/context/server" import type { ServerHealth } from "@/utils/server-health" interface ServerRowProps extends ParentProps { url: string status?: ServerHealth class?: string nameClass?: string versionClass?: string dimmed?: boolean badge?: JSXElement } export function ServerRow(props: ServerRowProps) { const [truncated, setTruncated] = createSignal(false) let nameRef: HTMLSpanElement | undefined let versionRef: HTMLSpanElement | undefined const check = () => { const nameTruncated = nameRef ? nameRef.scrollWidth > nameRef.clientWidth : false const versionTruncated = versionRef ? versionRef.scrollWidth > versionRef.clientWidth : false setTruncated(nameTruncated || versionTruncated) } createEffect(() => { props.url props.status?.version if (typeof requestAnimationFrame === "function") { requestAnimationFrame(check) return } check() }) onMount(() => { check() if (typeof window === "undefined") return window.addEventListener("resize", check) onCleanup(() => window.removeEventListener("resize", check)) }) const tooltipValue = () => ( {serverDisplayName(props.url)} {props.status?.version} ) return (
{serverDisplayName(props.url)} {props.status?.version} {props.badge} {props.children}
) }