Skip to content

Commit ba40809

Browse files
review comment fixed
1 parent 2416897 commit ba40809

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

__tests__/html2/speechToSpeech/mute.unmute.html

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
Test: Mute/Unmute functionality for Speech-to-Speech
1717
1818
This test validates:
19-
1. Mute is allowed from all state except idle
20-
2. When muted during listening, chunks contain all zeros (silent audio)
21-
3. When unmuted, chunks contain real audio
22-
4. Mute resets to false when recording stops
23-
5. Stopping while muted does NOT re-acquire microphone (cleanup order test)
24-
6. Uses useVoiceRecordingMuted hook for mute/unmute control
19+
1. Mute is independent of voiceState - can be toggled anytime
20+
2. Starting recording while muted should reset and start recording always unmuted.
21+
3. When muted during listening, chunks contain all zeros (silent audio)
22+
4. When unmuted, chunks contain real audio
23+
5. Mute resets to false when recording stops
24+
6. Stopping while muted does NOT re-acquire microphone (cleanup order test)
25+
7. Uses useVoiceRecordingMuted hook for mute/unmute control
2526
-->
2627
<script type="module">
2728
import { setupMockMediaDevices } from '/assets/esm/speechToSpeech/mockMediaDevices.js';
@@ -123,17 +124,17 @@
123124
const micButton = document.querySelector(`[data-testid="${testIds.sendBoxMicrophoneButton}"]`);
124125
expect(micButton).toBeTruthy();
125126

126-
// ===== TEST 1: Muting from idle state should be no-op =====
127+
// ===== TEST 1: Muting from idle state should work as independent from voice state =====
127128
expect(getVoiceState()).toBe('idle');
128129
expect(muteControlRef.muted).toBe(false);
129130

130131
muteControlRef.setMuted(true);
131132
await new Promise(r => setTimeout(r, 100));
132133

133134
expect(getVoiceState()).toBe('idle'); // Still idle, not muted
134-
expect(muteControlRef.muted).toBe(false);
135+
expect(muteControlRef.muted).toBe(true);
135136

136-
// ===== TEST 2: Start recording → listening state =====
137+
// ===== TEST 2: Start recording → listening state, microphoneMuted resets to false =====
137138
await host.click(micButton);
138139

139140
await pageConditions.became(
@@ -142,6 +143,10 @@
142143
2000
143144
);
144145

146+
// Starting recording resets microphoneMuted to false.
147+
// This ensures a clean slate - recording always starts unmuted.
148+
expect(muteControlRef.muted).toBe(false);
149+
145150
// Wait for some listening chunks
146151
await pageConditions.became(
147152
'At least 2 listening chunks received',

packages/core/src/reducers/voiceActivity.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ export default function voiceActivity(
4141
): VoiceActivityState {
4242
switch (action.type) {
4343
case VOICE_MUTE_RECORDING:
44-
// Only allow muting when in recording state
45-
if (state.voiceState === 'idle') {
46-
console.warn(`botframework-webchat: Cannot mute from "${state.voiceState}" state, must be in recording state.`);
47-
return state;
48-
}
49-
5044
return {
5145
...state,
5246
microphoneMuted: true
@@ -83,6 +77,7 @@ export default function voiceActivity(
8377

8478
return {
8579
...state,
80+
microphoneMuted: false,
8681
voiceState: 'listening'
8782
};
8883

0 commit comments

Comments
 (0)