From 40dead215ebdd3bf805c6324b067dc88aa9f6718 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Wed, 6 May 2026 14:29:19 +0800 Subject: [PATCH] fix: retry UDP discovery once if first attempt finds no devices --- internal/api/handlers.go | 3 +++ internal/web/ui.go | 4 ++++ 2 files changed, 7 insertions(+) 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) {