Skip to content

fix(react-client): clear VAD outline on peer reconnect#523

Merged
MiloszFilimowski merged 2 commits into
fishjam-cloud:mainfrom
Critteros:fix_use_vad_stuck_outline_on_reconnect
Apr 24, 2026
Merged

fix(react-client): clear VAD outline on peer reconnect#523
MiloszFilimowski merged 2 commits into
fishjam-cloud:mainfrom
Critteros:fix_use_vad_stuck_outline_on_reconnect

Conversation

@Critteros

Copy link
Copy Markdown
Contributor

Description

Rewrite useVAD to derive each peer's speaking boolean directly from the current microphone tracks instead of a per-trackId cache. voiceActivityChanged now only drives a re-render via a version counter.

This is a crude fix scoped to useVAD. The underlying invariant — that a track's last observed vadStatus is silence when it disappears — is still not enforced at the webrtc-client layer, so other consumers of FishjamTrackContext.vadStatus could hit the same class of bug.

Motivation and Context

When a peer disconnected mid-speech, their track was removed without a final silence vadNotification, leaving a stale oldTrackId -> "speech" entry in useVAD's cache. On reconnect the new track wrote under a new trackId, so the OR-reduce Object.values(tracks).some(v => v === "speech") kept returning true and the talking-indicator outline stayed stuck on for every other viewer. Deriving from the live track list auto-prunes vanished tracks, so there is no state left to go stale.

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)

useVAD cached vadStatus per trackId and never dropped entries for
tracks that disappeared. A peer disconnecting mid-speech left an
oldTrackId -> "speech" entry behind; after reconnect the OR-reduce
over the map kept returning true regardless of the new track's
status. Derive the per-peer boolean directly from current mic
tracks; use voiceActivityChanged only as a re-render trigger.
@MiloszFilimowski MiloszFilimowski merged commit 8569127 into fishjam-cloud:main Apr 24, 2026
3 of 4 checks passed

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.

Pull request overview

Fixes a stale “speaking” indicator after a peer disconnects mid-speech and reconnects, by making useVAD derive each peer’s speaking state from the current live microphone track list rather than a cached per-trackId map.

Changes:

  • Remove the per-trackId VAD cache/state and compute speaking booleans directly from the current mic track’s vadStatus.
  • Use a useReducer version counter to force re-renders on voiceActivityChanged events (since the track context is mutated in place).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MiloszFilimowski

Copy link
Copy Markdown
Collaborator

Fixes: FCE-3199

@Critteros Critteros deleted the fix_use_vad_stuck_outline_on_reconnect branch May 8, 2026 09:28
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