Skip to content

Maintenance sweep: docs, logging, production error fixes - #1

Open
Justrada wants to merge 1 commit into
mainfrom
maintenance-sweep
Open

Maintenance sweep: docs, logging, production error fixes#1
Justrada wants to merge 1 commit into
mainfrom
maintenance-sweep

Conversation

@Justrada

Copy link
Copy Markdown
Owner

One-time parallelized maintenance sweep. Three concerns were investigated concurrently by separate sub-agents (documentation, logging coverage, production error audit); the resulting changes are consolidated here into a single branch.

🐛 Production error fixes

No error-monitoring/log-aggregation is configured and the Vercel CLI here is unauthenticated, so this was a static production-error audit (a live partykit tail showed no traffic, as expected). The codebase was already hardened recently, so the list is short and not padded — these are real:

  1. crypto.randomUUID crash on non-secure/older clients (usePartySocket.ts) — crypto.randomUUID is undefined over plain HTTP and on older Safari; both the happy path and the catch fallback used it, so affected clients threw and hung on the connecting spinner. Added a guarded randomId() fallback. Production is HTTPS so the happy path holds today, but embedded webviews / HTTP proxies / old browsers were locked out.
  2. Suspicion event wiped submitted verbs (gameLogic.ts) — triggerSuspicionEvent re-initialized the event every time it fired; nudging suspicion at the cap (or another failure while the modal was open) reset verbs to [], losing what players already submitted. Made it idempotent. + regression test.
  3. Unhandled clipboard rejection (StreamSetup.tsx) — navigator.clipboard.writeText rejects (no focus / insecure / denied); the rejection was unhandled and the button falsely showed "Copied!". Now awaited; only flips on success.

📋 Logging coverage

Went from one console.error in the whole app to structured coverage of the critical paths:

  • party/index.ts: a log() helper emitting [CG room=XXXX] event key=value to the PartyKit log stream. Instruments connection lifecycle, joins (+rejects), phase transitions, all rolls (the roll.play line carries result/target/outcome/modifier/chaos/suspicion), suspicion trigger/resolve, item use/give, verb submit, every GM action, play-again, and both error paths (bad JSON + handler throw).
  • New requireGM() guard logs reject.notGM instead of ~15 silent returns.
  • usePartySocket.ts: client clog() for open/reconnect/close/socket-error (listener was missing entirely)/bad-message/server-error.
  • Deliberately not logged: render bodies, the VDO loudness handler, per-state messages — to avoid console spam.
  • Verified live: drove join/start-game through partykit dev and confirmed connect, join, reject.notGM, start-game, close.midgame all emit.

📚 Documentation

  • README: room codes are 4-char alphanumeric (not "4-letter"); documented the seat model (GM = seat 0, players 1–7) that drives video + overlay; noted there's no combined dev/deploy script and how to tail logs.
  • types.ts / gameLogic.ts: clarifying comments (chaos extremes + start value; suspicion-6 fires the verb event).

✅ Verification

  • next build ✅ · eslint src party ✅ (0 problems) · 23 logic assertions pass (incl. new idempotency test) · logging confirmed emitting on a live dev server.

⚠️ Needs your sign-off (not changed here)

  • Landing-page tagline says "for 3-8 Creatures of Chaos", but the code lets a game start with GM + 1 (i.e. 2–8 people). Left as-is because it's product copy — tell me the intended floor and I'll align code or copy.

🤖 Generated with Claude Code

Consolidates a parallel three-track maintenance pass (docs / logging /
error sweep) into one change set.

== Production error fixes (static audit; no log aggregation configured) ==
- usePartySocket: crypto.randomUUID is undefined in non-secure contexts
  (HTTP) and older Safari — both the happy path AND the catch fallback
  called it, so such clients threw and hung on the connecting spinner.
  Added a guarded randomId() fallback (mirrors partysocket's own guard).
- gameLogic.triggerSuspicionEvent is now idempotent: re-triggering while
  an event is active no longer wipes verbs players already submitted
  (could happen when the GM nudged suspicion at the cap). +regression test.
- StreamSetup.copy: navigator.clipboard.writeText rejection was unhandled
  (insecure context / no focus / denied) — produced an unhandled rejection
  and a false "Copied!". Now awaited; only flips on success.

== Logging coverage (was: 1 console.error total) ==
- party/index.ts: added a structured log() helper ([CG room=...] event
  key=value, to the PartyKit log stream) and instrumented connection
  lifecycle, joins (+rejects), phase transitions, all rolls (the
  roll.play line carries result/target/outcome/modifier/chaos/suspicion),
  suspicion trigger/resolve, item use/give, verb submit, every GM action,
  play-again, and both error paths (bad JSON, handler throw).
- Added requireGM() guard that logs reject.notGM instead of silently
  returning (replaces ~15 silent GM checks).
- usePartySocket: client clog() for open/reconnect/close/socket-error/
  bad-message/server-error. Added the previously-missing socket "error"
  listener. Nothing logged in render bodies or hot paths (VDO loudness,
  per-state messages) to avoid console spam.
- Verified live: drove join/start-game through partykit dev and confirmed
  the expected lines (connect, join, reject.notGM, start-game) emit.

== Documentation ==
- README: room codes are 4-char alphanumeric (not "4-letter"); documented
  the seat model (GM=seat 0, players 1-7) behind video+overlay; noted there
  is no combined dev/deploy script and how to tail server logs.
- types.ts / gameLogic.ts: clarifying comments (CHAOS extremes + start,
  suspicion-6 fires the verb event).

build + eslint clean; 23 logic assertions pass (incl. new idempotency test).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chaos-goblins Ready Ready Preview, Comment Jun 25, 2026 3:42am

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.

1 participant