You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(bx): invalidate monitor snapshot on box config changes (#146)
* fix(bx): invalidate monitor snapshot on box config changes
The Bx status monitor polls every 30 seconds and caches each box's full
status (level, latency, last_checked, ConsoleEnabled, etc.) in an
in-memory snapshot. /bx renders from that snapshot.
Side effect: toggling a per-box setting (Remote console, Enabled, …)
in /settings/boxes did not show on /bx until the next 30s tick. User
report described this as "I had it enabled but it was disabled when we
relaunched" (no shell icon visible) plus "I went back to the box and
confirmed the console feature was checked, it was, but I hit save
again anyway and then back to the Bx dashboard and after a couple
more refreshes, it showed up."
Wiring:
- Add EventTypeBoxConfigChanged ("box.config_changed") + Hub.PublishBoxConfigChanged helper.
- HAProxyBoxUpdatePost and HAProxyBoxTogglePost publish the event
immediately after UpdateBox / SetBoxEnabled returns.
- Bx Gear.Start subscribes to "box.config_changed" via deps.EventHub
and calls monitor.PokeBox(serverID) for the affected box.
- New statusMonitor.PokeBox(ctx, boxID) fetches the row, runs a single
probe, and writes the result via m.set — which also broadcasts to
SSE subscribers, so any open /bx tab updates in place without a refresh.
- PokeBox handles the "box was deleted" case by dropping the stale
snapshot entry instead of leaving last-known-good values for a
now-missing box.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* address Copilot review findings on PR #146
- Add statusMonitor.setAndBroadcast that always broadcasts to SSE
subscribers; PokeBox now uses it so a config edit that flips only a
non-level field (ConsoleEnabled, Enabled, Name, …) still pushes to
open /bx tabs. The chatter-suppression in set() is desirable for
the steady-state poll loop but defeats the purpose of an
out-of-band config-change refresh.
- PokeBox now distinguishes transient DB errors from "not found":
on err != nil we log and keep the last-known-good snapshot; only
box == nil drops the cached entry. Avoids poisoning the UI when
SQLite hiccups.
- Gear.Start stores the unsubscribe func returned by Subscribe and
Gear.Stop now calls it before shutting the monitor down. Closes
the events-adapter forwarder goroutine cleanly and stops new
PokeBox calls from reaching a winding-down monitor.
- Subscribe call now references events.EventTypeBoxConfigChanged
(cast to string for the gear.EventPublisher API) instead of a raw
"box.config_changed" literal — keeps publisher and subscriber on
the same constant.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments