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.
This commit is contained in:
totmin
2026-07-12 11:27:10 +07:00
parent 3709926c4a
commit f20a499c0f
2 changed files with 11 additions and 3 deletions
+3 -3
View File
@@ -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}`
+8
View File
@@ -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