import { useParams, Link } from "react-router-dom" import { Server, ExternalLink, Terminal } from "lucide-react" import { useService, useStatus, useCaddyfile } from "@/services/api/hooks" import { launcherLabel, subdomainUrl } from "@/lib/labels" import { HealthBadge } from "@/components/HealthBadge" import { LogViewer } from "@/components/LogViewer" import { DetailHeader } from "@/components/detail/DetailHeader" import { ServiceControls } from "@/components/detail/ServiceControls" import { SystemdPanel } from "@/components/detail/SystemdPanel" import { ConfigPanel } from "@/components/detail/ConfigPanel" import { RelatedDeployments } from "@/components/detail/RelatedDeployments" export function ServiceDetailPage() { const { name } = useParams<{ name: string }>() const { data: deployment, isLoading, error, refetch } = useService(name ?? "") const { data: statusResp } = useStatus() const health = statusResp?.statuses.find((s) => s.id === name) const isGateway = name === "wildpc-gateway" const { data: caddyfile } = useCaddyfile(isGateway) if (isLoading) { return (
Loading...
) } if (error || !deployment) { return (

Service not found

) } // A static is a caddy-served site, not a systemd unit — no start/stop, no logs; // it shows its served URL and the dir it serves instead of a port/launcher. const isStatic = deployment.kind === "static" || deployment.manager === "caddy" const root = (deployment.manifest?.root as string | undefined) ?? undefined // The gateway address to launch: a static is always served there (falls back to // its id); a systemd service only when it's actually proxied (has a subdomain). const launchLabel = deployment.subdomain ?? (isStatic ? deployment.id : undefined) const launchUrl = launchLabel ? subdomainUrl(launchLabel) : null return (
{!isStatic && health && } {launchUrl && ( )} {!isStatic && }

Overview

{isStatic && ( <> Status ● served by the gateway · manager: caddy {root && ( <> Root {root} )} )} {deployment.port && ( <> Port :{deployment.port} )} {deployment.health_path && ( <> Health {deployment.health_path} )} {deployment.launcher && ( <> Launch {launcherLabel(deployment.launcher)} {deployment.run_target && <> · {deployment.run_target}} )} {deployment.program && ( <> Program {deployment.program} )} {deployment.port && ( <> Docs OpenAPI docs )}
{isGateway && caddyfile?.content && (

Caddyfile

Generated reverse proxy configuration served by the gateway.

            {caddyfile.content}
          
)} {deployment.systemd && ( )} {deployment.managed && (

Logs

)}
) }