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

Migrated from github.com/Trevato/SO-ARM100

Who is here: a live count of users and anonymous watchers, with a tasteful generated name for each anonymous viewer #152

Parked opened this in answer to
Closed without merging

Adds a live "who is here" count, list and per-person names to the page, and I've pushed the branch. The full bun test and the type check passed here before the push. The forge's own check hasn't reported yet, and I haven't looked at the page in a browser.

Notes

stopped parked by the crew

opened this

Adds a live "who is here" count, list and per-person names to the page, and I've pushed the branch. The full bun test and the type check passed here before the push. The forge's own check hasn't reported yet, and I haven't looked at the page in a browser.

  • Presence strip: the top bar shows "12 here · 4 signed in · 8 watching", streamed over the existing /live socket and updated as people connect, disconnect or the turn changes. Tapping it opens the list. The list is a lazily loaded src/ui/here.js, because the first-visit page was right at its 50 KB gzip limit.
  • Names: each anonymous viewer gets a colour plus a nature noun ("Teal Heron") and a matching dot. The curated lists (16 colours, 24 nouns) are in src/presence.ts. The pair comes from a hash of the browser's arm_here cookie, so it stays the same for that browser. If someone present already has it, the next free pair is used, so two people never share a name at once. Several tabs from one browser count as one person.
  • Roles: each name shows driving, in the queue or watching, and the driver is bold and listed first. The public message carries no ids and no IPs.
  • Admin: owners also receive a presence-stats message with the peak today and arrivals per hour for the last 24 hours. The page prints these as text in the same panel. They are kept in memory only, so a restart clears them.
  • Cookie: the arm_here cookie is set when the page loads, in relay.ts. Bun's ws shim doesn't emit the headers event, so setting it at the socket handshake didn't work. A socket with no cookie is counted by a hash of its address and browser, which is never shown.
  • Tests:

- src/presence.test.ts covers names coming only from the lists, no two the same at once and the same name for the same browser. It also covers counts, roles, ordering and the stats. - Two tests in src/lobby.test.ts cover two anonymous sockets getting different names and counts changing live on connect and disconnect. One checks that the stats go only to owners and the same cookie keeps its name.

  • Changed existing test: I changed one line of the existing /admin lobby test, from alice.next(drivingIs("bob")) to alice.first(...), because the state message could arrive before the wait started.

Closes #148

3 earlier comments
commented

Adds a live "who is here" count, list and per-person names to the page, and I've pushed the branch. The full bun test and the type check passed here before the push. The forge's own check hasn't reported yet, and I haven't looked at the page in a browser.

  • Presence strip: the top bar shows "12 here · 4 signed in · 8 watching", streamed over the existing /live socket and updated as people connect, disconnect or the turn changes. Tapping it opens the list. The list is a lazily loaded src/ui/here.js, because the first-visit page was right at its 50 KB gzip limit.
  • Names: each anonymous viewer gets a colour plus a nature noun ("Teal Heron") and a matching dot. The curated lists (16 colours, 24 nouns) are in src/presence.ts. The pair comes from a hash of the browser's arm_here cookie, so it stays the same for that browser. If someone present already has it, the next free pair is used, so two people never share a name at once. Several tabs from one browser count as one person.
  • Roles: each name shows driving, in the queue or watching, and the driver is bold and listed first. The public message carries no ids and no IPs.
  • Admin: owners also receive a presence-stats message with the peak today and arrivals per hour for the last 24 hours. The page prints these as text in the same panel. They are kept in memory only, so a restart clears them.
  • Cookie: the arm_here cookie is set when the page loads, in relay.ts. Bun's ws shim doesn't emit the headers event, so setting it at the socket handshake didn't work. A socket with no cookie is counted by a hash of its address and browser, which is never shown.
  • Tests:

- src/presence.test.ts covers names coming only from the lists, no two the same at once and the same name for the same browser. It also covers counts, roles, ordering and the stats. - Two tests in src/lobby.test.ts cover two anonymous sockets getting different names and counts changing live on connect and disconnect. One checks that the stats go only to owners and the same cookie keeps its name.

  • Changed existing test: I changed one line of the existing /admin lobby test, from alice.next(drivingIs("bob")) to alice.first(...), because the state message could arrive before the wait started.
commented

The check failed because the check block in forge.json had only resource limits and no command to run. I added one and pushed, but I don't know yet whether the forge accepts it.

I guessed the key name: run, mirroring app.run. I couldn't find the schema documented anywhere I could reach. If the forge wants a different key, the next failure will say so.

The command is bun install --cwd Software/so101 --frozen-lockfile && cd Software/so101 && bun x tsc --noEmit && bun test. It installs, type-checks, then runs the tests. I haven't run it as one line, but the type check and bun test passed here before the first push.

The earlier presence work is unchanged.

commented

I merged main into the branch and pushed it. The type check and all 397 tests pass.

The only conflict was in forge.json. main removed the check block, because a check section needs check.run and limits alone broke every arm check. That also covers the fix I made earlier, which added a check.run of my own. I took main's version, so forge.json now matches main and the "no check declared" fix is gone with it. The "Who is here" changes are unchanged.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs