import { useRef } from "react" import { useParams } from "react-router-dom" import { Server, ExternalLink, Terminal, Trash2 } from "lucide-react" import { useService, useStatus, useEventStream, useCaddyfile } from "@/services/api/hooks" import { runnerLabel } from "@/lib/labels" import { HealthBadge } from "@/components/HealthBadge" import { LogViewer, type LogViewerHandle } 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" export function ServiceDetailPage() { useEventStream() const logRef = useRef(null) 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 === "castle-gateway" const { data: caddyfile } = useCaddyfile(isGateway) if (isLoading) { return (
Loading...
) } if (error || !deployment) { return (

Service not found

) } const runner = (deployment.manifest.run as Record)?.runner as string | undefined return (
{health && }

Overview

{deployment.port && ( <> Port :{deployment.port} )} {deployment.health_path && ( <> Health {deployment.health_path} )} {deployment.proxy_path && ( <> Proxy {deployment.proxy_path} )} {runner && ( <> Runner {runnerLabel(runner)} {(deployment.manifest.run as Record)?.program && ( <> · {(deployment.manifest.run as Record).program} )} )} {deployment.port && ( <> Docs OpenAPI docs )}
{deployment.systemd && ( )} {isGateway && caddyfile?.content && (

Caddyfile

Generated reverse proxy configuration served by the gateway.

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

Logs

)}
) }