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: troubleshooting mode
Gabriel Stein1c76da5c5c49
diff --git a/preload.js b/preload.jsindex b3ba8df8d..dc5eb087f 100644--- a/preload.js+++ b/preload.js@@ -178,6 +178,11 @@ contextBridge.exposeInMainWorld("electronAPI", {getLogLevel: () => ipcRenderer.invoke("get-log-level"),log: (entry) => ipcRenderer.invoke("app-log", entry),+ // Debug logging management+ getDebugState: () => ipcRenderer.invoke("get-debug-state"),+ setDebugLogging: (enabled) => ipcRenderer.invoke("set-debug-logging", enabled),+ openLogsFolder: () => ipcRenderer.invoke("open-logs-folder"),+// System settings helpers for microphone/audio permissionsopenMicrophoneSettings: () => ipcRenderer.invoke("open-microphone-settings"),openSoundInputSettings: () => ipcRenderer.invoke("open-sound-input-settings"),diff --git a/src/components/DeveloperSection.tsx b/src/components/DeveloperSection.tsxnew file mode 100644index 000000000..7a0e37daa--- /dev/null+++ b/src/components/DeveloperSection.tsx@@ -0,0 +1,298 @@+import { useState, useEffect } from "react";+import { Button } from "./ui/button";+import { FolderOpen, Info, Wrench, Copy, Check, AlertCircle, FileText } from "lucide-react";+import { useToast } from "./ui/Toast";++export default function DeveloperSection() {+ const [debugEnabled, setDebugEnabled] = useState(false);+ const [logPath, setLogPath] = useState<string | null>(null);+ const [isLoading, setIsLoading] = useState(true);+ const [isToggling, setIsToggling] = useState(false);+ const [copiedPath, setCopiedPath] = useState(false);+ const { toast } = useToast();++ useEffect(() => {+ loadDebugState();+ }, []);++ const loadDebugState = async () => {+ try {+ setIsLoading(true);+ const state = await window.electronAPI.getDebugState();+ setDebugEnabled(state.enabled);+ setLogPath(state.logPath);+ } catch (error) {+ console.error("Failed to load debug state:", error);+ toast({+ title: "Error loading debug state",+ description: "Could not retrieve debug logging status",+ variant: "destructive",+ });+ } finally {+ setIsLoading(false);+ }+ };++ const handleToggleDebug = async () => {+ if (isToggling) return;++ try {+ setIsToggling(true);+ const newState = !debugEnabled;+ const result = await window.electronAPI.setDebugLogging(newState);++ if (!result.success) {+ throw new Error(result.error || "Failed to update debug logging");+ }++ setDebugEnabled(newState);++ // Reload the state to get updated log path+ await loadDebugState();++ toast({+ title: newState ? "Debug Logging Enabled" : "Debug Logging Disabled",+ description: newState+ ? "Detailed logs are now being written to disk"+ : "Debug logging has been turned off",+ variant: "success",+ });+ } catch (error) {+ toast({+ title: "Error",+ description: `Failed to toggle debug logging: ${error}`,+ variant: "destructive",+ });+ } finally {+ setIsToggling(false);+ }+ };++ const handleOpenLogsFolder = async () => {+ try {+ const result = await window.electronAPI.openLogsFolder();+ if (!result.success) {+ throw new Error(result.error || "Failed to open folder");+ }+ } catch (error) {+ toast({+ title: "Error",+ description: `Failed to open logs folder: ${error}`,+ variant: "destructive",+ });+ }+ };++ const handleCopyPath = async () => {+ if (!logPath) return;++ try {+ await navigator.clipboard.writeText(logPath);+ setCopiedPath(true);+ toast({+ title: "Copied",+ description: "Log file path copied to clipboard",+ variant: "success",+ duration: 2000,+ });+ setTimeout(() => setCopiedPath(false), 2000);+ } catch (error) {+ toast({+ title: "Copy Failed",+ description: "Could not copy path to clipboard",+ variant: "destructive",+ });+ }+ };++ return (+ <div className="space-y-6">+ {/* Header */}+ <div>+ <h3 className="text-lg font-semibold text-gray-900 mb-2">Troubleshooting</h3>+ <p className="text-sm text-gray-600">+ Enable debug logging to diagnose issues and share logs for support+ </p>+ </div>++ {/* Main Debug Logging Card */}+ <div className="space-y-4 p-6 bg-linear-to-br from-slate-50 via-slate-50 to-slate-100 border border-slate-200 rounded-xl shadow-sm">+ {/* Header with status */}+ <div className="flex items-center justify-between mb-3">+ <div className="flex items-center gap-3">+ <div className="p-2 bg-slate-800 rounded-lg">+ <Wrench className="w-5 h-5 text-slate-100" />+ </div>+ <div>+ <h4 className="font-semibold text-slate-900">Debug Logging</h4>+ <div className="flex items-center gap-2 mt-1">+ <div+ className={`w-2 h-2 rounded-full ${+ debugEnabled+ ? "bg-emerald-500 animate-pulse shadow-lg shadow-emerald-500/50"+ : "bg-slate-300"+ }`}+ />+ <span className="text-xs font-medium text-slate-600">+ {isLoading ? "Loading..." : debugEnabled ? "Active" : "Inactive"}+ </span>+ </div>+ </div>+ </div>+ </div>++ {/* Description */}+ <p className="text-sm text-slate-600 leading-relaxed">+ Captures detailed logs of audio processing, transcription, and system operations. Enable+ this when experiencing issues to help diagnose problems.+ </p>++ {/* Log Path Display - Only when active */}+ {debugEnabled && logPath && (+ <div className="space-y-2">+ <label className="text-xs font-medium text-slate-600 uppercase tracking-wide">+ Current Log File+ </label>+ <div className="flex gap-2">+ <div className="flex-1 p-3 bg-slate-900 rounded-lg border border-slate-700 overflow-hidden">+ <code className="text-xs text-emerald-400 break-all leading-relaxed">+ {logPath}+ </code>+ </div>+ <Button+ onClick={handleCopyPath}+ variant="outline"+ size="icon"+ className="h-12 w-12 border-slate-300 hover:bg-slate-100"+ title="Copy log path"+ >+ {copiedPath ? (+ <Check className="h-4 w-4 text-emerald-600" />+ ) : (+ <Copy className="h-4 w-4 text-slate-600" />+ )}+ </Button>+ </div>+ </div>+ )}++ {/* Action Buttons */}+ <div className="flex gap-3 pt-2">+ <Button+ onClick={handleToggleDebug}+ disabled={isLoading || isToggling}+ className={`flex-1 font-medium ${+ debugEnabled+ ? "bg-amber-600 hover:bg-amber-700 text-white shadow-md shadow-amber-600/20"+ : "bg-slate-800 hover:bg-slate-900 text-white shadow-md shadow-slate-800/20"+ }`}+ >+ {isToggling ? (+ <>+ <div className="w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin mr-2" />+ {debugEnabled ? "Disabling..." : "Enabling..."}+ </>+ ) : (+ <>{debugEnabled ? "Disable Debug Mode" : "Enable Debug Mode"}</>+ )}+ </Button>++ <Button+ onClick={handleOpenLogsFolder}+ variant="outline"+ disabled={!debugEnabled || isLoading}+ className={`flex-1 font-medium ${+ debugEnabled+ ? "border-slate-300 hover:bg-slate-100 hover:border-slate-400"+ : "opacity-50 cursor-not-allowed"+ }`}+ >+ <FolderOpen className="mr-2 h-4 w-4" />+ Open Logs Folder+ </Button>+ </div>+ </div>++ {/* Sharing Instructions - Only when enabled */}+ {debugEnabled && (+ <div className="p-5 bg-linear-to-br from-indigo-50 to-blue-50 border border-indigo-200 rounded-xl">+ <div className="flex items-start gap-3">+ <div className="p-2 bg-indigo-600 rounded-lg mt-0.5">+ <FileText className="w-4 h-4 text-white" />+ </div>+ <div className="flex-1">+ <h4 className="font-semibold text-indigo-900 mb-2">How to Share Logs for Support</h4>+ <div className="text-sm text-indigo-800 space-y-2">+ <p>To help us diagnose your issue:</p>+ <ol className="space-y-1 ml-4 list-decimal">+ <li>Reproduce the issue while debug mode is enabled</li>+ <li>Click "Open Logs Folder" above</li>+ <li>Find the most recent log file (sorted by date)</li>+ <li>Attach the log file to your bug report or support email</li>+ </ol>+ <p className="text-xs text-indigo-700 mt-3 pt-3 border-t border-indigo-200">+ Your logs don't contain API keys or sensitive data+ </p>+ </div>+ </div>+ </div>+ </div>+ )}++ {/* Information Cards */}+ <div className="grid grid-cols-1 gap-4">+ {/* What Gets Logged */}+ <div className="p-4 bg-blue-50 border border-blue-200 rounded-lg">+ <div className="flex items-start gap-3">+ <Info className="w-5 h-5 text-blue-600 mt-0.5 flex-shrink-0" />+ <div className="flex-1 min-w-0">+ <h4 className="font-medium text-blue-900 mb-2">What Gets Logged</h4>+ <div className="grid grid-cols-2 gap-x-4 gap-y-1 text-sm text-blue-800">+ <div className="flex items-center gap-2">+ <div className="w-1 h-1 rounded-full bg-blue-600" />+ <span>Audio processing</span>+ </div>+ <div className="flex items-center gap-2">+ <div className="w-1 h-1 rounded-full bg-blue-600" />+ <span>API requests</span>+ </div>+ <div className="flex items-center gap-2">+ <div className="w-1 h-1 rounded-full bg-blue-600" />+ <span>FFmpeg operations</span>+ </div>+ <div className="flex items-center gap-2">+ <div className="w-1 h-1 rounded-full bg-blue-600" />+ <span>System diagnostics</span>+ </div>+ <div className="flex items-center gap-2">+ <div className="w-1 h-1 rounded-full bg-blue-600" />+ <span>Transcription pipeline</span>+ </div>+ <div className="flex items-center gap-2">+ <div className="w-1 h-1 rounded-full bg-blue-600" />+ <span>Error details</span>+ </div>+ </div>+ </div>+ </div>+ </div>++ {/* Performance Note */}+ {debugEnabled && (+ <div className="p-4 bg-amber-50 border border-amber-200 rounded-lg">+ <div className="flex items-start gap-3">+ <AlertCircle className="w-5 h-5 text-amber-600 mt-0.5 flex-shrink-0" />+ <div className="flex-1">+ <h4 className="font-medium text-amber-900 mb-1">Performance Note</h4>+ <p className="text-sm text-amber-800">+ Debug logging writes detailed information to disk and may have a minor impact on+ app performance. Disable it when not troubleshooting.+ </p>+ </div>+ </div>+ </div>+ )}+ </div>+ </div>+ );+}diff --git a/src/components/SettingsModal.tsx b/src/components/SettingsModal.tsxindex b2e72b640..e153d3148 100644--- a/src/components/SettingsModal.tsx+++ b/src/components/SettingsModal.tsx@@ -1,5 +1,5 @@import React from "react";-import { Settings, Mic, Brain, User, Sparkles } from "lucide-react";+import { Settings, Mic, Brain, User, Sparkles, Wrench } from "lucide-react";import SidebarModal, { SidebarItem } from "./ui/SidebarModal";import SettingsPage, { SettingsSectionType } from "./SettingsPage";@@ -15,6 +15,7 @@ export default function SettingsModal({ open, onOpenChange }: SettingsModalProps{ id: "aiModels", label: "AI Models", icon: Brain },{ id: "agentConfig", label: "Agent Configuration", icon: User },{ id: "prompts", label: "AI Prompts", icon: Sparkles },+ { id: "developer", label: "Troubleshooting", icon: Wrench },];const [activeSection, setActiveSection] = React.useState<SettingsSectionType>("general");diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsxindex cef33d274..b19cbbfca 100644--- a/src/components/SettingsPage.tsx+++ b/src/components/SettingsPage.tsx@@ -22,13 +22,15 @@ import type { UpdateInfoResult } from "../types/electron";import { HotkeyInput } from "./ui/HotkeyInput";import { useHotkeyRegistration } from "../hooks/useHotkeyRegistration";import { ActivationModeSelector } from "./ui/ActivationModeSelector";+import DeveloperSection from "./DeveloperSection";export type SettingsSectionType =| "general"| "transcription"| "aiModels"| "agentConfig"- | "prompts";+ | "prompts"+ | "developer";interface SettingsPageProps {activeSection?: SettingsSectionType;@@ -695,7 +697,7 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage</p></div>- <div className="space-y-4 p-4 bg-gradient-to-r from-purple-50 to-blue-50 border border-purple-200 rounded-xl">+ <div className="space-y-4 p-4 bg-linear-to-r from-purple-50 to-blue-50 border border-purple-200 rounded-xl"><h4 className="font-medium text-purple-900 mb-3">💡 How to use agent names:</h4><ul className="text-sm text-purple-800 space-y-2"><li>• Say "Hey {agentName}, write a formal email" for specific instructions</li>@@ -766,6 +768,10 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage<PromptStudio /></div>);++ case "developer":+ return <DeveloperSection />;+default:return null;}diff --git a/src/helpers/clipboard.js b/src/helpers/clipboard.jsindex 25897b003..886ac6980 100644--- a/src/helpers/clipboard.js+++ b/src/helpers/clipboard.js@@ -436,17 +436,21 @@ class ClipboardManager {const xdotoolExists = this.commandExists("xdotool");const wtypeExists = this.commandExists("wtype");- debugLogger.debug("Linux paste environment", {- isWayland,- xwaylandAvailable,- isGnome,- xdotoolExists,- wtypeExists,- display: process.env.DISPLAY,- waylandDisplay: process.env.WAYLAND_DISPLAY,- xdgSessionType: process.env.XDG_SESSION_TYPE,- xdgCurrentDesktop: process.env.XDG_CURRENT_DESKTOP,- }, "clipboard");+ debugLogger.debug(+ "Linux paste environment",+ {+ isWayland,+ xwaylandAvailable,+ isGnome,+ xdotoolExists,+ wtypeExists,+ display: process.env.DISPLAY,+ waylandDisplay: process.env.WAYLAND_DISPLAY,+ xdgSessionType: process.env.XDG_SESSION_TYPE,+ xdgCurrentDesktop: process.env.XDG_CURRENT_DESKTOP,+ },+ "clipboard"+ );// Get the active window ID before any focus changes// This is critical for X11 where our window might briefly take focus@@ -579,14 +583,18 @@ class ClipboardManager {// Filter to only available tools (this.commandExists is already cached)const available = candidates.filter((c) => this.commandExists(c.cmd));- debugLogger.debug("Available paste tools", {- candidateTools: candidates.map(c => c.cmd),- availableTools: available.map(c => c.cmd),- targetWindowId,- xdotoolWindowClass,- inTerminal,- pasteKeys,- }, "clipboard");+ debugLogger.debug(+ "Available paste tools",+ {+ candidateTools: candidates.map((c) => c.cmd),+ availableTools: available.map((c) => c.cmd),+ targetWindowId,+ xdotoolWindowClass,+ inTerminal,+ pasteKeys,+ },+ "clipboard"+ );// Attempt paste with a specific toolconst pasteWith = (tool) =>@@ -595,12 +603,16 @@ class ClipboardManager {const delay = isWayland ? 0 : PASTE_DELAYS.linux;setTimeout(() => {- debugLogger.debug("Attempting paste", {- cmd: tool.cmd,- args: tool.args,- delay,- isWayland,- }, "clipboard");+ debugLogger.debug(+ "Attempting paste",+ {+ cmd: tool.cmd,+ args: tool.args,+ delay,+ isWayland,+ },+ "clipboard"+ );const proc = spawn(tool.cmd, tool.args);let stderr = "";@@ -618,10 +630,14 @@ class ClipboardManager {const timeoutId = setTimeout(() => {timedOut = true;killProcess(proc, "SIGKILL");- debugLogger.warn("Paste tool timed out", {- cmd: tool.cmd,- timeoutMs: 2000,- }, "clipboard");+ debugLogger.warn(+ "Paste tool timed out",+ {+ cmd: tool.cmd,+ timeoutMs: 2000,+ },+ "clipboard"+ );}, 2000); // Increased timeout to 2s for windowactivate --syncproc.on("close", (code) => {@@ -635,25 +651,37 @@ class ClipboardManager {setTimeout(() => clipboard.writeText(originalClipboard), RESTORE_DELAYS.linux);resolve();} else {- debugLogger.error("Paste command failed", {- cmd: tool.cmd,- args: tool.args,- exitCode: code,- stderr: stderr.trim(),- stdout: stdout.trim(),- }, "clipboard");- reject(new Error(`${tool.cmd} exited with code ${code}${stderr ? `: ${stderr.trim()}` : ""}`));+ debugLogger.error(+ "Paste command failed",+ {+ cmd: tool.cmd,+ args: tool.args,+ exitCode: code,+ stderr: stderr.trim(),+ stdout: stdout.trim(),+ },+ "clipboard"+ );+ reject(+ new Error(+ `${tool.cmd} exited with code ${code}${stderr ? `: ${stderr.trim()}` : ""}`+ )+ );}});proc.on("error", (error) => {if (timedOut) return;clearTimeout(timeoutId);- debugLogger.error("Paste command spawn error", {- cmd: tool.cmd,- error: error.message,- code: error.code,- }, "clipboard");+ debugLogger.error(+ "Paste command spawn error",+ {+ cmd: tool.cmd,+ error: error.message,+ code: error.code,+ },+ "clipboard"+ );reject(error);});}, delay);@@ -686,10 +714,14 @@ class ClipboardManager {// This bypasses clipboard paste entirely and is more reliable for terminal emulators// that may have issues with Ctrl+Shift+V keystroke simulationif (inTerminal && xdotoolExists && !isWayland) {- debugLogger.debug("Trying xdotool type fallback for terminal", {- textLength: clipboard.readText().length,- targetWindowId,- }, "clipboard");+ debugLogger.debug(+ "Trying xdotool type fallback for terminal",+ {+ textLength: clipboard.readText().length,+ targetWindowId,+ },+ "clipboard"+ );this.safeLog("🔄 Trying xdotool type fallback for terminal...");const textToType = clipboard.readText(); // Read what we put in clipboardconst typeArgs = targetWindowId@@ -714,9 +746,10 @@ class ClipboardManager {}// All tools failed - create specific error for renderer to handle- const failureSummary = failedAttempts.length > 0- ? `\n\nAttempted tools: ${failedAttempts.map(f => `${f.tool} (${f.error})`).join(", ")}`- : "";+ const failureSummary =+ failedAttempts.length > 0+ ? `\n\nAttempted tools: ${failedAttempts.map((f) => `${f.tool} (${f.error})`).join(", ")}`+ : "";let errorMsg;if (isWayland) {@@ -765,12 +798,16 @@ class ClipboardManager {const err = new Error(errorMsg + failureSummary);err.code = "PASTE_SIMULATION_FAILED";err.failedAttempts = failedAttempts;- debugLogger.error("Throwing paste simulation failed error", {- errorMsg,- failedAttempts,- isWayland,- isGnome,- }, "clipboard");+ debugLogger.error(+ "Throwing paste simulation failed error",+ {+ errorMsg,+ failedAttempts,+ isWayland,+ isGnome,+ },+ "clipboard"+ );throw err;}diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex ea89a36c2..0e12bccda 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -1,4 +1,5 @@const { ipcMain, app, shell, BrowserWindow } = require("electron");+const path = require("path");const AppUtils = require("../utils");const debugLogger = require("./debugLogger");@@ -627,6 +628,88 @@ class IPCHandlers {return { success: false, error: error.message };}});++ // Debug logging handlers+ ipcMain.handle("get-debug-state", async () => {+ try {+ return {+ enabled: debugLogger.isEnabled(),+ logPath: debugLogger.getLogPath(),+ logLevel: debugLogger.getLevel(),+ };+ } catch (error) {+ debugLogger.error("Failed to get debug state:", error);+ return { enabled: false, logPath: null, logLevel: "info" };+ }+ });++ ipcMain.handle("set-debug-logging", async (event, enabled) => {+ try {+ const path = require("path");+ const fs = require("fs");+ const envPath = path.join(app.getPath("userData"), ".env");++ // Read current .env content+ let envContent = "";+ if (fs.existsSync(envPath)) {+ envContent = fs.readFileSync(envPath, "utf8");+ }++ // Parse lines+ const lines = envContent.split("\n");+ const logLevelIndex = lines.findIndex((line) =>+ line.trim().startsWith("OPENWHISPR_LOG_LEVEL=")+ );++ if (enabled) {+ // Set to debug+ if (logLevelIndex !== -1) {+ lines[logLevelIndex] = "OPENWHISPR_LOG_LEVEL=debug";+ } else {+ // Add new line+ if (lines.length > 0 && lines[lines.length - 1] !== "") {+ lines.push("");+ }+ lines.push("# Debug logging setting");+ lines.push("OPENWHISPR_LOG_LEVEL=debug");+ }+ } else {+ // Remove or set to info+ if (logLevelIndex !== -1) {+ lines[logLevelIndex] = "OPENWHISPR_LOG_LEVEL=info";+ }+ }++ // Write back+ fs.writeFileSync(envPath, lines.join("\n"), "utf8");++ // Update environment variable+ process.env.OPENWHISPR_LOG_LEVEL = enabled ? "debug" : "info";++ // Refresh logger state+ debugLogger.refreshLogLevel();++ return {+ success: true,+ enabled: debugLogger.isEnabled(),+ logPath: debugLogger.getLogPath(),+ };+ } catch (error) {+ debugLogger.error("Failed to set debug logging:", error);+ return { success: false, error: error.message };+ }+ });++ ipcMain.handle("open-logs-folder", async () => {+ try {+ const logsDir = path.join(app.getPath("userData"), "logs");+ await shell.openPath(logsDir);+ return { success: true };+ } catch (error) {+ debugLogger.error("Failed to open logs folder:", error);+ return { success: false, error: error.message };+ }+ });}broadcastToWindows(channel, payload) {diff --git a/src/types/electron.ts b/src/types/electron.tsindex e3ee923a3..21ec64c44 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -278,6 +278,18 @@ declare global {scope?: string;source?: string;}) => Promise<void>;+ getDebugState: () => Promise<{+ enabled: boolean;+ logPath: string | null;+ logLevel: string;+ }>;+ setDebugLogging: (enabled: boolean) => Promise<{+ success: boolean;+ enabled?: boolean;+ logPath?: string | null;+ error?: string;+ }>;+ openLogsFolder: () => Promise<{ success: boolean; error?: string }>;// FFmpeg availabilitycheckFFmpegAvailability: () => Promise<FFmpegAvailabilityResult>;