fix: Bug - User automatically leaves voice after short period of time
All checks were successful
Queue Release Build / prepare (push) Successful in 22s
Deploy Web Apps / deploy (push) Successful in 7m32s
Queue Release Build / build-windows (push) Successful in 27m41s
Queue Release Build / build-linux (push) Successful in 44m56s
Queue Release Build / build-android (push) Successful in 18m52s
Queue Release Build / finalize (push) Successful in 21s
All checks were successful
Queue Release Build / prepare (push) Successful in 22s
Deploy Web Apps / deploy (push) Successful in 7m32s
Queue Release Build / build-windows (push) Successful in 27m41s
Queue Release Build / build-linux (push) Successful in 44m56s
Queue Release Build / build-android (push) Successful in 18m52s
Queue Release Build / finalize (push) Successful in 21s
Ignore stale P2P self-disconnect voice-state echoes while this client actively owns voice, refresh noise-reduction input on re-join, and repair dual-signal E2E harness expectations. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import type { VoiceState } from '../../../../shared-kernel';
|
||||
import {
|
||||
isLocalVoiceOwner,
|
||||
isVoiceOnAnotherClient,
|
||||
shouldApplyRemoteVoiceStateToCurrentUser,
|
||||
shouldTransmitVoice
|
||||
} from './client-voice-session.rules';
|
||||
|
||||
@@ -51,4 +52,54 @@ describe('client-voice-session.rules', () => {
|
||||
|
||||
expect(shouldTransmitVoice(voiceState, localClientInstanceId)).toBe(true);
|
||||
});
|
||||
|
||||
it('ignores stale self disconnect updates while this client actively owns voice', () => {
|
||||
const voiceState: VoiceState = {
|
||||
isConnected: true,
|
||||
isMuted: false,
|
||||
isDeafened: false,
|
||||
isSpeaking: false,
|
||||
roomId: 'vc-general',
|
||||
serverId: 'server-1',
|
||||
clientInstanceId: localClientInstanceId
|
||||
};
|
||||
|
||||
expect(shouldApplyRemoteVoiceStateToCurrentUser(
|
||||
voiceState,
|
||||
{ isConnected: false },
|
||||
localClientInstanceId,
|
||||
true
|
||||
)).toBe(false);
|
||||
});
|
||||
|
||||
it('applies self disconnect updates when this client is not actively transmitting', () => {
|
||||
expect(shouldApplyRemoteVoiceStateToCurrentUser(
|
||||
{
|
||||
isConnected: true,
|
||||
isMuted: false,
|
||||
isDeafened: false,
|
||||
isSpeaking: false,
|
||||
clientInstanceId: localClientInstanceId
|
||||
},
|
||||
{ isConnected: false },
|
||||
localClientInstanceId,
|
||||
false
|
||||
)).toBe(true);
|
||||
});
|
||||
|
||||
it('ignores self disconnect echoes during the join race before clientInstanceId is stored', () => {
|
||||
expect(shouldApplyRemoteVoiceStateToCurrentUser(
|
||||
{
|
||||
isConnected: true,
|
||||
isMuted: false,
|
||||
isDeafened: false,
|
||||
isSpeaking: false,
|
||||
roomId: 'vc-general',
|
||||
serverId: 'server-1'
|
||||
},
|
||||
{ isConnected: false },
|
||||
localClientInstanceId,
|
||||
true
|
||||
)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,3 +32,29 @@ export function shouldTransmitVoice(
|
||||
|
||||
return voiceState.clientInstanceId === clientInstanceId;
|
||||
}
|
||||
|
||||
/** Ignore stale P2P disconnect echoes for the current user while this client actively owns voice. */
|
||||
export function shouldApplyRemoteVoiceStateToCurrentUser(
|
||||
currentVoiceState: Pick<VoiceState, 'isConnected' | 'clientInstanceId'> | null | undefined,
|
||||
incoming: Partial<VoiceState>,
|
||||
localClientInstanceId: string,
|
||||
isLocallyVoiceActive: boolean
|
||||
): boolean {
|
||||
if (incoming.isConnected !== false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isLocallyVoiceActive) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isLocalVoiceOwner(currentVoiceState, localClientInstanceId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!currentVoiceState?.clientInstanceId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user