Expand description
Remembers which events have already been narrated, so one background launch produces one ambient narration.
WHY THIS IS PROCESS-WIDE AND NOT A LOCAL IN register_handlers.
That function runs once per WebSocket CONNECTION, so a local set is reset by
every reconnect — and a reconnect is exactly when duplicates arrive. An
honored truncate clears the frontend’s own nodeIdSet and re-parses the
transcript, re-emitting every node as new, which re-invokes the narrate RPC
for ids already narrated before the drop. Nothing else backstops it: the
AmbientGateway singleton only guards calls that are concurrently in
flight for a key, and releases its guard as soon as the first completes.
Living on AppState alongside dock_snapshots and pending_background_pids
is what makes the “narrate once” claim actually true. (reagent P1 on #3169.)
Bounded, unlike a bare HashSet: this accumulates one entry per narrated
event for the lifetime of the process, which for a long-lived instance
running many background tasks is unbounded growth for a guard that only
needs recent history. Oldest entries are evicted first — a reconnect replays
recent nodes, not ancient ones, so forgetting the distant past costs nothing.
Structs§
Constants§
- MAX_
REMEMBERED 🔒 - How many narrated event ids to remember.