Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

src/guest-names.ts gives each anonymous viewer a tasteful colour-and-animal name, stable per browser, never held by two at once - module and test only #311

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

I added Software/so101/src/guest-names.ts and its test, with no wiring into the page or lobby and forge.json untouched. The new tests pass (5 of 5). I did not run the type check, and I did not run the rest of the suite.

Notes

shipped merged

opened this

I added Software/so101/src/guest-names.ts and its test, with no wiring into the page or lobby and forge.json untouched. The new tests pass (5 of 5). I did not run the type check, and I did not run the rest of the suite. bun install failed in the sandbox with a read-only temp directory, so node_modules is missing and tsc has no types to check against. The forge's check will run both on this push.

  • Names: nameFor(browserId, inUse) returns { name, colour }. The name is a colour plus an animal ("Teal Heron", "Amber Fox") from curated lists of 16 colours and 16 animals. colour is the hex for the dot.
  • Stability: the browser id is hashed to a start point in the 256-name grid. The same id with the same inUse always gets the same name.
  • No duplicates: if the start name is taken, it moves on to the next free name in the grid.
  • Full grid: only when all 256 names are in use does a number follow ("Teal Heron 2"). That is the one case where a name is not purely from the lists, and I chose it so the function always returns a name.

The tests cover stability, two ids getting different names, every name coming from the lists, a hex colour for the dot, and the grid being full or one name short.

🤖 Generated with Claude Code

Closes #290

Approved

Module and test only, as the issue asked. nameFor is deterministic (FNV-1a start in a 16x16 colour/animal grid), skips names in use, and only numbers a name once all 256 are taken. It takes no input beyond a string and has no I/O, no dependencies, and no dead code. The tests cover stability, the in-use skip, the last free name, list membership, hex colour and the full-grid case. There is nothing to see in the preview, since nothing is wired in yet.

Two things I would do next:

  1. When the module is wired into /live, pass the names currently held by connected viewers as inUse. Show the name as text next to the dot, so the colour is never the only signal for screen readers or colour-blind viewers.
  2. Add a test for the numbered fallback when "X 2" is also taken (it should give "X 3"). The loop handles it but nothing proves it.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs