Skip to content

Desktop app that records your on-screen work session and uses the GitHub Copilot SDK to reconstruct it as an intent + ordered steps, then builds a reusable Skill or Automation for Microsoft Autopilots like Scout, Microsoft Copilot Cowork, or Copilot Studio.

Analyze recording transcribes voice before analyzing (#31)

adilei222cab8420d7
diff --git a/electron/ipc.ts b/electron/ipc.ts
index 4b8e991..0258659 100644
--- a/electron/ipc.ts
+++ b/electron/ipc.ts
@@ -120,6 +120,11 @@ export function registerIpc(
const id = resolveSessionId(sessionId);
if (!id) return { ok: false, error: "No completed session to analyze yet." };
if (!isValidSessionId(id)) return { ok: false, error: "Unknown session." };
+ // Transcribe any recorded voice first so analysis never silently runs without
+ // the user's spoken intent. Downloads the model on first use. Best-effort: a
+ // failure here falls through to analyzing without voice (the error is surfaced
+ // via the narration status affordance and the audio stays saved).
+ await narration.ensureTranscribedForAnalysis(id);
try {
const analysis = await describer.analyze(id);
return { ok: true, analysis };
diff --git a/electron/narration/analyze-gate.test.ts b/electron/narration/analyze-gate.test.ts
new file mode 100644
index 0000000..8bbc299
--- /dev/null
+++ b/electron/narration/analyze-gate.test.ts
@@ -0,0 +1,16 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { shouldTranscribeBeforeAnalyze } from "./analyze-gate";
+
+test("analyze transcribes first only when audio exists without a transcript", () => {
+ // Voice was recorded but not yet transcribed → transcribe first so the analysis
+ // includes the user's spoken intent instead of silently dropping it.
+ assert.equal(shouldTranscribeBeforeAnalyze(true, false), true);
+ // Already transcribed → analyze straight away, no wasteful re-transcription.
+ assert.equal(shouldTranscribeBeforeAnalyze(true, true), false);
+ // No audio at all → nothing to transcribe; behave exactly as a plain analyze.
+ assert.equal(shouldTranscribeBeforeAnalyze(false, false), false);
+ // Defensive: no audio but a stray transcript → still nothing to do.
+ assert.equal(shouldTranscribeBeforeAnalyze(false, true), false);
+});
diff --git a/electron/narration/analyze-gate.ts b/electron/narration/analyze-gate.ts
new file mode 100644
index 0000000..7d5f293
--- /dev/null
+++ b/electron/narration/analyze-gate.ts
@@ -0,0 +1,14 @@
+/**
+ * Decide whether an analyze run must transcribe the session's voice narration
+ * first. Kept as a tiny pure module (no electron / whisper imports) so the rule
+ * is unit-testable in isolation and shared by the analyze flow.
+ *
+ * The narration is the user's own words describing their intent, so analysis
+ * must never silently run without it when it's available but not yet
+ * transcribed. We only transcribe-then-analyze when there is saved audio and no
+ * usable transcript yet; a session with no audio, or one already transcribed,
+ * analyzes straight away.
+ */
+export function shouldTranscribeBeforeAnalyze(hasAudio: boolean, hasTranscript: boolean): boolean {
+ return hasAudio && !hasTranscript;
+}
diff --git a/electron/narration/manager.ts b/electron/narration/manager.ts
index d352a48..fabb491 100644
--- a/electron/narration/manager.ts
+++ b/electron/narration/manager.ts
@@ -14,6 +14,7 @@ import { NARRATION_FILE, type NarrationTranscript } from "../../common/narration
import type { SessionMeta } from "../../common/types";
import { createLogger } from "../logger";
import { isValidSessionId, sessionDir } from "../recorder/session-store";
+import { shouldTranscribeBeforeAnalyze } from "./analyze-gate";
import { transcribeNarration } from "./transcribe";
import {
getAsrPipeline,
@@ -156,6 +157,33 @@ export class NarrationManager {
return task;
}
+ /**
+ * Ensure a session's voice narration is transcribed before an analysis runs, so
+ * `describer.analyze` never silently proceeds without the user's own words.
+ * Downloads the voice model on first use. Best-effort: on failure it resolves
+ * with the error (already surfaced via the narration status) instead of
+ * throwing, so the caller can still analyze without voice and the audio stays
+ * saved. A session with no audio, or one already transcribed, is a fast no-op
+ * that never touches the transcription queue.
+ */
+ async ensureTranscribedForAnalysis(sessionId: string): Promise<NarrationActionResult> {
+ if (!isValidSessionId(sessionId)) return { ok: false, error: "Unknown session." };
+ const dir = sessionDir(sessionId);
+ const hasAudio = existsSync(path.join(dir, "audio.json"));
+ const hasTranscript = readTranscript(path.join(dir, NARRATION_FILE)) != null;
+ if (!shouldTranscribeBeforeAnalyze(hasAudio, hasTranscript)) {
+ return hasTranscript ? { ok: true, outcome: "already-transcribed" } : { ok: true };
+ }
+ const result = await this.transcribeSessionWithDownload(sessionId, true);
+ if (!result.ok) {
+ log.warn(
+ `pre-analysis transcription failed for ${sessionId}:`,
+ result.error ?? result.outcome,
+ );
+ }
+ return result;
+ }
+
async transcribeIfCached(dir: string): Promise<void> {
if (!isNarrationModelCached()) return;
const id = path.basename(dir);
diff --git a/package.json b/package.json
index 2d23aa6..64a4667 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
"build": "tsc --noEmit && vite build",
"typecheck": "tsc --noEmit",
"typecheck:evals": "tsc --noEmit -p evals/tsconfig.json",
- "test": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs --test common/audio.test.ts common/microphone.test.ts electron/recording-controls-bounds.test.ts electron/recorder/controller.test.ts electron/frames/extractor.test.ts electron/narration/audio-analysis.test.ts electron/narration/transcribe.test.ts electron/sessions.test.ts",
+ "test": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs --test common/audio.test.ts common/microphone.test.ts electron/recording-controls-bounds.test.ts electron/recorder/controller.test.ts electron/frames/extractor.test.ts electron/narration/audio-analysis.test.ts electron/narration/analyze-gate.test.ts electron/narration/transcribe.test.ts electron/sessions.test.ts",
"eval": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/run.ts",
"eval:builder": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/builder/run.ts",
"eval:skill": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/skillbuilder/run.ts",
diff --git a/src/Library.tsx b/src/Library.tsx
index 5198974..70c1af8 100644
--- a/src/Library.tsx
+++ b/src/Library.tsx
@@ -250,8 +250,6 @@ function AnalysisWorkspace({
const voiceEmpty = summary.hasNarration && summary.narrationSegmentCount === 0;
const voiceBusy =
narrationStatus?.activeSessionId === sessionId && narrationStatus.phase !== "idle";
- const modelBusy =
- narrationStatus?.phase === "downloading" || narrationStatus?.phase === "loading";
const voiceError =
narrationStatus?.activeSessionId == null || narrationStatus.activeSessionId === sessionId
? narrationStatus?.error
@@ -368,13 +366,6 @@ function AnalysisWorkspace({
setAnalyzing(false);
}, [sessionId]);
- const transcribeVoice = useCallback(async () => {
- setError(null);
- const res = await window.skillRecorder.transcribeNarration(sessionId);
- if (!res.ok) setError(res.error ?? "Could not transcribe this recording.");
- await onChanged();
- }, [sessionId, onChanged]);
-
const startEdit = useCallback(() => {
if (!analysis) return;
setDraftTitle(analysis.title ?? "");
@@ -451,36 +442,11 @@ function AnalysisWorkspace({
</div>
<div className="ws-body">
- {voicePending && (
- <div className="voice-card">
- <div className="voice-card-copy">
- <strong>Voice not transcribed yet</strong>
- <span>
- {voiceBusy
- ? narrationWorkLabel(narrationStatus)
- : "Your audio is saved. Transcription runs locally and can be done later."}
- </span>
- {!voiceBusy && narrationStatus?.model !== "ready" && (
- <span>The first use requires a one-time ~250 MB download.</span>
- )}
- {!voiceBusy && voiceError && (
- <span className="voice-card-error">{voiceError}</span>
- )}
- </div>
- <button
- className="secondary"
- disabled={voiceBusy || modelBusy}
- onClick={() => void transcribeVoice()}
- >
- {voiceBusy || modelBusy
- ? narrationWorkLabel(narrationStatus)
- : narrationStatus?.model === "ready"
- ? "Transcribe voice"
- : narrationStatus?.model === "error"
- ? "Try again"
- : "Download & transcribe"}
- </button>
- </div>
+ {voicePending && voiceError && !analyzing && (
+ <p className="voice-analysis-note">
+ Couldn't transcribe your voice, so this analysis doesn't include it. Your audio is saved —
+ analyzing again will retry.
+ </p>
)}
{voiceEmpty && (
@@ -530,7 +496,9 @@ function AnalysisWorkspace({
<p>See what you did in this recording, step by step.</p>
{voicePending && (
<p className="voice-analysis-note">
- Voice is not transcribed yet. Analyzing now will not include it, but your audio will be kept.
+ {narrationStatus?.model === "ready"
+ ? "Your voice is transcribed first, then analyzed."
+ : "Your voice is transcribed first, then analyzed. The first run downloads a ~250 MB voice model once."}
</p>
)}
<button className="record-cta" onClick={run}>
@@ -542,13 +510,21 @@ function AnalysisWorkspace({
{analyzing && (
<div className="status-line">
<span className="spinner" />
- <span className="status-text">{statusLine || "Working…"}</span>
+ <span className="status-text">
+ {voiceBusy ? narrationWorkLabel(narrationStatus) : statusLine || "Working…"}
+ </span>
<button className="linky status-cancel" onClick={cancel}>
Cancel
</button>
</div>
)}
+ {analyzing && narrationStatus?.phase === "downloading" && (
+ <p className="voice-analysis-note">
+ First analysis downloads the ~250 MB voice model once — later runs skip this.
+ </p>
+ )}
+
{error && <div className="analysis-error">{error}</div>}
{analysis && !analyzing && (