diff --git a/internal/api/handlers.go b/internal/api/handlers.go index f0b8473..73d9a5f 100644 --- a/internal/api/handlers.go +++ b/internal/api/handlers.go @@ -132,6 +132,9 @@ func (h *Handler) ensureDevicesLoaded() { return } _, _ = h.discovery.SearchDefault() + if len(h.registry.GetDevices()) == 0 { + _, _ = h.discovery.SearchDefault() + } } func (h *Handler) ProxyAgent(w http.ResponseWriter, r *http.Request) { diff --git a/internal/web/ui.go b/internal/web/ui.go index d475882..8320588 100644 --- a/internal/web/ui.go +++ b/internal/web/ui.go @@ -704,6 +704,10 @@ func (u *UI) ensureDevicesLoaded() { return } _, _ = u.discovery.SearchDefault() + // Retry once if discovery returned nothing (UDP broadcast can be lossy on some networks) + if len(u.registry.GetDevices()) == 0 { + _, _ = u.discovery.SearchDefault() + } } func (u *UI) pageDashboard(w http.ResponseWriter, r *http.Request) {