From a197d124dc02751b6701af1d3d7bdeac3d1fd829 Mon Sep 17 00:00:00 2001 From: Gregory Salaun Date: Tue, 18 Aug 2026 05:51:34 +0200 Subject: [PATCH 1/9] feat(decodes): an FT decodes tab fed by the inbound UDP link Every FTx decode WSJT-X, JTDX or MSHV puts on the wire, grouped by T/R period. Optional and closable, from Tools -> FT decodes; its open state is remembered, because an operator running digital modes leaves it open for the session rather than consulting and closing it. The period is the point, and what separates this from the cluster list. FT8 is a sequence of fifteen-second slots and a band is read by watching them go by: who called CQ this slot, who answered, what I was sending while they did. A flat list sorted by time loses exactly that, so the list is grouped one section per period, newest first, with the operator's own transmission shown inside the slot it went out in. Three fields had to be carried up from the wire to make it possible: - the decode's OWN timestamp, which the parser read and threw away. It is what assigns a slot: a period's decodes arrive in one burst a second or two after it closes, so arrival time piles a whole period into the next one. Rebuilt to UTC from milliseconds-since-midnight, with the day-boundary case handled - a decode stamped 23:59:58 arriving at 00:00:01 would otherwise be dated a day ahead and sit at the top of the list for the rest of the session. - the decoded line itself. The exchange is what says where a station is in a QSO, and no set of extracted fields reads like "R-09" does. - tx_message and transmitting from Status, which nothing parsed before. Recorded once per message rather than on every Status, which repeats it about once a second for the whole over. Also picked up on the way: is_new, low_confidence, off_air, the operator's own call and grid, and the T/R period itself - better authority on slot length than the mode name, which says nothing about a custom period. The Status tail is read defensively: those fields were appended over successive schema versions and JTDX and MSHV each stop at their own point, so a short packet is normal and keeps whatever parsed. Status flags come from ClusterSpotStatuses, the resolver the cluster list and band map already use, filling the same cache. One verdict per call: "new band" in this panel and plain worked in the cluster two seconds later would be worse than no flag at all. Clicking a call goes through the same handler as a cluster spot, so answering a station is one gesture whether it came off telnet or off the receiver. Filters: CQ only, new-anything only, band, mode, continent, an SNR floor and a free search. The band, mode and continent choices are built from what is actually on the feed - offering 160 m to a station whose receivers are all on 6 m is noise. Decodes are held in the frontend and pruned to a rolling half hour: they are a live view, not data, nothing outside the panel reads them, and a night of FT8 on 20 m would otherwise grow a list no filter can rescue. Arrivals are staged on a 300 ms timer so a period landing as fifty packets costs one status lookup and one render. --- app.go | 38 ++ frontend/src/App.tsx | 147 +++++++ frontend/src/components/DecodesPanel.tsx | 380 +++++++++++++++++++ frontend/src/lib/i18n.tsx | 18 + internal/integrations/udp/decodetime_test.go | 52 +++ internal/integrations/udp/server.go | 69 +++- internal/integrations/udp/wsjt.go | 100 ++++- 7 files changed, 791 insertions(+), 13 deletions(-) create mode 100644 frontend/src/components/DecodesPanel.tsx create mode 100644 internal/integrations/udp/decodetime_test.go diff --git a/app.go b/app.go index b306f5f..7ba3353 100644 --- a/app.go +++ b/app.go @@ -12668,6 +12668,20 @@ func (a *App) consumeUDPEvents() { if a.ctx == nil { continue } + // The operator's own transmit message, from Status. Emitted before the + // switch because a Status can carry BOTH a DX call and a transmit + // message, and the switch below takes only one branch. + if ev.TxMessage != "" { + wruntime.EventsEmit(a.ctx, "udp:tx_message", map[string]any{ + "msg": ev.TxMessage, + "transmitting": ev.Transmitting, + "de_call": ev.DECall, + "mode": ev.Mode, + "freq_hz": ev.FreqHz, + "band": bandForHz(ev.FreqHz), + "at": time.Now().UTC().Format(time.RFC3339), + }) + } switch { case ev.DecodeCall != "": // Remember the grid before anything else: a CQ is the one message that @@ -12675,6 +12689,30 @@ func (a *App) consumeUDPEvents() { if ev.DecodeGrid != "" { a.rememberDecodeGrid(ev.DecodeCall, ev.DecodeGrid, gridcache.SourceDecode) } + // Hand every decode to the UI. Unconditional, and BEFORE the + // panadapter block below, which skips a call it spotted moments ago: + // that de-duplication exists to spare the radio, and applying it here + // would silently drop most of a period from the panel that is meant to + // show the period whole. + at := ev.DecodeAt + if at.IsZero() { + at = time.Now().UTC() // sender gave no timestamp — arrival will do + } + wruntime.EventsEmit(a.ctx, "udp:decode", map[string]any{ + "call": ev.DecodeCall, + "grid": ev.DecodeGrid, + "snr": ev.DecodeSNR, + "freq_hz": ev.DecodeFreqHz, + "dial_hz": ev.DecodeDial, + "band": bandForHz(ev.DecodeFreqHz), + "mode": ev.Mode, + "msg": ev.DecodeMsg, + "cq": ev.DecodeCQ, + "at": at.Format(time.RFC3339), + "tr_period": ev.DecodeTRPeriod, + "off_air": ev.DecodeOffAir, + "source": ev.Source, + }) // A WSJT-X decode (heard station). Render it on the FlexRadio // panadapter when the option is on; green + SNR comment, auto-expiring // after the configured duration. De-duped per call in the Flex backend. diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index abac865..64003a4 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -108,6 +108,7 @@ import { DetailsPanel, type DetailsState } from '@/components/DetailsPanel'; import { SendSpotModal, type RecentSpotQSO } from '@/components/SendSpotModal'; import { WinkeyerPanel, type WKStatus, type WKMacro } from '@/components/WinkeyerPanel'; import { RotorCompass } from '@/components/RotorCompass'; +import { DecodesPanel, type Decode as DecodeRow, type TxMsg as TxMsgRow } from '@/components/DecodesPanel'; import { subscribeRotorHeading, pokeRotorHeading } from '@/lib/rotorHeading'; import { writeUiPref } from '@/lib/uiPref'; import { formatDateTimeUTC } from '@/lib/dateFormat'; @@ -1031,6 +1032,20 @@ export default function App() { setStationTabOpen(false); setActiveTab((t) => (t === 'station' ? 'recent' : t)); } + // FTx decodes — same closable-tab pattern, but its open state is REMEMBERED: + // unlike Statistics, which is consulted and closed, this one is a panel an + // operator running digital modes leaves open for the session. + const [decodesTabOpen, setDecodesTabOpen] = useState(() => localStorage.getItem('opslog.decodesTab') === '1'); + function openDecodesTab() { + setDecodesTabOpen(true); + writeUiPref('opslog.decodesTab', '1'); + setActiveTab('decodes'); + } + function closeDecodesTab() { + setDecodesTabOpen(false); + writeUiPref('opslog.decodesTab', '0'); + setActiveTab((t) => (t === 'decodes' ? 'recent' : t)); + } // Recent QSOs row cap, persisted. With AG Grid's virtual scroller // huge logs render OK once loaded, but a 25k+ logbook still takes a // couple of seconds to round-trip from SQLite at launch. Defaulting @@ -2018,6 +2033,20 @@ export default function App() { // settings dialog closes, which is the only place it changes. const [rowColors, setRowColors] = useState(null); useEffect(() => { GetRowColors().then(setRowColors).catch(() => {}); }, [showSettings]); + // ── FTx decodes from the inbound UDP feed ────────────────────────── + // + // Held in the frontend, like the cluster spots: they are a live view, not + // data, and nothing outside this panel reads them. Pruned to a rolling + // half hour — long enough to hold a whole opening, short enough that a night + // of FT8 on 20 m does not turn the list into something no filter can rescue. + const DECODE_KEEP_MS = 30 * 60 * 1000; + const [decodes, setDecodes] = useState([]); + const [txMsgs, setTxMsgs] = useState([]); + // Staged like the cluster's, so a period arriving as one burst of fifty + // packets costs one status lookup and one render, not fifty of each. + const pendingDecodesRef = useRef([]); + const pendingDecodeTimer = useRef(undefined); + // Rotor quick-turn buttons (Settings → Rotator). Same reload trigger as the // row colours: the settings dialog is the only place they change. const [rotorPresets, setRotorPresets] = useState<{ label: string; azimuth: number }[]>([]); @@ -3010,6 +3039,83 @@ export default function App() { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + // ── FTx decodes ──────────────────────────────────────────────────── + useEffect(() => { + // Resolve the new-entity / new-slot flags into the SAME map the cluster + // fills. One cache, one verdict: a call must not be "new band" in the + // decodes panel and plain worked in the cluster list two seconds later. + const flushDecodes = async () => { + pendingDecodeTimer.current = undefined; + const batch = pendingDecodesRef.current; + pendingDecodesRef.current = []; + if (batch.length === 0) return; + try { + const known = spotStatusRef.current; + const seen = new Set(); + const unknown: { call: string; band: string; mode: string; pota_ref: string; spotter: string }[] = []; + for (const d of batch) { + const k = `${d.call}|${d.band ?? ''}|${(d.mode ?? '').toUpperCase()}`; + if (seen.has(k) || known[k]) continue; + seen.add(k); + unknown.push({ call: d.call, band: d.band ?? '', mode: (d.mode ?? '').toUpperCase(), pota_ref: '', spotter: '' }); + } + if (unknown.length > 0) { + const res = await ClusterSpotStatuses(unknown as any); + setSpotStatus((prev) => { + const next = { ...prev }; + for (const r of res) { + const k = `${r.call}|${r.band ?? ''}|${(r.mode ?? '').toUpperCase()}`; + next[k] = { + status: r.status ?? '', + country: r.country, + continent: (r as any).continent, + worked_call: !!(r as any).worked_call, + worked_slot: !!(r as any).worked_slot, + new_county: !!(r as any).new_county, lotw: !!(r as any).lotw, + grid: (r as any).grid, new_grid: !!(r as any).new_grid, + county: (r as any).county, state: (r as any).state, + new_pota: !!(r as any).new_pota, + new_pfx: !!(r as any).new_pfx, pfx: (r as any).pfx, + }; + } + return next; + }); + } + } catch { /* status unresolved — the decode still shows, just unflagged */ } + setDecodes((arr) => { + const cutoff = Date.now() - DECODE_KEEP_MS; + const next = [...arr, ...batch].filter((d) => Date.parse(d.at) >= cutoff); + return next; + }); + }; + + const unsubDecode = EventsOn('udp:decode', (d: DecodeRow) => { + pendingDecodesRef.current.push(d); + if (pendingDecodeTimer.current === undefined) { + pendingDecodeTimer.current = window.setTimeout(flushDecodes, 300); + } + }); + + // The operator's own transmission. Status repeats it about once a second + // for the whole over, so it is recorded ONCE per message: the panel wants + // "I sent this in that period", not sixty copies of it. + const unsubTx = EventsOn('udp:tx_message', (m: any) => { + if (!m?.transmitting || !String(m?.msg ?? '').trim()) return; + setTxMsgs((arr) => { + const last = arr[arr.length - 1]; + if (last && last.msg === m.msg && Date.parse(m.at) - Date.parse(last.at) < 30_000) return arr; + const cutoff = Date.now() - DECODE_KEEP_MS; + return [...arr, m as TxMsgRow].filter((x) => Date.parse(x.at) >= cutoff); + }); + }); + + return () => { + unsubDecode?.(); unsubTx?.(); + if (pendingDecodeTimer.current !== undefined) window.clearTimeout(pendingDecodeTimer.current); + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + // ── UDP integration events ─────────────────────────────────────────── // Live updates from external apps (WSJT-X / JTDX / MSHV / DXHunter…). // We push the broadcast DX call into the entry field and auto-log any @@ -4173,6 +4279,7 @@ export default function App() { { type: 'item', label: t('tools.qslManager'), action: 'tools.qslmanager' }, { type: 'item', label: t('stats.tab'), action: 'tools.stats' }, { type: 'item', label: t('station.title'), action: 'tools.station' }, + { type: 'item', label: t('dec.tab'), action: 'tools.decodes' }, { type: 'item', label: t('tools.qslDesigner'), action: 'tools.qsldesigner' }, { type: 'separator' }, { type: 'item', label: (wkEnabled ? '✓ ' : '') + t('tools.winkeyer'), action: 'tools.winkeyer' }, @@ -4222,6 +4329,7 @@ export default function App() { case 'tools.qslmanager': setQslTabOpen(true); setActiveTab('qsl'); break; case 'tools.stats': setStatsTabOpen(true); setActiveTab('stats'); break; case 'tools.station': setStationTabOpen(true); setActiveTab('station'); break; + case 'tools.decodes': openDecodesTab(); break; case 'tools.qsldesigner': setQslDesignerOpen(true); break; case 'tools.winkeyer': wkSetEnabled(!wkEnabled); break; case 'tools.dvk': setDvkEnabled((v) => !v); break; @@ -6596,6 +6704,24 @@ export default function App() { )} + {decodesTabOpen && ( + + {t('dec.tab')} + {decodes.length > 0 && ( + {decodes.length} + )} + { e.stopPropagation(); }} + onClick={(e) => { e.stopPropagation(); closeDecodesTab(); }} + > + + + + )} {stationTabOpen && ( {t('station.title')} @@ -7045,6 +7171,27 @@ export default function App() { )} + {decodesTabOpen && ( + + handleSpotClick({ + dx_call: d.call, + freq_hz: d.freq_hz, + freq_khz: d.freq_hz / 1000, + band: d.band, + comment: d.mode, + spotter: '', + } as any)} + /> + + )} + {stationTabOpen && ( ; + onCall: (d: Decode) => void; + myCall?: string; +} + +// DEFAULT_TR is the slot length assumed when the sender never told us its T/R +// period. Fifteen seconds is FT8, which is the overwhelming majority of what +// arrives here; a wrong guess only mis-groups, it never loses a decode. +const DEFAULT_TR = 15; + +// Status → the pill's look. The vocabulary is the cluster's, deliberately: the +// same fact must not be amber in one panel and green in the next. +const STATUS_STYLE: Record = { + 'new': 'bg-success text-success-foreground', + 'new-band': 'bg-warning text-warning-foreground', + 'new-mode': 'bg-info text-info-foreground', + 'new-slot': 'bg-caution text-caution-foreground', + 'new-call': 'bg-muted text-muted-foreground', +}; + +const STATUS_LABEL: Record = { + 'new': 'dec.stNew', + 'new-band': 'dec.stBand', + 'new-mode': 'dec.stMode', + 'new-slot': 'dec.stSlot', + 'new-call': 'dec.stCall', +}; + +// periodStart floors a decode's own timestamp to its slot. Its OWN timestamp, +// not arrival: a period's decodes reach us in one burst a second or two after +// the slot closes, so arrival time would pile a whole period into the next one. +function periodStart(at: string, tr: number): number { + const ms = Date.parse(at); + if (!Number.isFinite(ms)) return 0; + const s = Math.floor(ms / 1000); + const p = tr > 0 ? tr : DEFAULT_TR; + return Math.floor(s / p) * p; +} + +const hhmmss = (epochSec: number) => + new Date(epochSec * 1000).toISOString().slice(11, 19); + +// snrTone colours the report by readability rather than by a gradient: an +// operator scanning a period wants "workable" to jump out, and -24 dB is not +// three shades worse than -6, it is a different decision. +function snrTone(snr: number): string { + if (snr >= -5) return 'text-success'; + if (snr >= -15) return 'text-foreground'; + return 'text-muted-foreground'; +} + +export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Props) { + const { t } = useI18n(); + const [cqOnly, setCqOnly] = useState(false); + const [newOnly, setNewOnly] = useState(false); + const [bandSel, setBandSel] = useState(''); + const [modeSel, setModeSel] = useState(''); + const [contSel, setContSel] = useState(''); + const [minSnr, setMinSnr] = useState(''); + const [search, setSearch] = useState(''); + + const statusOf = (d: Decode): StatusEntry | undefined => + spotStatus[`${d.call}|${d.band ?? ''}|${(d.mode ?? '').toUpperCase()}`]; + + // The band / mode / continent choices are built from what is actually on the + // feed, not from a fixed list: a selector offering 160 m to an operator whose + // receivers are all on 6 m is noise. + const { bands, modes, conts } = useMemo(() => { + const b = new Set(), m = new Set(), c = new Set(); + for (const d of decodes) { + if (d.band) b.add(d.band); + if (d.mode) m.add(d.mode); + const ct = statusOf(d)?.continent; + if (ct) c.add(ct); + } + return { bands: [...b].sort(), modes: [...m].sort(), conts: [...c].sort() }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [decodes, spotStatus]); + + const isNewSomething = (e: StatusEntry | undefined): boolean => + !!e && ((!!e.status && e.status !== 'worked') || !!e.new_county || !!e.new_pota || !!e.new_pfx || !!e.new_grid); + + const filtered = useMemo(() => { + const q = search.trim().toUpperCase(); + const floor = minSnr.trim() === '' ? null : parseInt(minSnr, 10); + return decodes.filter((d) => { + if (cqOnly && !d.cq) return false; + if (bandSel && d.band !== bandSel) return false; + if (modeSel && d.mode !== modeSel) return false; + if (floor != null && Number.isFinite(floor) && d.snr < floor) return false; + const e = statusOf(d); + if (newOnly && !isNewSomething(e)) return false; + if (contSel && e?.continent !== contSel) return false; + if (q && !(d.call.includes(q) || (d.grid ?? '').toUpperCase().includes(q) || (d.msg ?? '').toUpperCase().includes(q))) return false; + return true; + }); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [decodes, spotStatus, cqOnly, newOnly, bandSel, modeSel, contSel, minSnr, search]); + + // Group into periods, newest first, and drop the operator's transmissions into + // the slot they went out in. + const groups = useMemo(() => { + const by = new Map(); + for (const d of filtered) { + const k = periodStart(d.at, d.tr_period ?? DEFAULT_TR); + let g = by.get(k); + if (!g) { g = { decodes: [], tx: [] }; by.set(k, g); } + g.decodes.push(d); + } + for (const m of txMsgs) { + const k = periodStart(m.at, DEFAULT_TR); + // Only into a period the list is actually showing — a transmission alone + // in an empty slot would be a section with nothing to read. + const g = by.get(k); + if (g) g.tx.push(m); + } + return [...by.entries()] + .sort((a, b) => b[0] - a[0]) + .map(([start, g]) => ({ + start, + tx: g.tx, + // Strongest first inside a period: the eye should land on what is + // workable, and time within a slot means nothing — they were all + // transmitting simultaneously. + decodes: g.decodes.sort((x, y) => y.snr - x.snr), + })); + }, [filtered, txMsgs]); + + const resetFilters = () => { + setCqOnly(false); setNewOnly(false); setBandSel(''); setModeSel(''); + setContSel(''); setMinSnr(''); setSearch(''); + }; + const anyFilter = cqOnly || newOnly || !!bandSel || !!modeSel || !!contSel || !!minSnr || !!search.trim(); + + const sel = 'h-7 rounded-md border border-border bg-background px-2 text-xs'; + const chip = (on: boolean) => cn( + 'h-7 px-2.5 rounded-full border text-xs font-medium transition-colors', + on ? 'border-primary bg-primary text-primary-foreground' : 'border-border text-muted-foreground hover:bg-muted', + ); + + return ( +
+ {/* ── Filter bar ─────────────────────────────────────────────── */} +
+ + + {t('dec.title')} + + + + + + + + + + + +
+ + setSearch(e.target.value)} + placeholder={t('dec.searchPh')} + className="h-7 w-44 rounded-md border border-border bg-background pl-7 pr-2 text-xs" + /> +
+ + {anyFilter && ( + + )} + + + + {t('dec.count', { shown: filtered.length, total: decodes.length })} + +
+ + {/* ── Periods ────────────────────────────────────────────────── */} +
+ {groups.length === 0 && ( +
+

+ {decodes.length === 0 ? t('dec.empty') : t('dec.emptyFiltered')} +

+
+ )} + + {groups.map((g, gi) => ( +
+ {/* Period header — sticky so the slot you are reading is always named. */} +
+ + {hhmmss(g.start)} + + + {t('dec.periodCount', { n: g.decodes.length })} + + {gi === 0 && ( + + + {t('dec.live')} + + )} +
+ + {/* The operator's own transmission, at the top of its slot: it is what + the stations below were answering (or ignoring). */} + {g.tx.map((m, i) => ( +
+ + + {t('dec.tx')} + + {m.msg} + {m.band && {m.band}} +
+ ))} + + {g.decodes.map((d, i) => { + const e = statusOf(d); + const st = e?.status && e.status !== 'worked' ? e.status : ''; + const markers = activeMarkers(e as any); + const mine = myCall && d.call === myCall.toUpperCase(); + return ( + + ); + })} +
+ ))} +
+
+ ); +} diff --git a/frontend/src/lib/i18n.tsx b/frontend/src/lib/i18n.tsx index 062b7b6..9a37af5 100644 --- a/frontend/src/lib/i18n.tsx +++ b/frontend/src/lib/i18n.tsx @@ -124,6 +124,15 @@ const en: Dict = { 'mx.tipCallConf': 'This callsign confirmed', 'mx.tipCallWork': 'This callsign worked (not confirmed)', 'mx.tipDxConf': 'Entity confirmed (other callsign)', 'mx.tipDxWork': 'Entity worked (other callsign)', 'mx.tipNone': 'Never worked', 'mx.tipClick': 'click to list the QSOs', + // FTx decodes panel (Tools -> FT decodes) + 'dec.tab': 'FT decodes', 'dec.title': 'Decodes', 'dec.cqOnly': 'CQ only', 'dec.newOnly': 'New only', + 'dec.allBands': 'All bands', 'dec.allModes': 'All modes', 'dec.allConts': 'All continents', + 'dec.minSnrTitle': 'Hide anything weaker than this SNR', 'dec.searchPh': 'Call, grid or message', + 'dec.clearFilters': 'Clear', 'dec.live': 'live', 'dec.tx': 'TX', + 'dec.count': '{shown} of {total}', 'dec.periodCount': '{n} decodes', 'dec.callTitle': 'Call {call} — fills the entry and tunes the rig', + 'dec.stNew': 'NEW', 'dec.stBand': 'BAND', 'dec.stMode': 'MODE', 'dec.stSlot': 'SLOT', 'dec.stCall': 'CALL', + 'dec.empty': 'Nothing decoded yet. Decodes arrive from WSJT-X, JTDX or MSHV over the inbound UDP link (Settings -> UDP).', + 'dec.emptyFiltered': 'No decode matches these filters.', 'sec.email': 'E-mail (SMTP)', 'sec.lookup': 'Callsign Lookup', 'sec.bands': 'Bands', 'sec.modes': 'Modes & default RST', 'sec.cluster': 'DX Cluster', 'sec.udp': 'Connections', 'sec.database': 'Database', 'sec.autostart': 'Autostart', 'sec.backup': 'Database backup', 'sec.uscounties': 'US Counties', @@ -580,6 +589,15 @@ const fr: Dict = { 'mx.tipCallConf': 'Cet indicatif est confirmé', 'mx.tipCallWork': 'Cet indicatif est contacté (non confirmé)', 'mx.tipDxConf': 'Entité confirmée (autre indicatif)', 'mx.tipDxWork': 'Entité contactée (autre indicatif)', 'mx.tipNone': 'Jamais contacté', 'mx.tipClick': 'cliquer pour lister les QSO', + // Panneau des decodes FTx (Outils -> Decodes FT) + 'dec.tab': 'Decodes FT', 'dec.title': 'Decodes', 'dec.cqOnly': 'CQ seulement', 'dec.newOnly': 'Nouveaux seulement', + 'dec.allBands': 'Toutes bandes', 'dec.allModes': 'Tous modes', 'dec.allConts': 'Tous continents', + 'dec.minSnrTitle': 'Masquer tout ce qui est plus faible que ce rapport', 'dec.searchPh': 'Indicatif, locator ou message', + 'dec.clearFilters': 'Effacer', 'dec.live': 'en direct', 'dec.tx': 'TX', + 'dec.count': '{shown} sur {total}', 'dec.periodCount': '{n} decodes', 'dec.callTitle': 'Appeler {call} — remplit la saisie et accorde le poste', + 'dec.stNew': 'NOUV', 'dec.stBand': 'BANDE', 'dec.stMode': 'MODE', 'dec.stSlot': 'SLOT', 'dec.stCall': 'IND', + 'dec.empty': "Aucun decode pour l'instant. Ils arrivent de WSJT-X, JTDX ou MSHV par le lien UDP entrant (Reglages -> UDP).", + 'dec.emptyFiltered': 'Aucun decode ne correspond a ces filtres.', 'sec.email': 'E-mail (SMTP)', 'sec.lookup': "Recherche d'indicatif", 'sec.bands': 'Bandes', 'sec.modes': 'Modes & RST par défaut', 'sec.cluster': 'DX Cluster', 'sec.udp': 'Connexions', 'sec.database': 'Base de données', 'sec.autostart': 'Démarrage auto', 'sec.backup': 'Sauvegarde base', 'sec.uscounties': 'Comtés US', diff --git a/internal/integrations/udp/decodetime_test.go b/internal/integrations/udp/decodetime_test.go new file mode 100644 index 0000000..a05014e --- /dev/null +++ b/internal/integrations/udp/decodetime_test.go @@ -0,0 +1,52 @@ +package udp + +import ( + "testing" + "time" +) + +// WSJT-X stamps a decode with a time of DAY and no date, so the date has to come +// from our own clock — and around midnight the two disagree. A decode stamped +// 23:59:58 that reaches us at 00:00:01 would be dated the NEW day, putting it +// almost 24 hours in the future: it would sort to the top of the decodes panel +// and stay there for the rest of the session, and its period would never line up +// with the ones around it. +func TestDecodeTimeCrossesMidnight(t *testing.T) { + const ms = 1000 + sec := func(h, m, s int) uint32 { return uint32((h*3600 + m*60 + s) * ms) } + + got := decodeTime(sec(23, 59, 58)) + now := time.Now().UTC() + // Whatever the clock says, a decode must never land in the future beyond the + // slack of a single period, nor more than a day in the past. + if d := got.Sub(now); d > time.Minute { + t.Errorf("decode at 23:59:58 resolved to %s, %s in the FUTURE", got.Format(time.RFC3339), d) + } + if d := now.Sub(got); d > 24*time.Hour { + t.Errorf("decode at 23:59:58 resolved to %s, %s in the past", got.Format(time.RFC3339), d) + } + + // And the ordinary case: a stamp close to now stays on today. + near := decodeTime(sec(now.Hour(), now.Minute(), now.Second())) + if diff := near.Sub(now); diff > 2*time.Second || diff < -2*time.Second { + t.Errorf("a decode stamped at the current time resolved to %s (%s off)", near.Format(time.RFC3339), diff) + } +} + +// The whole point of the timestamp is grouping, so two decodes from the same +// fifteen-second slot must floor to the same period however far apart in the +// slot they were heard. +func TestDecodesInOneSlotShareAPeriod(t *testing.T) { + const ms = 1000 + at := func(h, m, s int) time.Time { return decodeTime(uint32((h*3600 + m*60 + s) * ms)) } + floor := func(x time.Time) int64 { return x.Unix() / 15 * 15 } + + a, b := at(12, 30, 0), at(12, 30, 14) + if floor(a) != floor(b) { + t.Errorf("12:30:00 and 12:30:14 fell in different periods (%d vs %d)", floor(a), floor(b)) + } + c := at(12, 30, 15) + if floor(a) == floor(c) { + t.Error("12:30:00 and 12:30:15 shared a period — the slot boundary was not honoured") + } +} diff --git a/internal/integrations/udp/server.go b/internal/integrations/udp/server.go index cdd38ca..fbdfa66 100644 --- a/internal/integrations/udp/server.go +++ b/internal/integrations/udp/server.go @@ -77,6 +77,26 @@ func reusingListenConfig() net.ListenConfig { } } +// decodeTime turns WSJT-X's milliseconds-since-midnight into a UTC instant. +// +// The sender gives a time of DAY with no date, so the date comes from our own +// clock — and the two can straddle midnight: a decode stamped 23:59:58 that +// reaches us at 00:00:01 would otherwise be dated a day late and sort to the top +// of the list for the rest of the session. More than half a day apart is read as +// the wrong side of midnight and moved. +func decodeTime(msSinceMidnight uint32) time.Time { + now := time.Now().UTC() + midnight := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.UTC) + at := midnight.Add(time.Duration(msSinceMidnight) * time.Millisecond) + switch { + case at.Sub(now) > 12*time.Hour: + at = at.AddDate(0, 0, -1) // stamped late yesterday, arrived after midnight + case now.Sub(at) > 12*time.Hour: + at = at.AddDate(0, 0, 1) // stamped just after midnight, our clock still on the old day + } + return at +} + // Event is what a Server emits to its consumer for every parsed packet. // At most one of the fields is populated per event. type Event struct { @@ -96,6 +116,23 @@ type Event struct { DecodeFreqHz int64 // RF frequency (dial + audio offset) DecodeSNR int // reported SNR (dB) DecodeCQ bool // the decode was a CQ + DecodeMsg string // the decoded line as printed ("CQ K1ABC FN42") + // DecodeAt is the decode's own UTC timestamp, rebuilt from the sender's + // milliseconds-since-midnight. It is what groups decodes into T/R periods: + // a period's worth arrives in one burst, so arrival time would put them all + // in whichever slot the burst happened to land in. + DecodeAt time.Time + // DecodeTRPeriod is the transmit/receive period in seconds, from the last + // Status of the same program (15 = FT8). 0 when the sender never said. + DecodeTRPeriod int + DecodeDial int64 // dial frequency the decode was heard on, for the band + DecodeOffAir bool // decoded from a file rather than off the air + + // TxMessage is what the operator's digital app is sending, with Transmitting + // true while the carrier is actually up. From Status, so ~1 Hz. + TxMessage string + Transmitting bool + DECall string // the operator's own call, as the digital app knows it // ClearCall is set when a WSJT/JTDX/MSHV Status message reports an EMPTY DX // Call after previously reporting one — i.e. the operator cleared the call in @@ -127,7 +164,10 @@ type Server struct { // 50.400 panadapter. WSJT-X requires --rig-name for a second instance, so the // id is distinct whenever there is more than one. dialHz map[string]int64 - lastDX string // WSJT: last non-empty DX Call seen, to detect a clear + // trPeriod is the T/R period (seconds) from each program's last Status — + // what tells a decode which slot it belongs to. + trPeriod map[string]int + lastDX string // WSJT: last non-empty DX Call seen, to detect a clear // badPkts counts datagrams this listener could not parse, so the diagnostic // dump below stays bounded. A misconfigured port is not a one-off: the @@ -359,11 +399,28 @@ func (s *Server) handle(pkt []byte, remote *net.UDPAddr) { s.dialHz = map[string]int64{} } s.dialHz[w.ProgramID] = w.FreqHz + // The T/R period travels with Status, and a decode has to be told + // which slot it belongs to — so it is remembered per program the + // same way the dial is. + if w.TRPeriod > 0 { + if s.trPeriod == nil { + s.trPeriod = map[string]int{} + } + s.trPeriod[w.ProgramID] = w.TRPeriod + } s.mu.Unlock() } + if !w.IsDecode && (w.TxMessage != "" || w.DECall != "") { + // What the operator is sending. Carried on every Status, so the + // consumer sees it change as the QSO progresses. + ev.TxMessage = w.TxMessage + ev.Transmitting = w.Transmitting + ev.DECall = w.DECall + } if w.IsDecode { s.mu.Lock() dial := s.dialHz[w.ProgramID] + tr := s.trPeriod[w.ProgramID] s.mu.Unlock() if dial <= 0 { // No Status from THIS instance yet. Guessing with another @@ -377,6 +434,11 @@ func (s *Server) handle(pkt []byte, remote *net.UDPAddr) { ev.DecodeSNR = w.SNR ev.DecodeCQ = w.IsCQ ev.Mode = w.Mode + ev.DecodeMsg = w.DecodeMsg + ev.DecodeAt = decodeTime(w.DecodeMsSinceMidnight) + ev.DecodeTRPeriod = tr + ev.DecodeDial = dial + ev.DecodeOffAir = w.OffAir break } // Only a logged QSO is worth a line — WSJT-X/MSHV send a Status packet @@ -501,7 +563,10 @@ func (s *Server) handle(pkt []byte, remote *net.UDPAddr) { // Empty events are useless; skip — EXCEPT a clear signal, which is meant to be // empty (the DX Call was cleared in the digital app), and a tune-only // request (freq with no callsign). - if ev.DXCall == "" && ev.LoggedADIF == "" && ev.DecodeCall == "" && !ev.ClearCall && ev.TuneFreqHz == 0 { + // TxMessage rides on Status, which also carries the DX call — but a Status + // with an empty DX call and a live transmit message (calling CQ) used to be + // dropped here, and that is exactly the message the decodes panel needs. + if ev.DXCall == "" && ev.LoggedADIF == "" && ev.DecodeCall == "" && ev.TxMessage == "" && !ev.ClearCall && ev.TuneFreqHz == 0 { return } select { diff --git a/internal/integrations/udp/wsjt.go b/internal/integrations/udp/wsjt.go index beda735..b4069dc 100644 --- a/internal/integrations/udp/wsjt.go +++ b/internal/integrations/udp/wsjt.go @@ -55,6 +55,34 @@ type WSJTEvent struct { DeltaFreqHz int64 // audio offset within the passband (Hz) SNR int // reported signal-to-noise (dB) IsCQ bool // the decode was a CQ call + // DecodeMsg is the decoded text as WSJT-X printed it ("CQ K1ABC FN42", + // "F4BPO K1ABC -07"). Kept whole rather than only its parsed pieces: the + // exchange is what tells an operator where a station is in a QSO, and no set + // of extracted fields says "R-09" the way the line itself does. + DecodeMsg string + // DecodeMsSinceMidnight is the decode's own timestamp, in milliseconds since + // 00:00 UTC, as the sender reported it. It is what groups decodes into T/R + // PERIODS — arrival time cannot, since a whole period's decodes land in one + // burst and a slow link shifts the lot into the next slot. + DecodeMsSinceMidnight uint32 + DecodeIsNew bool // sender's "is_new": first time this line was decoded + LowConfidence bool // sender is unsure of the decode + OffAir bool // decoded from a file, not off the air + + // ---- Status extras ---- + + // TxMessage is what the operator is sending right now ("CQ F4BPO JN18"), + // with Transmitting saying whether the carrier is actually up. Both come + // from Status, so they arrive about once a second. + TxMessage string + Transmitting bool + DECall string // the operator's own callsign, as the digital app knows it + DEGrid string // and their square + // TRPeriod is the transmit/receive period in seconds (15 for FT8, 7 or 8 for + // FT4 depending on the sender's rounding). The authority on how long a slot + // is — better than inferring it from the mode name, which says nothing about + // a custom period. + TRPeriod int } // maxFwdHeader bounds how far into a packet the WSJT-X magic may sit behind a @@ -166,40 +194,80 @@ func ParseWSJT(pkt []byte) (WSJTEvent, bool, error) { return WSJTEvent{}, false, err } ev.DXCall = strings.ToUpper(strings.TrimSpace(dxCall)) - // Skip report, tx_mode (QUtf8), tx_enabled (bool), transmitting, - // decoding, rx_df (qint32), tx_df (qint32), de_call (QUtf8), - // de_grid (QUtf8) → then dx_grid. + // report, tx_mode → skipped. for _, name := range []string{"report", "tx_mode"} { if _, err := readQString(r); err != nil { return ev, true, fmt.Errorf("read %s: %w", name, err) } } - // 3 booleans (each 1 byte) - for i := 0; i < 3; i++ { - var b uint8 - if err := binary.Read(r, binary.BigEndian, &b); err != nil { + // tx_enabled, transmitting, decoding (1 byte each). The middle one is + // worth keeping: it says the carrier is up, which is what turns TxMessage + // from "what I would send" into "what is going out". + var txEnabled, transmitting, decoding uint8 + for _, p := range []*uint8{&txEnabled, &transmitting, &decoding} { + if err := binary.Read(r, binary.BigEndian, p); err != nil { return ev, true, err } } - // 2 int32 + ev.Transmitting = transmitting != 0 + // rx_df, tx_df var i32 int32 for i := 0; i < 2; i++ { if err := binary.Read(r, binary.BigEndian, &i32); err != nil { return ev, true, err } } - // de_call, de_grid, dx_grid - if _, err := readQString(r); err != nil { + deCall, err := readQString(r) + if err != nil { return ev, true, err } - if _, err := readQString(r); err != nil { + ev.DECall = strings.ToUpper(strings.TrimSpace(deCall)) + deGrid, err := readQString(r) + if err != nil { return ev, true, err } + ev.DEGrid = strings.ToUpper(strings.TrimSpace(deGrid)) dxGrid, err := readQString(r) if err != nil { return ev, true, err } ev.DXGrid = strings.ToUpper(strings.TrimSpace(dxGrid)) + + // Everything past here was APPENDED to the schema over successive + // releases, and JTDX and MSHV each stop at their own point. A short + // packet is therefore normal, not an error: read as far as the sender + // went and keep what we got. That is why the tail below swallows its + // errors instead of reporting them — the fields already parsed are good. + var b uint8 + if binary.Read(r, binary.BigEndian, &b) != nil { // tx_watchdog + return ev, true, nil + } + if _, err := readQString(r); err != nil { // sub_mode + return ev, true, nil + } + if binary.Read(r, binary.BigEndian, &b) != nil { // fast_mode + return ev, true, nil + } + if binary.Read(r, binary.BigEndian, &b) != nil { // special_operation_mode + return ev, true, nil + } + var u32 uint32 + if binary.Read(r, binary.BigEndian, &u32) != nil { // frequency_tolerance + return ev, true, nil + } + if binary.Read(r, binary.BigEndian, &u32) != nil { // tr_period (seconds) + return ev, true, nil + } + // 0xFFFFFFFF is WSJT-X's "not applicable" for the quint32 fields. + if u32 > 0 && u32 < 3600 { + ev.TRPeriod = int(u32) + } + if _, err := readQString(r); err != nil { // configuration_name + return ev, true, nil + } + if txMsg, err := readQString(r); err == nil { + ev.TxMessage = strings.TrimSpace(txMsg) + } return ev, true, nil case wsjtMsgDecode: @@ -217,6 +285,7 @@ func ParseWSJT(pkt []byte) (WSJTEvent, bool, error) { if err := binary.Read(r, binary.BigEndian, &b); err != nil { // is_new return WSJTEvent{}, false, err } + ev.DecodeIsNew = b != 0 var t32, df uint32 var snr int32 if err := binary.Read(r, binary.BigEndian, &t32); err != nil { // time @@ -240,6 +309,11 @@ func ParseWSJT(pkt []byte) (WSJTEvent, bool, error) { if err != nil { return WSJTEvent{}, false, err } + // low_confidence and off_air were appended later; absent on older senders. + var lowConf, offAir uint8 + _ = binary.Read(r, binary.BigEndian, &lowConf) + _ = binary.Read(r, binary.BigEndian, &offAir) + call, isCQ, grid := wsjtSender(msg) if call == "" { return WSJTEvent{}, false, nil // free-text / telemetry / unparseable → ignore @@ -251,6 +325,10 @@ func ParseWSJT(pkt []byte) (WSJTEvent, bool, error) { ev.DeltaFreqHz = int64(df) ev.SNR = int(snr) ev.Mode = strings.ToUpper(strings.TrimSpace(mode)) + ev.DecodeMsg = strings.TrimSpace(msg) + ev.DecodeMsSinceMidnight = t32 + ev.LowConfidence = lowConf != 0 + ev.OffAir = offAir != 0 return ev, true, nil case wsjtMsgLoggedADIF: From 4f77d51ffe7ac542d960f25726d8c7591237f5cc Mon Sep 17 00:00:00 2001 From: Gregory Salaun Date: Tue, 18 Aug 2026 06:04:28 +0200 Subject: [PATCH 2/9] refactor(decodes): real columns, spelled-out flags, bigger type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First pass on the panel from operating feedback. Columns are a grid template shared by the header row and every data row, so the two cannot drift and the eye has a rail to follow. It is capped at 1500 px and centred: free-flowing, a 2500 px window put the country a foot from the callsign it belonged to and left a hole in the middle of every line. "New" gets a COLUMN. It was only a coloured edge before, which says something is special without saying what — and every one of these is a reason to break off what you are doing and call. The entity verdict is a solid badge, the orthogonal ones (park, grid, prefix, county) are outlined in the colours markerColour already gives the cluster list and the band map, so a new park is the same green in all three. Applied inline because those are categorical --chart-* custom properties, which the theme does not expose as Tailwind colour utilities: written as border-chart-7 the badge would simply have had no colour. Band and mode selectors now appear only when the feed actually carries more than one of each. One MSHV is one band and one mode, so for most operators they were furniture; they show up the day a second instance puts a second band on the link, which is the only day they mean anything. Same rule for continent, and a receiver count when more than one instance is feeding. Added a LoTW-only filter, and raised the type throughout (call and message to 14 px, secondary to 12 px, badges to 11 px) with more room per row. The decode payload now carries the sending application's own id. It tells two receivers apart on one multicast group — and it is the address a WSJT-X Reply message would have to go back to, so it is carried now rather than requiring another trip through the parser later. --- app.go | 1 + frontend/src/components/DecodesPanel.tsx | 338 ++++++++++++++--------- frontend/src/lib/i18n.tsx | 6 + internal/integrations/udp/server.go | 7 + 4 files changed, 215 insertions(+), 137 deletions(-) diff --git a/app.go b/app.go index 7ba3353..924ccb7 100644 --- a/app.go +++ b/app.go @@ -12712,6 +12712,7 @@ func (a *App) consumeUDPEvents() { "tr_period": ev.DecodeTRPeriod, "off_air": ev.DecodeOffAir, "source": ev.Source, + "instance": ev.ProgramID, }) // A WSJT-X decode (heard station). Render it on the FlexRadio // panadapter when the option is on; green + SNR comment, auto-expiring diff --git a/frontend/src/components/DecodesPanel.tsx b/frontend/src/components/DecodesPanel.tsx index 2f50ae5..d2319f5 100644 --- a/frontend/src/components/DecodesPanel.tsx +++ b/frontend/src/components/DecodesPanel.tsx @@ -16,7 +16,7 @@ import { useMemo, useState } from 'react'; import { Radio, Search, X, Signal, ArrowUpRight } from 'lucide-react'; import { cn } from '@/lib/utils'; import { useI18n } from '@/lib/i18n'; -import { activeMarkers, markerColour } from '@/lib/spotMarkers'; +import { markerColour, type SpotMarkerKey } from '@/lib/spotMarkers'; export type Decode = { call: string; @@ -32,6 +32,7 @@ export type Decode = { tr_period?: number; off_air?: boolean; source?: string; + instance?: string; }; export type TxMsg = { @@ -69,23 +70,43 @@ interface Props { // arrives here; a wrong guess only mis-groups, it never loses a decode. const DEFAULT_TR = 15; -// Status → the pill's look. The vocabulary is the cluster's, deliberately: the -// same fact must not be amber in one panel and green in the next. -const STATUS_STYLE: Record = { - 'new': 'bg-success text-success-foreground', - 'new-band': 'bg-warning text-warning-foreground', - 'new-mode': 'bg-info text-info-foreground', - 'new-slot': 'bg-caution text-caution-foreground', - 'new-call': 'bg-muted text-muted-foreground', +// ROW is the column template, shared by the header and every row so the two can +// never drift. Fixed widths for the short fields, one flexible column for the +// message — and a hard cap on the whole grid, because on a 2500 px screen a +// free-flowing row puts the country a foot away from the callsign it belongs to +// and the eye has to travel the gap on every line. +const ROW = 'grid grid-cols-[3px_112px_56px_60px_1fr_260px_170px_28px] gap-x-3 items-center'; +const ROW_MAX = 'max-w-[1500px]'; + +// The "new" badges. Every one of these is a REASON TO CALL, which is why they +// get a column of their own rather than a coloured edge: a stripe says something +// is special, a badge says what, and the operator is deciding whether to break +// off what they are doing. +// +// Colours match the cluster list and the band map — the same fact must not be +// amber in one panel and green in the next. +const ENTITY_BADGE: Record = { + 'new': { label: 'dec.stNew', cls: 'bg-success text-success-foreground' }, + 'new-band': { label: 'dec.stBand', cls: 'bg-warning text-warning-foreground' }, + 'new-mode': { label: 'dec.stMode', cls: 'bg-info text-info-foreground' }, + 'new-slot': { label: 'dec.stSlot', cls: 'bg-caution text-caution-foreground' }, + 'new-call': { label: 'dec.stCall', cls: 'bg-muted text-muted-foreground' }, }; -const STATUS_LABEL: Record = { - 'new': 'dec.stNew', - 'new-band': 'dec.stBand', - 'new-mode': 'dec.stMode', - 'new-slot': 'dec.stSlot', - 'new-call': 'dec.stCall', -}; +// The orthogonal ones: a station already worked for its entity can still be a +// new grid, a new prefix or a park never logged. +// +// The colour comes from markerColour, the table the cluster list and the band +// map read — so a new park is the same green in all three. Applied inline +// because those are categorical --chart-* variables, which the theme exposes as +// CSS custom properties and not as Tailwind colour utilities; every other place +// that paints with them does the same. +const EXTRA_BADGES: { key: keyof StatusEntry; marker: SpotMarkerKey; label: string }[] = [ + { key: 'new_pota', marker: 'new_pota', label: 'dec.bgPota' }, + { key: 'new_grid', marker: 'new_grid', label: 'dec.bgGrid' }, + { key: 'new_pfx', marker: 'new_pfx', label: 'dec.bgPfx' }, + { key: 'new_county', marker: 'new_county', label: 'dec.bgCounty' }, +]; // periodStart floors a decode's own timestamp to its slot. Its OWN timestamp, // not arrival: a period's decodes reach us in one burst a second or two after @@ -101,19 +122,20 @@ function periodStart(at: string, tr: number): number { const hhmmss = (epochSec: number) => new Date(epochSec * 1000).toISOString().slice(11, 19); -// snrTone colours the report by readability rather than by a gradient: an +// snrTone colours the report by readability rather than as a gradient: an // operator scanning a period wants "workable" to jump out, and -24 dB is not // three shades worse than -6, it is a different decision. function snrTone(snr: number): string { if (snr >= -5) return 'text-success'; if (snr >= -15) return 'text-foreground'; - return 'text-muted-foreground'; + return 'text-muted-foreground/70'; } export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Props) { const { t } = useI18n(); const [cqOnly, setCqOnly] = useState(false); const [newOnly, setNewOnly] = useState(false); + const [lotwOnly, setLotwOnly] = useState(false); const [bandSel, setBandSel] = useState(''); const [modeSel, setModeSel] = useState(''); const [contSel, setContSel] = useState(''); @@ -123,18 +145,21 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr const statusOf = (d: Decode): StatusEntry | undefined => spotStatus[`${d.call}|${d.band ?? ''}|${(d.mode ?? '').toUpperCase()}`]; - // The band / mode / continent choices are built from what is actually on the - // feed, not from a fixed list: a selector offering 160 m to an operator whose - // receivers are all on 6 m is noise. - const { bands, modes, conts } = useMemo(() => { - const b = new Set(), m = new Set(), c = new Set(); + // The choices are built from what is actually on the feed, and a selector with + // nothing to choose is HIDDEN. One MSHV is one band and one mode, so those two + // dropdowns were pure furniture for most operators; they appear the day a + // second instance puts a second band on the link, which is the only day they + // mean anything. + const { bands, modes, conts, instances } = useMemo(() => { + const b = new Set(), m = new Set(), c = new Set(), i = new Set(); for (const d of decodes) { if (d.band) b.add(d.band); if (d.mode) m.add(d.mode); + if (d.instance) i.add(d.instance); const ct = statusOf(d)?.continent; if (ct) c.add(ct); } - return { bands: [...b].sort(), modes: [...m].sort(), conts: [...c].sort() }; + return { bands: [...b].sort(), modes: [...m].sort(), conts: [...c].sort(), instances: [...i].sort() }; // eslint-disable-next-line react-hooks/exhaustive-deps }, [decodes, spotStatus]); @@ -150,13 +175,14 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr if (modeSel && d.mode !== modeSel) return false; if (floor != null && Number.isFinite(floor) && d.snr < floor) return false; const e = statusOf(d); + if (lotwOnly && !e?.lotw) return false; if (newOnly && !isNewSomething(e)) return false; if (contSel && e?.continent !== contSel) return false; if (q && !(d.call.includes(q) || (d.grid ?? '').toUpperCase().includes(q) || (d.msg ?? '').toUpperCase().includes(q))) return false; return true; }); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [decodes, spotStatus, cqOnly, newOnly, bandSel, modeSel, contSel, minSnr, search]); + }, [decodes, spotStatus, cqOnly, newOnly, lotwOnly, bandSel, modeSel, contSel, minSnr, search]); // Group into periods, newest first, and drop the operator's transmissions into // the slot they went out in. @@ -188,78 +214,113 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr }, [filtered, txMsgs]); const resetFilters = () => { - setCqOnly(false); setNewOnly(false); setBandSel(''); setModeSel(''); - setContSel(''); setMinSnr(''); setSearch(''); + setCqOnly(false); setNewOnly(false); setLotwOnly(false); setBandSel(''); + setModeSel(''); setContSel(''); setMinSnr(''); setSearch(''); }; - const anyFilter = cqOnly || newOnly || !!bandSel || !!modeSel || !!contSel || !!minSnr || !!search.trim(); + const anyFilter = cqOnly || newOnly || lotwOnly || !!bandSel || !!modeSel || !!contSel || !!minSnr || !!search.trim(); - const sel = 'h-7 rounded-md border border-border bg-background px-2 text-xs'; - const chip = (on: boolean) => cn( - 'h-7 px-2.5 rounded-full border text-xs font-medium transition-colors', - on ? 'border-primary bg-primary text-primary-foreground' : 'border-border text-muted-foreground hover:bg-muted', + const sel = 'h-8 rounded-lg border border-border bg-background px-2 text-sm'; + const chip = (on: boolean, tone = 'primary') => cn( + 'h-8 px-3 rounded-full border text-sm font-medium transition-colors', + on + ? tone === 'success' + ? 'border-success bg-success text-success-foreground' + : 'border-primary bg-primary text-primary-foreground' + : 'border-border text-muted-foreground hover:bg-muted hover:text-foreground', ); return (
{/* ── Filter bar ─────────────────────────────────────────────── */} -
+
- + {t('dec.title')} - + - - - + {/* Only when there is a choice to make — see the memo above. */} + {bands.length > 1 && ( + + )} + {modes.length > 1 && ( + + )} + {conts.length > 1 && ( + + )} -
+ {/* ── Column header ──────────────────────────────────────────── */} +
+
+ + {t('dec.colCall')} + {t('dec.colSnr')} + {t('dec.colGrid')} + {t('dec.colMsg')} + {t('dec.colFlags')} + {t('dec.colCountry')} + L +
+
+ {/* ── Periods ────────────────────────────────────────────────── */}
{groups.length === 0 && ( @@ -271,105 +332,108 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr )} {groups.map((g, gi) => ( -
- {/* Period header — sticky so the slot you are reading is always named. */} -
- - {hhmmss(g.start)} - - - {t('dec.periodCount', { n: g.decodes.length })} - - {gi === 0 && ( - - - {t('dec.live')} +
+ {/* Period header — sticky, so the slot being read is always named. */} +
+
+ + {hhmmss(g.start)} - )} + + {t('dec.periodCount', { n: g.decodes.length })} + + {gi === 0 && ( + + + {t('dec.live')} + + )} +
{/* The operator's own transmission, at the top of its slot: it is what the stations below were answering (or ignoring). */} {g.tx.map((m, i) => ( -
- - - {t('dec.tx')} - - {m.msg} - {m.band && {m.band}} +
+
+ + + {t('dec.tx')} + + {m.msg} + {m.band && {m.band}} +
))} {g.decodes.map((d, i) => { const e = statusOf(d); const st = e?.status && e.status !== 'worked' ? e.status : ''; - const markers = activeMarkers(e as any); + const entity = st ? ENTITY_BADGE[st] : undefined; + const extras = EXTRA_BADGES.filter((b) => !!e?.[b.key]); const mine = myCall && d.call === myCall.toUpperCase(); + const hot = !!entity || extras.length > 0; return ( - + + + {e?.lotw && ( + L + )} + + +
); })}
diff --git a/frontend/src/lib/i18n.tsx b/frontend/src/lib/i18n.tsx index 9a37af5..441a2ed 100644 --- a/frontend/src/lib/i18n.tsx +++ b/frontend/src/lib/i18n.tsx @@ -130,6 +130,9 @@ const en: Dict = { 'dec.minSnrTitle': 'Hide anything weaker than this SNR', 'dec.searchPh': 'Call, grid or message', 'dec.clearFilters': 'Clear', 'dec.live': 'live', 'dec.tx': 'TX', 'dec.count': '{shown} of {total}', 'dec.periodCount': '{n} decodes', 'dec.callTitle': 'Call {call} — fills the entry and tunes the rig', + 'dec.lotwOnly': 'LoTW only', 'dec.instances': '{n} receivers', + 'dec.colCall': 'Call', 'dec.colSnr': 'SNR', 'dec.colGrid': 'Grid', 'dec.colMsg': 'Message', 'dec.colFlags': 'New', 'dec.colCountry': 'Country', + 'dec.bgPota': 'POTA', 'dec.bgGrid': 'GRID', 'dec.bgPfx': 'PFX', 'dec.bgCounty': 'CTY', 'dec.stNew': 'NEW', 'dec.stBand': 'BAND', 'dec.stMode': 'MODE', 'dec.stSlot': 'SLOT', 'dec.stCall': 'CALL', 'dec.empty': 'Nothing decoded yet. Decodes arrive from WSJT-X, JTDX or MSHV over the inbound UDP link (Settings -> UDP).', 'dec.emptyFiltered': 'No decode matches these filters.', @@ -595,6 +598,9 @@ const fr: Dict = { 'dec.minSnrTitle': 'Masquer tout ce qui est plus faible que ce rapport', 'dec.searchPh': 'Indicatif, locator ou message', 'dec.clearFilters': 'Effacer', 'dec.live': 'en direct', 'dec.tx': 'TX', 'dec.count': '{shown} sur {total}', 'dec.periodCount': '{n} decodes', 'dec.callTitle': 'Appeler {call} — remplit la saisie et accorde le poste', + 'dec.lotwOnly': 'LoTW seulement', 'dec.instances': '{n} recepteurs', + 'dec.colCall': 'Indicatif', 'dec.colSnr': 'SNR', 'dec.colGrid': 'Locator', 'dec.colMsg': 'Message', 'dec.colFlags': 'Nouveau', 'dec.colCountry': 'Pays', + 'dec.bgPota': 'POTA', 'dec.bgGrid': 'LOC', 'dec.bgPfx': 'PFX', 'dec.bgCounty': 'CTY', 'dec.stNew': 'NOUV', 'dec.stBand': 'BANDE', 'dec.stMode': 'MODE', 'dec.stSlot': 'SLOT', 'dec.stCall': 'IND', 'dec.empty': "Aucun decode pour l'instant. Ils arrivent de WSJT-X, JTDX ou MSHV par le lien UDP entrant (Reglages -> UDP).", 'dec.emptyFiltered': 'Aucun decode ne correspond a ces filtres.', diff --git a/internal/integrations/udp/server.go b/internal/integrations/udp/server.go index fbdfa66..715c807 100644 --- a/internal/integrations/udp/server.go +++ b/internal/integrations/udp/server.go @@ -127,6 +127,12 @@ type Event struct { DecodeTRPeriod int DecodeDial int64 // dial frequency the decode was heard on, for the band DecodeOffAir bool // decoded from a file rather than off the air + // ProgramID is the sending application's own id ("WSJT-X", "MSHV", or + // "WSJT-X - 2" for a second instance started with --rig-name). It is what + // tells two receivers apart on one multicast group — and it is the address a + // Reply message would have to be sent back to, so it is carried even though + // nothing replies yet. + ProgramID string // TxMessage is what the operator's digital app is sending, with Transmitting // true while the carrier is actually up. From Status, so ~1 Hz. @@ -439,6 +445,7 @@ func (s *Server) handle(pkt []byte, remote *net.UDPAddr) { ev.DecodeTRPeriod = tr ev.DecodeDial = dial ev.DecodeOffAir = w.OffAir + ev.ProgramID = w.ProgramID break } // Only a logged QSO is worth a line — WSJT-X/MSHV send a Status packet From ffaf6fc869fe599470efd908d123e407291beb7a Mon Sep 17 00:00:00 2001 From: Gregory Salaun Date: Tue, 18 Aug 2026 06:12:21 +0200 Subject: [PATCH 3/9] refactor(decodes): column rules, left-aligned grid, no CQ stutter Three things from reading it on a real screen. Column rules. The grid alone was not enough to follow a line across: cells now carry a right border and the row stretches, so the rules run unbroken from the header to the bottom of the list. That is what turns rows of text into a table. Left-aligned. The previous pass centred the grid inside a maximum width, which on a wide screen opened a dead margin down the left before the first callsign - trading the hole in the middle for a bigger one at the edge. Now it fills the width and the slack lands in the message column, which is the one that can use it and the one bounded by rules on both sides, so it reads as a cell rather than a gap. "CQ CQ PE1NAO JO32" - a green CQ badge in front of a message whose own first word is CQ. The badge is gone; the word already in the line is picked out instead, which scans the same and stutters not at all. --- frontend/src/components/DecodesPanel.tsx | 178 +++++++++++++---------- 1 file changed, 100 insertions(+), 78 deletions(-) diff --git a/frontend/src/components/DecodesPanel.tsx b/frontend/src/components/DecodesPanel.tsx index d2319f5..0c263aa 100644 --- a/frontend/src/components/DecodesPanel.tsx +++ b/frontend/src/components/DecodesPanel.tsx @@ -71,12 +71,20 @@ interface Props { const DEFAULT_TR = 15; // ROW is the column template, shared by the header and every row so the two can -// never drift. Fixed widths for the short fields, one flexible column for the -// message — and a hard cap on the whole grid, because on a 2500 px screen a -// free-flowing row puts the country a foot away from the callsign it belongs to -// and the eye has to travel the gap on every line. -const ROW = 'grid grid-cols-[3px_112px_56px_60px_1fr_260px_170px_28px] gap-x-3 items-center'; -const ROW_MAX = 'max-w-[1500px]'; +// never drift. Full width and left-aligned — an earlier pass centred it inside a +// maximum width, which on a wide screen opened a huge dead margin down the left +// before the first callsign. +// +// Message is the one elastic column, with a floor so it does not collapse; the +// slack lands there rather than between two fixed columns, which is what read as +// a hole in the middle of every line. +const ROW = 'grid grid-cols-[3px_120px_64px_68px_minmax(280px,1fr)_230px_180px_36px] items-stretch'; + +// CELL draws the column rule. items-stretch above plus a right border here is +// what makes the lines run unbroken from the header to the bottom of the list — +// the thing that turns rows of text into a table you can follow across. +const CELL = 'flex items-center min-w-0 px-3 border-r border-border/40'; +const CELL_LAST = 'flex items-center justify-center min-w-0 px-2'; // The "new" badges. Every one of these is a REASON TO CALL, which is why they // get a column of their own rather than a coloured edge: a stripe says something @@ -122,6 +130,23 @@ function periodStart(at: string, tr: number): number { const hhmmss = (epochSec: number) => new Date(epochSec * 1000).toISOString().slice(11, 19); +// renderMsg prints the decoded line with its leading CQ picked out. +// +// There used to be a separate green "CQ" badge in front of the message, which +// read "CQ CQ PE1NAO JO32" — the badge and the message's own first word saying +// the same thing twice. Highlighting the word already in the line keeps the +// scannability and drops the stutter. +function renderMsg(msg: string) { + const m = /^(CQ(?:\s+DX)?)\s+(.*)$/i.exec(msg); + if (!m) return {msg}; + return ( + <> + {m[1].toUpperCase()} + {' ' + m[2]} + + ); +} + // snrTone colours the report by readability rather than as a gradient: an // operator scanning a period wants "workable" to jump out, and -24 dB is not // three shades worse than -6, it is a different decision. @@ -308,16 +333,16 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr
{/* ── Column header ──────────────────────────────────────────── */} -
-
+
+
- {t('dec.colCall')} - {t('dec.colSnr')} - {t('dec.colGrid')} - {t('dec.colMsg')} - {t('dec.colFlags')} - {t('dec.colCountry')} - L + {t('dec.colCall')} + {t('dec.colSnr')} + {t('dec.colGrid')} + {t('dec.colMsg')} + {t('dec.colFlags')} + {t('dec.colCountry')} + L
@@ -334,8 +359,8 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr {groups.map((g, gi) => (
{/* Period header — sticky, so the slot being read is always named. */} -
-
+
+
{hhmmss(g.start)} @@ -355,15 +380,14 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr {/* The operator's own transmission, at the top of its slot: it is what the stations below were answering (or ignoring). */} {g.tx.map((m, i) => ( -
-
- - - {t('dec.tx')} - - {m.msg} - {m.band && {m.band}} -
+
+ + + {t('dec.tx')} + + {m.msg} + {m.band && {m.band}}
))} @@ -375,65 +399,63 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr const mine = myCall && d.call === myCall.toUpperCase(); const hot = !!entity || extras.length > 0; return ( -
- -
+ + {e?.lotw && ( + L + )} + + ); })}
From fba7e79a1cf535ade23e7b6b2c28a73ad09def83 Mon Sep 17 00:00:00 2001 From: Gregory Salaun Date: Tue, 18 Aug 2026 06:53:10 +0200 Subject: [PATCH 4/9] feat(decodes): answer a station on click, DT and Freq, badge filters Clicking a decode now ANSWERS it. It sends WSJT-X/MSHV a Reply message (type 4), which is the same thing as double-clicking the line in their own Band Activity window: the application looks the decode up, sets its transmit frequency to the caller's and starts the exchange. It deliberately does not tune the radio, which is what it did before and why nothing happened. On FT8 the whole band sits inside one passband, so moving the dial changes nothing about who gets answered - the decision belongs to the decoding application, and the Reply is the only way to hand it over. Tuning would also just fight it for the VFO. The entry is still filled so the QSO can be logged here. The reply is routed by PROGRAM ID, not by listener: two receivers can share one multicast group, and answering a station heard on the 6 m instance by talking to the 20 m one would start a call on the wrong band. It goes to the address that instance's packets actually arrive from - a multicast listener must answer the sender, never the group. WSJT-X matches the reply against its own decode list, so the payload replays the decode field for field: time, snr, delta time, audio offset, mode and message text. Two columns added, DT and Freq - the audio offset inside the passband, not the RF frequency, which is the same for every station in the list and says nothing. Past about two seconds DT takes a warning tint: that station is drifting out of the window. The transmit strip. "You cannot see what you are sending, or who you are calling" - two separate faults. The message was only ever threaded into its period, and in FT8 you transmit in the slots you are NOT receiving in, so its period had no decodes and the whole line was dropped; a transmit slot now creates its period. And the state is a strip of its own at the top, because it is the one thing on the screen that is about the operator rather than the band. It is fed by every Status rather than only by one carrying transmit text, so it can still name the station being called on MSHV and older JTDX builds, which stop before tx_message in the Status payload. "New only" became per-category badges, in the colours and the vocabulary of the Chase New panel. None lit shows the whole band - this is a decode log first, and a panel that opened by hiding most of the traffic would be lying about what is on the air. --- app.go | 54 ++++++- frontend/src/App.tsx | 40 ++++-- frontend/src/components/DecodesPanel.tsx | 174 ++++++++++++++++++++--- frontend/src/lib/i18n.tsx | 14 +- frontend/wailsjs/go/main/App.d.ts | 2 + frontend/wailsjs/go/main/App.js | 4 + internal/integrations/udp/server.go | 33 ++++- internal/integrations/udp/wsjt.go | 5 + internal/integrations/udp/wsjtreply.go | 129 +++++++++++++++++ 9 files changed, 417 insertions(+), 38 deletions(-) create mode 100644 internal/integrations/udp/wsjtreply.go diff --git a/app.go b/app.go index 924ccb7..e7d88b1 100644 --- a/app.go +++ b/app.go @@ -12668,17 +12668,24 @@ func (a *App) consumeUDPEvents() { if a.ctx == nil { continue } - // The operator's own transmit message, from Status. Emitted before the - // switch because a Status can carry BOTH a DX call and a transmit - // message, and the switch below takes only one branch. - if ev.TxMessage != "" { - wruntime.EventsEmit(a.ctx, "udp:tx_message", map[string]any{ + // The operator's own transmit state, from Status. Emitted before the + // switch because a Status carries BOTH a DX call and a transmit message, + // and the switch below takes only one branch. + // + // Sent on EVERY Status, not only when there is a transmit message: MSHV + // and older JTDX builds stop before tx_message in the Status payload, and + // the panel still has to be able to say who is being called and whether + // the carrier is up. A Status always carries de_call, so that is the test. + if ev.DECall != "" || ev.TxMessage != "" { + wruntime.EventsEmit(a.ctx, "udp:tx_state", map[string]any{ "msg": ev.TxMessage, "transmitting": ev.Transmitting, "de_call": ev.DECall, + "dx_call": ev.DXCall, "mode": ev.Mode, "freq_hz": ev.FreqHz, "band": bandForHz(ev.FreqHz), + "instance": ev.ProgramID, "at": time.Now().UTC().Format(time.RFC3339), }) } @@ -12713,6 +12720,12 @@ func (a *App) consumeUDPEvents() { "off_air": ev.DecodeOffAir, "source": ev.Source, "instance": ev.ProgramID, + "dt": ev.DecodeDT, + "audio_hz": ev.DecodeAudioHz, + // Carried so a click can answer the station: WSJT-X matches a + // Reply against its own decode list, field for field. + "ms": ev.DecodeMs, + "low_conf": ev.DecodeLowConf, }) // A WSJT-X decode (heard station). Render it on the FlexRadio // panadapter when the option is on; green + SNR comment, auto-expiring @@ -18339,6 +18352,37 @@ type GridCacheStatus struct { Pending int `json:"pending"` // waiting for the next batch write } +// AnswerDecode tells the decoding application to call a station — the same +// thing as double-clicking the line in WSJT-X's own Band Activity window. +// +// This is not something OpsLog can do by tuning the radio. On FT8 the whole band +// sits inside one passband, so moving the dial changes nothing about who gets +// answered: the decision belongs to WSJT-X/MSHV, and the Reply message is the +// only way to hand it over. The panel therefore does NOT retune the rig on a +// click, which would only fight the digital application for the VFO. +// +// Every argument replays the decode as it arrived, because the target matches it +// against its own decode list and ignores anything it cannot find. +func (a *App) AnswerDecode(instance string, ms uint32, snr int, dt float64, audioHz int64, mode, msg string, lowConf bool) error { + if a.udp == nil { + return fmt.Errorf("udp not initialized") + } + err := a.udp.SendReply(udp.Reply{ + ProgramID: instance, + MsSinceMidnig: ms, + SNR: int32(snr), + DeltaTime: dt, + DeltaFreqHz: uint32(audioHz), + Mode: mode, + Message: msg, + LowConfidence: lowConf, + }) + if err != nil { + applog.Printf("udp: answer decode %q on %q failed: %v", msg, instance, err) + } + return err +} + // GetGridCacheStatus reports what the locator store holds. func (a *App) GetGridCacheStatus() GridCacheStatus { out := GridCacheStatus{Enabled: a.gridStore != nil} diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 64003a4..f031997 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -94,7 +94,7 @@ import { ShutdownProgress } from '@/components/ShutdownProgress'; import { ClusterGrid } from '@/components/ClusterGrid'; import { cleanSpotter, inferSpotMode, spotModeCategory, spotStatusKey } from '@/lib/spot'; import { applySpotDisplay, readSpotDisplayOptions, spotIsWorked, SPOT_DISPLAY_OPTIONS_EXPOSED } from '@/lib/spotDisplay'; -import { GetMatrixColors, GetRotorPresets, GetRowColors, GetSpotTTLMinutes, IsNewUSCounty } from '../wailsjs/go/main/App'; +import { AnswerDecode, GetMatrixColors, GetRotorPresets, GetRowColors, GetSpotTTLMinutes, IsNewUSCounty } from '../wailsjs/go/main/App'; import { applyMatrixColors } from '@/lib/matrixColors'; import { WorkedBeforeGrid } from '@/components/WorkedBeforeGrid'; import { NetControlPanel } from '@/components/NetControlPanel'; @@ -2042,6 +2042,9 @@ export default function App() { const DECODE_KEEP_MS = 30 * 60 * 1000; const [decodes, setDecodes] = useState([]); const [txMsgs, setTxMsgs] = useState([]); + // The LIVE transmit state, replaced on every Status — what is going out now + // and to whom, which the period history cannot answer between overs. + const [txState, setTxState] = useState(null); // Staged like the cluster's, so a period arriving as one burst of fifty // packets costs one status lookup and one render, not fifty of each. const pendingDecodesRef = useRef([]); @@ -3099,7 +3102,13 @@ export default function App() { // The operator's own transmission. Status repeats it about once a second // for the whole over, so it is recorded ONCE per message: the panel wants // "I sent this in that period", not sixty copies of it. - const unsubTx = EventsOn('udp:tx_message', (m: any) => { + const unsubTx = EventsOn('udp:tx_state', (m: any) => { + // The live strip takes every Status: it has to say who is being called + // even between overs, and on a sender that never reports its transmit + // text at all. + setTxState(m as TxMsgRow); + // The period history takes only real transmissions — Status repeats + // itself once a second whether the carrier is up or not. if (!m?.transmitting || !String(m?.msg ?? '').trim()) return; setTxMsgs((arr) => { const last = arr[arr.length - 1]; @@ -7176,18 +7185,25 @@ export default function App() { handleSpotClick({ - dx_call: d.call, - freq_hz: d.freq_hz, - freq_khz: d.freq_hz / 1000, - band: d.band, - comment: d.mode, - spotter: '', - } as any)} + // A click ANSWERS the station: it hands the decode back to + // WSJT-X/MSHV as a Reply, which is the same thing as + // double-clicking the line in their own window. + // + // Deliberately NOT a rig tune, unlike a cluster spot. On FT8 + // the whole band is inside one passband, so moving the dial + // changes nothing about who gets answered — and it would only + // fight the digital application for the VFO. The entry is + // still filled, so the QSO can be logged here. + onCall={(d) => { + onCallsignInput(d.call, { force: true }); + AnswerDecode( + d.instance ?? '', d.ms ?? 0, d.snr, d.dt ?? 0, + d.audio_hz ?? 0, d.mode ?? '', d.msg ?? '', !!d.low_conf, + ).catch((e: any) => setError(String(e?.message ?? e))); + }} /> )} diff --git a/frontend/src/components/DecodesPanel.tsx b/frontend/src/components/DecodesPanel.tsx index 0c263aa..b73f63a 100644 --- a/frontend/src/components/DecodesPanel.tsx +++ b/frontend/src/components/DecodesPanel.tsx @@ -33,14 +33,22 @@ export type Decode = { off_air?: boolean; source?: string; instance?: string; + dt?: number; + audio_hz?: number; + // Replayed verbatim when answering the station — see AnswerDecode. + ms?: number; + low_conf?: boolean; }; export type TxMsg = { msg: string; de_call?: string; + dx_call?: string; mode?: string; band?: string; freq_hz?: number; + instance?: string; + transmitting?: boolean; at: string; }; @@ -60,11 +68,52 @@ type StatusEntry = { interface Props { decodes: Decode[]; txMsgs: TxMsg[]; + // txState is the LIVE transmit state — what is going out right now and to + // whom. Separate from txMsgs, which is the history threaded into the periods. + txState?: TxMsg | null; spotStatus: Record; onCall: (d: Decode) => void; myCall?: string; } +// The "new" categories, as toggle badges — the same idea and the same colours as +// the Chase New panel, so an operator who has learned one has learned both. +// +// All off means no filtering at all: this is a decode LOG first, and a panel +// that starts by hiding most of the band would be lying about what is on it. +type NewCat = 'dxcc' | 'band' | 'mode' | 'slot' | 'pfx' | 'grid' | 'pota' | 'cty'; + +const NEW_CATS: { key: NewCat; label: string; colour: string }[] = [ + { key: 'dxcc', label: 'dec.stNew', colour: 'var(--success)' }, + { key: 'band', label: 'dec.stBand', colour: 'var(--warning)' }, + { key: 'mode', label: 'dec.stMode', colour: 'var(--info)' }, + { key: 'slot', label: 'dec.stSlot', colour: 'var(--caution)' }, + { key: 'pota', label: 'dec.bgPota', colour: markerColour('new_pota') }, + { key: 'grid', label: 'dec.bgGrid', colour: markerColour('new_grid') }, + { key: 'pfx', label: 'dec.bgPfx', colour: markerColour('new_pfx') }, + { key: 'cty', label: 'dec.bgCounty', colour: markerColour('new_county') }, +]; + +// catsOf lists everything a decode is new for. A station can be several at once +// — a new entity that is also a new park — so this is a set, not a verdict. +function catsOf(e: StatusEntry | undefined): Set { + const out = new Set(); + if (!e) return out; + switch (e.status) { + case 'new': out.add('dxcc'); break; + case 'new-band': out.add('band'); break; + case 'new-mode': out.add('mode'); break; + case 'new-slot': out.add('slot'); break; + } + if (e.new_pota) out.add('pota'); + if (e.new_grid) out.add('grid'); + if (e.new_pfx) out.add('pfx'); + if (e.new_county) out.add('cty'); + return out; +} + +const CAT_KEY = 'opslog.decodeCats'; + // DEFAULT_TR is the slot length assumed when the sender never told us its T/R // period. Fifteen seconds is FT8, which is the overwhelming majority of what // arrives here; a wrong guess only mis-groups, it never loses a decode. @@ -78,7 +127,7 @@ const DEFAULT_TR = 15; // Message is the one elastic column, with a floor so it does not collapse; the // slack lands there rather than between two fixed columns, which is what read as // a hole in the middle of every line. -const ROW = 'grid grid-cols-[3px_120px_64px_68px_minmax(280px,1fr)_230px_180px_36px] items-stretch'; +const ROW = 'grid grid-cols-[3px_120px_58px_54px_62px_64px_minmax(240px,1fr)_222px_160px_34px] items-stretch'; // CELL draws the column rule. items-stretch above plus a right border here is // what makes the lines run unbroken from the header to the bottom of the list — @@ -156,11 +205,22 @@ function snrTone(snr: number): string { return 'text-muted-foreground/70'; } -export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Props) { +export function DecodesPanel({ decodes, txMsgs, txState, spotStatus, onCall, myCall }: Props) { const { t } = useI18n(); const [cqOnly, setCqOnly] = useState(false); - const [newOnly, setNewOnly] = useState(false); const [lotwOnly, setLotwOnly] = useState(false); + const [cats, setCats] = useState>(() => { + try { + const raw = JSON.parse(localStorage.getItem(CAT_KEY) || '[]'); + return new Set(Array.isArray(raw) ? raw : []); + } catch { return new Set(); } + }); + const toggleCat = (k: NewCat) => setCats((prev) => { + const next = new Set(prev); + if (next.has(k)) next.delete(k); else next.add(k); + try { localStorage.setItem(CAT_KEY, JSON.stringify([...next])); } catch { /* not worth failing over */ } + return next; + }); const [bandSel, setBandSel] = useState(''); const [modeSel, setModeSel] = useState(''); const [contSel, setContSel] = useState(''); @@ -188,9 +248,6 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr // eslint-disable-next-line react-hooks/exhaustive-deps }, [decodes, spotStatus]); - const isNewSomething = (e: StatusEntry | undefined): boolean => - !!e && ((!!e.status && e.status !== 'worked') || !!e.new_county || !!e.new_pota || !!e.new_pfx || !!e.new_grid); - const filtered = useMemo(() => { const q = search.trim().toUpperCase(); const floor = minSnr.trim() === '' ? null : parseInt(minSnr, 10); @@ -201,13 +258,20 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr if (floor != null && Number.isFinite(floor) && d.snr < floor) return false; const e = statusOf(d); if (lotwOnly && !e?.lotw) return false; - if (newOnly && !isNewSomething(e)) return false; + // Any badge lit narrows the list to the things it names; none lit shows + // the band as it is. + if (cats.size > 0) { + const have = catsOf(e); + let hit = false; + for (const c of cats) if (have.has(c)) { hit = true; break; } + if (!hit) return false; + } if (contSel && e?.continent !== contSel) return false; if (q && !(d.call.includes(q) || (d.grid ?? '').toUpperCase().includes(q) || (d.msg ?? '').toUpperCase().includes(q))) return false; return true; }); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [decodes, spotStatus, cqOnly, newOnly, lotwOnly, bandSel, modeSel, contSel, minSnr, search]); + }, [decodes, spotStatus, cqOnly, lotwOnly, cats, bandSel, modeSel, contSel, minSnr, search]); // Group into periods, newest first, and drop the operator's transmissions into // the slot they went out in. @@ -221,10 +285,15 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr } for (const m of txMsgs) { const k = periodStart(m.at, DEFAULT_TR); - // Only into a period the list is actually showing — a transmission alone - // in an empty slot would be a section with nothing to read. - const g = by.get(k); - if (g) g.tx.push(m); + // A transmit slot CREATES its period when there is none. + // + // This is the whole alternation, and getting it wrong hid the feature + // completely: FT8 transmits and receives in opposite slots, so the period + // you were sending in is exactly the one with no decodes in it. Dropping + // the message when its period was empty meant it never appeared at all. + let g = by.get(k); + if (!g) { g = { decodes: [], tx: [] }; by.set(k, g); } + g.tx.push(m); } return [...by.entries()] .sort((a, b) => b[0] - a[0]) @@ -239,10 +308,12 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr }, [filtered, txMsgs]); const resetFilters = () => { - setCqOnly(false); setNewOnly(false); setLotwOnly(false); setBandSel(''); + setCqOnly(false); setLotwOnly(false); setBandSel(''); setModeSel(''); setContSel(''); setMinSnr(''); setSearch(''); + setCats(new Set()); + try { localStorage.setItem(CAT_KEY, '[]'); } catch { /* not worth failing over */ } }; - const anyFilter = cqOnly || newOnly || lotwOnly || !!bandSel || !!modeSel || !!contSel || !!minSnr || !!search.trim(); + const anyFilter = cqOnly || lotwOnly || cats.size > 0 || !!bandSel || !!modeSel || !!contSel || !!minSnr || !!search.trim(); const sel = 'h-8 rounded-lg border border-border bg-background px-2 text-sm'; const chip = (on: boolean, tone = 'primary') => cn( @@ -266,13 +337,32 @@ export function DecodesPanel({ decodes, txMsgs, spotStatus, onCall, myCall }: Pr - + {/* Per-category badges, in the colours of the flags they select — the + same vocabulary as the Chase New panel. */} + + {NEW_CATS.map((c) => { + const on = cats.has(c.key); + return ( + + ); + })} + + {/* Only when there is a choice to make — see the memo above. */} {bands.length > 1 && (