feat(watchlist): the DXHunter watchlist as an OpsLog tab

The concept, transplanted: a list of callsigns or prefixes being hunted,
matched against the live spot stream, one card per entry with the spots
underneath and the two questions that matter answered on every line — is this
slot still needed, and what is it worth (the cluster's own NEW badges, read
from the same status index).

The file is DXHunter's own watchlist.json, field for field, ClubLog block
included though phase 2 will fill it — a file that round-trips unchanged is the
whole of 'same format', and a test pins it with a real DXHunter entry. Global
(dataDir), not per profile.

CONTEST is per entry, not the global mode DXHunter has: a contest entry is
judged against the current UTC day — the boundary lives in the query's date
bound, so midnight needs no timer and resets nothing. Normal entries read the
same in-memory worked index the alerts use. Prefix matching is why RI0SP
catches RI0SP/MM, pinned by test.

Notify goes through the existing alert:fired event — the frontend already
toasts and sounds it — throttled to one alert per entry per two minutes,
because a DXpedition lights every skimmer on the planet.

Tab wired like NET Control: opt-in from Tools, persisted, closable. Single
click fills the callsign, double click works the spot — the cluster's own
gesture, kept.
This commit is contained in:
2026-08-29 00:25:40 +02:00
parent 284ee4ba7c
commit e4abcda94f
12 changed files with 991 additions and 3 deletions
+13
View File
@@ -74,6 +74,7 @@ import (
"hamlog/internal/tunergenius"
"hamlog/internal/uls"
"hamlog/internal/ultrabeam"
"hamlog/internal/watchlist"
"hamlog/internal/winkeyer"
wruntime "github.com/wailsapp/wails/v2/pkg/runtime"
@@ -735,6 +736,9 @@ type App struct {
uls *uls.Store // US callsign→county/grid (offline FCC ULS), lazily opened
awardRefs *awardref.Repo
qslTemplates *qslcard.Repo
watchlist *watchlist.Store // Tools → Watchlist (global watchlist.json)
watchAlertMu sync.Mutex // throttles watchlist alerts…
watchAlertAt map[string]time.Time // …per entry
operating *operating.Repo
udp *udp.Manager
udpRepo *udp.Repo
@@ -1385,6 +1389,8 @@ func (a *App) startup(ctx context.Context) {
// POTA: background poller of api.pota.app so cluster spots can be tagged
// when the DX station is currently activating a park. Best-effort.
a.pota = pota.New(func(format string, args ...any) { applog.Printf(format, args...) })
a.watchlist = watchlist.New(filepath.Join(a.dataDir, "watchlist.json"))
a.watchAlertAt = map[string]time.Time{}
go a.pota.Run(a.ctx)
// DX Cluster (multi-server): the spot callback enriches each spot
@@ -1796,6 +1802,9 @@ func (a *App) setSettingGlobal(key, val string) {
}
func (a *App) shutdown(ctx context.Context) {
if a.watchlist != nil {
a.watchlist.Flush() // the save debounce would lose the last edits
}
// If the user managed to skip beforeClose (force kill, OS shutdown,
// crash recovery) we still try the backup here as a best-effort
// safety net. HasBackupToday makes a double-run a no-op.
@@ -9003,6 +9012,10 @@ func (a *App) clusterEventWorker() {
a.detectBandOpening(s)
// Fire any matching alert rules (sound / visual / e-mail).
a.evaluateAlerts(s)
// The watchlist sees the same live stream the alerts do — never the
// SH/DX replay above, which would mark forty stations "just seen" with
// spots from three hours ago.
a.watchSpot(s.DXCall, s.Band, alerts.InferMode(s.Comment, s.FreqHz), s.Country, s.Comment, s.FreqHz)
// Mirror the spot onto the FlexRadio panadapter when enabled. Infer the
// mode (from the comment, else the band plan) so clicking the spot on the
// panadapter tunes AND switches mode — a DX cluster line carries no mode,