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
fix: return python in PATH
Gabriel Stein254a5ace8831
diff --git a/src/helpers/pythonInstaller.js b/src/helpers/pythonInstaller.jsindex fb644ac9a..812b675f5 100644--- a/src/helpers/pythonInstaller.js+++ b/src/helpers/pythonInstaller.js@@ -159,6 +159,11 @@ class PythonInstaller {progressCallback({ stage: "Installing Python...", percentage: 60 });}+ // Determine install target directory for later verification+ // Version without dots for folder name (e.g., "311" from "3.11.9")+ const versionShort = this.pythonVersion.split(".").slice(0, 2).join("");+ let expectedPythonPath;+// Install Python with appropriate options based on admin rightsconst installArgs = isAdmin? [@@ -182,19 +187,72 @@ class PythonInstaller {"Include_debug=0","Include_launcher=1","InstallLauncherAllUsers=0",- "DefaultJustForMeTargetDir=%LOCALAPPDATA%\\Programs\\Python\\Python311",+ `DefaultJustForMeTargetDir=${process.env.LOCALAPPDATA}\\Programs\\Python\\Python${versionShort}`,];+ // Determine expected install path based on admin rights+ if (isAdmin) {+ // System-wide install goes to Program Files+ expectedPythonPath = path.join(+ process.env.ProgramFiles || "C:\\Program Files",+ `Python${versionShort}`,+ "python.exe"+ );+ } else {+ // User install goes to LOCALAPPDATA+ expectedPythonPath = path.join(+ process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local"),+ "Programs",+ "Python",+ `Python${versionShort}`,+ "python.exe"+ );+ }+await runCommand(installerPath, installArgs, { timeout: TIMEOUTS.INSTALL });- // Clean up+ // Clean up installerfs.unlink(installerPath, () => {});+ if (progressCallback) {+ progressCallback({ stage: "Verifying installation...", percentage: 90 });+ }++ // Verify the installation by checking if python.exe exists at expected location+ // Give Windows a moment to finalize the installation+ await new Promise((resolve) => setTimeout(resolve, 1000));++ let installedPythonPath = null;++ // Check expected path first+ if (fs.existsSync(expectedPythonPath)) {+ installedPythonPath = expectedPythonPath;+ } else {+ // Fallback: scan common Windows Python install locations+ const possiblePaths = [+ path.join(process.env.LOCALAPPDATA || "", "Programs", "Python", `Python${versionShort}`, "python.exe"),+ path.join(process.env.ProgramFiles || "", `Python${versionShort}`, "python.exe"),+ path.join(process.env["ProgramFiles(x86)"] || "", `Python${versionShort}`, "python.exe"),+ path.join("C:", `Python${versionShort}`, "python.exe"),+ ];++ for (const p of possiblePaths) {+ if (p && fs.existsSync(p)) {+ installedPythonPath = p;+ break;+ }+ }+ }+if (progressCallback) {progressCallback({ stage: "Python installation complete!", percentage: 100 });}- return { success: true, method: "official_installer" };+ return {+ success: true,+ method: "official_installer",+ pythonPath: installedPythonPath, // Return the actual path for immediate use+ };} catch (error) {// Clean up on errorif (fs.existsSync(installerPath)) {diff --git a/src/helpers/whisper.js b/src/helpers/whisper.jsindex 174ef9e33..d0b7d34f1 100644--- a/src/helpers/whisper.js+++ b/src/helpers/whisper.js@@ -1047,6 +1047,13 @@ class WhisperManager {const result = await this.pythonInstaller.installPython(progressCallback);+ // On Windows, the installer returns the exact path to python.exe+ // Use it directly since PATH environment won't be updated in running process+ if (process.platform === "win32" && result.pythonPath) {+ debugLogger.log(`Using freshly installed Python at: ${result.pythonPath}`);+ this.pythonCmd = result.pythonPath;+ }+// After installation, prepare isolated environmentawait this.ensureManagedVenv();diff --git a/src/hooks/usePython.ts b/src/hooks/usePython.tsindex bfe56b10a..f92b790da 100644--- a/src/hooks/usePython.ts+++ b/src/hooks/usePython.ts@@ -45,10 +45,16 @@ export function usePython(showAlertDialog: ShowAlertDialog) {const [hasChecked, setHasChecked] = useState<boolean>(false);const isCheckingRef = useRef(false);+ const hasInitialCheckRef = useRef(false);+ const pythonInfoRef = useRef<PythonInstallation | null>(null);++ // Keep ref in sync with state for use in callbacks without re-creating them+ pythonInfoRef.current = pythonInfo;const checkPythonInstallation = useCallback(async () => {+ // Prevent concurrent checksif (isCheckingRef.current) {- return pythonInfo;+ return pythonInfoRef.current;}try {@@ -76,7 +82,7 @@ export function usePython(showAlertDialog: ShowAlertDialog) {setIsChecking(false);setHasChecked(true);}- }, [pythonInfo]);+ }, []); // No dependencies - uses refs to avoid re-creating callbackconst installPython = useCallback(async () => {if (!window.electronAPI) {@@ -138,7 +144,13 @@ export function usePython(showAlertDialog: ShowAlertDialog) {}, [showAlertDialog, checkPythonInstallation]);// Check Python installation on mount with a small delay to ensure preload is ready+ // Only runs once - uses ref to prevent re-triggeringuseEffect(() => {+ if (hasInitialCheckRef.current) {+ return;+ }+ hasInitialCheckRef.current = true;+// In development, there might be a race condition where React loads before preloadconst timer = setTimeout(() => {checkPythonInstallation();