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): count every step narrated during the recording, not just the last take

Luis Ortizff11d3f2eeca
diff --git a/src/entrypoints/background/voice.ts b/src/entrypoints/background/voice.ts
index 1b174ec..3d8f404 100644
--- a/src/entrypoints/background/voice.ts
+++ b/src/entrypoints/background/voice.ts
@@ -39,6 +39,20 @@ const START_TIMEOUT_MS = 8000;
let resumeNarration: (() => Promise<unknown>) | null = null;
+const narratedSteps = new Map<string, Set<string>>();
+
+export function recordNarrated(guideId: string, stepIds: readonly string[]): void {
+ const seen = narratedSteps.get(guideId) ?? new Set<string>();
+ for (const stepId of stepIds) seen.add(stepId);
+ narratedSteps.set(guideId, seen);
+}
+
+export function takeNarrated(guideId: string): string[] {
+ const seen = narratedSteps.get(guideId);
+ narratedSteps.delete(guideId);
+ return seen ? [...seen] : [];
+}
+
let phase: PanelVoiceUpdate = { type: 'VOICE_UPDATE', phase: 'idle' };
export function getVoiceUpdate(): PanelVoiceUpdate {
@@ -253,6 +267,7 @@ async function applyNarration(guideId: string, result: VoiceResultEvent['result'
await applyNarrationToSteps(updates);
const narratedIds = updates.map((update) => update.stepId);
discardDeferred(guideId, narratedIds);
+ recordNarrated(guideId, narratedIds);
logger.info('voice: narration applied', {
narrated: updates.length,
of: narrated.length,
@@ -260,8 +275,9 @@ async function applyNarration(guideId: string, result: VoiceResultEvent['result'
stats: result.stats,
});
if (final) {
- report({ phase: 'idle', narrated: updates.length });
- describeUnnarratedSteps(guideId, narratedIds);
+ const narratedSoFar = takeNarrated(guideId);
+ report({ phase: 'idle', narrated: narratedSoFar.length });
+ describeUnnarratedSteps(guideId, narratedSoFar);
}
} catch (error) {
logger.error('voice: narration could not be applied', error);