From 2cd9d374a750c58bcc6c55247857a92e67bbd258 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Thu, 25 Sep 2025 23:04:24 +0200 Subject: [PATCH] Add Docker badge to UI --- pkg/instance/instance.go | 25 ++++++++++++++++++--- webui/src/components/BackendBadge.tsx | 31 +++++++++++++++++++-------- webui/src/components/InstanceCard.tsx | 2 +- webui/src/types/instance.ts | 1 + 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index e1509a8..0bea06c 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -221,14 +221,33 @@ func (i *Process) MarshalJSON() ([]byte, error) { i.mu.RLock() defer i.mu.RUnlock() + // Determine if docker is enabled for this instance's backend + var dockerEnabled bool + if i.options != nil { + switch i.options.BackendType { + case backends.BackendTypeLlamaCpp: + if i.globalBackendSettings != nil && i.globalBackendSettings.LlamaCpp.Docker != nil && i.globalBackendSettings.LlamaCpp.Docker.Enabled { + dockerEnabled = true + } + case backends.BackendTypeVllm: + if i.globalBackendSettings != nil && i.globalBackendSettings.VLLM.Docker != nil && i.globalBackendSettings.VLLM.Docker.Enabled { + dockerEnabled = true + } + case backends.BackendTypeMlxLm: + // MLX does not support docker currently + } + } + // Use anonymous struct to avoid recursion type Alias Process return json.Marshal(&struct { *Alias - Options *CreateInstanceOptions `json:"options,omitempty"` + Options *CreateInstanceOptions `json:"options,omitempty"` + DockerEnabled bool `json:"docker_enabled,omitempty"` }{ - Alias: (*Alias)(i), - Options: i.options, + Alias: (*Alias)(i), + Options: i.options, + DockerEnabled: dockerEnabled, }) } diff --git a/webui/src/components/BackendBadge.tsx b/webui/src/components/BackendBadge.tsx index 779fc81..88d29d7 100644 --- a/webui/src/components/BackendBadge.tsx +++ b/webui/src/components/BackendBadge.tsx @@ -1,13 +1,14 @@ import React from "react"; import { Badge } from "@/components/ui/badge"; import { BackendType, type BackendTypeValue } from "@/types/instance"; -import { Server } from "lucide-react"; +import { Server, Package } from "lucide-react"; interface BackendBadgeProps { backend?: BackendTypeValue; + docker?: boolean; } -const BackendBadge: React.FC = ({ backend }) => { +const BackendBadge: React.FC = ({ backend, docker }) => { if (!backend) { return null; } @@ -39,13 +40,25 @@ const BackendBadge: React.FC = ({ backend }) => { }; return ( - - - {getText()} - +
+ + + {getText()} + + {docker && ( + + + Docker + + )} +
); }; diff --git a/webui/src/components/InstanceCard.tsx b/webui/src/components/InstanceCard.tsx index b3b3339..a867dd3 100644 --- a/webui/src/components/InstanceCard.tsx +++ b/webui/src/components/InstanceCard.tsx @@ -66,7 +66,7 @@ function InstanceCard({ {/* Badges row */}
- + {running && }
diff --git a/webui/src/types/instance.ts b/webui/src/types/instance.ts index f55600a..074e2f2 100644 --- a/webui/src/types/instance.ts +++ b/webui/src/types/instance.ts @@ -23,4 +23,5 @@ export interface Instance { name: string; status: InstanceStatus; options?: CreateInstanceOptions; + docker_enabled?: boolean; // indicates backend is running via Docker } \ No newline at end of file