feat: AIS live traffic overlay on the Live tab (#25)#145
Merged
Conversation
added 9 commits
July 23, 2026 20:49
Live verification against aisstream.io showed a bad key produces NO error frame: the socket accepts the subscription, then closes bare (1006, empty reason) on every reconnect. Applies the plan's pinned adjustment: three consecutive subscribed-then-closed cycles with zero inbound messages route to the existing terminal keyError state (no retry storm); unopened connect failures and post-message closes stay transient.
DocGerd
commented
Jul 23, 2026
…ch keyError (#25) Review F1 (PR #145): earlyCloses previously counted ANY subscribed-but-silent close and reset only on an inbound message, so a valid key over a vessel-empty bbox (zero traffic) plus 3 network drops hit terminal keyError. Now each connect arms a 30 s auth-stability timer (injected setTimer): if the socket is still open when it fires, the key is proven (aisstream kills bad-key sockets within ~a second) and earlyCloses/attempt reset; once proven, silent closes are always transient. Timer cleared on close/stop/error-frame (leak-probed in tests).
This was referenced Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the reviewed plan
docs/superpowers/plans/2026-07-23-ais-traffic-overlay.md(spec:docs/superpowers/specs/2026-07-23-ais-traffic-overlay-design.md): a live AIS traffic overlay on the Live tab, sourced browser-direct from aisstream.io over a BYOK WebSocket.What shipped (one commit per plan task)
aisApiKey/ownMmsionSettings(absent = feature off, no migration) +isValidMmsi(9-digit string, leading zeros preserved).AisStreamClient(services/aisStream.ts) — pure, React-free connection state machine: subscription/bbox builders, sentinel-aware message parsing (heading 511, SOG 102.3, COG 360), full-jitter capped-exponential backoff, terminalkeyErrorstate; injectable socket factory + timers, onlybrowserAisSockettouches a real WebSocket.lib/aisTargets.ts) — MMSI-keyed merge of PositionReport + ShipStaticData, ownship dropped at ingest, fresh < 3 min / stale 3–10 min / dropped > 10 min; explicit-clock pure functions.useAisTraffic— component-local hook (useOwnshipGps discipline): targetMapin a ref, ≤1 Hz snapshot publish + sweep, key/online/visible/bbox gates, five-state UI status.lib/projectionVector.ts(reused by Live view: ownship 6-minute COG/SOG projection vector (parity with AIS target vectors) #141),lib/aisGeoJson.tsfeature/popup builders,AisLayer(one GeoJSON source, three declutter-tiered layers anchored below the route stack, themed.ais-popup).AisTrafficcontroller (debounced padded-viewport subscription, status chip overlay),AIS_VESSEL_LAYERregistered inINTERACTIVE_MAP_LAYER_IDS.Test counts
mmsi7,aisStream23,aisTargets8,useAisTraffic10,projectionVector3,aisGeoJson9,AisTrafficchip 6,OptionsPanel+5,db.test+1; net +36 incl. shared-file counts). Full gate: lint ✓, typecheck ✓,npm test86 files / 880 ✓, build ✓.plan.spec.ts,layout.spec.ts,offline.spec.tsall passing (no key configured in e2e → zero AIS network; wind fixture restored, not committed).Live pass (owner key, real aisstream.io, dev server + Playwright)
connecting…→live · N Schiffe; layer order verified from the live style: depth → harbors → seamarks → AIS (vectors/vessels/labels) → route stack; ownship is a DOM marker (always on top).rgb(251,251,252)/ darkrgb(13,14,16)chrome incl. both tip borders): name/MMSI/type/SOG/COG/age rows + disclaimer.ownMmsiset to a live vessel's MMSI → that vessel never enters the overlay while others keep arriving.AIS offline, socket closed, zero retries; back online → exactly one new socket,liveagain with no user action.{"error": …}frame — the socket accepts the subscription, then closes bare (1006, empty reason) on every reconnect, which the pinned error-frame rule alone would retry forever. Applied the plan's pre-authorized adjustment (plan §Task 2 note / §Notes): three consecutive subscribed-then-closed-with-zero-messages cycles are promoted to the existing terminalkeyErrorstate (unopened connect failures and post-message closes stay transient; error-frame path kept as belt-and-braces). Re-verified live: chipAIS: API-Schlüssel prüfen, no retry storm (socket count static over 20+ s), and a corrected key recovers tolive.Deviations from the plan (all minimal, reported)
useAisTraffic: the plan's render-body ref write +setClientStatus('closed')inside the lifecycle effect trip the repo's react-hooks lint rules — replaced with an effect-synced ref and a render-time derivedeffectiveStatus(theuseOwnshipGpsderived-fix precedent); observable status mapping identical, all 10 plan tests pass unchanged.aisStreamkeyError promotion (above) — the plan's pinned live-adjustment path, executed.live.spec.ts; no such spec exists — ranlayout.spec.ts+offline.spec.ts(the specs covering the Live tab/offline) plusplan.spec.tsinstead.Closes #25
🤖 Generated with Claude Code
https://claude.ai/code/session_01UXvHWVP7iALk2rScg3CtkT