From ae8a0403b1f3188111ae1255e957ccc12a9a6965 Mon Sep 17 00:00:00 2001 From: Eric Wagoner Date: Tue, 10 Nov 2026 22:01:19 -0500 Subject: [PATCH] The template's A seat given a new token loses its address note: whoever used it before has no claim on it by address, and the next use from the new device is noted afresh Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01CCLa2PaEeCj8njQZSWGqHx --- template/server/src/rooms.test.ts | 9 +++++++-- template/server/src/rooms.ts | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/template/server/src/rooms.test.ts b/template/server/src/rooms.test.ts index 34673e2..fc99d6e 100644 --- a/template/server/src/rooms.test.ts +++ b/template/server/src/rooms.test.ts @@ -378,8 +378,13 @@ describe('a seat a browser lost', () => { rooms.seen(room, bo, 'home'); const other = rooms.create('Bo', 3); rooms.seen(other.room, other.token, 'home'); - expect(rooms.findSeats('Bo', 'home', other.room.id).seated.map((s) => s.roomId)).toEqual([other.room.id]); - expect(rooms.findSeats('Bo', 'home').seated.map((s) => s.roomId).sort()).toEqual([other.room.id, room.id].sort()); + const first = rooms.findSeats('Bo', 'home', other.room.id).seated; + expect(first.map((s) => s.roomId)).toEqual([other.room.id]); + // A seat given back is noted afresh from its next use; until then its old address claims nothing. + const second = rooms.findSeats('Bo', 'home').seated; + expect(second.map((s) => s.roomId)).toEqual([room.id]); + rooms.seen(other.room, first[0].token, 'home'); + rooms.seen(room, second[0].token, 'home'); room.over = true; expect(rooms.findSeats('Bo', 'home').seated.map((s) => s.roomId)).toEqual([other.room.id]); }); diff --git a/template/server/src/rooms.ts b/template/server/src/rooms.ts index fc110af..1e19ba1 100644 --- a/template/server/src/rooms.ts +++ b/template/server/src/rooms.ts @@ -797,6 +797,8 @@ export class Rooms { const seat = room.seats.find((s) => s.id === line.id); if (!seat) break; seat.tokenHash = line.tokenHash; + // Whoever used the seat before has no claim on it by address now: the next use from the new device is noted afresh. + delete seat.addr; seat.bot = false; delete seat.standIn; break;