Engineering Blog

Engineering: Multi-Tab BroadcastChannel Synchronization

Silencing key-corruption by synchronizing multiple Duplex open browser tabs in real-time.

The Out-of-Sync Token Threat

If a user opens Duplex in tab A, modifies their Anthropic API key, and starts a model stream in tab B, inconsistent state can cause request errors. Storing settings in localStorage does not instantly notify open siblings.

We implemented `window.BroadcastChannel` to link all active tabs. Operating on a simple peer-to-peer contract, tab A broadcasts a lightweight `STATE_SYNC` signal on save events. Tab B captures the frame and instantly updates its internal state pointer, preventing key exhaustion or credential conflicts.