feat(sia-video-source): add opt-in reader progress feature - #1202
Merged
Merged
Conversation
- forward worker read.retry milestones at debug severity - dispatch typed sia-worker-milestone-change for each LOG - derive reading, retrying, retry, read, and byte counts from milestones - reset progress state at every load boundary
This comment has been minimized.
This comment has been minimized.
- add workerLogEventName const and derive the catalog type from it - compare and emit milestone names through the catalog everywhere
…tone names - clear reading and retrying when the reader exhausts its budget - emit and compare milestone names through the workerLogEventName catalog - derive WORKER_LOG_EVENT_NAMES members from the typed catalog object
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
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.
Adds an opt-in
siaProgressFeatureplayer feature (root exportssiaProgressFeature,selectSiaProgress,SiaProgressStateand the Reacthook
useSiaProgress) that derives reader progress state from real workermilestones instead of log-text parsing.
The host now dispatches a typed
sia-worker-milestone-changeevent for everyaccepted worker
LOG, carrying the milestone name, severity, owningrequestId, scalar detail, and a monotonic sequence. Read windows, retries,
byte counts, and stalls update the state; every load boundary resets it.
Also forwards
read.retryat debug severity from the worker composition,which previously dropped the milestone. The feature is not part of
siaFeatures; apps compose it explicitly with[...videoFeatures, ...siaFeatures, siaProgressFeature].Pull Request Description
Summary
This PR adds an opt-in reader-progress feature for the Sia video source, letting apps surface loading/retrying indicators and byte-count telemetry driven by real worker milestones (structured events) instead of parsing log text.
The feature is deliberately not part of the default
siaFeatures— apps opt in by composingsiaProgressFeatureinto their player store and (for React consumers) using the newuseSiaProgress()hook. When the feature isn't configured, the selector returnsundefinedand the default player state stays lean.What Changed
1. New typed worker-milestone event (
sia-video-source.ts)SiaVideoSourcenow dispatches asia-worker-milestone-changeDOM event for every accepted workerLOGmessage, alongside the existing console forwarding (which is unchanged).SiaWorkerMilestoneDetail) carries the wire facts verbatim: milestonename, severitylevel, owningrequestId, scalardetailfields (defaulted to{}), plus a per-host monotonicsequencethat never resets across load boundaries.2. New optional player feature (
sia-progress-feature.ts)siaProgressFeature(a Video.js v10PlayerFeature) +selectSiaProgressselector derive a small semantic state from milestone events:reading/reads— opened read windows (viaread.window-start/read.window-complete)retrying/retries— retry attempts (viaread.retry)bytesRead— cumulative bytes reported by the worker (viabytes.read)last— provenance of the most recent derived milestone (name, position, requestId)read.stalledclears in-flight read/retry statesia-load-change { accepted: false }) resets the whole state; detach/reattach is handled via the feature signal.3. Milestone severity mapping (
session/sia-composition.ts)milestoneLevel()function.read.retrywas added as a debug-level forwarded milestone, ensuring a retry attempt is visible to the progress feature (and to debug-severity log consumers) without crowding the log cap.4. New React hook (
react/index.tsx)useSiaProgress()subscribes to the sameselectSiaProgressstate viausePlayer, so React and non-React consumers see identical state. It requires the player store to be built withsiaProgressFeature; it also requires the host logger atdebugfor reader milestones to be forwarded (a louder logger yields an inert state, no errors).5. Public exports (
index.ts)siaProgressFeature,selectSiaProgress,SiaProgressState,siaWorkerMilestoneChange, andSiaWorkerMilestoneDetailare now part of the package surface.6. Tests
sia-progress-feature.spec.ts).sia-worker-milestone.host.spec.ts).@videojs/react<Player>with a test-only harness (progress-react-harness.tsx).milestoneLevelmapping (log-wire.spec.ts).Known Issue (from code review)
sia-progress-feature.ts, theonMilestoneswitch handlesread.stalledandread.window-completebut has noread.errorcase. A terminal short-read/SDK error (which emitsread.error) would leavereading/retryingstuck attrue, since nothing clears the in-flight window on that path.