M4: name prompt, connection badge, reconnect and resync #68

Closed
opened 2026-11-20 22:31:44 +01:00 by SirStone · 1 comment
Owner

Part of #63

Goal

First-sign-in name, badge states, jittered backoff, full view rebuild after reconnect, two devices in sync.

Acceptance criteria

  • Name prompt once, name-taken visible
  • Badge transitions
  • Backoff 1/2/4/8/10 s +/- jitter
  • Reconnect restores tokens, fog, explored, markers, lists
  • Two connections both live
  • Pending reqIds dropped with the close
  • Standing gate: full devbox run test green on a clean checkout, no test weakened or skipped, and the behaviour above proven at the seam(s) listed under "Proven at".

User stories covered

  • 5 — As a player signing in for the first time, I want to be asked once for a display name, so that the rest of the table can tell who I am.
  • 6 — As a player, I want a taken name refused with a visible reason, so that I can pick another.
  • 7 — As a player, I want a connection badge (connected / reconnecting / offline), so that I know whether the map is live.
  • 8 — As a player, I want automatic reconnection with growing, jittered delays capped near 10 s, so that a flaky phone network recovers without a reload.
  • 11 — As a player, I want a reconnect to rebuild my whole view (tokens, fog, explored, markers, lists), so that nothing is stale or missing.
  • 12 — As a player on a second device, I want both connections to stay in sync, so that either device can drive my token.

Proven at

reducer connection slice, WS client, e2e

Notes

  • Size: M (about one agent session, ~100K tokens). Lane: C (client core, after T4).
Part of #63 ## Goal First-sign-in name, badge states, jittered backoff, full view rebuild after reconnect, two devices in sync. ## Acceptance criteria - [ ] Name prompt once, `name-taken` visible - [ ] Badge transitions - [ ] Backoff 1/2/4/8/10 s +/- jitter - [ ] Reconnect restores tokens, fog, explored, markers, lists - [ ] Two connections both live - [ ] Pending reqIds dropped with the close - [ ] Standing gate: full `devbox run test` green on a clean checkout, no test weakened or skipped, and the behaviour above proven at the seam(s) listed under "Proven at". ## User stories covered - 5 — As a player signing in for the first time, I want to be asked once for a display name, so that the rest of the table can tell who I am. - 6 — As a player, I want a taken name refused with a visible reason, so that I can pick another. - 7 — As a player, I want a connection badge (connected / reconnecting / offline), so that I know whether the map is live. - 8 — As a player, I want automatic reconnection with growing, jittered delays capped near 10 s, so that a flaky phone network recovers without a reload. - 11 — As a player, I want a reconnect to rebuild my whole view (tokens, fog, explored, markers, lists), so that nothing is stale or missing. - 12 — As a player on a second device, I want both connections to stay in sync, so that either device can drive my token. ## Proven at reducer connection slice, WS client, e2e ## Notes - Size: M (about one agent session, ~100K tokens). Lane: C (client core, after T4).
SirStone added the ready-for-agentenhancement labels 2026-11-20 22:31:44 +01:00
SirStone added a new dependency 2026-11-20 22:31:45 +01:00
SirStone added a new dependency 2026-11-20 22:31:45 +01:00
SirStone added a new dependency 2026-11-20 22:31:46 +01:00
SirStone added a new dependency 2026-11-20 22:31:46 +01:00
Author
Owner

Landed on main as 465259c (rebased onto 2727617, #65).

What shipped (client only, no wire change)

  • First-sign-in name prompt: a live player with me.name === null gets #name, no HUD and no Pixi stage (the server sends no scene until named). player.setname is acked before the second hello (#33); name-taken, invalid and not-allowed render as visible text and the prompt stays. Acceptance triggers hello + the 6.3 resync, so it is asked once and survives a reload.
  • Badge #badge[data-state]: connected / reconnecting / offline. offline is driven by navigator.onLine and terminal close outcomes; reconnecting keeps the stale map on screen.
  • Reconnect: transport close after a live connection retries at 1/2/4/8/10 s base with ±20 % jitter, then the cap. revoked/proto-mismatch stay terminal; pending reqIds die with the socket; the browser online event skips the remaining wait. A drop keeps the view; hello resets all slices and the resync rebuilds tokens, fog, explored, markers and lists.
  • Two connections on one player key stay live and receive the same frames.

Proven at

  • Unit (devbox run client-test, 61 tests): test/ws.test.ts schedule + retry state machine + pending drop; test/reducer.test.ts badge transitions, reconnect reset, name errors.
  • Browser e2e (devbox run e2e, 8 tests): new e2e/session.test.mjs — name prompt once + taken name; kill/restart the real server under a live page and assert reconnecting → connected plus the full resync frames (roster, encountered, vision, explored, marker, token, all full:true where applicable); context.setOffline network drop; two pages on one key.
  • Standing gates on the rebased tree: devbox run test 157 tests + 19 group evidence OK, devbox run client-test 61 OK, devbox run e2e 8 OK. Scratch results/* reverted before push.

AC: name prompt once + name-taken visible ✓; badge transitions ✓; backoff 1/2/4/8/10 s ± jitter ✓; reconnect restores tokens/fog/explored/markers/lists ✓; two connections live ✓; pending reqIds dropped with the close ✓; full devbox run test green on a clean checkout, no test weakened or skipped ✓.

Landed on `main` as 465259c (rebased onto 2727617, #65). **What shipped (client only, no wire change)** - First-sign-in name prompt: a live player with `me.name === null` gets `#name`, no HUD and no Pixi stage (the server sends no scene until named). `player.setname` is acked before the second `hello` (#33); `name-taken`, `invalid` and `not-allowed` render as visible text and the prompt stays. Acceptance triggers `hello` + the 6.3 resync, so it is asked once and survives a reload. - Badge `#badge[data-state]`: `connected` / `reconnecting` / `offline`. `offline` is driven by `navigator.onLine` and terminal close outcomes; `reconnecting` keeps the stale map on screen. - Reconnect: transport close after a live connection retries at 1/2/4/8/10 s base with ±20 % jitter, then the cap. `revoked`/`proto-mismatch` stay terminal; pending `reqId`s die with the socket; the browser `online` event skips the remaining wait. A drop keeps the view; `hello` resets all slices and the resync rebuilds tokens, fog, explored, markers and lists. - Two connections on one player key stay live and receive the same frames. **Proven at** - Unit (`devbox run client-test`, 61 tests): `test/ws.test.ts` schedule + retry state machine + pending drop; `test/reducer.test.ts` badge transitions, reconnect reset, name errors. - Browser e2e (`devbox run e2e`, 8 tests): new `e2e/session.test.mjs` — name prompt once + taken name; kill/restart the real server under a live page and assert reconnecting → connected plus the full resync frames (roster, encountered, vision, explored, marker, token, all `full:true` where applicable); `context.setOffline` network drop; two pages on one key. - Standing gates on the rebased tree: `devbox run test` 157 tests + 19 group evidence OK, `devbox run client-test` 61 OK, `devbox run e2e` 8 OK. Scratch `results/*` reverted before push. AC: name prompt once + `name-taken` visible ✓; badge transitions ✓; backoff 1/2/4/8/10 s ± jitter ✓; reconnect restores tokens/fog/explored/markers/lists ✓; two connections live ✓; pending reqIds dropped with the close ✓; full `devbox run test` green on a clean checkout, no test weakened or skipped ✓.
Sign in to join this conversation.