diff --git a/frontend-modern/src/components/AI/Chat/MentionAutocomplete.tsx b/frontend-modern/src/components/AI/Chat/MentionAutocomplete.tsx index ad9db32ac..c09a58c39 100644 --- a/frontend-modern/src/components/AI/Chat/MentionAutocomplete.tsx +++ b/frontend-modern/src/components/AI/Chat/MentionAutocomplete.tsx @@ -110,7 +110,7 @@ export function MentionAutocomplete(props: MentionAutocompleteProps) { // Get status color const getStatusColor = (status?: string) => { - switch (status?.toLowerCase()) { + switch (status?.trim().toLowerCase()) { case 'running': case 'online': case 'healthy': diff --git a/frontend-modern/src/components/AI/Chat/mentionResources.ts b/frontend-modern/src/components/AI/Chat/mentionResources.ts index 1a0ef1ae7..f1bfd7dbb 100644 --- a/frontend-modern/src/components/AI/Chat/mentionResources.ts +++ b/frontend-modern/src/components/AI/Chat/mentionResources.ts @@ -253,7 +253,7 @@ export function buildMentionResources(state: MentionStateSubset): MentionResourc id: `host:${host.id}`, name: hostName, type: 'host', - status: host.status, + status: host.status || 'online', }, aliases, ); diff --git a/internal/models/converters.go b/internal/models/converters.go index 49ba792e0..974d3c26a 100644 --- a/internal/models/converters.go +++ b/internal/models/converters.go @@ -462,28 +462,30 @@ func (r RemovedKubernetesCluster) ToFrontend() RemovedKubernetesClusterFrontend // ToFrontend converts a Host to HostFrontend. func (h Host) ToFrontend() HostFrontend { host := HostFrontend{ - ID: h.ID, - Hostname: h.Hostname, - DisplayName: h.DisplayName, - Platform: h.Platform, - OSName: h.OSName, - OSVersion: h.OSVersion, - KernelVersion: h.KernelVersion, - Architecture: h.Architecture, - CPUCount: h.CPUCount, - CPUUsage: h.CPUUsage, - Status: h.Status, - UptimeSeconds: h.UptimeSeconds, - IntervalSeconds: h.IntervalSeconds, - AgentVersion: h.AgentVersion, - TokenID: h.TokenID, - TokenName: h.TokenName, - TokenHint: h.TokenHint, - Tags: append([]string(nil), h.Tags...), - LastSeen: h.LastSeen.Unix() * 1000, - CommandsEnabled: h.CommandsEnabled, - IsLegacy: h.IsLegacy, - LinkedNodeId: h.LinkedNodeID, + ID: h.ID, + Hostname: h.Hostname, + DisplayName: h.DisplayName, + Platform: h.Platform, + OSName: h.OSName, + OSVersion: h.OSVersion, + KernelVersion: h.KernelVersion, + Architecture: h.Architecture, + CPUCount: h.CPUCount, + CPUUsage: h.CPUUsage, + Status: h.Status, + UptimeSeconds: h.UptimeSeconds, + IntervalSeconds: h.IntervalSeconds, + AgentVersion: h.AgentVersion, + TokenID: h.TokenID, + TokenName: h.TokenName, + TokenHint: h.TokenHint, + Tags: append([]string(nil), h.Tags...), + LastSeen: h.LastSeen.Unix() * 1000, + CommandsEnabled: h.CommandsEnabled, + IsLegacy: h.IsLegacy, + LinkedNodeId: h.LinkedNodeID, + LinkedVmId: h.LinkedVMID, + LinkedContainerId: h.LinkedContainerID, } // Fall back to Hostname if DisplayName is empty diff --git a/internal/models/converters_test.go b/internal/models/converters_test.go index c9d52833c..a4c7a9e6d 100644 --- a/internal/models/converters_test.go +++ b/internal/models/converters_test.go @@ -1080,9 +1080,11 @@ func TestHostToFrontend(t *testing.T) { Sensors: HostSensorSummary{ TemperatureCelsius: map[string]float64{"cpu": 55.0}, }, - CommandsEnabled: true, - IsLegacy: false, - LinkedNodeID: "node-abc", + CommandsEnabled: true, + IsLegacy: false, + LinkedNodeID: "node-abc", + LinkedVMID: "vm-xyz", + LinkedContainerID: "ct-456", } frontend := host.ToFrontend() @@ -1135,6 +1137,12 @@ func TestHostToFrontend(t *testing.T) { if frontend.LinkedNodeId != host.LinkedNodeID { t.Errorf("LinkedNodeId = %q, want %q", frontend.LinkedNodeId, host.LinkedNodeID) } + if frontend.LinkedVmId != host.LinkedVMID { + t.Errorf("LinkedVmId = %q, want %q", frontend.LinkedVmId, host.LinkedVMID) + } + if frontend.LinkedContainerId != host.LinkedContainerID { + t.Errorf("LinkedContainerId = %q, want %q", frontend.LinkedContainerId, host.LinkedContainerID) + } if frontend.TokenLastUsedAt == nil || *frontend.TokenLastUsedAt != tokenLastUsed.Unix()*1000 { t.Errorf("TokenLastUsedAt = %v, want %d", frontend.TokenLastUsedAt, tokenLastUsed.Unix()*1000) } diff --git a/internal/models/models_frontend.go b/internal/models/models_frontend.go index 162185a03..87536eb06 100644 --- a/internal/models/models_frontend.go +++ b/internal/models/models_frontend.go @@ -438,9 +438,11 @@ type HostFrontend struct { TokenHint string `json:"tokenHint,omitempty"` TokenLastUsedAt *int64 `json:"tokenLastUsedAt,omitempty"` Tags []string `json:"tags,omitempty"` - CommandsEnabled bool `json:"commandsEnabled,omitempty"` // Whether AI command execution is enabled - IsLegacy bool `json:"isLegacy,omitempty"` // True if using legacy agent protocol - LinkedNodeId string `json:"linkedNodeId,omitempty"` // ID of linked PVE node (if running on a node) + CommandsEnabled bool `json:"commandsEnabled,omitempty"` // Whether AI command execution is enabled + IsLegacy bool `json:"isLegacy,omitempty"` // True if using legacy agent protocol + LinkedNodeId string `json:"linkedNodeId,omitempty"` // ID of linked PVE node (if running on a node) + LinkedVmId string `json:"linkedVmId,omitempty"` // ID of linked VM (if running inside a VM) + LinkedContainerId string `json:"linkedContainerId,omitempty"` // ID of linked container (if running inside a container) } // HostSensorSummaryFrontend mirrors HostSensorSummary with primitives for the frontend.