Skip to content

fix(elected-leader): suppress transport echoes and propagate event id#6

Merged
joelshejar merged 1 commit into
mainfrom
fix/echo-suppression-elected-leader-hub
May 9, 2026
Merged

fix(elected-leader): suppress transport echoes and propagate event id#6
joelshejar merged 1 commit into
mainfrom
fix/echo-suppression-elected-leader-hub

Conversation

@joelshejar
Copy link
Copy Markdown
Member

Summary

  • Mirrors the echo-suppression fix in fix(worker): suppress server echoes of locally-sent events #5 for the elected-leader fallback hub. When the leader forwards an outbox entry to the transport and the server bounces it back, the event currently returns through onTransportMessage and is broadcast to every tab — including the originating tab — as source: 'remote'.
  • Bonus: onTransportMessage was throwing away the incoming id (eventId: ''). Now propagates parsed.id so subscribers see the original event id alongside source: 'remote'.

Test plan

  • pnpm --filter @tabmesh/core exec vitest --run — 93/93 pass
  • Biome clean on ElectedLeaderHub.ts
  • Manual playground verification was done against the SharedWorker path (fix(worker): suppress server echoes of locally-sent events #5); ElectedLeader is exercised via ?hub=elected and shares the same protocol shape.

🤖 Generated with Claude Code

Same echo loop as the SharedWorker hub: when the leader forwards an
outbox entry to the transport and the server bounces it back, the event
returns through `onTransportMessage` and is broadcast to every tab —
including the originating tab — as `source: 'remote'`. Activity feeds
double up and any handler keyed on `source === 'remote'` fires for
own-sends.

- Add a per-instance bounded TTL set of recently-sent ids; drop incoming
  transport messages whose id matches.
- Bonus: `onTransportMessage` was discarding the incoming `id`
  (`eventId: ''`); now propagates `parsed.id` so subscribers can see the
  original event id alongside `source: 'remote'`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joelshejar joelshejar merged commit 86632f3 into main May 9, 2026
3 of 4 checks passed
joelshejar added a commit that referenced this pull request May 10, 2026
…-state

feat(worker): pong carries visibilityState (unblocks lifecycle e2e #6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant