Repository navigation
feat(packages): surface explicit mic intent so built-in controls can publish audio-only - #35
Conversation
…publish audio-only Declare micActive on MediaCaptureSourceCapability and the capture-source store slice (with a toggleMic action), and count the mic toward the aggregate capture state only under explicit intent — an implied mic acquired as a side effect of video intent must not enable publish controls the video pipelines no longer justify. Older media generations without the property keep working: the slice defaults the intent to false and toggleMic refuses to write an inert slot.
📦 Bundle Size Report🎨 @videojs/html — 67 small size changes
Presets (7)
Media (17)
Players (6)
Skins (32)
UI Components (52)
⚛️ @videojs/react — 68 small size changes
Presets (7)
Media (19)
Players (5)
Skins (29)
UI Components (47)
🧩 @videojs/core — 2 small size changes
Entries (77)
🏷️ @videojs/element — no changesEntries (2)
📦 @videojs/store — no changesEntries (3)
🔧 @videojs/utils — no changesEntries (13)
📦 @videojs/jsx — no changesEntries (3)
📦 @videojs/media — no changesEntries (15)
📦 @videojs/spf — no changesEntries (13)
ℹ️ How to interpretEach entry is independently bundled, minified, and brotli-compressed. Initial size includes its static import graph; lazy dynamic chunks are reported separately. Entries are not additive because their dependency graphs overlap. Preset rows represent realistic combined bundles. Changes of 300 B or less across initial, lazy, and total size are collapsed, not discarded. Run |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff234b2d25
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| * a beat. | ||
| */ | ||
| export function aggregateCaptureState(source: AggregatableCaptureSource): MediaCaptureState { | ||
| const micState = source.micActive ? source.micState : 'idle'; |
There was a problem hiding this comment.
Preserve mic terminal states after intent consumption
When an audio-only microphone request is denied or its track ends, runCaptureAcquisition sets micState to denied/ended and immediately consumes micActive by setting it to false. This conditional therefore replaces the terminal state with idle, so CapturePlaceholder never shows the permission-denied guidance for a failed mic-only request and instead exposes the camera-oriented enable-devices CTA. Track whether the mic state originated from explicit intent, or otherwise preserve terminal mic states after the intent is consumed rather than gating every state on the current boolean.
Useful? React with 👍 / 👎.
The acquire pipeline consumes micActive on denied/ended while parking micState there so UIs can say why capture stopped — gating the whole mic contribution on the intent erased that residue, so a mic-only permission denial showed the enable-devices CTA instead of the blocked guidance. Only the mic's in-flight states stay gated on explicit intent; terminal states can never enable a publish control anyway. Flagged by the Codex CLI review.
…eline The widened MediaCaptureSourceCapability made FakePublishMedia's implements clause fail (TS2420). Run micActive as a third, audio-only pipeline mirroring the camera's shape — token-cancelled acquisition, intent consumption on denied/ended, device re-keying, mute wiring — and accept an explicit active mic as the publish() precondition, so ?fake mode can drive a mic-only session. Flagged by the Codex CLI review.
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…ance A terminal micState does not prove the mic was explicitly requested: the pipeline also parks denied/ended for a video-implied mic, so counting every terminal residue let a camera-granted, mic-denied page claim blocked permissions after the camera was released. The captureSource feature now latches micExplicit — set while micActive reads true, carried across intent consumption only while the state stays parked terminal, reset when a new implied lifecycle starts — and the aggregation counts the mic solely on that claim. Flagged by the Codex CLI review.
A mic-only session sampled ~30 fps and 2.5 Mbps of nonexistent video; the stats contract uses NaN for absent metrics. Derive each sample from the live streams so audio-only sessions report NaN video metrics and a video source joining mid-session starts counting. Flagged by the Codex CLI review.
There was a problem hiding this comment.
1 issue found across 17 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/react/src/ui/publish-button/tests/publish-button.test.tsx">
<violation number="1" location="packages/react/src/ui/publish-button/tests/publish-button.test.tsx:27">
P2: The "stays disabled on an implied mic without explicit intent" test can never represent an implied mic, because the mock couples `micActive: micExplicit`, so an implied mic (mic active but not explicitly requested) is unconstructable. `aggregateCaptureState` gates solely on `micExplicit`/`micState` and ignores `micActive`, so this test currently passes whether the rule keys on `micExplicit` or regresses to `micActive`: with `micActive` forced equal to `micExplicit`, both branches stay disabled. It therefore provides no regression protection for the implied-mic scenario the test name claims to cover. Decouple the fields so the implied case (micActive true, micExplicit false) can actually be set up.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
| // `captureSource` feature slice | ||
| cameraActive: captureState === 'active', | ||
| screenShareActive: false, | ||
| micActive: micExplicit, |
There was a problem hiding this comment.
P2: The "stays disabled on an implied mic without explicit intent" test can never represent an implied mic, because the mock couples micActive: micExplicit, so an implied mic (mic active but not explicitly requested) is unconstructable. aggregateCaptureState gates solely on micExplicit/micState and ignores micActive, so this test currently passes whether the rule keys on micExplicit or regresses to micActive: with micActive forced equal to micExplicit, both branches stay disabled. It therefore provides no regression protection for the implied-mic scenario the test name claims to cover. Decouple the fields so the implied case (micActive true, micExplicit false) can actually be set up.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/react/src/ui/publish-button/tests/publish-button.test.tsx, line 27:
<comment>The "stays disabled on an implied mic without explicit intent" test can never represent an implied mic, because the mock couples `micActive: micExplicit`, so an implied mic (mic active but not explicitly requested) is unconstructable. `aggregateCaptureState` gates solely on `micExplicit`/`micState` and ignores `micActive`, so this test currently passes whether the rule keys on `micExplicit` or regresses to `micActive`: with `micActive` forced equal to `micExplicit`, both branches stay disabled. It therefore provides no regression protection for the implied-mic scenario the test name claims to cover. Decouple the fields so the implied case (micActive true, micExplicit false) can actually be set up.</comment>
<file context>
@@ -24,7 +24,8 @@ function createWrapper({
cameraActive: captureState === 'active',
screenShareActive: false,
- micActive,
+ micActive: micExplicit,
+ micExplicit,
cameraState: captureState,
</file context>
There was a problem hiding this comment.
Partly disagree on the reasoning, agree on the remedy. An implied mic has micActive false (video intent drives the pipeline; the slot was never written), so the implied scenario was constructible — micActive true + micExplicit false is unreachable by the store latch. But coupling the knobs did misrepresent other states (a consumed-intent denial showed micActive true) and weakened the fixtures. Fixed in 316343d: micActive and micExplicit are independent parameters with honest per-scenario values in the html and react publish-button and capture-placeholder fixtures.
isMediaCaptureSourceCapable deliberately admits hosts from before the audio-only generation, so a required micActive made that public guard unsound: narrowed code could assign the slot on a legacy host and create an inert expando instead of starting capture. Declare the generational truth in the type — writers check presence, as the store feature's toggleMic already does — and document the latch's attach-boundary limitation. Flagged by the Codex CLI review.
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
Ran the Codex CLI review against the branch (three rounds until clean). Fixes landed for each verified finding:
One finding intentionally deferred: an explicit mic attempt whose terminal outcome lands before the store feature attaches (React mount + persisted instant denial) reads as implied on the first sync, showing the CTA instead of denied guidance until the user retries. Exact provenance needs the host to persist it (engine/adapter-level Final Codex verdict: "The explicit microphone intent is consistently propagated through the media contract, store, capture aggregation, and HTML/React publish controls. … no actionable regressions were identified." 🤖 Generated with Claude Code |
Merged video audio can hold the derived micState at 'active' across explicit mic pipeline transitions, so the unconditional dispatches fired capturestatechange with nothing changed. Route every mic mutation through a before/after guard, mirroring #setCaptureState's dedupe for the video pipelines. Flagged by Cubic on the PR.
…y predicate case Coupling micActive to micExplicit in the publish-button and placeholder fixtures made states like a consumed-intent denial unrepresentable; give each knob its own value per scenario. The new capture predicate test also duplicated the released-capture case's input — exercise the actual in-between generation instead (mic lifecycle present, intent slot absent). Flagged by Cubic on the PR.
Closes #32
Summary
The engine and adapter learned audio-only capture in #31, but the stock publish UI couldn't drive it: the media contract had no mic intent slot, the capture-source store slice didn't expose one, and the capture aggregation only counted the video pipelines — so a voice-only page's publish button never enabled. This surfaces
micActiveend to end, with the mic counting toward capture aggregation only under explicit intent.Changes
MediaCaptureSourceCapabilitydeclaresmicActivewith the same intent-consumption semantics as the video intents; the "mic has no intent slot" contract prose is updated to match.captureSourcestore feature exposes the mic intent (micActivestate +toggleMic()action). Older media generations without the property stay coherent: the slice defaults the intent tofalse, andtoggleMic()refuses to write an inert expando that the next sync would read back as real intent.aggregateCaptureStatenow takes the capture slice and counts the mic only whenmicActiveis set — the load-bearing rule lives in one place. An implied mic (video-driven, e.g. one that outlives a dismissed screen picker by a beat) never enables capture-gated controls on its own.PublishButtonenables and starts/stops the session;EnableDevicesButtonandCapturePlaceholderreport the mic-only capture state coherently. HTML and React behave identically (parity tests).Testing
pnpm -F @videojs/media test(613),pnpm -F @videojs/core test(1602),pnpm -F @videojs/html test(406),pnpm -F @videojs/react test(467),pnpm -F @videojs/spf test(all files) — greenpnpm typecheckclean after a full declarations rebuild🤖 Generated with Claude Code
Summary by cubic
Enables audio-only publishing by adding an explicit mic intent and provenance. Previously publish required an active camera or screen; now an explicitly requested mic can start a session, while a video‑implied mic never enables controls or shows permission errors.
Adds optional
micActivetoMediaCaptureSourceCapability. The sandboxFakePublishMediaimplements a real audio‑only pipeline (token‑canceled acquisition, consume intent on denied/ended, device re‑keying, mute wiring), accepts an explicit active mic as apublish()precondition, reports source‑aware stats (NaN for absent metrics), and only dispatches mic capture state events on real changes.The
captureSourcestore exposestoggleMic()and latchesmicExplicitacross intent consumption on terminal outcomes; it resets when a new implied lifecycle starts. Legacy hosts withoutmicActiveremain compatible; the intent defaults tofalseandtoggleMic()no‑ops.aggregateCaptureState(media)replaces the two‑arg form and counts the mic only whenmicExplicitis true; terminal mic states keep counting after intent consumption. An implied mic never surfacesactiveordeniedon its own.PublishButton,EnableDevicesButton, and capture placeholders handle mic‑only across@videojs/core,@videojs/html, and@videojs/react. Elements passmicStateandmicExplicitinto the core; explicit mic enables Publish, implied mic does not.Migration
micActiveand emitcapturesourcechangewhen it changes.aggregateCaptureStateto pass the capture source object. If gating publish outside the built‑ins, enable on mic only whenmicExplicitis true andmicStateisactive; surface blocks withmicExplicit && (micState === 'denied' || micState === 'ended').Written for commit 316343d. Summary will update on new commits.