/ concept-collection / commonroom
Sign in
concept-collection / commonroom
commonroom / CLAUDE.md
7.6 KBPreviewCodeBlameHistoryRaw

CLAUDE.md#

Tips for future agents working in this repo. It combines the p2p techniques of the sibling projects commonview (auto-connecting mesh) and commoncall (WebRTC media, settings, screen share) — read those first; this file only covers what is different here.

Architecture#

src/p2p/
  identity.ts  schnorr keypair; pubkey hex = peer ID     — ported from commoncall
  nostr.ts     minimal relay client + topic scheme        — ported (roomTopic takes a room ID)
  peer.ts      WebRTC wrapper: media + control channel    — ported (replaceTrack generalized to audio|video)
  settings.ts  shared ROOM settings, quality presets      — default quality is 'medium', not 'auto'
  turn.ts      optional TURN: build-time endpoint, credential fetch, sanitizers
  network.ts   the heart: rooms, presence, mesh, media, settings sync, relay sharing
src/App.tsx    landing form (light) + in-room view (dark), video grid with
               click-to-spotlight (gallery ↔ one big tile + filmstrip; Esc or
               click again to return), control bar, chat panel (side panel on
               wide screens, overlay ≤700px, unread badge)
worker/        Cloudflare Worker that mints TURN credentials — deployed
               separately (wrangler), NOT part of `npm run build`

Key design decisions#

Testing#

npm run dev, then open the room in two browsers (identity is per-browser-profile via localStorage, so two tabs in one profile are the SAME peer — use a private window or second browser). npm run build type-checks (tsc -b) and bundles. Let the user test multi-party media in real browsers; don't try to automate camera/mic flows.

The Worker CAN be tested without a browser: cd worker && cp .dev.vars.example .dev.vars && npm run dev, then curl it. With the example values, token checks work (goodtoken passes, anything else 401s) and the upstream call 404s, which surfaces as a 502 — enough to cover auth, CORS and method handling. cd worker && npx tsc --noEmit type-checks it; the root tsc -b does not (it only includes src). The sanitizers in turn.ts are pure and testable under node via npx esbuild src/p2p/turn.ts --format=esm --define:import.meta.env='{}'. Whether a relay is actually USED can only be seen in a real browser (chrome://webrtc-internals, candidate pair type relay).

moveopenescclose