Conversation
Renaming yourself in a room only wrote the new name to localStorage and then tried to restart the room; peers were never told, so the desk kept rendering the name from the join handshake. The restart itself was dead code: it called startRoom(root, ...) from renderWaiting, where root is not in scope, so it threw before doing anything. Add a 'rename' action to the protocol plus a setName() API that updates self (what later joins and state-syncs carry), rewrites our participant record and broadcasts the change. Incoming renames are accepted only from the connection that owns the identity and are name-sanitized like any other peer string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Renaming yourself in a room never reached the other players. The name changed on your own screen, but the desk kept showing the old one — including when it came time to vote.
Root cause
The rename has to travel three hops, and it broke at the second.
The wire had no rename message.
protocol.jsshared a name exactly once, in thejoinhandshake. Any rename after joining had no way to reach a peer, so every other client kept the value it learned when you arrived.The UI had a workaround for this, and the workaround was broken too:
renderWaiting(el, s, userId, protocol, force, roomId)has norootparameter and no binding for it in scope, so this threwReferenceErrorinside a timer callback and vanished silently. That is why the symptom looked so strange:setUserNamepersisted the new name tolocalStorageand the peer-list row painted its✓, whilestate.participants[userId].name— the value the desk actually renders — never moved.Even a working restart would not have fixed the remote side. Peers reject a re-join for an id that already has a live connection, so they would have kept the old name regardless.
The render layer was innocent throughout:
renderVoting,renderRevealedand the reveal overlay all readp.namefromparticipantsat render time, and votes never embed a name.The fix
A
renameaction on the wire, plussetName(name)which mutatesself— so laterjoinandstate-syncpayloads carry the new value — rewrites our own participant record, broadcasts, and emits.getRenameapplies the same ownership check asvote,leaveandheartbeat(a peer cannot rename someone else) and passes the incoming value throughcleanName.The UI now calls
protocol.setName(newName)instead of restarting the room. The 600 ms✓flourish stays; adoneflag stops the Enter-then-blur double save.Tests
describe('protocol — rename'), seven cases: the local record updates and broadcasts; a rename mid-round survives into the voting phase alongside the vote; laterjoin/state-syncpayloads carry the new name; an incoming rename from the owning connection is applied; a renamed peer can still vote (records are keyed by id, not name); a rename forged on another participant's behalf is rejected; oversized and blank incoming names are sanitized.Six of the seven fail against
HEAD~1, verified by swapping the oldprotocol.jsback in. Full suite 88/88,npm run buildclean.Known issue found but not fixed here
getStateSyncrebuilds state withoutstoryIdsorstoryId, thoughcreateInitialStatesets both. A peer that joins via state-sync therefore hasstate.storyIdsundefined, andrenderWaiting(s.storyIds[i]) andstartVoting(state.storyIds[idx]) will throw for it.storyIdsis also never broadcast, so per-story results cannot line up across peers. Separate bug, separate PR.Note on CI
ci.ymltriggers onpull_request, so this PR is its first automated run — the push todevelopdid not trigger one.