feat(client): extract ChromelessSession — the answerer machine, importable without the demo page (Track 5) #47
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/client-session-split"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
client/main.tswas 754 lines of which ~350 were the reusable answerer state machine — exported nowhere. A third party integrating chromeless had to re-derive it by reading the demo page (the original Track 5 finding).client/src/session.ts—ChromelessSession, DOM-free: signaling dial (token → ICE → WS), offer/answer/ICE pump, reconnect with per-generation pc rebuild, stats sampling+emission, pre-call probe, codec-outcome classification, bye/teardown. Event surface (on()/detach — same contract as StatsSampler/ReconnectingWebSocket):log status track dataChannel pcCreated stats codecOutcome signaling+ 4 pc-state mirrors +closed. Injection seams (socketCtor/pcFactory/fetchToken/fetchIce/probe) mirror reconnect.ts's existing pattern.client/main.ts— now the 349-line demo it always claimed to be: DOM, log pane, video element, input/cursor/file-upload wiring, T81 passthrough button. Per-pc-generation DOM attachments drop onpcCreated/closed— preserving the §T10 rule that passthrough never survives a rebuild without a fresh click.Load-bearing behavior preserved verbatim: hello frame on every open, probe_result after hello, no pc teardown on underlyingClose, null-ICE end-of-candidates, echo guard, codec_fallback stats event, bye-then-close teardown ordering.
Integration recipe (the thing this PR makes possible):
Verification: 10 new vitest cases drive the machine through fake socket + fake pc (dial shape, hello, offer→answer with the codec munge asserted on the wire, stats internalization vs forwarding, ICE relay + null marker, echo guard, bye teardown incl. idempotent disconnect, reconnect rebuild with fresh hello, status transitions, double-connect throw).
tsc --noEmitclean · vitest 217/217 (was 207) · esbuild bundle OK.🤖 Generated with Claude Code