bug: GM roster 'connected' goes stale on plain reconnect #88

Closed
opened 2026-11-21 23:23:47 +01:00 by SirStone · 1 comment
Owner

Part of #63

Problem

A player reconnects with an existing name (tab reload or a plain close/reopen) and the GM's roster row stays offline while the player's own connection badge says Connected. A pure reconnect never changes roster state on the GM side.

Cause

roster is sent only to the connecting connection during resync; a plain connect/close sends no roster to anyone else. The connected flag is derived from conns.activeCountFor only when some other operation (setname/rename/key.*) happens to broadcast a roster.

Fix direction

Per DESIGN §6.x roster semantics, broadcast the roster to the GM connection(s) when a player connection becomes active and when one closes (the full list every time, connected recomputed after the registry change). Keep the #33 ordering invariant on the existing setname path: ack first, then hello/resync/roster. Do not add a duplicate roster ahead of the connecting connection's own resync-and-snapshot order.

Acceptance

  • WS test: GM sees a named player's connected:true on connect, false after close, and true again on reconnect with the same name.
  • E2E: GM roster row flips online/offline when the player tab is reloaded/closed and online again after reload.
  • Existing #33 ordering test still passes (ack precedes hello/resync/roster on setname).
Part of #63 ## Problem A player reconnects with an existing name (tab reload or a plain close/reopen) and the GM's roster row stays `offline` while the player's own connection badge says Connected. A pure reconnect never changes roster state on the GM side. ## Cause `roster` is sent only to the connecting connection during `resync`; a plain connect/close sends no roster to anyone else. The connected flag is derived from `conns.activeCountFor` only when some other operation (setname/rename/key.*) happens to broadcast a roster. ## Fix direction Per DESIGN §6.x roster semantics, broadcast the roster to the GM connection(s) when a player connection becomes active and when one closes (the full list every time, `connected` recomputed after the registry change). Keep the #33 ordering invariant on the existing setname path: ack first, then hello/resync/roster. Do not add a duplicate roster ahead of the connecting connection's own resync-and-snapshot order. ## Acceptance - [ ] WS test: GM sees a named player's `connected:true` on connect, `false` after close, and `true` again on reconnect with the same name. - [ ] E2E: GM roster row flips online/offline when the player tab is reloaded/closed and online again after reload. - [ ] Existing #33 ordering test still passes (ack precedes hello/resync/roster on setname).
SirStone added the ready-for-agentbug labels 2026-11-21 23:23:47 +01:00
SirStone added a new dependency 2026-11-21 23:23:52 +01:00
Author
Owner

Fixed on main in fda8362.

Fix: sendRosterToGms broadcasts the full roster to every GM connection when a player connection activates and after it closes. On connect the connecting connection is skipped because it already gets the same roster as the first frame of its 6.3 resync; on close the registry entry is removed first so connected is recomputed. The malformed-flood server-initiated close now broadcasts too. The player.setname ack-before-hello/resync/roster ordering (#33) is untouched.

Tests: WS test — a named player's GM row goes connected:true, false on close, true on a plain reconnect with the same stored name; e2e — GM row follows a player tab reload and close. The protocol test now accounts for the extra roster on a second connection.

Full gate green (test, client-test, e2e) plus mutation.

Fixed on main in `fda8362`. **Fix:** `sendRosterToGms` broadcasts the full roster to every GM connection when a player connection activates and after it closes. On connect the connecting connection is skipped because it already gets the same roster as the first frame of its 6.3 resync; on close the registry entry is removed first so `connected` is recomputed. The malformed-flood server-initiated close now broadcasts too. The `player.setname` ack-before-hello/resync/roster ordering (#33) is untouched. **Tests:** WS test — a named player's GM row goes `connected:true`, `false` on close, `true` on a plain reconnect with the same stored name; e2e — GM row follows a player tab reload and close. The protocol test now accounts for the extra roster on a second connection. Full gate green (`test`, `client-test`, `e2e`) plus `mutation`.
Sign in to join this conversation.