"use client"; import { useSyncExternalStore } from "react"; /** The browser's host name; null while rendering on the server, so hydration matches. */ export function useHostname(): string | null { return useSyncExternalStore( () => () => {}, () => window.location.hostname, () => null, ); } /** llama-server's built-in chat UI, served at / on the published host port. */ export function webUiUrl( d: { engine: string; hostPort: number | null; options: { webui?: boolean | null } }, hostname: string | null, ): string | null { return d.engine === "llama.cpp" && d.options.webui !== false && d.hostPort && hostname ? `http://${hostname}:${d.hostPort}/` : null; }