diff --git a/internal/web/ui.go b/internal/web/ui.go index 32388f1..44cabb2 100644 --- a/internal/web/ui.go +++ b/internal/web/ui.go @@ -933,9 +933,10 @@ func (u *UI) pageConsole(w http.ResponseWriter, r *http.Request) { } features := make([]ConsoleFeature, 0, len(capsResp.Capabilities)) for _, c := range capsResp.Capabilities { - if c.Available { - features = append(features, ConsoleFeature{Key: c.Key, Label: c.Label, Description: c.Description, Enabled: false}) - } + features = append(features, ConsoleFeature{ + Key: c.Key, Label: c.Label, Description: c.Description, + Available: c.Available, Enabled: false, + }) } deviceAvailableFeatures[dev.DeviceID] = features } @@ -1038,19 +1039,36 @@ func (u *UI) pageConsole(w http.ResponseWriter, r *http.Request) { activeKeys = map[string]bool{} } - // Features from device capabilities (filtered by agent /v1/capabilities). - // Fall back to persisted keys if agent doesn't respond. + // Features from device capabilities (from agent /v1/capabilities). + // Overlay persisted DB state for checkmarks and conflict detection. available := deviceAvailableFeatures[dev.DeviceID] var features []ConsoleFeature if len(available) > 0 { for _, f := range available { f.Enabled = activeKeys[f.Key] + // Conflict: user enabled a feature that the device no longer supports. + if f.Enabled && !f.Available { + f.Conflict = true + } features = append(features, f) } - } else { - // Old agent: use persisted keys to show at least what's configured. + // Show persisted features that the agent didn't report (e.g. new features + // added to registry but old agent doesn't know them). + seen := map[string]bool{} + for _, f := range features { + seen[f.Key] = true + } for key := range activeKeys { - features = append(features, ConsoleFeature{Key: key, Label: key, Enabled: true}) + if !seen[key] { + features = append(features, ConsoleFeature{ + Key: key, Label: key, Enabled: true, Available: false, Conflict: true, + }) + } + } + } else { + // Old agent: show persisted keys. + for key := range activeKeys { + features = append(features, ConsoleFeature{Key: key, Label: key, Enabled: true, Available: true}) } } @@ -4732,4 +4750,6 @@ type ConsoleFeature struct { Label string Description string Enabled bool + Available bool // device actually supports this (from agent /v1/capabilities) + Conflict bool // enabled in DB but unavailable on device } diff --git a/internal/web/ui/templates/console.html b/internal/web/ui/templates/console.html index 231e124..ac8516b 100644 --- a/internal/web/ui/templates/console.html +++ b/internal/web/ui/templates/console.html @@ -61,8 +61,10 @@ {{range $f := $cd.Features}} - - + + {{end}}
{{$f.Label}} + {{$f.Label}}{{if $f.Conflict}} ⚠{{end}} +