Fix Docker host custom display name not persisting in UI (related to #662)

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.
This commit is contained in:
rcourtman 2025-11-08 10:28:20 +00:00
parent 1a3abf7f3f
commit 8cea433443
2 changed files with 22 additions and 20 deletions

View file

@ -201,6 +201,7 @@ func (d DockerHost) ToFrontend() DockerHostFrontend {
AgentID: d.AgentID, AgentID: d.AgentID,
Hostname: d.Hostname, Hostname: d.Hostname,
DisplayName: d.DisplayName, DisplayName: d.DisplayName,
CustomDisplayName: d.CustomDisplayName,
MachineID: d.MachineID, MachineID: d.MachineID,
OS: d.OS, OS: d.OS,
KernelVersion: d.KernelVersion, KernelVersion: d.KernelVersion,

View file

@ -102,6 +102,7 @@ type DockerHostFrontend struct {
AgentID string `json:"agentId"` AgentID string `json:"agentId"`
Hostname string `json:"hostname"` Hostname string `json:"hostname"`
DisplayName string `json:"displayName"` DisplayName string `json:"displayName"`
CustomDisplayName string `json:"customDisplayName,omitempty"`
MachineID string `json:"machineId,omitempty"` MachineID string `json:"machineId,omitempty"`
OS string `json:"os,omitempty"` OS string `json:"os,omitempty"`
KernelVersion string `json:"kernelVersion,omitempty"` KernelVersion string `json:"kernelVersion,omitempty"`