oficina / slides Public

Keep the presence client id across a reload

A reload drew this tab's own previous self as a colleague for ~40 s:
the server held the old client id until its TTL and the new page had a
fresh newClientId(). The id now lives in sessionStorage, one key per
deck (fixtures/client-id.mjs), so a reload reuses it. A duplicated tab
copies sessionStorage, so each tab claims its id on a BroadcastChannel;
a live tab holding it answers and the newcomer switches to a fresh one
(presence.setClientId beats with it at once).

No leave-on-pagehide: the server has no leave route, and with a stable
id a reload no longer needs one.

Node: client-id.test.mjs. Browser: TestBrowserReloadIsNotSomebodyElse.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 54ae9d7bdaae0929428a16b5e769ab94afe89031 parent 8b5141e
6 files changed, +265 −20
  • fixtures/client-id.mjs +62 −0
  • fixtures/client-id.test.mjs +107 −0
  • fixtures/editor-entry.js +20 −1
  • fixtures/presence.mjs +14 −4
  • internal/slides/static/{editor.ea69e9f399e840e0.js => editor.94492ae03aa185ba.js} +15 −15
  • internal/slidestest/browser_editor_presence_test.go +47 −0
fixtures/client-id.mjs

Loading diff…

fixtures/client-id.test.mjs

Loading diff…

fixtures/editor-entry.js

Loading diff…

fixtures/presence.mjs

Loading diff…

internal/slides/static/{editor.ea69e9f399e840e0.js => editor.94492ae03aa185ba.js}

Loading diff…

internal/slidestest/browser_editor_presence_test.go

Loading diff…