Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

cleanup: cleaned up excessive logging

Gabriel Steinca4d529a5d9f
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsx
index 8da8e6e29..d0263a7ec 100644
--- a/src/components/ControlPanel.tsx
+++ b/src/components/ControlPanel.tsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from "react";
+import { useState, useEffect } from "react";
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card";
import { Button } from "./ui/button";
import { Trash2, RefreshCw, Settings, FileText, Mic } from "lucide-react";
@@ -43,24 +43,35 @@ export default function ControlPanel() {
const status = await window.electronAPI.getUpdateStatus();
setUpdateStatus(status);
} catch (error) {
- console.error("Error initializing update status:", error);
+ // Update status not critical for app function
}
};
initializeUpdateStatus();
// Set up update event listeners
- window.electronAPI.onUpdateAvailable((event, info) => {
+ const handleUpdateAvailable = (_event: any, _info: any) => {
setUpdateStatus((prev) => ({ ...prev, updateAvailable: true }));
- });
+ };
- window.electronAPI.onUpdateDownloaded((event, info) => {
+ const handleUpdateDownloaded = (_event: any, _info: any) => {
setUpdateStatus((prev) => ({ ...prev, updateDownloaded: true }));
- });
+ };
- window.electronAPI.onUpdateError((event, error) => {
- console.error("Update error:", error);
- });
+ const handleUpdateError = (_event: any, _error: any) => {
+ // Update errors are handled by the update service
+ };
+
+ window.electronAPI.onUpdateAvailable(handleUpdateAvailable);
+ window.electronAPI.onUpdateDownloaded(handleUpdateDownloaded);
+ window.electronAPI.onUpdateError(handleUpdateError);
+
+ // Cleanup listeners on unmount
+ return () => {
+ window.electronAPI.removeAllListeners?.("update-available");
+ window.electronAPI.removeAllListeners?.("update-downloaded");
+ window.electronAPI.removeAllListeners?.("update-error");
+ };
}, []);
const loadTranscriptions = async () => {
@@ -127,7 +138,6 @@ export default function ControlPanel() {
if (result.success) {
// Remove from local state
setHistory((prev) => prev.filter((item) => item.id !== id));
- console.log(`πŸ—‘οΈ Deleted transcription ${id}`);
} else {
showAlertDialog({
title: "Delete Failed",
@@ -136,7 +146,6 @@ export default function ControlPanel() {
});
}
} catch (error) {
- console.error("❌ Failed to delete transcription:", error);
showAlertDialog({
title: "Delete Failed",
description: "Failed to delete transcription. Please try again.",
@@ -148,7 +157,6 @@ export default function ControlPanel() {
};
const refreshHistory = async () => {
- console.log("πŸ”„ Refreshing transcription history...");
await loadTranscriptions();
};
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index 1dde914b7..4524df092 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -94,49 +94,70 @@ export default function SettingsPage({
// Defer heavy operations for better performance
useEffect(() => {
+ let mounted = true;
+
// Defer version and update checks to improve initial render
const timer = setTimeout(async () => {
+ if (!mounted) return;
+
const versionResult = await window.electronAPI?.getAppVersion();
- if (versionResult) setCurrentVersion(versionResult.version);
+ if (versionResult && mounted) setCurrentVersion(versionResult.version);
const statusResult = await window.electronAPI?.getUpdateStatus();
- if (statusResult) {
+ if (statusResult && mounted) {
setUpdateStatus(statusResult);
subscribeToUpdates();
}
// Check whisper after initial render
- whisperHook.checkWhisperInstallation();
+ if (mounted) {
+ whisperHook.checkWhisperInstallation();
+ }
}, 100);
- return () => clearTimeout(timer);
+ return () => {
+ mounted = false;
+ clearTimeout(timer);
+ // Always clean up update listeners if they exist
+ if (window.electronAPI) {
+ window.electronAPI.removeAllListeners?.("update-available");
+ window.electronAPI.removeAllListeners?.("update-downloaded");
+ window.electronAPI.removeAllListeners?.("update-error");
+ window.electronAPI.removeAllListeners?.("update-download-progress");
+ }
+ };
}, [whisperHook]);
const subscribeToUpdates = () => {
if (window.electronAPI) {
- window.electronAPI.onUpdateAvailable?.((event, info) => {
+ const handleUpdateAvailable = (event, info) => {
setUpdateStatus((prev) => ({ ...prev, updateAvailable: true }));
setUpdateInfo({
version: info.version,
releaseDate: info.releaseDate,
releaseNotes: info.releaseNotes,
});
- });
+ };
- window.electronAPI.onUpdateDownloaded?.((event, info) => {
+ const handleUpdateDownloaded = (event, info) => {
setUpdateStatus((prev) => ({ ...prev, updateDownloaded: true }));
setDownloadingUpdate(false);
- });
+ };
- window.electronAPI.onUpdateDownloadProgress?.((event, progressObj) => {
+ const handleUpdateProgress = (event, progressObj) => {
setUpdateDownloadProgress(progressObj.percent || 0);
- });
+ };
- window.electronAPI.onUpdateError?.((event, error) => {
+ const handleUpdateError = (event, error) => {
setCheckingForUpdates(false);
setDownloadingUpdate(false);
console.error("Update error:", error);
- });
+ };
+
+ window.electronAPI.onUpdateAvailable?.(handleUpdateAvailable);
+ window.electronAPI.onUpdateDownloaded?.(handleUpdateDownloaded);
+ window.electronAPI.onUpdateDownloadProgress?.(handleUpdateProgress);
+ window.electronAPI.onUpdateError?.(handleUpdateError);
}
};
diff --git a/src/helpers/clipboard.js b/src/helpers/clipboard.js
index 72e4b9a9f..9d92149bd 100644
--- a/src/helpers/clipboard.js
+++ b/src/helpers/clipboard.js
@@ -6,15 +6,16 @@ class ClipboardManager {
// Initialize clipboard manager
}
- // Safe logging method to prevent EPIPE errors
+ // Safe logging method - only log in development
safeLog(...args) {
- try {
- console.log(...args);
- } catch (error) {
- // Silently ignore EPIPE errors in logging
- if (error.code !== "EPIPE") {
- // Only log non-EPIPE errors to stderr
- process.stderr.write(`Log error: ${error.message}\n`);
+ if (process.env.NODE_ENV === "development") {
+ try {
+ console.log(...args);
+ } catch (error) {
+ // Silently ignore EPIPE errors in logging
+ if (error.code !== "EPIPE") {
+ process.stderr.write(`Log error: ${error.message}\n`);
+ }
}
}
}
@@ -59,13 +60,11 @@ class ClipboardManager {
return await this.pasteLinux(originalClipboard);
}
} catch (error) {
- console.error("❌ Paste error:", error);
throw error;
}
}
async pasteMacOS(originalClipboard) {
- console.log("🍎 Attempting macOS paste...");
return new Promise((resolve, reject) => {
setTimeout(() => {
const pasteProcess = spawn("osascript", [
@@ -97,8 +96,6 @@ class ClipboardManager {
}, 100);
resolve();
} else {
- console.error("❌ Failed to paste text, code:", code);
- console.error("Error output:", errorOutput);
const errorMsg = `Paste failed (code ${code}). Text is copied to clipboard - please paste manually with Cmd+V.`;
reject(new Error(errorMsg));
}
@@ -108,7 +105,6 @@ class ClipboardManager {
if (hasTimedOut) return;
clearTimeout(timeoutId);
pasteProcess.removeAllListeners();
- console.error("❌ Error running paste command:", error);
const errorMsg = `Paste command failed: ${error.message}. Text is copied to clipboard - please paste manually with Cmd+V.`;
reject(new Error(errorMsg));
});
@@ -117,7 +113,6 @@ class ClipboardManager {
hasTimedOut = true;
pasteProcess.kill("SIGKILL");
pasteProcess.removeAllListeners();
- console.error("⏰ Paste operation timed out");
const errorMsg =
"Paste operation timed out. Text is copied to clipboard - please paste manually with Cmd+V.";
reject(new Error(errorMsg));
@@ -127,7 +122,6 @@ class ClipboardManager {
}
async pasteWindows(originalClipboard) {
- console.log("πŸͺŸ Simulating Ctrl+V on Windows");
return new Promise((resolve, reject) => {
const pasteProcess = spawn("powershell", [
"-Command",
@@ -136,14 +130,12 @@ class ClipboardManager {
pasteProcess.on("close", (code) => {
if (code === 0) {
- console.log("βœ… Text pasted successfully on Windows");
+ // Text pasted successfully
setTimeout(() => {
clipboard.writeText(originalClipboard);
- console.log("πŸ”„ Original clipboard content restored");
}, 100);
resolve();
} else {
- console.error("❌ Failed to paste on Windows, code:", code);
reject(
new Error(
`Windows paste failed with code ${code}. Text is copied to clipboard.`
@@ -153,7 +145,6 @@ class ClipboardManager {
});
pasteProcess.on("error", (error) => {
- console.error("❌ Windows paste error:", error);
reject(
new Error(
`Windows paste failed: ${error.message}. Text is copied to clipboard.`
@@ -164,20 +155,17 @@ class ClipboardManager {
}
async pasteLinux(originalClipboard) {
- console.log("🐧 Simulating Ctrl+V on Linux");
return new Promise((resolve, reject) => {
const pasteProcess = spawn("xdotool", ["key", "ctrl+v"]);
pasteProcess.on("close", (code) => {
if (code === 0) {
- console.log("βœ… Text pasted successfully on Linux");
+ // Text pasted successfully
setTimeout(() => {
clipboard.writeText(originalClipboard);
- console.log("πŸ”„ Original clipboard content restored");
}, 100);
resolve();
} else {
- console.error("❌ Failed to paste on Linux, code:", code);
reject(
new Error(
`Linux paste failed with code ${code}. Text is copied to clipboard.`
@@ -187,7 +175,6 @@ class ClipboardManager {
});
pasteProcess.on("error", (error) => {
- console.error("❌ Linux paste error:", error);
reject(
new Error(
`Linux paste failed: ${error.message}. Text is copied to clipboard.`
@@ -201,7 +188,7 @@ class ClipboardManager {
if (process.platform !== "darwin") return true;
return new Promise((resolve) => {
- console.log("πŸ” Checking accessibility permissions...");
+ // Check accessibility permissions
const testProcess = spawn("osascript", [
"-e",
@@ -220,23 +207,15 @@ class ClipboardManager {
});
testProcess.on("close", (code) => {
- console.log("Initial accessibility test - Code:", code);
- console.log("Test output:", testOutput);
- console.log("Test error:", testError);
-
if (code === 0) {
- console.log("βœ… Accessibility permissions: GRANTED");
resolve(true);
} else {
- console.log("❌ Accessibility permissions: DENIED");
this.showAccessibilityDialog(testError);
resolve(false);
}
});
testProcess.on("error", (error) => {
- console.error("Error checking accessibility permissions:", error);
- console.log("Fallback: Assuming permissions are needed");
resolve(false);
});
});
@@ -298,13 +277,7 @@ Would you like to open System Settings now?`;
});
permissionDialog.on("error", (error) => {
- console.error("Error showing permission dialog:", error);
- console.log(
- "Fallback: User needs to manually grant accessibility permissions"
- );
- console.log(
- "πŸ’‘ TIP: If this is a rebuilt app, remove old OpenWispr entries from Accessibility settings first"
- );
+ // Permission dialog error - user will need to manually grant permissions
});
}
@@ -327,32 +300,21 @@ Would you like to open System Settings now?`;
const settingsProcess = spawn(cmd, args);
settingsProcess.on("error", (error) => {
- console.log(`Settings command ${commandIndex + 1} failed:`, error);
commandIndex++;
tryNextCommand();
});
settingsProcess.on("close", (settingsCode) => {
if (settingsCode !== 0) {
- console.log(
- `Settings command ${commandIndex + 1} failed with code:`,
- settingsCode
- );
commandIndex++;
tryNextCommand();
- } else {
- console.log(
- `βœ… Opened System Settings with command ${commandIndex + 1}`
- );
}
});
} else {
- console.log(
- "❌ All settings commands failed, user will need to open manually"
- );
+ // All settings commands failed, try fallback
spawn("open", ["-a", "System Preferences"]).on("error", () => {
spawn("open", ["-a", "System Settings"]).on("error", () => {
- console.log("Could not open settings app");
+ // Could not open settings app
});
});
}
@@ -364,10 +326,8 @@ Would you like to open System Settings now?`;
async readClipboard() {
try {
const text = clipboard.readText();
- console.log("πŸ“‹ Clipboard read:", text ? "Text found" : "Empty");
return text;
} catch (error) {
- console.error("❌ Error reading clipboard:", error);
throw error;
}
}
@@ -375,13 +335,8 @@ Would you like to open System Settings now?`;
async writeClipboard(text) {
try {
clipboard.writeText(text);
- console.log(
- "πŸ“‹ Text written to clipboard:",
- text.substring(0, 50) + "..."
- );
return { success: true };
} catch (error) {
- console.error("❌ Error writing to clipboard:", error);
throw error;
}
}
diff --git a/src/helpers/debugLogger.js b/src/helpers/debugLogger.js
index c66d7f8ea..716cd89f4 100644
--- a/src/helpers/debugLogger.js
+++ b/src/helpers/debugLogger.js
@@ -1,88 +1,94 @@
-const fs = require('fs');
-const path = require('path');
-const { app } = require('electron');
+const fs = require("fs");
+const path = require("path");
+const { app } = require("electron");
class DebugLogger {
constructor() {
- // Check multiple sources for debug mode
- this.debugMode = process.env.OPENWISPR_DEBUG === 'true' ||
- process.argv.includes('--debug') ||
- process.env.NODE_ENV === 'development' ||
- this.checkDebugFile();
+ // Only enable debug mode when explicitly requested
+ this.debugMode =
+ process.env.OPENWISPR_DEBUG === "true" ||
+ process.argv.includes("--debug") ||
+ this.checkDebugFile();
this.logFile = null;
this.logStream = null;
-
+
if (this.debugMode) {
// Create logs directory
- const logsDir = path.join(app.getPath('userData'), 'logs');
+ const logsDir = path.join(app.getPath("userData"), "logs");
if (!fs.existsSync(logsDir)) {
fs.mkdirSync(logsDir, { recursive: true });
}
-
+
// Create log file with timestamp
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
+ const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
this.logFile = path.join(logsDir, `debug-${timestamp}.log`);
-
+
// Create write stream for better performance
- this.logStream = fs.createWriteStream(this.logFile, { flags: 'a' });
-
- this.log('πŸš€ Debug logging enabled', `Log file: ${this.logFile}`);
- this.log('System Info:', {
+ this.logStream = fs.createWriteStream(this.logFile, { flags: "a" });
+
+ this.log("πŸš€ Debug logging enabled", `Log file: ${this.logFile}`);
+ this.log("System Info:", {
platform: process.platform,
nodeVersion: process.version,
electronVersion: process.versions.electron,
appPath: app.getAppPath(),
- userDataPath: app.getPath('userData'),
+ userDataPath: app.getPath("userData"),
resourcesPath: process.resourcesPath,
- environment: process.env.NODE_ENV
+ environment: process.env.NODE_ENV,
});
}
}
-
+
log(...args) {
if (!this.debugMode) return;
-
+
const timestamp = new Date().toISOString();
- const message = args.map(arg =>
- typeof arg === 'object' ? JSON.stringify(arg, null, 2) : String(arg)
- ).join(' ');
-
+ const message = args
+ .map((arg) =>
+ typeof arg === "object" ? JSON.stringify(arg, null, 2) : String(arg)
+ )
+ .join(" ");
+
const logLine = `[${timestamp}] ${message}\n`;
-
+
console.log(...args);
-
+
if (this.logStream) {
this.logStream.write(logLine);
}
}
-
+
error(...args) {
if (!this.debugMode) return;
-
+
const timestamp = new Date().toISOString();
- const message = '❌ ERROR: ' + args.map(arg =>
- typeof arg === 'object' ? JSON.stringify(arg, null, 2) : String(arg)
- ).join(' ');
-
+ const message =
+ "❌ ERROR: " +
+ args
+ .map((arg) =>
+ typeof arg === "object" ? JSON.stringify(arg, null, 2) : String(arg)
+ )
+ .join(" ");
+
const logLine = `[${timestamp}] ${message}\n`;
-
+
console.error(...args);
-
+
if (this.logStream) {
this.logStream.write(logLine);
}
}
-
+
logFFmpegDebug(context, ffmpegPath, additionalInfo = {}) {
if (!this.debugMode) return;
-
+
const debugInfo = {
context,
ffmpegPath,
exists: ffmpegPath ? fs.existsSync(ffmpegPath) : false,
- ...additionalInfo
+ ...additionalInfo,
};
-
+
if (ffmpegPath && fs.existsSync(ffmpegPath)) {
try {
const stats = fs.statSync(ffmpegPath);
@@ -91,13 +97,13 @@ class DebugLogger {
isFile: stats.isFile(),
isExecutable: !!(stats.mode & fs.constants.X_OK),
permissions: stats.mode.toString(8),
- modified: stats.mtime
+ modified: stats.mtime,
};
} catch (e) {
debugInfo.statError = e.message;
}
}
-
+
// Check parent directory permissions
if (ffmpegPath) {
const dir = path.dirname(ffmpegPath);
@@ -109,53 +115,67 @@ class DebugLogger {
debugInfo.dirError = e.message;
}
}
-
+
// Check all possible FFmpeg locations
const possiblePaths = [
ffmpegPath,
- ffmpegPath?.replace('app.asar', 'app.asar.unpacked'),
- path.join(process.resourcesPath || '', 'app.asar.unpacked', 'node_modules', 'ffmpeg-static', process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'),
- '/usr/local/bin/ffmpeg',
- '/opt/homebrew/bin/ffmpeg',
- '/usr/bin/ffmpeg'
+ ffmpegPath?.replace("app.asar", "app.asar.unpacked"),
+ path.join(
+ process.resourcesPath || "",
+ "app.asar.unpacked",
+ "node_modules",
+ "ffmpeg-static",
+ process.platform === "win32" ? "ffmpeg.exe" : "ffmpeg"
+ ),
+ "/usr/local/bin/ffmpeg",
+ "/opt/homebrew/bin/ffmpeg",
+ "/usr/bin/ffmpeg",
].filter(Boolean);
-
- debugInfo.pathChecks = possiblePaths.map(p => ({
+
+ debugInfo.pathChecks = possiblePaths.map((p) => ({
path: p,
- exists: fs.existsSync(p)
+ exists: fs.existsSync(p),
}));
-
+
this.log(`🎬 FFmpeg Debug - ${context}`, debugInfo);
}
-
+
logAudioData(context, audioBlob) {
if (!this.debugMode) return;
-
+
const audioInfo = {
context,
- type: audioBlob?.type || 'unknown',
+ type: audioBlob?.type || "unknown",
size: audioBlob?.size || 0,
- constructor: audioBlob?.constructor?.name || 'unknown'
+ constructor: audioBlob?.constructor?.name || "unknown",
};
-
+
if (audioBlob instanceof ArrayBuffer) {
audioInfo.byteLength = audioBlob.byteLength;
// Check first few bytes
- const view = new Uint8Array(audioBlob, 0, Math.min(16, audioBlob.byteLength));
- audioInfo.firstBytes = Array.from(view).map(b => b.toString(16).padStart(2, '0')).join(' ');
+ const view = new Uint8Array(
+ audioBlob,
+ 0,
+ Math.min(16, audioBlob.byteLength)
+ );
+ audioInfo.firstBytes = Array.from(view)
+ .map((b) => b.toString(16).padStart(2, "0"))
+ .join(" ");
} else if (audioBlob instanceof Uint8Array) {
audioInfo.byteLength = audioBlob.byteLength;
const view = audioBlob.slice(0, Math.min(16, audioBlob.byteLength));
- audioInfo.firstBytes = Array.from(view).map(b => b.toString(16).padStart(2, '0')).join(' ');
+ audioInfo.firstBytes = Array.from(view)
+ .map((b) => b.toString(16).padStart(2, "0"))
+ .join(" ");
}
-
- this.log('πŸ”Š Audio Data Debug', audioInfo);
+
+ this.log("πŸ”Š Audio Data Debug", audioInfo);
}
-
+
logProcessStart(command, args, options = {}) {
if (!this.debugMode) return;
-
- this.log('πŸš€ Starting process', {
+
+ this.log("πŸš€ Starting process", {
command,
args,
cwd: options.cwd || process.cwd(),
@@ -163,45 +183,45 @@ class DebugLogger {
FFMPEG_PATH: options.env?.FFMPEG_PATH,
FFMPEG_EXECUTABLE: options.env?.FFMPEG_EXECUTABLE,
FFMPEG_BINARY: options.env?.FFMPEG_BINARY,
- PATH_preview: options.env?.PATH?.substring(0, 200) + '...'
- }
+ PATH_preview: options.env?.PATH?.substring(0, 200) + "...",
+ },
});
}
-
+
logProcessOutput(processName, type, data) {
if (!this.debugMode) return;
-
+
const output = data.toString().trim();
if (output) {
this.log(`πŸ“ ${processName} ${type}:`, output);
}
}
-
+
logWhisperPipeline(stage, details) {
if (!this.debugMode) return;
-
+
this.log(`πŸŽ™οΈ Whisper Pipeline - ${stage}`, details);
}
-
+
getLogPath() {
return this.logFile;
}
-
+
isEnabled() {
return this.debugMode;
}
-
+
close() {
if (this.logStream) {
- this.log('πŸ“ Debug logger closing');
+ this.log("πŸ“ Debug logger closing");
this.logStream.end();
this.logStream = null;
}
}
-
+
checkDebugFile() {
try {
- const debugFilePath = path.join(app.getPath('userData'), 'ENABLE_DEBUG');
+ const debugFilePath = path.join(app.getPath("userData"), "ENABLE_DEBUG");
return fs.existsSync(debugFilePath);
} catch (e) {
return false;
@@ -212,4 +232,4 @@ class DebugLogger {
// Singleton instance
const debugLogger = new DebugLogger();
-module.exports = debugLogger;
\ No newline at end of file
+module.exports = debugLogger;
diff --git a/src/helpers/environment.js b/src/helpers/environment.js
index d265fb770..724a24578 100644
--- a/src/helpers/environment.js
+++ b/src/helpers/environment.js
@@ -27,7 +27,6 @@ class EnvironmentManager {
if (fs.existsSync(envPath)) {
const result = require("dotenv").config({ path: envPath });
if (!result.error) {
- console.log("βœ… Environment loaded from:", envPath);
envLoaded = true;
break;
}
@@ -36,15 +35,10 @@ class EnvironmentManager {
// Continue to next path
}
}
-
- if (!envLoaded) {
- console.log("⚠️ No .env file found in any expected location");
- }
}
getOpenAIKey() {
const apiKey = process.env.OPENAI_API_KEY;
- console.log("πŸ”‘ OpenAI API Key requested:", apiKey ? "Present" : "Missing");
return apiKey || "";
}
@@ -52,10 +46,9 @@ class EnvironmentManager {
try {
// Update the environment variable in memory for immediate use
process.env.OPENAI_API_KEY = key;
- console.log("πŸ”‘ OpenAI API Key updated in memory");
return { success: true };
} catch (error) {
- console.error("❌ Error saving OpenAI API key:", error);
+ console.error("Error saving OpenAI API key:", error.message);
throw error;
}
}
@@ -70,17 +63,12 @@ OPENAI_API_KEY=${apiKey}
`;
fs.writeFileSync(envPath, envContent, "utf8");
- console.log("βœ… Production .env file created at:", envPath);
- // Reload environment variables
require("dotenv").config({ path: envPath });
- console.log(
- "πŸ”„ Environment variables reloaded from production .env file"
- );
return { success: true, path: envPath };
} catch (error) {
- console.error("❌ Error creating production .env file:", error);
+ console.error("Error creating production .env file:", error.message);
throw error;
}
}
diff --git a/src/helpers/hotkeyManager.js b/src/helpers/hotkeyManager.js
index a9d106f3f..e6c6e88de 100644
--- a/src/helpers/hotkeyManager.js
+++ b/src/helpers/hotkeyManager.js
@@ -20,10 +20,9 @@ class HotkeyManager {
if (success) {
this.currentHotkey = hotkey;
- console.log(`πŸ”‘ Hotkey registered: ${hotkey}`);
return { success: true, hotkey };
} else {
- console.error(`❌ Failed to register hotkey: ${hotkey}`);
+ console.error(`Failed to register hotkey: ${hotkey}`);
return {
success: false,
error: `Failed to register hotkey: ${hotkey}`,
@@ -62,7 +61,7 @@ class HotkeyManager {
if (savedHotkey && savedHotkey !== "`") {
const result = this.setupShortcuts(savedHotkey, callback);
if (result.success) {
- console.log("πŸ”‘ Hotkey initialized from localStorage:", savedHotkey);
+ // Hotkey initialized from localStorage
}
}
} catch (err) {
@@ -97,7 +96,6 @@ class HotkeyManager {
unregisterAll() {
globalShortcut.unregisterAll();
- console.log("πŸ”‘ All hotkeys unregistered");
}
isHotkeyRegistered(hotkey) {
diff --git a/src/helpers/tray.js b/src/helpers/tray.js
index d07abc929..543ba579a 100644
--- a/src/helpers/tray.js
+++ b/src/helpers/tray.js
@@ -22,28 +22,20 @@ class TrayManager {
if (process.platform !== "darwin") return;
try {
- console.log("πŸ”„ Creating tray icon...");
const trayIcon = await this.loadTrayIcon();
if (!trayIcon || trayIcon.isEmpty()) {
- console.error("❌ Failed to load tray icon - icon is empty or null");
+ console.error("Failed to load tray icon");
return;
}
- console.log("πŸ”§ Setting up tray icon...");
trayIcon.setTemplateImage(true);
this.tray = new Tray(trayIcon);
this.tray.setIgnoreDoubleClickEvents(true);
this.setupTrayMenu();
this.setupTrayEventHandlers();
-
- console.log("βœ… Tray icon created successfully");
} catch (error) {
- console.error("❌ Error creating tray icon:", error);
- console.error("Error details:", {
- message: error.message,
- stack: error.stack,
- });
+ console.error("Error creating tray icon:", error.message);
}
}
@@ -56,12 +48,10 @@ class TrayManager {
"assets",
);
- console.log("πŸ” Looking for tray icon at:", iconPath);
if (fs.existsSync(iconPath)) {
- console.log("βœ… Found tray icon at:", iconPath);
return nativeImage.createFromPath(iconPath);
} else {
- console.error("❌ Tray icon not found at:", iconPath);
+ console.error("Tray icon not found at:", iconPath);
return this.createFallbackIcon();
}
} else {
diff --git a/src/helpers/whisper.js b/src/helpers/whisper.js
index 70c8eb64c..5f63a75c4 100644
--- a/src/helpers/whisper.js
+++ b/src/helpers/whisper.js
@@ -525,18 +525,15 @@ class WhisperManager {
let ffmpegPath;
try {
ffmpegPath = require("ffmpeg-static");
- console.log("🎬 [WhisperManager] Initial FFmpeg path for check:", ffmpegPath);
- const envInfo = {
+ debugLogger.logFFmpegDebug('checkFFmpegAvailability', ffmpegPath, {
NODE_ENV: process.env.NODE_ENV,
resourcesPath: process.resourcesPath,
__dirname: __dirname
- };
- console.log("🎬 [WhisperManager] Environment:", envInfo);
- debugLogger.logFFmpegDebug('checkFFmpegAvailability', ffmpegPath, envInfo);
+ });
// Always check if the path exists and handle ASAR unpacking
if (!fs.existsSync(ffmpegPath)) {
- console.log("🎬 [WhisperManager] FFmpeg not found at initial path, checking alternatives...");
+ debugLogger.log('FFmpeg not found at initial path, checking alternatives');
const possiblePaths = [
// Direct ASAR replacement
@@ -549,17 +546,17 @@ class WhisperManager {
path.join(__dirname, "..", "..", "node_modules", "ffmpeg-static", process.platform === "win32" ? "ffmpeg.exe" : "ffmpeg")
].filter(Boolean);
- console.log("🎬 [WhisperManager] Checking alternative paths:");
+ // Check alternative paths
debugLogger.log('Checking alternative FFmpeg paths for availability check');
for (const possiblePath of possiblePaths) {
const exists = fs.existsSync(possiblePath);
- console.log("🎬 [WhisperManager] Checking:", possiblePath, "exists:", exists);
+ // Check path existence
debugLogger.logFFmpegDebug('Checking availability path', possiblePath);
if (exists) {
ffmpegPath = possiblePath;
- console.log("βœ… [WhisperManager] Found FFmpeg at:", ffmpegPath);
+ // Found FFmpeg
debugLogger.log('FFmpeg found for availability check at:', ffmpegPath);
break;
}
@@ -568,13 +565,13 @@ class WhisperManager {
// Final validation
if (!ffmpegPath || !fs.existsSync(ffmpegPath)) {
- console.warn("⚠️ [WhisperManager] FFmpeg not found at any location");
+ debugLogger.log('FFmpeg not found at any location');
ffmpegPath = null;
} else {
- console.log("βœ… [WhisperManager] Using FFmpeg at:", ffmpegPath);
+ // Using bundled FFmpeg
}
} catch (e) {
- console.warn("⚠️ [WhisperManager] ffmpeg-static error:", e.message);
+ debugLogger.log('ffmpeg-static error:', e.message);
ffmpegPath = null;
}
@@ -655,48 +652,42 @@ class WhisperManager {
const pythonCmd = await this.findPythonExecutable();
// Upgrade pip first to avoid version issues
- console.log("Upgrading pip to latest version...");
try {
await this.upgradePip(pythonCmd);
- console.log("Pip upgraded successfully");
} catch (error) {
- console.warn("First pip upgrade attempt failed:", error.message);
+ debugLogger.log("First pip upgrade attempt failed:", error.message);
// Try user install for pip upgrade
try {
- console.log("Retrying pip upgrade with --user flag...");
await runCommand(pythonCmd, ["-m", "pip", "install", "--user", "--upgrade", "pip"], { timeout: TIMEOUTS.PIP_UPGRADE });
- console.log("Pip upgraded successfully with --user flag");
} catch (userError) {
// If pip upgrade fails completely, try to detect if it's the TOML error
if (error.message.includes("pyproject.toml") || error.message.includes("TomlError")) {
// Try installing with legacy resolver as a workaround
- console.log("Pip upgrade failed due to TOML error, trying legacy resolver...");
try {
await runCommand(pythonCmd, ["-m", "pip", "install", "--use-deprecated=legacy-resolver", "--upgrade", "pip"], { timeout: TIMEOUTS.PIP_UPGRADE });
- console.log("Pip upgraded with legacy resolver");
} catch (legacyError) {
throw new Error("Failed to upgrade pip. Please manually run: python -m pip install --upgrade pip");
}
} else {
- console.warn("Pip upgrade failed completely, attempting to continue...");
+ debugLogger.log("Pip upgrade failed completely, attempting to continue");
}
}
}
// Try regular install, then user install if permission issues
- console.log("Installing OpenAI Whisper...");
+ // Install OpenAI Whisper
try {
return await runCommand(pythonCmd, ["-m", "pip", "install", "-U", "openai-whisper"], { timeout: TIMEOUTS.DOWNLOAD });
} catch (error) {
if (error.message.includes("Permission denied") || error.message.includes("access is denied")) {
- console.log("Retrying with user installation...");
+ // Retry with user installation
return await runCommand(pythonCmd, ["-m", "pip", "install", "--user", "-U", "openai-whisper"], { timeout: TIMEOUTS.DOWNLOAD });
}
// If we still get TOML error after pip upgrade, try legacy resolver for whisper
if (error.message.includes("pyproject.toml") || error.message.includes("TomlError")) {
- console.log("TOML error persists, trying legacy resolver for Whisper install...");
+ // TOML error persists, try legacy resolver
try {
return await runCommand(pythonCmd, ["-m", "pip", "install", "--use-deprecated=legacy-resolver", "-U", "openai-whisper"], { timeout: TIMEOUTS.DOWNLOAD });
} catch (legacyError) {
diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.js
index 602a7a0e7..f0ad2daa7 100644
--- a/src/helpers/windowManager.js
+++ b/src/helpers/windowManager.js
@@ -19,27 +19,18 @@ class WindowManager {
}
async createMainWindow() {
- console.log("πŸ”„ Creating main window...");
const display = screen.getPrimaryDisplay();
const position = WindowPositionUtil.getMainWindowPosition(display);
- console.log("πŸ“ Window dimensions:", position);
-
this.mainWindow = new BrowserWindow({
...MAIN_WINDOW_CONFIG,
...position,
});
-
- console.log("πŸ“± Loading main window content...");
await this.loadMainWindow();
- console.log("⌨️ Setting up shortcuts...");
await this.initializeHotkey();
- console.log("πŸ–±οΈ Setting up drag manager...");
this.dragManager.setTargetWindow(this.mainWindow);
- console.log("🍎 Setting up menu...");
MenuManager.setupMainMenu();
- console.log("βœ… Main window created successfully");
this.mainWindow.webContents.on(
"did-fail-load",
@@ -54,7 +45,7 @@ class WindowManager {
process.env.NODE_ENV === "development" &&
validatedURL.includes("localhost:5174")
) {
- console.log("Retrying connection to dev server in 2 seconds...");
+ // Retry connection to dev server
setTimeout(async () => {
const isReady = await DevServerManager.waitForDevServer();
if (isReady) {
@@ -67,26 +58,15 @@ class WindowManager {
);
this.mainWindow.webContents.on("did-finish-load", () => {
- console.log("πŸ“± Main window content loaded");
+ // Ensure window is visible after loading
setTimeout(() => {
if (!this.mainWindow.isVisible()) {
- console.log("⚠️ Window not visible, forcing show...");
this.mainWindow.show();
this.mainWindow.focus();
- } else {
- console.log("βœ… Main window is visible");
}
}, 1000);
});
- this.mainWindow.on("show", () => {
- console.log("🎯 Main window shown");
- });
-
- this.mainWindow.on("focus", () => {
- console.log("🎯 Main window focused");
- });
-
// Ensure window is always on top, even above fullscreen apps
WindowPositionUtil.setupAlwaysOnTop(this.mainWindow);
this.mainWindow.on("show", () => {
@@ -99,7 +79,7 @@ class WindowManager {
if (process.env.NODE_ENV === "development") {
const isReady = await DevServerManager.waitForDevServer();
if (!isReady) {
- console.error("Dev server not ready, loading anyway...");
+ // Dev server not ready, continue anyway
}
}
this.mainWindow.loadURL(appUrl);
@@ -136,9 +116,7 @@ class WindowManager {
}
async createControlPanelWindow() {
- console.log("πŸ”„ Creating control panel window...");
if (this.controlPanelWindow && !this.controlPanelWindow.isDestroyed()) {
- console.log("πŸ“‹ Control panel already exists, focusing...");
if (!this.controlPanelWindow.isVisible()) {
this.controlPanelWindow.show();
}
@@ -154,16 +132,12 @@ class WindowManager {
// Set up menu for control panel to ensure text input works
MenuManager.setupControlPanelMenu(this.controlPanelWindow);
- // Show and focus the window after content is loaded
this.controlPanelWindow.show();
this.controlPanelWindow.focus();
this.controlPanelWindow.on("closed", () => {
- console.log("πŸ“‹ Control panel window closed");
this.controlPanelWindow = null;
});
-
- console.log("βœ… Control panel window created successfully");
}
async loadControlPanel() {
diff --git a/src/hooks/usePython.ts b/src/hooks/usePython.ts
index be8380b77..a1aeab009 100644
--- a/src/hooks/usePython.ts
+++ b/src/hooks/usePython.ts
@@ -1,4 +1,4 @@
-import { useState, useEffect, useCallback, useRef } from "react";
+import { useState, useEffect, useCallback } from "react";
interface PythonInstallation {
installed: boolean;
diff --git a/src/types/electron.ts b/src/types/electron.ts
index d4f6198c8..f2c1e18b4 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -194,6 +194,12 @@ declare global {
openExternal: (
url: string
) => Promise<{ success: boolean; error?: string }>;
+
+ // Event listener cleanup
+ removeAllListeners?: (channel: string) => void;
+
+ // Hotkey management
+ updateHotkey?: (key: string) => Promise<void>;
};
}
}