Skip to content

Stop compounding username rename suffixes with a per-tab handshake - #14

Merged
athrvk merged 1 commit into
masterfrom
claude/init-7ts3xc
Aug 27, 2026
Merged

athrvk merged 1 commit into
masterfrom
claude/init-7ts3xc

Conversation

@athrvk

@athrvk athrvk commented Aug 27, 2026

Copy link
Copy Markdown
Owner

What

Fixes the runaway usernames like self-appointed-p-nsa-rwz-5xb-7n8-... (20+ stacked suffixes).

Root cause: the duplicated-tab protection renamed any connection whose username was held by a live session — but when a renamed client reconnected under its new name, its own stale socket could still register as live for a moment. The server renamed again, the client adopted and persisted again, looping one suffix per cycle.

Fix (implemented by Sonnet agents, reviewed and validated):

  • The client sends a per-page-load tab id on connect — deliberately in-memory only, so a duplicated tab (which clones sessionStorage) gets a fresh id while a reconnect of the same page keeps its own.
  • Server: same username + same tab id = the same tab reconnecting — keep the name, close the stale socket. Different tab id = a genuine duplicate — rename once.
  • Rename base is capped at 20 chars, so even pathological repeated duplication can never grow a name beyond 24 chars.
  • The header username gets ellipsis overflow protection, so any historical monster name (persisted until that tab closes) is cosmetic only.

Testing

  • Protocol-level tests against the running jar: same-tab reconnect keeps the name (racer → racer) and the server closes the stale session; a different tab renames exactly once (racer-3ym); a 40-char runaway name is trimmed to 24 on rename.
  • Full e2e suite: 11/11 passing, including the duplicated-tab seating test.
  • npm run build and mvn clean package clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rs2vdovnTd4RjchV1b5dnF


Generated by Claude Code

The duplicated-tab rename could loop: the renamed client's reconnect
raced its own stale socket, the server saw a 'live' session on the
name and renamed again, and each adopted suffix was persisted -
producing usernames like name-nsa-rwz-5xb-... 20 suffixes deep.

- The client now sends a per-page-load tab id (in-memory only, so a
  duplicated tab gets a fresh one while a reconnect keeps its own)
- Same username + same tab id = the same tab reconnecting: the server
  keeps the name and drops the stale session; different tab id = a
  genuine duplicate, renamed once
- Rename base capped at 20 chars so names are bounded regardless
- Header username gains ellipsis overflow protection

Verified at the protocol level: same-tab reconnect keeps the name and
closes the stale socket, a different tab renames exactly once, and an
already-runaway 40-char name is trimmed to 24 on rename. Full e2e
suite 11/11.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rs2vdovnTd4RjchV1b5dnF
@athrvk
athrvk merged commit a98f679 into master Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants