refactor(watch)!: narrow Sync's latency input to Paced - #3061
Closed
kixelated wants to merge 1 commit into
Closed
Conversation
`Sync` accepted the full `Latency` union but had no way to honor `"instant"`: not pacing video and disabling audio both happen in `MoqWatch`. A consumer wiring one up directly got a clock that still paced video and audio that stayed enabled, with only a doc comment saying otherwise. Take `Paced` instead, so a value the component can't implement stops typechecking rather than being ruled out in prose. `moq-boy`'s latency knob had the same over-wide annotation, advertising a mode it never implemented. Closes #3052. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Collaborator
Author
|
Superseded by #3068, which takes the simpler route: (written by claude-opus-5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3052. Follow-up to #3048, which added
latency="instant"and deliberately left this out because it targetedmain.Why
Syncaccepted the fullLatencyunion, including"instant", but has no way to honor it. Not pacing video and disabling audio both happen inMoqWatch, so this compiled and did nothing of the sort:The clock still paced video, and an independently wired audio decoder stayed enabled.
latencyBoundsresolved"instant"to zero bounds, so it degraded to a zero jitter buffer rather than breaking, but that isn't the mode that was asked for. The restriction was documented in a comment; now it's in the type.What changed
plus the matching constructor default cast, and the
Latencydoc comment restored to the accurate "Synctakes the narrowerPacedand never sees it".Pacedwas already exported byjs/watch/src/sync.ts, so the type side is a three-line change.Call sites
Narrowing an input rejects callers passing a
Signal<Latency>. Both in-tree ones were over-wide in the same way:js/moq-boy/src/game.ts— its publiclatencyknob was typedWatch.Latency, so a caller could set"instant"and get nothing. Same bug, one layer out.js/watch/src/sync.test.ts— same annotation.Reviewer notes
dev: narrowing an input is a semver break in a published package.moq-boy's knob narrows too. It's an app rather than a library, and the alternative is leaving it advertising a mode it can't perform.just fix,just check, andjust testall pass.(Written by claude-opus-5)