From 4339ca5fe1ee68bcfd61d1e2970de9f657fc7d79 Mon Sep 17 00:00:00 2001 From: Maksim Totmin Date: Sun, 12 Jul 2026 11:27:10 +0700 Subject: [PATCH] fix: stale display outputs leaking between pages in web UI Bug: when the StreamDeck was on a non-main page (e.g. dashboard) and the web UI was opened in a private browser tab, the frontend defaulted to the first page in config while display outputs from the other page were still applied to keys sharing the same index. Fix 1 (backend): send the current active page via SSE immediately on new client connection so the frontend knows the correct page from the start. Fix 2 (frontend): only apply display output text/background to keys that have a display config, preventing cross-page leakage. --- static/app.js | 6 +++--- web.go | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/static/app.js b/static/app.js index 05e6bf2..bf82f93 100644 --- a/static/app.js +++ b/static/app.js @@ -181,8 +181,8 @@ document.addEventListener('alpine:init', () => { hasDisplay: !!(kc?.display), hasAction: !!(kc?.actions?.length), actionTypes: this.getActionTypes(kc?.actions || []), - displayBg: dout?.background || '', - displayText: dout?.text || '', + displayBg: (kc?.display && dout?.background) || '', + displayText: (kc?.display && dout?.text) || '', previewUrl: this.keyPreviewUrl(kc ? kc : {}, dout), isDynamic: !!(page.dynamic_keys && page.effective_keys?.find(k => k.index === i)), }) @@ -204,7 +204,7 @@ document.addEventListener('alpine:init', () => { const k = kc || {} let url = '/api/render?key_size=72' if (k.icon) url += `&icon=${encodeURIComponent(k.icon)}` - const label = dout?.text || this.displayOutputs[k.index]?.text || k.label + const label = (k.display && (dout?.text || this.displayOutputs[k.index]?.text)) || k.label if (label) url += `&label=${encodeURIComponent(label)}` if (k.icon_scale != null) url += `&icon_scale=${k.icon_scale}` if (k.font_size != null) url += `&font_size=${k.font_size}` diff --git a/web.go b/web.go index 1d388c0..31fe979 100644 --- a/web.go +++ b/web.go @@ -172,6 +172,14 @@ func (s *WebServer) handleSSE(w http.ResponseWriter, r *http.Request) { s.sseClients[ch] = struct{}{} s.sseMu.Unlock() + s.mu.RLock() + if s.pm != nil { + if active := s.pm.ActivePageName(); active != "" { + ch <- active + } + } + s.mu.RUnlock() + notify := r.Context().Done() go func() { <-notify