MCPcopy Create free account
hub / github.com/anomalyco/opencode / ServerRow

Function ServerRow

packages/app/src/components/server/server-row.tsx:28–114  ·  view source on GitHub ↗
(props: ServerRowProps)

Source from the content-addressed store, hash-verified

26}
27
28export function ServerRow(props: ServerRowProps) {
29 const language = useLanguage()
30 const [truncated, setTruncated] = createSignal(false)
31 let nameRef: HTMLSpanElement | undefined
32 let versionRef: HTMLSpanElement | undefined
33 const name = createMemo(() => serverName(props.conn))
34
35 const check = () => {
36 const nameTruncated = nameRef ? nameRef.scrollWidth > nameRef.clientWidth : false
37 const versionTruncated = versionRef ? versionRef.scrollWidth > versionRef.clientWidth : false
38 setTruncated(nameTruncated || versionTruncated)
39 }
40
41 createEffect(() => {
42 name()
43 props.conn.http.url
44 props.status?.version
45 queueMicrotask(check)
46 })
47
48 onMount(() => {
49 if (typeof ResizeObserver !== "function") return
50 createResizeObserver([nameRef, versionRef], check)
51 check()
52 })
53
54 const tooltipValue = () => (
55 <span class="flex items-center gap-2">
56 <span>{serverName(props.conn, true)}</span>
57 <Show when={props.status?.version}>
58 <span class="text-text-invert-weak">v{props.status?.version}</span>
59 </Show>
60 </span>
61 )
62
63 const badge = children(() => props.badge)
64
65 return (
66 <Tooltip
67 class="flex-1 min-w-0"
68 value={tooltipValue()}
69 contentStyle={{ "max-width": "none", "white-space": "nowrap" }}
70 placement="top-start"
71 inactive={!truncated() && !props.conn.displayName}
72 >
73 <div class={props.class} classList={{ "opacity-50": props.dimmed }}>
74 <div class="flex flex-col items-start min-w-0 w-full">
75 <div class="flex flex-row items-center gap-2 min-w-0 w-full">
76 <span ref={nameRef} class={`${props.nameClass ?? "truncate"} min-w-0`}>
77 {name()}
78 </span>
79 <Show
80 when={badge()}
81 fallback={
82 <Show when={props.status?.version}>
83 <span
84 ref={versionRef}
85 class={`${props.versionClass ?? "text-text-weak text-14-regular truncate"} min-w-0`}

Callers

nothing calls this directly

Calls 5

serverNameFunction · 0.90
checkFunction · 0.70
tooltipValueFunction · 0.70
nameFunction · 0.50
childrenFunction · 0.50

Tested by

no test coverage detected