From 8cea4334432a9b700c9e46cf788d2ba6e541dfa0 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Sat, 8 Nov 2025 10:28:20 +0000 Subject: [PATCH] Fix Docker host custom display name not persisting in UI (related to #662) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The custom display name feature added in cd627f33c had a critical bug where the backend successfully stored custom names but the frontend never received them, making the feature appear non-functional. Root cause: - DockerHost.CustomDisplayName was stored in backend state (models.go:201) - SetDockerHostCustomDisplayName() correctly updated the field - BUT DockerHostFrontend struct was missing customDisplayName field - AND ToFrontend() converter didn't copy CustomDisplayName - Result: WebSocket state broadcasts stripped out the custom name When users edited a Docker host display name: - API returned 200 OK ✓ - Success notification appeared ✓ - Edit state cleared ✓ - But subsequent state broadcasts lacked customDisplayName ✗ - UI continued showing original name ✗ Fix: - Add CustomDisplayName field to DockerHostFrontend (models_frontend.go:105) - Copy d.CustomDisplayName in ToFrontend() converter (converters.go:204) - Now custom display names properly propagate to frontend via WebSocket The feature now works as originally intended - custom names persist across agent reconnections and display correctly in the UI. --- internal/models/converters.go | 41 +++++++++++++++--------------- internal/models/models_frontend.go | 1 + 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/internal/models/converters.go b/internal/models/converters.go index b4a809e..8a8c81c 100644 --- a/internal/models/converters.go +++ b/internal/models/converters.go @@ -197,26 +197,27 @@ func (c Container) ToFrontend() ContainerFrontend { // ToFrontend converts a DockerHost to DockerHostFrontend func (d DockerHost) ToFrontend() DockerHostFrontend { h := DockerHostFrontend{ - ID: d.ID, - AgentID: d.AgentID, - Hostname: d.Hostname, - DisplayName: d.DisplayName, - MachineID: d.MachineID, - OS: d.OS, - KernelVersion: d.KernelVersion, - Architecture: d.Architecture, - Runtime: d.Runtime, - RuntimeVersion: d.RuntimeVersion, - DockerVersion: d.DockerVersion, - CPUs: d.CPUs, - TotalMemoryBytes: d.TotalMemoryBytes, - UptimeSeconds: d.UptimeSeconds, - CPUUsagePercent: d.CPUUsage, - Status: d.Status, - LastSeen: d.LastSeen.Unix() * 1000, - IntervalSeconds: d.IntervalSeconds, - AgentVersion: d.AgentVersion, - Containers: make([]DockerContainerFrontend, len(d.Containers)), + ID: d.ID, + AgentID: d.AgentID, + Hostname: d.Hostname, + DisplayName: d.DisplayName, + CustomDisplayName: d.CustomDisplayName, + MachineID: d.MachineID, + OS: d.OS, + KernelVersion: d.KernelVersion, + Architecture: d.Architecture, + Runtime: d.Runtime, + RuntimeVersion: d.RuntimeVersion, + DockerVersion: d.DockerVersion, + CPUs: d.CPUs, + TotalMemoryBytes: d.TotalMemoryBytes, + UptimeSeconds: d.UptimeSeconds, + CPUUsagePercent: d.CPUUsage, + Status: d.Status, + LastSeen: d.LastSeen.Unix() * 1000, + IntervalSeconds: d.IntervalSeconds, + AgentVersion: d.AgentVersion, + Containers: make([]DockerContainerFrontend, len(d.Containers)), } if h.DisplayName == "" { diff --git a/internal/models/models_frontend.go b/internal/models/models_frontend.go index 0854459..d22a4ec 100644 --- a/internal/models/models_frontend.go +++ b/internal/models/models_frontend.go @@ -102,6 +102,7 @@ type DockerHostFrontend struct { AgentID string `json:"agentId"` Hostname string `json:"hostname"` DisplayName string `json:"displayName"` + CustomDisplayName string `json:"customDisplayName,omitempty"` MachineID string `json:"machineId,omitempty"` OS string `json:"os,omitempty"` KernelVersion string `json:"kernelVersion,omitempty"`