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.

Add consent-gated Whisper download

Giorgio Ughini96e7058b0c4d
diff --git a/README.md b/README.md
index 936b417..ca2adf5 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,8 @@ activity" panel shows exactly what's collected:
meaningful moments to disambiguate the steps.
- **Clipboard** — copy/paste content that ties steps together.
- **Narration** *(optional)* — turn on **Narrate** to explain out loud; audio is
- transcribed **on-device** (Whisper via transformers.js) and never leaves your machine.
+ saved immediately and can be transcribed **on-device** (Whisper via transformers.js).
+ The first transcription uses an explicit, one-time ~250 MB model download.
## Requirements
diff --git a/common/analysis.ts b/common/analysis.ts
index b4e46ae..69912f9 100644
--- a/common/analysis.ts
+++ b/common/analysis.ts
@@ -68,6 +68,8 @@ export const AnalysisSchema = z.object({
/** Bumped on every (re)analysis; revision 1 is the first pass. */
revision: z.number().int(),
createdAt: z.number(),
+ /** Narration file version available when this analysis turn started. */
+ narrationSourceUpdatedAt: z.number().nullable().default(null),
/** Short 2–5 word label for lists/menus. Empty on analyses saved before titles existed. */
title: z.string().default(""),
intent: z.string(),
@@ -97,12 +99,14 @@ export function toAnalysis(
revision: number,
submission: AnalysisSubmission,
feedbackLog: FeedbackEntry[],
+ narrationSourceUpdatedAt: number | null,
): Analysis {
return AnalysisSchema.parse({
version: 1,
sessionId,
revision,
createdAt: Date.now(),
+ narrationSourceUpdatedAt,
title: submission.title,
intent: submission.intent,
intentConfidence: submission.intentConfidence,
diff --git a/common/ipc.ts b/common/ipc.ts
index 7e1b465..78a7036 100644
--- a/common/ipc.ts
+++ b/common/ipc.ts
@@ -19,6 +19,12 @@ export interface SessionSummary {
/** True once post-processing produced a bundle. */
processed: boolean;
hasVideo: boolean;
+ /** True when the user opted into narration and usable audio was saved. */
+ hasAudio: boolean;
+ /** True once transcription completed, including recordings with no detected speech. */
+ hasNarration: boolean;
+ narrationSegmentCount: number | null;
+ narrationUpdatedAt: number | null;
/** True once a skill has been built and persisted for this session. */
hasSkill: boolean;
/** True once an automation has been built and persisted for this session. */
@@ -26,6 +32,8 @@ export interface SessionSummary {
/** Present once the describer has produced an analysis for this session. */
analysis: {
revision: number;
+ createdAt: number;
+ narrationSourceUpdatedAt: number | null;
title: string;
intent: string;
intentConfidence: Confidence;
@@ -33,6 +41,26 @@ export interface SessionSummary {
} | null;
}
+export type NarrationModelState = "missing" | "downloading" | "ready" | "error";
+export type NarrationPhase = "idle" | "loading" | "downloading" | "transcribing";
+
+/** Shared model/job state shown in the HUD and Sessions library. */
+export interface NarrationStatus {
+ model: NarrationModelState;
+ phase: NarrationPhase;
+ progress: number | null;
+ loadedBytes: number | null;
+ totalBytes: number | null;
+ activeSessionId: string | null;
+ error: string | null;
+}
+
+export interface NarrationActionResult {
+ ok: boolean;
+ outcome?: "ready" | "transcribed" | "no-speech" | "already-transcribed" | "model-missing";
+ error?: string;
+}
+
export interface RecorderStatus {
state: RecorderState;
sessionId: string | null;
@@ -225,6 +253,10 @@ export const IPC = {
marker: "recorder:marker",
doctor: "doctor:check",
statusChanged: "recorder:status-changed",
+ narrationStatus: "narration:status",
+ narrationDownload: "narration:download",
+ narrationTranscribe: "narration:transcribe",
+ narrationStatusChanged: "narration:status-changed",
analyze: "analyze:start",
analyzeFeedback: "analyze:feedback",
getAnalysis: "analyze:get",
@@ -257,6 +289,10 @@ export interface SkillRecorderApi {
marker(note: string): Promise<MarkerResult>;
doctor(): Promise<DoctorReport>;
onStatusChanged(cb: (status: RecorderStatus) => void): () => void;
+ narrationStatus(): Promise<NarrationStatus>;
+ downloadNarrationModel(): Promise<NarrationActionResult>;
+ transcribeNarration(sessionId: string): Promise<NarrationActionResult>;
+ onNarrationStatusChanged(cb: (status: NarrationStatus) => void): () => void;
/** Run the Copilot describer on a session (defaults to the last completed one). */
analyze(sessionId?: string): Promise<AnalyzeResult>;
/** Send NL feedback and re-analyze in the same multi-turn session. */
diff --git a/docs/windows-capture.md b/docs/windows-capture.md
index 65cdffd..1db3413 100644
--- a/docs/windows-capture.md
+++ b/docs/windows-capture.md
@@ -15,7 +15,7 @@ before trusting a Windows build.
| Browser URLs | UI Automation address bar read (`powershell.exe` host) | Functional, not byte exact | None |
| Clipboard | Electron clipboard | Full | None |
| Screen video + frames | `desktopCapturer` + ffmpeg + sharp | Full | Screen capture |
-| Voice narration (opt-in) | hidden-window `getUserMedia` mic + `MediaRecorder`, transcribed offline (Whisper via transformers.js) | Should work, unverified here | Microphone |
+| Voice narration (opt-in) | hidden-window `getUserMedia` mic + `MediaRecorder`, transcribed offline (Whisper via transformers.js) | Verified on Windows 11 ARM64 with the x64 Electron build | Microphone |
Notes:
@@ -65,10 +65,11 @@ Run a real recording on Windows and verify each source lands in the session's
5. **Video.** Confirm a `.webm` is written and `frame.captured` events appear.
6. **Voice narration.** Turn on the **Narrate** switch before starting, then speak
a sentence or two during the recording. After Stop, confirm `audio.webm` +
- `audio.json` are written and, once processing finishes, `narration.json`
- contains your words with `atMs` offsets. First run downloads the ~250 MB
- Whisper model once (needs network); later runs are offline. On Windows the mic
- grant is requested by the OS on first use.
+ `audio.json` are written. If the model is not installed, use **Download &
+ transcribe** in Sessions (or the actionable HUD readiness row) to approve the
+ one-time ~250 MB Whisper download. Confirm `narration.json` then contains your
+ words with `atMs` offsets. Later runs are offline. On Windows the mic grant is
+ requested by the OS on first use.
7. **Stop.** The recording should show up in the library as `recorded`, and
analysis should produce a coherent intent + ordered steps.
@@ -82,8 +83,9 @@ unavailable on this platform", or a reduced-capture notice).
(nsis x64). Native modules (`get-windows`, `sharp`, `@img/*`, `ffmpeg-static`,
`@huggingface/transformers`, `onnxruntime-node`) are listed under `asarUnpack` so
their binaries load from disk rather than from inside the asar archive. The
-Whisper model itself is not bundled; it downloads once to the app's user-data
-`models` folder on first narrated session.
+Whisper model itself is not bundled. It downloads to the app's user-data
+`models` folder only after the user approves the one-time ~250 MB download from
+the HUD or Sessions; recording and core session processing do not wait for it.
Build the Windows installer on Windows (or a Windows CI runner) so the native
binaries for `win32-x64` are present:
@@ -103,12 +105,15 @@ binaries and is not supported here.
approach is tracked in issue #7.
- Semantic UI events (focus/invoke/value via UI Automation) are not implemented
on either platform yet.
-- Voice narration is verified end to end on macOS (mic capture -> `audio.webm` ->
- offline Whisper transcription -> `narration.json`). The Windows mic-capture path
- is written the same way but has not been run on a real Windows machine; verify it
- with step 6 of the checklist above. `onnxruntime-node` ships prebuilt binaries for
- `win32-x64`/`win32-arm64`, so no compiler is needed there.
-- The Windows paths above are validated by typecheck, a PowerShell parse check of
- the UIA script, and a `win32` describer eval (`evals/scenarios/windows-deploy.ts`).
- Live capture must still be verified on a real Windows machine using the checklist
- above.
+- Voice narration is verified end to end on macOS and Windows 11 ARM64 running the
+ supported x64 Electron build (mic capture -> `audio.webm` -> offline Whisper
+ transcription -> `narration.json`). `onnxruntime-node` ships prebuilt binaries
+ for `win32-x64`/`win32-arm64`, so no compiler is needed there.
+- A live smoke test on Windows 11 ARM64 covered the supported x64 Electron build,
+ `get-windows` native-addon loading, ffmpeg-backed video and frames, microphone
+ audio persistence, explicit Whisper download and offline transcription, and
+ Copilot analysis. Browser URL and clipboard capture were not re-verified in
+ that test; use the checklist above when validating those sources.
+- The Windows paths are also validated by typecheck, a PowerShell parse check of
+ the UIA script, and a `win32` describer eval
+ (`evals/scenarios/windows-deploy.ts`).
diff --git a/electron/describer/describer.ts b/electron/describer/describer.ts
index 37f1cc1..3b00f3f 100644
--- a/electron/describer/describer.ts
+++ b/electron/describer/describer.ts
@@ -1,4 +1,4 @@
-import { existsSync, readFileSync, writeFileSync } from "node:fs";
+import { existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
import path from "node:path";
import { approveAll, CopilotClient, type CopilotSession } from "@github/copilot-sdk";
@@ -304,6 +304,10 @@ export class Describer {
prompt: string,
pendingFeedback?: AnalysisFeedback,
): Promise<Analysis> {
+ const narrationFile = path.join(live.sessionDir, "narration.json");
+ const narrationSourceUpdatedAt = existsSync(narrationFile)
+ ? statSync(narrationFile).mtimeMs
+ : null;
live.holder.submission = undefined;
this.emit(live.sessionId, "working", "Thinking…");
try {
@@ -335,7 +339,13 @@ export class Describer {
];
}
this.emit(live.sessionId, "drafting", "Finalizing analysis…");
- const analysis = toAnalysis(live.sessionId, live.revision, submission, [...live.feedbackLog]);
+ const analysis = toAnalysis(
+ live.sessionId,
+ live.revision,
+ submission,
+ [...live.feedbackLog],
+ narrationSourceUpdatedAt,
+ );
this.persist(live.sessionDir, analysis);
this.emit(live.sessionId, "done", `Analysis ready (revision ${analysis.revision}).`);
return analysis;
diff --git a/electron/ipc.ts b/electron/ipc.ts
index 6a4fbe2..04cb6ec 100644
--- a/electron/ipc.ts
+++ b/electron/ipc.ts
@@ -21,6 +21,7 @@ import { AutomationBuilder, loadPersistedAutomation } from "./automationbuilder/
import { Describer, loadPersistedAnalysis } from "./describer/describer";
import { runDoctor } from "./doctor";
import { createLogger } from "./logger";
+import type { NarrationManager } from "./narration/manager";
import type { RecorderController } from "./recorder/controller";
import { isValidSessionId } from "./recorder/session-store";
import { deleteSession, listSessions } from "./sessions";
@@ -34,12 +35,18 @@ export function registerIpc(
describer: Describer,
builder: SkillBuilder,
automationBuilder: AutomationBuilder,
+ narration: NarrationManager,
): void {
ipcMain.handle(IPC.start, (_event, options?: StartOptions) => recorder.start(options));
ipcMain.handle(IPC.stop, () => recorder.stop());
ipcMain.handle(IPC.status, () => recorder.status());
ipcMain.handle(IPC.marker, (_event, note: string) => recorder.marker(note));
ipcMain.handle(IPC.doctor, () => runDoctor());
+ ipcMain.handle(IPC.narrationStatus, () => narration.status());
+ ipcMain.handle(IPC.narrationDownload, () => narration.downloadModel());
+ ipcMain.handle(IPC.narrationTranscribe, (_event, sessionId: string) =>
+ narration.transcribeSession(sessionId),
+ );
const resolveSessionId = (sessionId?: string): string | null => {
if (sessionId) return sessionId;
@@ -114,6 +121,9 @@ export function registerIpc(
if (describer.isAnalyzing(sessionId)) {
return { ok: false, error: "This recording is being analyzed. Cancel that first, then delete." };
}
+ if (narration.isBusyWith(sessionId)) {
+ return { ok: false, error: "This recording is being transcribed. Wait for that to finish before deleting it." };
+ }
if (builder.isBuilding(sessionId)) {
return { ok: false, error: "This recording is being turned into a skill. Cancel that first, then delete." };
}
@@ -220,4 +230,3 @@ export function registerIpc(
return { ok: true };
});
}
-
diff --git a/electron/main.ts b/electron/main.ts
index 6b606d6..3df826e 100644
--- a/electron/main.ts
+++ b/electron/main.ts
@@ -7,6 +7,7 @@ import { Describer } from "./describer/describer";
import { processSession } from "./pipeline";
import { registerIpc } from "./ipc";
import { createLogger } from "./logger";
+import { NarrationManager } from "./narration/manager";
import { RecorderController } from "./recorder/controller";
import { SkillBuilder } from "./skillbuilder/builder";
import { AutomationBuilder } from "./automationbuilder/builder";
@@ -20,12 +21,20 @@ const log = createLogger("Main");
let recorderWindow: BrowserWindow | null = null;
let libraryWindow: BrowserWindow | null = null;
let recorderHome: Electron.Rectangle | null = null;
+const narration = new NarrationManager((status) =>
+ broadcast(IPC.narrationStatusChanged, status),
+);
const recorder = new RecorderController({
resolveConfig: () => ({ ...FULL_CAPTURE }),
buildCollectors: createCollectors,
createVideoRecorder: () => new VideoRecorder(),
createAudioRecorder: () => new AudioRecorder(),
- postProcess: processSession,
+ postProcess: async (dir) => {
+ await processSession(dir);
+ void narration.transcribeIfCached(dir).catch((err) =>
+ log.warn("Cached narration processing failed:", err),
+ );
+ },
});
/** Send an event to every live window (recorder HUD + library, if open). */
@@ -67,7 +76,8 @@ function openLibrary(): void {
}
app.whenReady().then(() => {
- registerIpc(recorder, describer, builder, automationBuilder);
+ narration.initialize();
+ registerIpc(recorder, describer, builder, automationBuilder, narration);
log.info("Capture: recording all sources");
ipcMain.handle(IPC.openLibrary, () => openLibrary());
@@ -114,5 +124,3 @@ app.on("will-quit", () => {
void automationBuilder.dispose();
});
-
-
diff --git a/electron/narration/manager.ts b/electron/narration/manager.ts
new file mode 100644
index 0000000..fec52fb
--- /dev/null
+++ b/electron/narration/manager.ts
@@ -0,0 +1,320 @@
+import { existsSync, readFileSync } from "node:fs";
+import { readdir, rename, rm, writeFile } from "node:fs/promises";
+import path from "node:path";
+
+import type {
+ NarrationActionResult,
+ NarrationStatus,
+} from "../../common/ipc";
+import { NARRATION_FILE, type NarrationTranscript } from "../../common/narration";
+import type { SessionMeta } from "../../common/types";
+import type { AudioResult } from "../audio/recorder";
+import { createLogger } from "../logger";
+import { isValidSessionId, sessionDir } from "../recorder/session-store";
+import { transcribeNarration } from "./transcribe";
+import {
+ getAsrPipeline,
+ isNarrationModelCached,
+ narrationModelCacheDir,
+ type ModelLoadProgress,
+} from "./whisper";
+
+const log = createLogger("Narration");
+
+function message(err: unknown): string {
+ return err instanceof Error ? err.message : String(err);
+}
+
+function readJson<T>(file: string): T {
+ return JSON.parse(readFileSync(file, "utf8")) as T;
+}
+
+function readTranscript(file: string): NarrationTranscript | null {
+ if (!existsSync(file)) return null;
+ try {
+ const transcript = readJson<NarrationTranscript>(file);
+ return typeof transcript.model === "string" && Array.isArray(transcript.segments)
+ ? transcript
+ : null;
+ } catch {
+ return null;
+ }
+}
+
+async function writeTranscript(file: string, transcript: NarrationTranscript): Promise<void> {
+ const temp = `${file}.tmp.${process.pid}.${Date.now()}`;
+ try {
+ await writeFile(temp, JSON.stringify(transcript, null, 2));
+ await rename(temp, file);
+ } finally {
+ await rm(temp, { force: true });
+ }
+}
+
+async function removePartialDownloads(dir: string): Promise<void> {
+ let entries;
+ try {
+ entries = await readdir(dir, { withFileTypes: true });
+ } catch {
+ return;
+ }
+ await Promise.all(
+ entries.map(async (entry) => {
+ const file = path.join(dir, entry.name);
+ if (entry.isDirectory()) {
+ await removePartialDownloads(file);
+ } else if (/\.tmp\.\d+\./.test(entry.name)) {
+ await rm(file, { force: true });
+ }
+ }),
+ );
+}
+
+export class NarrationManager {
+ private current: NarrationStatus = {
+ model: "missing",
+ phase: "idle",
+ progress: null,
+ loadedBytes: null,
+ totalBytes: null,
+ activeSessionId: null,
+ error: null,
+ };
+ private queue: Promise<void> = Promise.resolve();
+ private downloadTask: Promise<NarrationActionResult> | null = null;
+ private readonly sessionTasks = new Map<string, Promise<NarrationActionResult>>();
+ private lastProgress = -1;
+
+ constructor(private readonly emitStatus: (status: NarrationStatus) => void) {}
+
+ initialize(): void {
+ this.update({
+ model: isNarrationModelCached() ? "ready" : "missing",
+ phase: "idle",
+ error: null,
+ });
+ }
+
+ status(): NarrationStatus {
+ return { ...this.current };
+ }
+
+ isBusyWith(sessionId: string): boolean {
+ return this.sessionTasks.has(sessionId);
+ }
+
+ downloadModel(): Promise<NarrationActionResult> {
+ if (this.current.model === "ready") {
+ return Promise.resolve({ ok: true, outcome: "ready" });
+ }
+ if (this.downloadTask) return this.downloadTask;
+ const task = this.enqueue(async () => {
+ try {
+ await this.loadModel(true, null);
+ return { ok: true, outcome: "ready" } satisfies NarrationActionResult;
+ } catch (err) {
+ const error = message(err);
+ this.update({
+ model: isNarrationModelCached() ? "ready" : "error",
+ phase: "idle",
+ activeSessionId: null,
+ error,
+ });
+ return { ok: false, error } satisfies NarrationActionResult;
+ }
+ });
+ this.downloadTask = task;
+ void task.finally(() => {
+ if (this.downloadTask === task) this.downloadTask = null;
+ });
+ return task;
+ }
+
+ transcribeSession(sessionId: string): Promise<NarrationActionResult> {
+ if (!isValidSessionId(sessionId)) {
+ return Promise.resolve({ ok: false, error: "Unknown session." });
+ }
+ const existing = this.sessionTasks.get(sessionId);
+ if (existing) return existing;
+ const task = this.enqueue(() => this.runTranscription(sessionId, true));
+ this.sessionTasks.set(sessionId, task);
+ void task.finally(() => {
+ if (this.sessionTasks.get(sessionId) === task) this.sessionTasks.delete(sessionId);
+ });
+ return task;
+ }
+
+ async transcribeIfCached(dir: string): Promise<void> {
+ if (!isNarrationModelCached()) return;
+ const id = path.basename(dir);
+ if (!isValidSessionId(id)) return;
+ const result = await this.transcribeSessionWithDownload(id, false);
+ if (!result.ok && result.outcome !== "model-missing") {
+ log.warn("cached narration transcription failed:", result.error);
+ }
+ }
+
+ private transcribeSessionWithDownload(
+ sessionId: string,
+ allowDownload: boolean,
+ ): Promise<NarrationActionResult> {
+ const existing = this.sessionTasks.get(sessionId);
+ if (existing) return existing;
+ const task = this.enqueue(() => this.runTranscription(sessionId, allowDownload));
+ this.sessionTasks.set(sessionId, task);
+ void task.finally(() => {
+ if (this.sessionTasks.get(sessionId) === task) this.sessionTasks.delete(sessionId);
+ });
+ return task;
+ }
+
+ private enqueue<T>(work: () => Promise<T>): Promise<T> {
+ const task = this.queue.then(work, work);
+ this.queue = task.then(
+ () => undefined,
+ () => undefined,
+ );
+ return task;
+ }
+
+ private async runTranscription(
+ sessionId: string,
+ allowDownload: boolean,
+ ): Promise<NarrationActionResult> {
+ const dir = sessionDir(sessionId);
+ const narrationFile = path.join(dir, NARRATION_FILE);
+ if (readTranscript(narrationFile)) {
+ return { ok: true, outcome: "already-transcribed" };
+ }
+ await rm(narrationFile, { force: true });
+
+ const audioJson = path.join(dir, "audio.json");
+ if (!existsSync(audioJson)) return { ok: false, error: "This recording has no saved narration." };
+
+ let meta: SessionMeta;
+ let audio: AudioResult;
+ try {
+ meta = readJson<SessionMeta>(path.join(dir, "session.json"));
+ audio = readJson<AudioResult>(audioJson);
+ } catch (err) {
+ return { ok: false, error: `Could not read narration metadata: ${message(err)}` };
+ }
+
+ const audioPath = path.join(dir, audio.file);
+ if (!existsSync(audioPath)) return { ok: false, error: "The saved narration audio is missing." };
+
+ if (!allowDownload && !isNarrationModelCached()) {
+ this.update({
+ model: "missing",
+ phase: "idle",
+ activeSessionId: null,
+ error: null,
+ });
+ return { ok: false, outcome: "model-missing" };
+ }
+
+ try {
+ const pipe = await this.loadModel(allowDownload, sessionId);
+ this.update({
+ model: "ready",
+ phase: "transcribing",
+ progress: null,
+ loadedBytes: null,
+ totalBytes: null,
+ activeSessionId: sessionId,
+ error: null,
+ });
+ const transcript: NarrationTranscript = await transcribeNarration(
+ audioPath,
+ audio.startEpoch - meta.startedAt,
+ audio.durationMs,
+ pipe,
+ );
+ await writeTranscript(narrationFile, transcript);
+ log.info(`transcribed ${sessionId}: ${transcript.segments.length} segment(s)`);
+ this.update({
+ model: "ready",
+ phase: "idle",
+ activeSessionId: null,
+ error: null,
+ });
+ return {
+ ok: true,
+ outcome: transcript.segments.length > 0 ? "transcribed" : "no-speech",
+ };
+ } catch (err) {
+ const error = message(err);
+ const modelReady = isNarrationModelCached();
+ this.update({
+ model: modelReady ? "ready" : allowDownload ? "error" : "missing",
+ phase: "idle",
+ activeSessionId: sessionId,
+ error,
+ });
+ log.warn(`transcription failed for ${sessionId}:`, error);
+ return { ok: false, error };
+ }
+ }
+
+ private async loadModel(
+ allowDownload: boolean,
+ activeSessionId: string | null,
+ ): ReturnType<typeof getAsrPipeline> {
+ const cached = isNarrationModelCached();
+ const downloading = allowDownload && !cached;
+ if (!allowDownload && !cached) throw new Error("Voice model is not downloaded.");
+ if (downloading) await removePartialDownloads(narrationModelCacheDir());
+
+ this.lastProgress = -1;
+ this.update({
+ model: cached ? "ready" : "downloading",
+ phase: cached ? "loading" : "downloading",
+ progress: cached ? null : 0,
+ loadedBytes: cached ? null : 0,
+ totalBytes: null,
+ activeSessionId,
+ error: null,
+ });
+
+ const pipe = await getAsrPipeline({
+ allowDownload,
+ onProgress: (progress) =>
+ this.onModelProgress(progress, activeSessionId, downloading),
+ });
+ this.update({
+ model: "ready",
+ phase: "idle",
+ progress: null,
+ loadedBytes: null,
+ totalBytes: null,
+ activeSessionId: null,
+ error: null,
+ });
+ return pipe;
+ }
+
+ private onModelProgress(
+ progress: ModelLoadProgress,
+ activeSessionId: string | null,
+ downloading: boolean,
+ ): void {
+ if (!downloading || progress.status !== "progress_total") return;
+ const percent = Math.max(0, Math.min(100, Math.floor(progress.progress ?? 0)));
+ if (percent === this.lastProgress) return;
+ this.lastProgress = percent;
+ this.update({
+ model: "downloading",
+ phase: "downloading",
+ progress: percent,
+ loadedBytes: progress.loaded ?? null,
+ totalBytes: progress.total ?? null,
+ activeSessionId,
+ error: null,
+ });
+ }
+
+ private update(patch: Partial<NarrationStatus>): void {
+ this.current = { ...this.current, ...patch };
+ this.emitStatus(this.status());
+ }
+}
diff --git a/electron/narration/transcribe.ts b/electron/narration/transcribe.ts
index e28410c..5c20360 100644
--- a/electron/narration/transcribe.ts
+++ b/electron/narration/transcribe.ts
@@ -4,7 +4,7 @@ import { promisify } from "node:util";
import type { NarrationSegment } from "../../common/narration";
import { createLogger } from "../logger";
-import { getAsrPipeline, narrationModelId } from "./whisper";
+import { narrationModelId, type AsrPipeline } from "./whisper";
const log = createLogger("Narration/transcribe");
const require = createRequire(import.meta.url);
@@ -35,37 +35,22 @@ export async function transcribeNarration(
audioPath: string,
anchorDeltaMs: number,
durationMs: number,
-): Promise<{ model: string; segments: NarrationSegment[] } | null> {
- const pipe = await getAsrPipeline();
- if (!pipe) return null;
-
- let samples: Float32Array;
- try {
- samples = await decodePcm(audioPath);
- } catch (err) {
- log.warn("failed to decode narration audio:", err instanceof Error ? err.message : err);
- return null;
- }
+ pipe: AsrPipeline,
+): Promise<{ model: string; segments: NarrationSegment[] }> {
+ const samples = await decodePcm(audioPath);
if (samples.length === 0) {
- log.warn("narration audio decoded to zero samples");
- return null;
+ throw new Error("Narration audio decoded to zero samples.");
}
// Silence detection runs on the same file and only reads the audio, so its
// intervals line up with the decoded samples and never shift timestamps.
const silences = await detectSilence(audioPath);
- let result: { text: string; chunks?: Array<{ timestamp: [number, number | null]; text: string }> };
- try {
- result = await pipe(samples, {
- return_timestamps: true,
- chunk_length_s: 30,
- stride_length_s: 5,
- });
- } catch (err) {
- log.warn("whisper transcription failed:", err instanceof Error ? err.message : err);
- return null;
- }
+ const result = await pipe(samples, {
+ return_timestamps: true,
+ chunk_length_s: 30,
+ stride_length_s: 5,
+ });
const durationSec = durationMs > 0 ? durationMs / 1000 : samples.length / SAMPLE_RATE;
const raw = result.chunks?.length
diff --git a/electron/narration/whisper.ts b/electron/narration/whisper.ts
index 8af5557..67bbac7 100644
--- a/electron/narration/whisper.ts
+++ b/electron/narration/whisper.ts
@@ -1,16 +1,22 @@
+import { existsSync } from "node:fs";
import path from "node:path";
import { app } from "electron";
-import { createLogger } from "../logger";
-
-const log = createLogger("Narration/whisper");
-
// Whisper small.en: English-only, int8 (q8) ONNX weights (~250 MB). Downloaded
// once into the user-data models cache, then used fully offline. base.en is the
// lighter fallback if this ever proves too heavy on low-end machines.
const MODEL_ID = "Xenova/whisper-small.en";
const DTYPE = "q8";
+const REQUIRED_MODEL_FILES = [
+ "config.json",
+ "generation_config.json",
+ "preprocessor_config.json",
+ "tokenizer_config.json",
+ "tokenizer.json",
+ path.join("onnx", "encoder_model_quantized.onnx"),
+ path.join("onnx", "decoder_model_merged_quantized.onnx"),
+] as const;
/**
* The subset of the transformers.js ASR pipeline we actually call. Typing it as a
@@ -25,6 +31,20 @@ export type AsrPipeline = (
chunks?: Array<{ timestamp: [number, number | null]; text: string }>;
}>;
+export interface ModelLoadProgress {
+ status: string;
+ file?: string;
+ progress?: number;
+ loaded?: number;
+ total?: number;
+}
+
+export interface WhisperLoadOptions {
+ allowDownload: boolean;
+ onProgress?: (progress: ModelLoadProgress) => void;
+}
+
+let loadedPipe: AsrPipeline | null = null;
let pipePromise: Promise<AsrPipeline | null> | null = null;
/** The model id transcripts are tagged with. */
@@ -32,49 +52,55 @@ export function narrationModelId(): string {
return MODEL_ID;
}
-async function build(): Promise<AsrPipeline | null> {
- let tf: typeof import("@huggingface/transformers");
- try {
- // Dynamic import: transformers.js + onnxruntime-node are heavy native deps we
- // only ever touch when a session actually has narration to transcribe.
- tf = await import("@huggingface/transformers");
- } catch (err) {
- log.warn("transformers.js unavailable; narration disabled:", err instanceof Error ? err.message : err);
- return null;
- }
+export function narrationModelCacheDir(): string {
+ const override = process.env.SKILL_RECORDER_MODELS_DIR;
+ if (override) return path.resolve(override);
+ return path.join(app.getPath("userData"), "models");
+}
+
+export function isNarrationModelCached(): boolean {
+ const root = path.join(narrationModelCacheDir(), ...MODEL_ID.split("/"));
+ return REQUIRED_MODEL_FILES.every((file) => existsSync(path.join(root, file)));
+}
+
+async function build(options: WhisperLoadOptions): Promise<AsrPipeline> {
+ // Dynamic import: transformers.js + onnxruntime-node are heavy native deps we
+ // only ever touch when a model download or transcription is requested.
+ const tf = await import("@huggingface/transformers");
// Keep every downloaded model under the app's user-data dir so it survives
// upgrades and is trivial to locate or clear. First run needs the network once;
// every run after is offline from this cache. Nothing is bundled with the app.
- tf.env.cacheDir = path.join(app.getPath("userData"), "models");
- tf.env.allowLocalModels = false;
+ tf.env.cacheDir = narrationModelCacheDir();
- try {
- const pipe = await tf.pipeline("automatic-speech-recognition", MODEL_ID, {
- dtype: DTYPE,
- // onnxruntime-node's CPU memory arena SIGTRAPs (hard native crash) under
- // Electron's runtime, in both the main and utility processes. Disabling the
- // arena is the single option that avoids it; unlike throttling threads or
- // graph optimization it keeps multithreading and fusions on, so transcription
- // stays near-native speed (~12s for 77s of audio) with no change in output.
- // If this ever needs more isolation, move inference to a forked utility
- // process (it still needs this flag) so a future native fault can't take the
- // app down with it.
- session_options: { enableCpuMemArena: false },
- });
- return pipe as unknown as AsrPipeline;
- } catch (err) {
- log.warn("failed to load whisper model (offline + not yet cached?):", err instanceof Error ? err.message : err);
- return null;
- }
+ const pipe = await tf.pipeline("automatic-speech-recognition", MODEL_ID, {
+ dtype: DTYPE,
+ local_files_only: !options.allowDownload,
+ progress_callback: options.onProgress,
+ // onnxruntime-node's CPU memory arena SIGTRAPs (hard native crash) under
+ // Electron's runtime, in both the main and utility processes. Disabling the
+ // arena is the single option that avoids it; unlike throttling threads or
+ // graph optimization it keeps multithreading and fusions on, so transcription
+ // stays near-native speed (~12s for 77s of audio) with no change in output.
+ session_options: { enableCpuMemArena: false },
+ });
+ return pipe as unknown as AsrPipeline;
}
/**
- * Lazily builds and caches the ASR pipeline for the process. Returns null when
- * the engine or model can't be loaded, so callers degrade cleanly to "no
- * narration" instead of failing the analysis.
+ * Lazily builds and caches the ASR pipeline for the process. Failed loads are
+ * deliberately not memoized so an offline attempt can be retried without an app
+ * restart.
*/
-export function getAsrPipeline(): Promise<AsrPipeline | null> {
- if (!pipePromise) pipePromise = build();
- return pipePromise;
+export async function getAsrPipeline(options: WhisperLoadOptions): Promise<AsrPipeline> {
+ if (loadedPipe) return loadedPipe;
+ if (!pipePromise) pipePromise = build(options);
+ try {
+ const pipe = await pipePromise;
+ if (!pipe) throw new Error("Whisper model did not load.");
+ loadedPipe = pipe;
+ return pipe;
+ } finally {
+ pipePromise = null;
+ }
}
diff --git a/electron/pipeline.ts b/electron/pipeline.ts
index b1430f4..30e939c 100644
--- a/electron/pipeline.ts
+++ b/electron/pipeline.ts
@@ -5,13 +5,10 @@ import { buildBundle } from "../common/bundle";
import { MEANINGFUL_EVENT_TYPES } from "../common/correlation";
import type { CorrelationResult } from "../common/correlation";
import { renderDescription } from "../common/describe";
-import { NARRATION_FILE } from "../common/narration";
import type { SessionMeta } from "../common/types";
-import type { AudioResult } from "./audio/recorder";
import { CorrelationEngine, readEvents } from "./frames/correlate";
import { FrameExtractor } from "./frames/extractor";
import { createLogger } from "./logger";
-import { transcribeNarration } from "./narration/transcribe";
import type { VideoResult } from "./video/recorder";
const log = createLogger("Pipeline");
@@ -77,49 +74,6 @@ async function runFrameStage(sessionDir: string): Promise<CorrelationResult | nu
}
}
-/**
- * Optional narration stage: if the user opted into voice for this session, an
- * `audio.webm` + `audio.json` pair exists. Transcribe it offline (Whisper via
- * transformers.js) into session-clock segments and write `narration.json`. The
- * transcript is the user's own stated intent; it is never merged into
- * `events.jsonl` and is read only through the describer's `get_narration` tool.
- * Best-effort: a missing model, engine, or mic degrades to no narration.
- */
-async function runNarrationStage(sessionDir: string, meta: SessionMeta): Promise<void> {
- const audioJsonPath = path.join(sessionDir, "audio.json");
- if (!existsSync(audioJsonPath)) return;
-
- let audio: AudioResult;
- try {
- audio = JSON.parse(readFileSync(audioJsonPath, "utf8")) as AudioResult;
- } catch (err) {
- log.warn("unreadable audio.json; skipping narration:", err instanceof Error ? err.message : err);
- return;
- }
-
- const audioPath = path.join(sessionDir, audio.file);
- if (!existsSync(audioPath)) {
- log.warn("narration audio missing; skipping narration stage");
- return;
- }
-
- try {
- const transcript = await transcribeNarration(
- audioPath,
- audio.startEpoch - meta.startedAt,
- audio.durationMs,
- );
- if (!transcript || transcript.segments.length === 0) {
- log.info("no usable narration produced");
- return;
- }
- writeFileSync(path.join(sessionDir, NARRATION_FILE), JSON.stringify(transcript, null, 2));
- log.info(`narration: ${transcript.segments.length} segments → ${NARRATION_FILE}`);
- } catch (err) {
- log.warn("narration stage failed:", err instanceof Error ? err.message : err);
- }
-}
-
/**
* Post-stop processing for a completed session. Always produces `bundle.json`
* (segmented steps) and `description.md` (baseline narrative) from the primary
@@ -134,13 +88,7 @@ export async function processSession(sessionDir: string): Promise<void> {
}
const events = readEvents(path.join(sessionDir, "events.jsonl"));
- // Frame correlation (ffmpeg) and narration transcription (Whisper) are
- // independent; run them together so a first-run model download overlaps with
- // frame extraction instead of adding to it.
- const [correlation] = await Promise.all([
- runFrameStage(sessionDir),
- runNarrationStage(sessionDir, meta),
- ]);
+ const correlation = await runFrameStage(sessionDir);
try {
const bundle = buildBundle({ meta, events, correlation });
diff --git a/electron/preload.cjs b/electron/preload.cjs
index 82e2417..72ac046 100644
--- a/electron/preload.cjs
+++ b/electron/preload.cjs
@@ -9,6 +9,10 @@ const IPC = {
marker: "recorder:marker",
doctor: "doctor:check",
statusChanged: "recorder:status-changed",
+ narrationStatus: "narration:status",
+ narrationDownload: "narration:download",
+ narrationTranscribe: "narration:transcribe",
+ narrationStatusChanged: "narration:status-changed",
analyze: "analyze:start",
analyzeFeedback: "analyze:feedback",
getAnalysis: "analyze:get",
@@ -44,6 +48,14 @@ contextBridge.exposeInMainWorld("skillRecorder", {
ipcRenderer.on(IPC.statusChanged, listener);
return () => ipcRenderer.removeListener(IPC.statusChanged, listener);
},
+ narrationStatus: () => ipcRenderer.invoke(IPC.narrationStatus),
+ downloadNarrationModel: () => ipcRenderer.invoke(IPC.narrationDownload),
+ transcribeNarration: (sessionId) => ipcRenderer.invoke(IPC.narrationTranscribe, sessionId),
+ onNarrationStatusChanged: (cb) => {
+ const listener = (_event, status) => cb(status);
+ ipcRenderer.on(IPC.narrationStatusChanged, listener);
+ return () => ipcRenderer.removeListener(IPC.narrationStatusChanged, listener);
+ },
analyze: (sessionId) => ipcRenderer.invoke(IPC.analyze, sessionId),
analyzeFeedback: (input) => ipcRenderer.invoke(IPC.analyzeFeedback, input),
getAnalysis: (sessionId) => ipcRenderer.invoke(IPC.getAnalysis, sessionId),
diff --git a/electron/sessions.ts b/electron/sessions.ts
index c2c4203..2ae901b 100644
--- a/electron/sessions.ts
+++ b/electron/sessions.ts
@@ -3,6 +3,7 @@ import path from "node:path";
import { AnalysisSchema, type Analysis } from "../common/analysis";
import type { SessionSummary } from "../common/ipc";
+import { NARRATION_FILE, type NarrationTranscript } from "../common/narration";
import type { SessionMeta } from "../common/types";
import { isValidSessionId, sessionDir, sessionsRoot } from "./recorder/session-store";
@@ -27,6 +28,20 @@ async function loadAnalysis(dir: string): Promise<Analysis | null> {
}
}
+async function loadNarration(
+ dir: string,
+): Promise<{ segmentCount: number; updatedAt: number } | null> {
+ const file = path.join(dir, NARRATION_FILE);
+ try {
+ const raw = JSON.parse(await readFile(file, "utf8")) as NarrationTranscript;
+ if (!Array.isArray(raw?.segments)) return null;
+ const info = await stat(file);
+ return { segmentCount: raw.segments.length, updatedAt: info.mtimeMs };
+ } catch {
+ return null;
+ }
+}
+
/** Build the library summary for a single session dir, or null if it isn't one. */
async function summarize(root: string, name: string): Promise<SessionSummary | null> {
const dir = path.join(root, name);
@@ -44,10 +59,12 @@ async function summarize(root: string, name: string): Promise<SessionSummary | n
}
if (!meta?.id) return null;
- const [analysis, processed, hasVideo, hasSkill, hasAutomation] = await Promise.all([
+ const [analysis, processed, hasVideo, hasAudio, narration, hasSkill, hasAutomation] = await Promise.all([
loadAnalysis(dir),
exists(path.join(dir, "bundle.json")),
exists(path.join(dir, "video.json")),
+ exists(path.join(dir, "audio.json")),
+ loadNarration(dir),
exists(path.join(dir, "skill.json")),
exists(path.join(dir, "built-automation.json")),
]);
@@ -59,11 +76,17 @@ async function summarize(root: string, name: string): Promise<SessionSummary | n
durationMs: meta.startedAt && meta.stoppedAt ? meta.stoppedAt - meta.startedAt : null,
processed,
hasVideo,
+ hasAudio,
+ hasNarration: narration !== null,
+ narrationSegmentCount: narration?.segmentCount ?? null,
+ narrationUpdatedAt: narration?.updatedAt ?? null,
hasSkill,
hasAutomation,
analysis: analysis
? {
revision: analysis.revision,
+ createdAt: analysis.createdAt,
+ narrationSourceUpdatedAt: analysis.narrationSourceUpdatedAt,
title: analysis.title ?? "",
intent: analysis.intent,
intentConfidence: analysis.intentConfidence,
diff --git a/evals/lib/seed.ts b/evals/lib/seed.ts
index d03857f..08f6794 100644
--- a/evals/lib/seed.ts
+++ b/evals/lib/seed.ts
@@ -27,7 +27,7 @@ export function seedScenario(root: string, scenario: SeedInput): void {
const dir = path.join(root, scenario.id);
mkdirSync(dir, { recursive: true });
const analysis: Analysis = {
- ...toAnalysis(scenario.id, 1, scenario.analysis, []),
+ ...toAnalysis(scenario.id, 1, scenario.analysis, [], null),
approved: true,
approvedAt: Date.now(),
};
diff --git a/src/App.css b/src/App.css
index 0dbf8d2..ab655dd 100644
--- a/src/App.css
+++ b/src/App.css
@@ -48,6 +48,7 @@
--go: hsl(158, 100%, 26%); /* Scout success-loud (dark green) */
--go-rgb: 0, 133, 84;
--warn: hsl(35, 92%, 42%); /* amber for "needs setup" (not an error) */
+ --warn-rgb: 206, 123, 9;
--sans: "Segoe Sans", Aptos, Calibri, -apple-system, BlinkMacSystemFont,
"Segoe UI", Roboto, sans-serif;
@@ -290,7 +291,7 @@ button:focus-visible,
.hud {
display: flex;
flex-direction: column;
- gap: 12px;
+ gap: 10px;
padding: 16px 18px 14px;
height: 100vh;
}
@@ -1180,6 +1181,56 @@ button:focus-visible,
font-size: 13px;
}
+.voice-card {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 18px;
+ border: 1px solid rgba(var(--warn-rgb), 0.45);
+ background: rgba(var(--warn-rgb), 0.08);
+ border-radius: 10px;
+ padding: 12px 14px;
+ color: var(--text);
+}
+
+.voice-card.quiet {
+ border-color: var(--line);
+ background: var(--surface);
+}
+
+.voice-card-copy {
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ font-size: 12px;
+ line-height: 1.4;
+ color: var(--muted);
+}
+
+.voice-card-copy strong {
+ color: var(--text);
+ font-size: 12.5px;
+}
+
+.voice-card-error {
+ color: var(--rec);
+}
+
+.voice-card-actions {
+ flex: none;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.voice-analysis-note {
+ max-width: 520px;
+ margin: -4px 0 0;
+ color: var(--muted);
+ line-height: 1.45;
+}
+
.analysis-error {
background: rgba(var(--rec-rgb), 0.12);
border: 1px solid rgba(var(--rec-rgb), 0.5);
diff --git a/src/Library.tsx b/src/Library.tsx
index 07c94aa..e77a049 100644
--- a/src/Library.tsx
+++ b/src/Library.tsx
@@ -4,6 +4,7 @@ import type { Analysis, AnalysisStep } from "../common/analysis";
import type {
AnalyzeProgress,
AutomationBuildProgress,
+ NarrationStatus,
SessionSummary,
SkillBuildProgress,
} from "../common/ipc";
@@ -30,6 +31,7 @@ export function Library() {
const [selectedId, setSelectedId] = useState<string | null>(null);
const [loaded, setLoaded] = useState(false);
const [notice, setNotice] = useState<string | null>(null);
+ const [narrationStatus, setNarrationStatus] = useState<NarrationStatus | null>(null);
const loadSessions = useCallback(async () => {
const list = await window.skillRecorder.listSessions();
@@ -45,6 +47,14 @@ export function Library() {
});
}, [loadSessions]);
+ useEffect(() => {
+ void window.skillRecorder.narrationStatus().then(setNarrationStatus);
+ return window.skillRecorder.onNarrationStatusChanged((next) => {
+ setNarrationStatus(next);
+ if (next.phase === "idle") void loadSessions();
+ });
+ }, [loadSessions]);
+
const deleteSession = useCallback(async (id: string) => {
setNotice(null);
const res = await window.skillRecorder.deleteSession(id);
@@ -90,7 +100,12 @@ export function Library() {
</aside>
<main className="lib-detail">
{selected ? (
- <AnalysisWorkspace key={selected.id} summary={selected} onChanged={loadSessions} />
+ <AnalysisWorkspace
+ key={selected.id}
+ summary={selected}
+ narrationStatus={narrationStatus}
+ onChanged={loadSessions}
+ />
) : (
<div className="detail-empty">
<span className="eyebrow">No session selected</span>
@@ -180,6 +195,8 @@ function SessionsList({
{s.durationMs != null && <span>{formatDur(s.durationMs)}</span>}
{s.analysis && <span>{s.analysis.stepCount} steps</span>}
{s.hasVideo && <span>video</span>}
+ {s.hasAudio && !s.hasNarration && <span>voice pending</span>}
+ {s.hasNarration && <span>voice</span>}
</div>
</button>
<button
@@ -210,12 +227,30 @@ function SessionsList({
function AnalysisWorkspace({
summary,
+ narrationStatus,
onChanged,
}: {
summary: SessionSummary;
+ narrationStatus: NarrationStatus | null;
onChanged: () => void | Promise<void>;
}) {
const sessionId = summary.id;
+ const voicePending = summary.hasAudio && !summary.hasNarration;
+ 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
+ : null;
+ const voiceStale =
+ summary.analysis != null &&
+ (summary.narrationSegmentCount ?? 0) > 0 &&
+ summary.narrationUpdatedAt != null &&
+ (summary.analysis.narrationSourceUpdatedAt == null ||
+ summary.narrationUpdatedAt > summary.analysis.narrationSourceUpdatedAt);
const [analysis, setAnalysis] = useState<Analysis | null>(null);
const [analyzing, setAnalyzing] = useState(false);
@@ -224,6 +259,7 @@ function AnalysisWorkspace({
const [editing, setEditing] = useState(false);
const [draftTitle, setDraftTitle] = useState("");
const [draftIntent, setDraftIntent] = useState("");
+ const [confirmReanalysis, setConfirmReanalysis] = useState(false);
// Directly-editable steps (the source of truth downstream); persisted on a short
// debounce so typing stays instant. `stepsDirty` gates the persist so seeding from
// a freshly loaded analysis never writes back.
@@ -298,6 +334,9 @@ function AnalysisWorkspace({
const run = useCallback(async () => {
canceled.current = false;
+ setEditing(false);
+ setDraftTitle("");
+ setDraftIntent("");
setAnalyzing(true);
setError(null);
setStatusLine("Starting…");
@@ -318,6 +357,13 @@ 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 ?? "");
@@ -394,6 +440,76 @@ 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>
+ )}
+
+ {voiceEmpty && (
+ <div className="voice-card quiet">
+ <div className="voice-card-copy">
+ <strong>No speech detected</strong>
+ <span>The saved voice recording was transcribed, but it contained no usable speech.</span>
+ </div>
+ </div>
+ )}
+
+ {voiceStale && !analyzing && (
+ <div className="voice-card">
+ <div className="voice-card-copy">
+ <strong>Voice transcript added after this analysis</strong>
+ <span>Re-analyze to include it. This replaces the current summary and any edits.</span>
+ </div>
+ {confirmReanalysis ? (
+ <div className="voice-card-actions">
+ <button className="linky" onClick={() => setConfirmReanalysis(false)}>
+ Cancel
+ </button>
+ <button
+ className="secondary"
+ onClick={() => {
+ setConfirmReanalysis(false);
+ void run();
+ }}
+ >
+ Replace analysis
+ </button>
+ </div>
+ ) : (
+ <button className="secondary" onClick={() => setConfirmReanalysis(true)}>
+ Re-analyze with voice
+ </button>
+ )}
+ </div>
+ )}
+
{!summary.processed && (
<p className="ws-note">Still processing this recording… try again in a moment.</p>
)}
@@ -401,6 +517,11 @@ function AnalysisWorkspace({
{summary.processed && !analysis && !analyzing && (
<div className="ws-empty">
<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.
+ </p>
+ )}
<button className="record-cta" onClick={run}>
Analyze recording
</button>
@@ -524,6 +645,18 @@ function AnalysisWorkspace({
);
}
+function narrationWorkLabel(status: NarrationStatus | null): string {
+ if (!status) return "Working…";
+ if (status.phase === "transcribing") return "Transcribing voice…";
+ if (status.phase === "loading") return "Preparing voice model…";
+ if (status.phase === "downloading") {
+ return status.progress == null
+ ? "Downloading voice model…"
+ : `Downloading voice model… ${status.progress}%`;
+ }
+ return "Working…";
+}
+
/* --- Final stage: target picker + builders -------------------------------- */
/** Which final-stage surface the analysis workspace is showing. */
diff --git a/src/Recorder.tsx b/src/Recorder.tsx
index 3f5183c..ab55ada 100644
--- a/src/Recorder.tsx
+++ b/src/Recorder.tsx
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useState } from "react";
-import type { DoctorReport, RecorderStatus } from "../common/ipc";
+import type { DoctorReport, NarrationStatus, RecorderStatus } from "../common/ipc";
import { formatMs } from "./format";
import { WhatsRecorded } from "./WhatsRecorded";
@@ -11,6 +11,7 @@ const TOGGLE_SHORTCUT = IS_MAC ? "⌘⇧R" : "Ctrl+Shift+R";
export function Recorder() {
const [status, setStatus] = useState<RecorderStatus | null>(null);
const [doctor, setDoctor] = useState<DoctorReport | null>(null);
+ const [narrationStatus, setNarrationStatus] = useState<NarrationStatus | null>(null);
const [showPrivacy, setShowPrivacy] = useState(false);
const [narrate, setNarrate] = useState(false);
const [elapsed, setElapsed] = useState(0);
@@ -26,8 +27,14 @@ export function Recorder() {
useEffect(() => {
void window.skillRecorder.status().then(setStatus);
void window.skillRecorder.doctor().then(setDoctor);
+ void window.skillRecorder.narrationStatus().then(setNarrationStatus);
void refreshCount();
- return window.skillRecorder.onStatusChanged(setStatus);
+ const offRecorder = window.skillRecorder.onStatusChanged(setStatus);
+ const offNarration = window.skillRecorder.onNarrationStatusChanged(setNarrationStatus);
+ return () => {
+ offRecorder();
+ offNarration();
+ };
}, [refreshCount]);
// The analyze step happens in the library window, so re-check how many
@@ -68,6 +75,11 @@ export function Recorder() {
void window.skillRecorder.openLibrary();
}, []);
+ const downloadNarrationModel = useCallback(async () => {
+ const res = await window.skillRecorder.downloadNarrationModel();
+ if (!res.ok) window.alert(res.error ?? "Could not download the voice transcription model.");
+ }, []);
+
return (
<div className="hud">
<header className="hud-head">
@@ -128,7 +140,9 @@ export function Recorder() {
? "Listening to your voice"
: "Voice off for this recording"
: narrate
- ? "Your voice will be included"
+ ? narrationStatus?.model === "ready"
+ ? "Your voice will be included"
+ : "Voice saved · transcription needs ~250 MB later"
: "Explain out loud (optional)"}
</span>
</span>
@@ -237,22 +251,33 @@ export function Recorder() {
<div className="doctor">
<Row
label="window tracking"
- ok={doctor.activeWindow.ok}
+ status={doctor.activeWindow.ok ? "good" : "bad"}
note={doctor.activeWindow.ok ? "native" : "addon missing"}
/>
{doctor.activeSources.some((s) => s.key === "browserUrls") && (
<Row
label="browser URLs"
- ok={doctor.browserUrl.supported}
+ status={doctor.browserUrl.supported ? "good" : "bad"}
note={doctor.browserUrl.supported ? doctor.browserUrl.kind : "not on this OS"}
/>
)}
<Row
label="ffmpeg"
- ok={doctor.ffmpeg.ok}
+ status={doctor.ffmpeg.ok ? "good" : "bad"}
note={doctor.ffmpeg.ok ? doctor.ffmpeg.source : "missing"}
/>
- <Row label="copilot CLI" ok={doctor.copilotCli.ok} note={doctor.copilotCli.ok ? "found" : "missing"} />
+ <Row
+ label="copilot CLI"
+ status={doctor.copilotCli.ok ? "good" : "bad"}
+ note={doctor.copilotCli.ok ? "found" : "missing"}
+ />
+ {narrationStatus && (
+ <VoiceModelRow
+ status={narrationStatus}
+ recording={recording}
+ onDownload={downloadNarrationModel}
+ />
+ )}
</div>
)}
@@ -263,12 +288,63 @@ export function Recorder() {
);
}
-function Row({ label, ok, note }: { label: string; ok: boolean; note: string }) {
+type RowStatus = "good" | "warn" | "bad";
+
+function Row({
+ label,
+ status,
+ note,
+ action,
+}: {
+ label: string;
+ status: RowStatus;
+ note: string;
+ action?: { label: string; disabled?: boolean; onClick: () => void };
+}) {
+ const symbol = status === "good" ? "✓" : status === "warn" ? "!" : "✕";
return (
<div className="row">
- <span className={`badge ${ok ? "good" : "bad"}`}>{ok ? "✓" : "✕"}</span>
+ <span className={`badge ${status}`}>{symbol}</span>
<span className="row-label">{label}</span>
<span className="row-note">{note}</span>
+ {action && (
+ <button className="row-action" disabled={action.disabled} onClick={action.onClick}>
+ {action.label}
+ </button>
+ )}
</div>
);
}
+
+function VoiceModelRow({
+ status,
+ recording,
+ onDownload,
+}: {
+ status: NarrationStatus;
+ recording: boolean;
+ onDownload: () => void;
+}) {
+ if (status.phase === "downloading") {
+ const progress = status.progress == null ? "downloading" : `${status.progress}%`;
+ return <Row label="voice transcription" status="warn" note={progress} />;
+ }
+ if (status.phase === "loading") {
+ return <Row label="voice transcription" status="warn" note="preparing" />;
+ }
+ if (status.model === "ready") {
+ return <Row label="voice transcription" status="good" note="offline" />;
+ }
+ return (
+ <Row
+ label="voice transcription"
+ status="warn"
+ note={status.model === "error" ? "download failed" : "~250 MB"}
+ action={{
+ label: status.model === "error" ? "retry" : "download",
+ disabled: recording,
+ onClick: onDownload,
+ }}
+ />
+ );
+}
diff --git a/src/WhatsRecorded.tsx b/src/WhatsRecorded.tsx
index 4507902..6c2a8d2 100644
--- a/src/WhatsRecorded.tsx
+++ b/src/WhatsRecorded.tsx
@@ -74,7 +74,10 @@ export function WhatsRecorded({ onClose }: { onClose: () => void }) {
<p className="sheet-note">Off by default. The Narrate switch is your choice, per recording.</p>
<ul>
<li>Your microphone is used only while Narrate is on and a recording is running.</li>
- <li>The recording is turned into text on this computer, using an offline model.</li>
+ <li>
+ The recording can be turned into text on this computer using an offline model. The
+ first transcription needs a one-time ~250 MB download that you choose when to start.
+ </li>
<li>Turn Narrate off and your microphone is never touched.</li>
</ul>
</section>