Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
feat: live transcription preview window with streaming local transcription
Gabriel Steinbae324b24c51
diff --git a/preload.js b/preload.jsindex d520e5508..7528e0fc3 100644--- a/preload.js+++ b/preload.js@@ -607,9 +607,22 @@ contextBridge.exposeInMainWorld("electronAPI", {"preview-append",(callback) => (_event, text) => callback(text)),+ onPreviewHold: registerListener(+ "preview-hold",+ (callback) => (_event, payload) => callback(payload)+ ),+ onPreviewResult: registerListener(+ "preview-result",+ (callback) => (_event, payload) => callback(payload)+ ),onPreviewHide: registerListener("preview-hide", (callback) => () => callback()),startDictationPreview: (opts) => ipcRenderer.invoke("start-dictation-preview", opts),- stopDictationPreview: () => ipcRenderer.invoke("stop-dictation-preview"),+ stopDictationPreview: (opts) => ipcRenderer.invoke("stop-dictation-preview", opts),+ dismissDictationPreview: () => ipcRenderer.invoke("dismiss-dictation-preview"),+ completeDictationPreview: (payload) => ipcRenderer.invoke("complete-dictation-preview", payload),+ hideDictationPreview: () => ipcRenderer.invoke("hide-dictation-preview"),+ resizeTranscriptionPreviewWindow: (width, height) =>+ ipcRenderer.invoke("resize-transcription-preview-window", width, height),sendDictationPreviewAudio: (data) => ipcRenderer.send("dictation-preview-audio", data),acquireRecordingLock: (pipeline) => ipcRenderer.invoke("acquire-recording-lock", pipeline),releaseRecordingLock: (pipeline) => ipcRenderer.invoke("release-recording-lock", pipeline),diff --git a/src/components/TranscriptionPreviewOverlay.tsx b/src/components/TranscriptionPreviewOverlay.tsxindex e9e17e06f..d21c3b381 100644--- a/src/components/TranscriptionPreviewOverlay.tsx+++ b/src/components/TranscriptionPreviewOverlay.tsx@@ -1,67 +1,393 @@-import { useState, useEffect } from "react";-import { X } from "lucide-react";+import { useCallback, useEffect, useMemo, useRef, useState } from "react";+import { Check, Copy, X } from "lucide-react";+import { useTranslation } from "react-i18next";++type PreviewPhase = "listening" | "live" | "hold" | "cleanup" | "final";++const HOLD_DURATION_MS = 3000;+const FINAL_HIDE_DURATION_MS = 4500;+const COPIED_RESET_MS = 1400;+const HIDE_ANIMATION_MS = 220;export default function TranscriptionPreviewOverlay() {- const [text, setText] = useState("");+ const { t } = useTranslation();+ const [rawText, setRawText] = useState("");+ const [finalText, setFinalText] = useState("");+ const [phase, setPhase] = useState<PreviewPhase>("listening");const [isVisible, setIsVisible] = useState(false);+ const [copied, setCopied] = useState(false);+ const [showCleanupAfterHold, setShowCleanupAfterHold] = useState(false);+ const [hasOverflow, setHasOverflow] = useState(false);++ const shellRef = useRef<HTMLDivElement | null>(null);+ const textRef = useRef<HTMLDivElement | null>(null);+ const phaseRef = useRef<PreviewPhase>("listening");+ const rawTextRef = useRef("");+ const hideTimerRef = useRef<number | null>(null);+ const holdTimerRef = useRef<number | null>(null);+ const copiedTimerRef = useRef<number | null>(null);+ const resetTimerRef = useRef<number | null>(null);+ const pendingResultRef = useRef("");+ const showCleanupAfterHoldRef = useRef(false);++ useEffect(() => {+ phaseRef.current = phase;+ }, [phase]);++ useEffect(() => {+ rawTextRef.current = rawText;+ }, [rawText]);useEffect(() => {- setTimeout(() => setIsVisible(true), 50);+ showCleanupAfterHoldRef.current = showCleanupAfterHold;+ }, [showCleanupAfterHold]);++ const clearTimer = (timerRef: { current: number | null }) => {+ if (timerRef.current) {+ clearTimeout(timerRef.current);+ timerRef.current = null;+ }+ };++ const clearLifecycleTimers = useCallback(() => {+ clearTimer(hideTimerRef);+ clearTimer(holdTimerRef);+ clearTimer(resetTimerRef);+ }, []);++ const resetCopyState = useCallback(() => {+ clearTimer(copiedTimerRef);+ copiedTimerRef.current = window.setTimeout(() => setCopied(false), COPIED_RESET_MS);+ }, []);++ const startHideTimer = useCallback((delayMs: number) => {+ clearTimer(hideTimerRef);+ hideTimerRef.current = window.setTimeout(() => {+ window.electronAPI?.hideDictationPreview?.();+ }, delayMs);+ }, []);++ const activeText = phase === "final" ? finalText || rawText : rawText;++ const targetWidth = useMemo(() => {+ if (phase === "listening" && !rawText) return 400;+ if (activeText.length > 300) return 540;+ if (activeText.length > 100 || phase === "cleanup" || phase === "final") return 480;+ return 420;+ }, [activeText.length, phase, rawText]);- const cleanupText = window.electronAPI?.onPreviewText?.((incoming: string) => {- setText(incoming);+ const showFinalResult = useCallback(+ (text: string) => {+ const trimmed = text.trim();+ if (!trimmed) {+ window.electronAPI?.hideDictationPreview?.();+ return;+ }++ pendingResultRef.current = "";+ clearLifecycleTimers();+ setFinalText(trimmed);+ setPhase("final");+ setCopied(false);+ setIsVisible(true);+ startHideTimer(FINAL_HIDE_DURATION_MS);+ },+ [clearLifecycleTimers, startHideTimer]+ );++ const requestResize = useCallback(() => {+ if (!isVisible || !shellRef.current || !window.electronAPI?.resizeTranscriptionPreviewWindow) {+ return;+ }++ const nextHeight = Math.ceil(shellRef.current.getBoundingClientRect().height) + 16;+ window.electronAPI.resizeTranscriptionPreviewWindow(targetWidth, nextHeight).catch(() => {});+ }, [isVisible, targetWidth]);++ useEffect(() => {+ if (!isVisible || !shellRef.current) return;++ const node = shellRef.current;+ const frameId = window.requestAnimationFrame(() => requestResize());+ const observer = new ResizeObserver(() => requestResize());+ observer.observe(node);++ return () => {+ window.cancelAnimationFrame(frameId);+ observer.disconnect();+ };+ }, [isVisible, requestResize]);++ useEffect(() => {+ const el = textRef.current;+ if (!el) return;+ requestAnimationFrame(() => {+ el.scrollTop = el.scrollHeight;+ setHasOverflow(el.scrollHeight > el.clientHeight + 2);});+ }, [rawText, finalText, phase]);- const cleanupAppend = window.electronAPI?.onPreviewAppend?.((chunk: string) => {- setText((prev) => (prev ? prev + " " + chunk : chunk));+ useEffect(() => {+ const handlePreviewText = window.electronAPI?.onPreviewText?.((incoming: string) => {+ clearLifecycleTimers();+ clearTimer(copiedTimerRef);+ pendingResultRef.current = "";+ setRawText(incoming?.trim?.() || "");+ setFinalText("");+ setCopied(false);+ setShowCleanupAfterHold(false);+ setHasOverflow(false);+ setPhase(incoming?.trim?.() ? "live" : "listening");+ setIsVisible(true);});- const cleanupHide = window.electronAPI?.onPreviewHide?.(() => {+ const handlePreviewAppend = window.electronAPI?.onPreviewAppend?.((chunk: string) => {+ const trimmedChunk = chunk?.trim?.();+ if (!trimmedChunk) return;++ setRawText((prev) => (prev ? `${prev} ${trimmedChunk}` : trimmedChunk));+ if (+ phaseRef.current !== "hold" &&+ phaseRef.current !== "cleanup" &&+ phaseRef.current !== "final"+ ) {+ setPhase("live");+ }+ setIsVisible(true);+ });++ const handlePreviewHold = window.electronAPI?.onPreviewHold?.((payload) => {+ clearTimer(hideTimerRef);+ setCopied(false);++ const shouldShowCleanup = !!payload?.showCleanup;+ setShowCleanupAfterHold(shouldShowCleanup);+ setPhase(rawTextRef.current.trim() ? "hold" : "cleanup");++ clearTimer(holdTimerRef);+ holdTimerRef.current = window.setTimeout(() => {+ if (pendingResultRef.current) {+ showFinalResult(pendingResultRef.current);+ return;+ }++ if (showCleanupAfterHoldRef.current) {+ setPhase("cleanup");+ return;+ }++ window.electronAPI?.hideDictationPreview?.();+ }, HOLD_DURATION_MS);+ });++ const handlePreviewResult = window.electronAPI?.onPreviewResult?.((payload) => {+ const nextText = payload?.text?.trim?.();+ if (!nextText) {+ window.electronAPI?.hideDictationPreview?.();+ return;+ }++ if (phaseRef.current === "hold") {+ pendingResultRef.current = nextText;+ return;+ }++ showFinalResult(nextText);+ });++ const handlePreviewHide = window.electronAPI?.onPreviewHide?.(() => {+ clearLifecycleTimers();+ clearTimer(copiedTimerRef);setIsVisible(false);- setTimeout(() => setText(""), 200);++ clearTimer(resetTimerRef);+ resetTimerRef.current = window.setTimeout(() => {+ pendingResultRef.current = "";+ setRawText("");+ setFinalText("");+ setCopied(false);+ setShowCleanupAfterHold(false);+ setHasOverflow(false);+ setPhase("listening");+ }, HIDE_ANIMATION_MS);});return () => {- cleanupText?.();- cleanupAppend?.();- cleanupHide?.();+ clearLifecycleTimers();+ clearTimer(copiedTimerRef);+ handlePreviewText?.();+ handlePreviewAppend?.();+ handlePreviewHold?.();+ handlePreviewResult?.();+ handlePreviewHide?.();};+ }, [clearLifecycleTimers, showFinalResult]);++ const handleCopy = useCallback(async () => {+ const textToCopy = activeText.trim();+ if (!textToCopy) return;++ try {+ const result = await window.electronAPI?.writeClipboard?.(textToCopy);+ if (result?.success === false) throw new Error("clipboard-write-failed");+ setCopied(true);+ resetCopyState();+ if (phaseRef.current === "final") startHideTimer(FINAL_HIDE_DURATION_MS);+ } catch {+ try {+ await navigator.clipboard.writeText(textToCopy);+ setCopied(true);+ resetCopyState();+ if (phaseRef.current === "final") startHideTimer(FINAL_HIDE_DURATION_MS);+ } catch {+ setCopied(false);+ }+ }+ }, [activeText, resetCopyState, startHideTimer]);++ const handleDismiss = useCallback(() => {+ window.electronAPI?.dismissDictationPreview?.();}, []);if (!isVisible) {- return <div className="w-full h-full bg-transparent" />;+ return <div className="h-full w-full bg-transparent" />;}+ const statusLabel =+ phase === "final"+ ? t("transcriptionPreview.ready", { defaultValue: "Ready" })+ : phase === "cleanup"+ ? t("transcriptionPreview.polishing", { defaultValue: "Polishing..." })+ : phase === "hold"+ ? t("transcriptionPreview.captured", { defaultValue: "Captured" })+ : t("transcriptionPreview.listening", { defaultValue: "Listening..." });+return (- <div className="meeting-notification-window w-full h-full bg-transparent p-2">+ <div className="meeting-notification-window h-full w-full bg-transparent p-2"><div+ ref={shellRef}className={[- "bg-card/95 dark:bg-surface-2/95 backdrop-blur-xl",- "border border-border/40 dark:border-border-subtle/40",- "rounded-xl shadow-lg p-2.5",+ "relative overflow-hidden rounded-xl border bg-card/92 p-3 backdrop-blur-xl",+ "border-border/40 shadow-[0_8px_24px_rgba(0,0,0,0.14)]",+ "dark:border-border-subtle/45 dark:bg-surface-2/92","transition-all duration-200 ease-out",isVisible ? "translate-y-0 opacity-100" : "translate-y-2 opacity-0",].join(" ")}>- <div className="flex items-start gap-2">- <div className="flex-1 min-w-0">- {text ? (- <p className="text-[12px] text-foreground leading-snug">{text}</p>+ <div className="flex items-center justify-between">+ <div className="flex items-center gap-1.5 min-w-0">+ {phase === "final" ? (+ <Check className="h-3.5 w-3.5 shrink-0 text-emerald-500/70" />) : (- <div className="flex items-center gap-1.5">- <div className="w-1.5 h-1.5 rounded-full bg-primary animate-pulse" />- <p className="text-[11px] text-muted-foreground">Listening...</p>- </div>+ <span+ className={[+ "block h-1.5 w-1.5 shrink-0 rounded-full animate-pulse",+ phase === "cleanup"+ ? "bg-muted-foreground/40"+ : rawText+ ? "bg-primary/70"+ : "bg-muted-foreground/30",+ ].join(" ")}+ />)}+ <span className="text-[12px] font-medium tracking-tight text-muted-foreground/70 truncate">+ {statusLabel}+ </span>+ </div>++ <div className="flex shrink-0 items-center gap-0.5">+ {activeText ? (+ <button+ onClick={handleCopy}+ className={[+ "inline-flex h-6 items-center gap-1 rounded-md border px-1.5 text-[11px] font-medium transition-colors",+ copied+ ? "border-emerald-500/15 text-emerald-500/70"+ : "border-border/30 text-muted-foreground/60 hover:border-border/50 hover:bg-background/40 hover:text-foreground/80",+ ].join(" ")}+ >+ {copied ? <Check className="h-3 w-3" /> : <Copy className="h-3 w-3" />}+ {copied+ ? t("transcriptionPreview.copied", { defaultValue: "Copied" })+ : t("transcriptionPreview.copy", { defaultValue: "Copy" })}+ </button>+ ) : null}++ <button+ onClick={handleDismiss}+ className="inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/40 transition-colors hover:bg-background/40 hover:text-muted-foreground/70"+ >+ <X className="h-3 w-3" />+ </button></div>- <button- onClick={() => window.electronAPI?.stopDictationPreview?.()}- className="shrink-0 text-muted-foreground/60 hover:text-foreground transition-colors p-0.5"- >- <X className="w-3.5 h-3.5" />- </button></div>++ {activeText && (+ <div className="relative mt-2">+ {hasOverflow && (+ <div className="pointer-events-none absolute inset-x-0 top-0 z-10 h-5 rounded-t-lg bg-gradient-to-b from-background/60 to-transparent dark:from-surface-2/60" />+ )}++ <div+ ref={textRef}+ className={[+ "preview-text-scroll rounded-lg border px-2.5 py-2 max-h-[220px] overflow-y-auto",+ phase === "final"+ ? "border-emerald-500/10 bg-emerald-500/[0.03]"+ : "border-border/25 bg-background/30",+ ].join(" ")}+ >+ <p className="select-text text-[13px] leading-[1.52] text-foreground whitespace-pre-wrap break-words [text-wrap:pretty]">+ {activeText}+ </p>+ </div>+ </div>+ )}++ {phase === "cleanup" && (+ <div+ className={[+ "h-px overflow-hidden rounded-full bg-muted-foreground/8",+ activeText ? "mt-1.5" : "mt-2",+ ].join(" ")}+ >+ <div+ className="h-full w-1/4 rounded-full bg-muted-foreground/20"+ style={{ animation: "indeterminate 1.4s ease-in-out infinite" }}+ />+ </div>+ )}++ {phase === "listening" && !rawText && (+ <div className="mt-2 flex items-center gap-2 px-1 py-1">+ <div className="flex items-end gap-[3px]">+ {[8, 13, 10].map((h, i) => (+ <span+ key={i}+ className="w-[2px] rounded-full bg-primary/35"+ style={{+ height: h,+ animation: "preview-bars 0.9s ease-in-out infinite",+ animationDelay: `${i * 0.12}s`,+ }}+ />+ ))}+ </div>+ <span className="text-[11px] text-muted-foreground/45">+ {t("transcriptionPreview.waitingForInput", { defaultValue: "Say something..." })}+ </span>+ </div>+ )}</div>++ <style>{`+ @keyframes preview-bars {+ 0%, 100% { transform: scaleY(0.7); opacity: 0.6; }+ 50% { transform: scaleY(1.3); opacity: 1; }+ }+ .preview-text-scroll::-webkit-scrollbar { display: none; }+ .preview-text-scroll { scrollbar-width: none; }+ `}</style></div>);}diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.jsindex 0a571f080..44cfd8bab 100644--- a/src/helpers/audioManager.js+++ b/src/helpers/audioManager.js@@ -344,7 +344,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);this._silenceCtx = null;this._silenceAnalyser = null;- this.cleanupPreview();+ this.cleanupPreview({ showCleanup: this.shouldShowPreviewCleanupState() });this.isRecording = false;this.isProcessing = true;@@ -443,7 +443,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);cancelRecording() {if (this.mediaRecorder && this.mediaRecorder.state === "recording") {this.mediaRecorder.onstop = () => {- this.cleanupPreview();+ this.cleanupPreview({ dismiss: true });this.isRecording = false;this.isProcessing = false;this.audioChunks = [];@@ -2560,7 +2560,14 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);return true;}- cleanupPreview() {+ shouldShowPreviewCleanupState() {+ const settings = getSettings();+ return !!settings.useReasoningModel && !this.skipReasoning;+ }++ cleanupPreview(options = {}) {+ const { dismiss = false, showCleanup = false } = options;+if (this._previewProcessor) {this._previewProcessor.port.postMessage("stop");this._previewProcessor.disconnect();@@ -2574,7 +2581,11 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);this._previewAudioContext.close().catch(() => {});this._previewAudioContext = null;}- window.electronAPI?.stopDictationPreview?.();+ if (dismiss) {+ window.electronAPI?.dismissDictationPreview?.();+ return;+ }+ window.electronAPI?.stopDictationPreview?.({ showCleanup });}cleanupStreamingAudio() {diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex 5ebdf5465..81f660860 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -3019,6 +3019,22 @@ class IPCHandlers {let dictationPreviewTranscribing = false;let dictationPreviewProvider = null;let dictationPreviewModel = null;+ let dictationPreviewSessionActive = false;++ const resetDictationPreviewState = ({ preserveSession = false } = {}) => {+ if (dictationPreviewTimer) {+ clearInterval(dictationPreviewTimer);+ dictationPreviewTimer = null;+ }+ dictationPreviewMode = false;+ if (!preserveSession) {+ dictationPreviewSessionActive = false;+ }+ dictationPreviewBuffer = [];+ dictationPreviewTranscribing = false;+ dictationPreviewProvider = null;+ dictationPreviewModel = null;+ };const transcribeDictationPreviewChunk = async () => {if (dictationPreviewTranscribing) return;@@ -3351,10 +3367,11 @@ class IPCHandlers {});ipcMain.handle("start-dictation-preview", async (_event, { provider, model }) => {+ resetDictationPreviewState();dictationPreviewMode = true;+ dictationPreviewSessionActive = true;dictationPreviewProvider = provider;dictationPreviewModel = model;- dictationPreviewBuffer = [];dictationPreviewChunkCount = 0;this.windowManager.showTranscriptionPreview("");dictationPreviewTimer = setInterval(() => transcribeDictationPreviewChunk(), 1500);@@ -3377,18 +3394,50 @@ class IPCHandlers {);});- ipcMain.handle("stop-dictation-preview", async () => {- if (dictationPreviewTimer) {- clearInterval(dictationPreviewTimer);- dictationPreviewTimer = null;+ ipcMain.handle("dismiss-dictation-preview", async () => {+ resetDictationPreviewState();+ this.windowManager.hideTranscriptionPreview();+ return { success: true };+ });++ ipcMain.handle("complete-dictation-preview", async (_event, { text } = {}) => {+ if (!dictationPreviewSessionActive) {+ return { success: true };}- await transcribeDictationPreviewChunk();+ if (typeof text === "string" && text.trim()) {+ this.windowManager.completeTranscriptionPreview(text);+ } else {+ resetDictationPreviewState();+ this.windowManager.hideTranscriptionPreview();+ }+ return { success: true };+ });++ ipcMain.handle("hide-dictation-preview", async () => {+ resetDictationPreviewState();this.windowManager.hideTranscriptionPreview();- dictationPreviewMode = false;- dictationPreviewBuffer = [];- dictationPreviewTranscribing = false;- dictationPreviewProvider = null;- dictationPreviewModel = null;+ return { success: true };+ });++ ipcMain.handle("resize-transcription-preview-window", async (_event, width, height) => {+ if (!dictationPreviewSessionActive) {+ return { success: false, error: "Preview session not active" };+ }+ return this.windowManager.resizeTranscriptionPreview(width, height);+ });++ ipcMain.handle("stop-dictation-preview", async (_event, options = {}) => {+ if (!dictationPreviewMode && !dictationPreviewSessionActive) {+ return { success: true };+ }+ clearInterval(dictationPreviewTimer);+ dictationPreviewTimer = null;+ await transcribeDictationPreviewChunk();+ resetDictationPreviewState({ preserveSession: true });+ if (!dictationPreviewSessionActive) {+ return { success: true };+ }+ this.windowManager.holdTranscriptionPreview(options);return { success: true };});diff --git a/src/helpers/windowConfig.js b/src/helpers/windowConfig.jsindex 2054543f0..dc8253b27 100644--- a/src/helpers/windowConfig.js+++ b/src/helpers/windowConfig.js@@ -120,9 +120,18 @@ const NOTIFICATION_WINDOW_CONFIG = {type: FLOATING_OVERLAY_TYPE,};+const TRANSCRIPTION_PREVIEW_SIZE_LIMITS = {+ minWidth: 400,+ defaultWidth: 460,+ maxWidth: 640,+ minHeight: 96,+ defaultHeight: 132,+ maxHeight: 520,+};+const TRANSCRIPTION_PREVIEW_CONFIG = {- width: 380,- height: 200,+ width: TRANSCRIPTION_PREVIEW_SIZE_LIMITS.defaultWidth,+ height: TRANSCRIPTION_PREVIEW_SIZE_LIMITS.defaultHeight,frame: false,transparent: true,alwaysOnTop: true,@@ -174,9 +183,15 @@ class WindowPositionUtil {return { x, y, width, height };}- static getTranscriptionPreviewPosition(display, mainWindowBounds) {- const width = 380;- const height = 200;+ static getTranscriptionPreviewPosition(display, mainWindowBounds, size = {}) {+ const width =+ size.width ||+ TRANSCRIPTION_PREVIEW_CONFIG.width ||+ TRANSCRIPTION_PREVIEW_SIZE_LIMITS.defaultWidth;+ const height =+ size.height ||+ TRANSCRIPTION_PREVIEW_CONFIG.height ||+ TRANSCRIPTION_PREVIEW_SIZE_LIMITS.defaultHeight;const GAP = 8;const workArea = display.workArea || display.bounds;@@ -250,6 +265,7 @@ module.exports = {AGENT_OVERLAY_CONFIG,NOTIFICATION_WINDOW_CONFIG,TRANSCRIPTION_PREVIEW_CONFIG,+ TRANSCRIPTION_PREVIEW_SIZE_LIMITS,WINDOW_SIZES,WindowPositionUtil,};diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.jsindex a3253a5fa..4383088ef 100644--- a/src/helpers/windowManager.js+++ b/src/helpers/windowManager.js@@ -13,6 +13,7 @@ const {AGENT_OVERLAY_CONFIG,NOTIFICATION_WINDOW_CONFIG,TRANSCRIPTION_PREVIEW_CONFIG,+ TRANSCRIPTION_PREVIEW_SIZE_LIMITS,WINDOW_SIZES,WindowPositionUtil,} = require("./windowConfig");@@ -762,7 +763,10 @@ class WindowManager {if (mainBounds) {const display = screen.getDisplayNearestPoint({ x: mainBounds.x, y: mainBounds.y });- const position = WindowPositionUtil.getTranscriptionPreviewPosition(display, mainBounds);+ const position = WindowPositionUtil.getTranscriptionPreviewPosition(display, mainBounds, {+ width: TRANSCRIPTION_PREVIEW_CONFIG.width,+ height: TRANSCRIPTION_PREVIEW_CONFIG.height,+ });this.transcriptionPreviewWindow.setBounds(position);}@@ -776,6 +780,20 @@ class WindowManager {this.transcriptionPreviewWindow.webContents.send("preview-append", text);}+ holdTranscriptionPreview(options = {}) {+ if (!this.transcriptionPreviewWindow || this.transcriptionPreviewWindow.isDestroyed()) return;+ this.transcriptionPreviewWindow.webContents.send("preview-hold", {+ showCleanup: !!options.showCleanup,+ });+ }++ completeTranscriptionPreview(text) {+ if (!this.transcriptionPreviewWindow || this.transcriptionPreviewWindow.isDestroyed()) return;+ this.transcriptionPreviewWindow.webContents.send("preview-result", { text });+ this.transcriptionPreviewWindow.showInactive();+ WindowPositionUtil.setupAlwaysOnTop(this.transcriptionPreviewWindow);+ }+hideTranscriptionPreview() {if (!this.transcriptionPreviewWindow || this.transcriptionPreviewWindow.isDestroyed()) return;@@ -787,6 +805,44 @@ class WindowManager {}, 200);}+ resizeTranscriptionPreview(width, height) {+ if (!this.transcriptionPreviewWindow || this.transcriptionPreviewWindow.isDestroyed()) {+ return { success: false, error: "Preview window not available" };+ }++ const targetWidth = Math.max(+ TRANSCRIPTION_PREVIEW_SIZE_LIMITS.minWidth,+ Math.min(Math.round(width), TRANSCRIPTION_PREVIEW_SIZE_LIMITS.maxWidth)+ );+ const targetHeight = Math.max(+ TRANSCRIPTION_PREVIEW_SIZE_LIMITS.minHeight,+ Math.min(Math.round(height), TRANSCRIPTION_PREVIEW_SIZE_LIMITS.maxHeight)+ );++ const anchorBounds =+ this.mainWindow && !this.mainWindow.isDestroyed()+ ? this.mainWindow.getBounds()+ : this.transcriptionPreviewWindow.getBounds();+ const display = screen.getDisplayNearestPoint({ x: anchorBounds.x, y: anchorBounds.y });+ const bounds = WindowPositionUtil.getTranscriptionPreviewPosition(display, anchorBounds, {+ width: targetWidth,+ height: targetHeight,+ });++ const currentBounds = this.transcriptionPreviewWindow.getBounds();+ if (+ currentBounds.x === bounds.x &&+ currentBounds.y === bounds.y &&+ currentBounds.width === bounds.width &&+ currentBounds.height === bounds.height+ ) {+ return { success: true, bounds };+ }++ this.transcriptionPreviewWindow.setBounds(bounds);+ return { success: true, bounds };+ }+resizeAgentWindow(width, height) {if (!this.agentWindow || this.agentWindow.isDestroyed()) return;diff --git a/src/hooks/useAudioRecording.js b/src/hooks/useAudioRecording.jsindex 719217ed9..90507dd6b 100644--- a/src/hooks/useAudioRecording.js+++ b/src/hooks/useAudioRecording.js@@ -95,6 +95,9 @@ export const useAudioRecording = (toast, options = {}) => {}},onError: (error) => {+ if (error?.title !== "Paste Error") {+ window.electronAPI?.hideDictationPreview?.();+ }const title = getRecordingErrorTitle(error, t);toast({title,@@ -118,10 +121,12 @@ export const useAudioRecording = (toast, options = {}) => {const transcribedText = result.text?.trim();if (!transcribedText) {+ window.electronAPI?.hideDictationPreview?.();return;}setTranscript(result.text);+ window.electronAPI?.completeDictationPreview?.({ text: result.text });const isStreaming = result.source?.includes("streaming");const { keepTranscriptionInClipboard } = getSettings();diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex 7037a2530..a3a037efe 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -2102,6 +2102,13 @@"conversationSelector": "Switch conversation"},"transcriptionPreview": {- "label": "Preview"+ "label": "Preview",+ "listening": "Listening...",+ "polishing": "Polishing...",+ "captured": "Captured",+ "ready": "Ready",+ "copy": "Copy",+ "copied": "Copied",+ "waitingForInput": "Say something..."}}diff --git a/src/types/electron.ts b/src/types/electron.tsindex 4ca8419f2..a54162a57 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -1360,12 +1360,24 @@ declare global {updateNotificationRespond?: (action: string) => Promise<{ success: boolean }>;onPreviewText?: (callback: (text: string) => void) => () => void;onPreviewAppend?: (callback: (text: string) => void) => () => void;+ onPreviewHold?: (callback: (payload: { showCleanup: boolean }) => void) => () => void;+ onPreviewResult?: (callback: (payload: { text: string }) => void) => () => void;onPreviewHide?: (callback: () => void) => () => void;startDictationPreview?: (opts: {provider: string;model: string;}) => Promise<{ success: boolean }>;- stopDictationPreview?: () => Promise<{ success: boolean }>;+ stopDictationPreview?: (opts?: { showCleanup?: boolean }) => Promise<{ success: boolean }>;+ dismissDictationPreview?: () => Promise<{ success: boolean }>;+ completeDictationPreview?: (payload: { text?: string }) => Promise<{ success: boolean }>;+ hideDictationPreview?: () => Promise<{ success: boolean }>;+ resizeTranscriptionPreviewWindow?: (+ width: number,+ height: number+ ) => Promise<{+ success: boolean;+ bounds?: { x: number; y: number; width: number; height: number };+ }>;sendDictationPreviewAudio?: (data: ArrayBuffer) => void;};