Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

fix(voice): end a narration that heard nothing with the calm note on the extension too

Luis Ortiz42b49d1c123b
diff --git a/apps/extension/src/entrypoints/background/__tests__/narration-settle.test.ts b/apps/extension/src/entrypoints/background/__tests__/narration-settle.test.ts
index 12092d3..7a4fe1d 100644
--- a/apps/extension/src/entrypoints/background/__tests__/narration-settle.test.ts
+++ b/apps/extension/src/entrypoints/background/__tests__/narration-settle.test.ts
@@ -129,12 +129,23 @@ describe('a narration that has nothing left to transcribe', () => {
await expect(whenNarrationSettled()).resolves.toBeUndefined();
});
- it('does not leave the panel transcribing when the host refuses the stop', async () => {
+ it('ends a take that heard nothing calmly, as nothing narrated, and still describes the steps', async () => {
stopVoiceCapture.mockResolvedValue({ ok: false, reason: 'no-audio', error: 'No microphone audio was captured' });
await beginRecording();
await stopVoiceNarration('g1');
+ expect(getVoiceUpdate()).toMatchObject({ phase: 'idle', narrated: 0 });
+ expect(describeUnnarratedSteps).toHaveBeenCalledWith('g1', []);
+ await expect(whenNarrationSettled()).resolves.toBeUndefined();
+ });
+
+ it('still reports a stop the host refuses for another reason as an error', async () => {
+ stopVoiceCapture.mockResolvedValue({ ok: false, reason: 'unknown', error: 'host gone' });
+
+ await beginRecording();
+ await stopVoiceNarration('g1');
+
expect(getVoiceUpdate().phase).toBe('error');
await expect(whenNarrationSettled()).resolves.toBeUndefined();
});
diff --git a/apps/extension/src/entrypoints/background/voice.ts b/apps/extension/src/entrypoints/background/voice.ts
index 1a34310..92070ba 100644
--- a/apps/extension/src/entrypoints/background/voice.ts
+++ b/apps/extension/src/entrypoints/background/voice.ts
@@ -302,6 +302,13 @@ export async function stopVoiceNarration(guideId: string): Promise<void> {
return;
}
+ if (response.reason === 'no-audio') {
+ logger.info('voice: nothing was heard', response);
+ if (releaseTranscription(guideId)) finishWithNothingHeard(guideId);
+ await closeVoiceHostIfIdle();
+ return;
+ }
+
logger.warn('voice: no narration to apply', response);
if (releaseTranscription(guideId)) report({ phase: 'error', reason: response.reason, error: response.error });
await closeVoiceHostIfIdle();
@@ -312,6 +319,12 @@ export async function stopVoiceNarration(guideId: string): Promise<void> {
}
}
+function finishWithNothingHeard(guideId: string): void {
+ const narratedSoFar = takeNarrated(guideId);
+ report({ phase: 'idle', narrated: narratedSoFar.length });
+ describeUnnarratedSteps(guideId, narratedSoFar);
+}
+
export async function applyNarration(
guideId: string,
result: VoiceResultEvent['result'],