Skip to content

FCE-3852 Publish device toggled on while joining - #612

Merged
Magmusacy merged 3 commits into
mainfrom
fix/publish-device-toggled-while-joining
Sep 18, 2026
Merged

Magmusacy merged 3 commits into
mainfrom
fix/publish-device-toggled-while-joining

Conversation

@Magmusacy

@Magmusacy Magmusacy commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Description

A device turned on with toggleMicrophone() / toggleCamera() while joinRoom() is in progress is now published once the peer joins.

  • usePeerStatus also returns getLatestPeerStatus(), read from a ref updated in the client event handlers (ahead of the re-render).
  • toggleDevice re-reads the published track id and the latest peer status after startDevice() resolves, then publishes or resumes the track.
  • Joining with a device already running is unchanged: the joined handler still publishes it, once.

Motivation and Context

If joined fired while getUserMedia was pending, nothing published the device:

  • the joined handler skipped it, because the device did not exist yet;
  • toggleDevice still saw "connecting" and no track id, both read before the await.

The device ran locally (isMicrophoneOn: true), but the room got no track.

Checked:

  • toggleDuringJoin.spec.ts: 3 tests fail before the fix, all 6 pass after.
  • On an Android emulator against a sandbox room: before, only video was published; after, audio was published once the microphone started, then video.

Documentation impact

  • Documentation update required
  • Documentation updated in another PR
  • No documentation update required

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)

@Magmusacy Magmusacy changed the title Publish device toggled on while joining FCE-3852 Publish device toggled on while joining Sep 18, 2026
@linear

linear Bot commented Sep 18, 2026

Copy link
Copy Markdown

FCE-3852

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Two new tests fail strict TypeScript definite-assignment checking.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes device publication when camera or microphone activation completes during room joining.

Changes:

  • Adds synchronous access to the latest peer status.
  • Rechecks publication state after device startup.
  • Adds race-condition regression tests.
File summaries
File Description
packages/react-client/src/tests/toggleDuringJoin.spec.ts Tests device toggling across join timing scenarios.
packages/react-client/src/hooks/internal/useTrackManager.ts Publishes or resumes tracks using current state.
packages/react-client/src/hooks/internal/usePeerStatus.ts Tracks status in a ref for immediate reads.
packages/react-client/src/FishjamProvider.tsx Supplies the status getter to track managers.
Review details

Suppressed comments (1)

packages/react-client/src/tests/toggleDuringJoin.spec.ts:50

  • This second callback-assigned promise has the same strict-mode definite-assignment error when it is later awaited. Mark it as definitely assigned (or initialize it) so tsc --noEmit succeeds.
    let toggle: Promise<unknown>;
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/react-client/src/tests/toggleDuringJoin.spec.ts
@Magmusacy
Magmusacy requested a review from czerwiukk September 18, 2026 14:55
@czerwiukk czerwiukk self-assigned this Sep 18, 2026
@Magmusacy
Magmusacy merged commit 76400ee into main Sep 18, 2026
2 checks passed
@Magmusacy
Magmusacy deleted the fix/publish-device-toggled-while-joining branch September 18, 2026 15:02
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