Skip to content

Route moq-boy status and command tracks through moq-json#1778

Open
kixelated wants to merge 1 commit into
mainfrom
claude/moq-boy-moq-json-20wsze
Open

Route moq-boy status and command tracks through moq-json#1778
kixelated wants to merge 1 commit into
mainfrom
claude/moq-boy-moq-json-20wsze

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

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.

  • Status track (Rust publishes → JS consumes): StatusPublisher now wraps moq_json::Producer<Status>, dropping the manual serialize / last_json dedupe / append_group logic. The JS viewer reads it with Json.Consumer, reusing the existing GameStatusSchema for validation instead of a separate safeParse.
  • Command track (JS publishes → Rust consumes): each viewer's command track is written via a per-track Json.Producer and read with moq_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_json is no longer a direct dependency of moq-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-boy and cargo clippy -p moq-boy clean
  • bun run check (tsc) passes for js/moq-boy
  • Biome clean on js/moq-boy/src/index.ts
  • Manual: run moq-boy + web viewer, confirm status (buttons/latency/stats) renders and button/reset input still controls the emulator

(Written by Claude)


Generated by Claude Code

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
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed36d6e9-0809-4b72-b8e9-25f249b7f7cb

📥 Commits

Reviewing files that changed from the base of the PR and between 36c9625 and 31fe90c.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • js/moq-boy/package.json
  • js/moq-boy/src/index.ts
  • rs/moq-boy/Cargo.toml
  • rs/moq-boy/src/input.rs
  • rs/moq-boy/src/status.rs

Walkthrough

Both the Rust (rs/moq-boy) and JavaScript (js/moq-boy) implementations of moq-boy are refactored to use a shared moq-json / @moq/json library for JSON serialization and deserialization. The respective manifests add the new dependency (and remove serde_json from the Rust side). In Rust, StatusPublisher now holds a moq_json::Producer<Status> and calls producer.update(status) directly, while handle_viewer_commands uses a moq_json::Consumer<RawCommand> stream instead of manual frame/UTF-8/serde parsing. In TypeScript, #runStatus switches to Json.Consumer with schema validation and #runCommandTrack uses Json.Producer for emitting command updates.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: routing moq-boy status and command tracks through the moq-json library instead of hand-rolled JSON handling.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, detailing the refactoring of JSON handling for both status and command tracks using moq-json.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/moq-boy-moq-json-20wsze

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

2 participants