fix: sync bell state on all dashboard tiles when tab regains focus

The orange bell outline on tiles could get stuck because:

1. The terminal tab clears its bell localStorage entry on focus/keypress,
   but the 'storage' event only fires across tabs — the dashboard in the
   same browser never sees the removal.

2. The only way to clear the bell class was to click the tile to open it
   (openTile → clearBellState). Simply switching back to the dashboard
   tab never re-checked localStorage.

Now onDashboardFocusChanged() calls syncAllBellStates() which re-reads
localStorage for every tile and toggles the bell class accordingly,
clearing stale orange outlines as soon as the dashboard becomes visible.
This commit is contained in:
GitHub Copilot
2026-02-26 20:33:44 +00:00
parent 571d0c0b9c
commit 41071f8a89
+13
View File
@@ -1240,6 +1240,14 @@ func (s *LocalServer) handleRoot(w http.ResponseWriter, r *http.Request) {
updateDashboardTitle();
}
function syncAllBellStates() {
for (const tile of tiles) {
if (tile && tile.slug) {
applyBellState(tile.slug);
}
}
}
function clearBellState(slug) {
if (!slug) return;
localStorage.removeItem(bellStorageKey(slug));
@@ -1490,6 +1498,11 @@ func (s *LocalServer) handleRoot(w http.ResponseWriter, r *http.Request) {
function onDashboardFocusChanged() {
if (dashboardCanRequestScreenshots()) {
// Re-check bell state for all tiles — the terminal tab may have
// cleared its localStorage entry while we were hidden, and the
// storage event only fires across tabs, not within the same tab.
syncAllBellStates();
// If the dashboard was hidden for more than a few seconds,
// clear ETags and refresh all tiles so the user sees current state.
const away = dashboardHiddenAt ? (Date.now() - dashboardHiddenAt) : 0;