/** Status bar widget listing language servers, with a popup to restart them. */ import { useMemo, useRef, useState } from "react"; import clsx from "clsx"; import { getAction, executeAction } from "@/platform/actions"; import { BarButton, Button, IconButton, Popup, T } from "@/ui"; import { downloadJdkActions } from "@/platform/jdk"; import { relativePath, useProject } from "@/platform/project"; import { STATUS_LABEL, restartServer, servedByOther, serversSummary, useServers } from "./servers"; import styles from "./ServerStatus.module.css"; import { tx } from "@/platform/i18n"; export function ServerStatus() { const map = useServers((s) => s.servers); const servers = useMemo(() => [...map.values()].sort((a, b) => a.name.localeCompare(b.name)), [map]); const root = useProject((s) => s.project?.root ?? ""); const [open, setOpen] = useState(false); const ref = useRef(null); const summary = serversSummary(servers); // features/tools owns installing; without it, fall back to the manual hint text. const canInstall = !!getAction("tools.install"); if (!summary) return null; return ( <> setOpen((v) => !v)} > {summary.text} setOpen(false)} aria-label="Language servers" >
Language Servers
{servers.map((s) => { // jdtls without a JDK new enough to run it: "Download JDK 25". const [jdkFix] = s.status === "misconfigured" ? downloadJdkActions(s.message) : []; return (
{s.name} {STATUS_LABEL[s.status]} {jdkFix ? ( ) : s.status === "missing" && canInstall ? ( ) : ( void restartServer(s.id)} /> )}
{(s.languages.length > 0 || s.root) && (
{s.languages.join(", ")} {s.root && s.root !== root ? ` ยท ${relativePath(root, s.root) || s.root}` : ""}
)} {s.message && (
{s.message}
)}
); })}
); } function toneOf(status: string): "ok" | "busy" | "error" | "idle" { if (status === "ready") return "ok"; if (status === "starting" || status === "busy") return "busy"; if (status === "crashed" || status === "missing" || status === "misconfigured") return "error"; return "idle"; }