Route moq-boy status and command tracks through moq-json#1778
Conversation
Replace the hand-rolled JSON publishing in moq-boy with the moq-json / @moq/json snapshot+delta helper, matching how the hang catalog is published. - Status track (Rust publishes, JS consumes): StatusPublisher now wraps moq_json::Producer<Status> with deltas enabled, dropping the manual serialize/dedupe/append-group logic. JS reads it via Json.Consumer with the existing GameStatusSchema for validation. - Command track (JS publishes, Rust consumes): the viewer command track is written via a per-track Json.Producer and read with moq_json::Consumer<RawCommand>, so snapshots and merge-patch deltas are reconstructed into a full command before dispatch. The status track gains merge-patch deltas (its per-frame stats and latency change incrementally), while unchanged values are still skipped. serde_json is no longer a direct dependency of moq-boy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014YHhHt7bc3hqfiCMNB3gNE
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (5)
WalkthroughBoth the Rust ( 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
moq-boy hand-rolled its JSON tracks: the Rust side serialized the status struct, deduped against the last string, and appended a one-frame group per change; the JS side read raw frames and wrote raw command JSON. This PR routes both JSON tracks through the existing snapshot/delta helper (
moq-json/@moq/json), the same one the hang catalog already uses.StatusPublishernow wrapsmoq_json::Producer<Status>, dropping the manual serialize /last_jsondedupe /append_grouplogic. The JS viewer reads it withJson.Consumer, reusing the existingGameStatusSchemafor validation instead of a separatesafeParse.Json.Producerand read withmoq_json::Consumer<RawCommand>, so snapshots and RFC 7396 merge-patch deltas are reconstructed into a full command before dispatch.The status track now gets merge-patch deltas (delta ratio left at the default
8): its per-frame stats and latency change incrementally, so deltas are a clear win, while unchanged values are still skipped. Malformed-command and invalid-status handling stays lenient (warn and continue); a real track error still ends the stream.serde_jsonis no longer a direct dependency ofmoq-boy.Both ends of each track ship together, so the wire-format shift (snapshot-per-group → snapshot+deltas) is internal to moq-boy.
Test plan
cargo build -p moq-boyandcargo clippy -p moq-boycleanbun run check(tsc) passes forjs/moq-boyjs/moq-boy/src/index.ts(Written by Claude)
Generated by Claude Code