Skip to content

Conversation

@ao-anam
Copy link
Contributor

@ao-anam ao-anam commented Sep 15, 2025

Summary by cubic

Request microphone permission asynchronously so WebRTC connection setup is non-blocking. Audio is attached after permission is granted, with clear permission state and events for UI.

  • New Features

    • Request mic access in the background; connection proceeds without waiting.
    • Added AudioPermissionState and InputAudioState.permissionState to track not_requested, pending, granted, denied.
    • New events: MIC_PERMISSION_PENDING, MIC_PERMISSION_GRANTED, MIC_PERMISSION_DENIED.
    • On grant, attach audio via replaceTrack (fallback to addTrack) and emit INPUT_AUDIO_STREAM_STARTED.
    • If a user-provided MediaStream is passed, we only validate it; we no longer block to request mic access during setup.
  • Migration

    • Listen for MIC_PERMISSION_* events to prompt users and handle errors.
    • Do not assume mic access is available at connect time; audio may attach later.
    • Import and use AudioPermissionState if you consume permission state.
    • To bypass permission flow, continue passing a pre-captured MediaStream.

Copilot AI review requested due to automatic review settings September 15, 2025 16:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds asynchronous microphone permission handling to the streaming client, allowing microphone access requests to be made in parallel with connection setup rather than blocking the initial connection.

  • Introduces a new AudioPermissionState enum to track microphone permission status
  • Adds new events for microphone permission lifecycle (MIC_PERMISSION_PENDING, MIC_PERMISSION_GRANTED, MIC_PERMISSION_DENIED)
  • Refactors audio setup to use replaceTrack API when permissions are granted asynchronously

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types/index.ts Exports the new AudioPermissionState enum
src/types/events/public/EventCallbacks.ts Adds callback types for new microphone permission events
src/types/events/public/AnamEvent.ts Defines the new microphone permission event constants
src/types/InputAudioState.ts Adds AudioPermissionState enum and updates InputAudioState interface
src/modules/StreamingClient.ts Implements async microphone permission handling and audio track replacement
src/AnamClient.ts Updates input audio state initialization to include permission state
package.json Updates version number for this feature branch

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ao-anam ao-anam force-pushed the feat/non-blocking-mic branch 2 times, most recently from 42a6628 to 7bc9304 Compare September 15, 2025 17:01
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

@ao-anam ao-anam force-pushed the feat/non-blocking-mic branch from 7bc9304 to 624657c Compare October 15, 2025 09:07
BREAKING CHANGE: session start no longer awaits mic permission.
This will speed up start time connection for first time users,
but may break existing flows that rely on the previously blocking
behaviour.
@ao-anam ao-anam force-pushed the feat/non-blocking-mic branch from 624657c to 889a56d Compare October 15, 2025 09:13
@ao-anam ao-anam merged commit 4558ec8 into main Oct 15, 2025
3 checks passed
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.

3 participants