Skip to content

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

refactor: cahche bbinaries during build

Gabriel Stein3ac91cc94609
diff --git a/.github/workflows/build-and-notarize.yml b/.github/workflows/build-and-notarize.yml
index 1605b7ede..f61d7997d 100644
--- a/.github/workflows/build-and-notarize.yml
+++ b/.github/workflows/build-and-notarize.yml
@@ -3,8 +3,16 @@ name: Build and Notarize
on:
push:
branches: [ main, develop ]
+ paths-ignore:
+ - '**.md'
+ - 'LICENSE'
+ - '.github/ISSUE_TEMPLATE/**'
pull_request:
branches: [ main ]
+ paths-ignore:
+ - '**.md'
+ - 'LICENSE'
+ - '.github/ISSUE_TEMPLATE/**'
workflow_dispatch:
jobs:
@@ -22,11 +30,27 @@ jobs:
- name: Install dependencies
run: npm ci
+ - name: Cache native binaries
+ uses: actions/cache@v4
+ with:
+ path: resources/bin
+ key: linux-x64-bin-${{ hashFiles('scripts/download-*.js') }}
+
- name: Download whisper.cpp binaries
run: node scripts/download-whisper-cpp.js --current
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+ - name: Download llama-server binaries
+ run: node scripts/download-llama-server.js --current
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
+ - name: Download sherpa-onnx binaries
+ run: node scripts/download-sherpa-onnx.js --current
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
- name: Cache Electron
uses: actions/cache@v4
with:
@@ -42,6 +66,7 @@ jobs:
- name: Build Application
run: npm run build:linux -- --publish never
env:
+ GH_TOKEN: ${{ secrets.GH_TOKEN }}
VITE_NEON_AUTH_URL: ${{ vars.VITE_NEON_AUTH_URL }}
VITE_OPENWHISPR_API_URL: ${{ vars.VITE_OPENWHISPR_API_URL }}
VITE_OPENWHISPR_OAUTH_CALLBACK_URL: ${{ vars.VITE_OPENWHISPR_OAUTH_CALLBACK_URL }}
@@ -67,11 +92,27 @@ jobs:
- name: Install dependencies
run: npm ci
+ - name: Cache native binaries
+ uses: actions/cache@v4
+ with:
+ path: resources/bin
+ key: windows-x64-bin-${{ hashFiles('scripts/download-*.js') }}
+
- name: Download whisper.cpp binaries
run: node scripts/download-whisper-cpp.js --current
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+ - name: Download llama-server binaries
+ run: node scripts/download-llama-server.js --current
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
+ - name: Download sherpa-onnx binaries
+ run: node scripts/download-sherpa-onnx.js --current
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
- name: Download nircmd.exe
run: node scripts/download-nircmd.js
env:
@@ -117,17 +158,33 @@ jobs:
- name: Install dependencies
run: npm ci
+ - name: Cache native binaries
+ uses: actions/cache@v4
+ with:
+ path: resources/bin
+ key: macos-${{ matrix.arch }}-bin-${{ hashFiles('scripts/download-*.js') }}
+
- name: Download whisper.cpp binaries
run: node scripts/download-whisper-cpp.js --current --platform darwin --arch ${{ matrix.arch }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+ - name: Download llama-server binaries
+ run: node scripts/download-llama-server.js --current --platform darwin --arch ${{ matrix.arch }}
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
+ - name: Download sherpa-onnx binaries
+ run: node scripts/download-sherpa-onnx.js --current --platform darwin --arch ${{ matrix.arch }}
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
- name: Cache Electron
uses: actions/cache@v4
with:
path: ~/.cache/electron
- key: macos-electron-${{ hashFiles('**/package-lock.json') }}
- restore-keys: macos-electron-
+ key: macos-${{ matrix.arch }}-electron-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: macos-${{ matrix.arch }}-electron-
- name: Setup macOS Code Signing
if: github.event_name != 'pull_request'
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index cc626f558..81822a563 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -29,11 +29,27 @@ jobs:
- name: Install dependencies
run: npm ci
+ - name: Cache native binaries
+ uses: actions/cache@v4
+ with:
+ path: resources/bin
+ key: linux-x64-bin-${{ hashFiles('scripts/download-*.js') }}
+
- name: Download whisper.cpp binaries
run: node scripts/download-whisper-cpp.js --current
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+ - name: Download llama-server binaries
+ run: node scripts/download-llama-server.js --current
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
+ - name: Download sherpa-onnx binaries
+ run: node scripts/download-sherpa-onnx.js --current
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
- name: Cache Electron
uses: actions/cache@v4
with:
@@ -68,11 +84,27 @@ jobs:
- name: Install dependencies
run: npm ci
+ - name: Cache native binaries
+ uses: actions/cache@v4
+ with:
+ path: resources/bin
+ key: windows-x64-bin-${{ hashFiles('scripts/download-*.js') }}
+
- name: Download whisper.cpp binaries
run: node scripts/download-whisper-cpp.js --current
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+ - name: Download llama-server binaries
+ run: node scripts/download-llama-server.js --current
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
+ - name: Download sherpa-onnx binaries
+ run: node scripts/download-sherpa-onnx.js --current
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
- name: Download nircmd.exe
run: node scripts/download-nircmd.js
env:
@@ -101,27 +133,43 @@ jobs:
arch: [x64, arm64]
steps:
- uses: actions/checkout@v4
-
+
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
-
+
- name: Install dependencies
run: npm ci
+ - name: Cache native binaries
+ uses: actions/cache@v4
+ with:
+ path: resources/bin
+ key: macos-${{ matrix.arch }}-bin-${{ hashFiles('scripts/download-*.js') }}
+
- name: Download whisper.cpp binaries
run: node scripts/download-whisper-cpp.js --current --platform darwin --arch ${{ matrix.arch }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+ - name: Download llama-server binaries
+ run: node scripts/download-llama-server.js --current --platform darwin --arch ${{ matrix.arch }}
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
+ - name: Download sherpa-onnx binaries
+ run: node scripts/download-sherpa-onnx.js --current --platform darwin --arch ${{ matrix.arch }}
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+
- name: Cache Electron
uses: actions/cache@v4
with:
path: ~/.cache/electron
- key: macos-electron-${{ hashFiles('**/package-lock.json') }}
- restore-keys: macos-electron-
+ key: macos-${{ matrix.arch }}-electron-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: macos-${{ matrix.arch }}-electron-
- name: Setup macOS Code Signing
env:
@@ -165,4 +213,4 @@ jobs:
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db || true
rm -f $RUNNER_TEMP/build_certificate.p12
- rm -f $RUNNER_TEMP/api_key.p8
\ No newline at end of file
+ rm -f $RUNNER_TEMP/api_key.p8
diff --git a/src/components/AuthenticationStep.tsx b/src/components/AuthenticationStep.tsx
index 4ee90ac05..78ee16a21 100644
--- a/src/components/AuthenticationStep.tsx
+++ b/src/components/AuthenticationStep.tsx
@@ -12,6 +12,7 @@ import { Button } from "./ui/button";
import { Input } from "./ui/input";
import { AlertCircle, ArrowRight, Check, Loader2, ChevronLeft } from "lucide-react";
import logoIcon from "../assets/icon.png";
+import logger from "../utils/logger";
import ForgotPasswordView from "./ForgotPasswordView";
import ResetPasswordView from "./ResetPasswordView";
@@ -24,7 +25,6 @@ interface AuthenticationStepProps {
type AuthMode = "sign-in" | "sign-up" | null;
type PasswordResetView = "forgot" | "reset" | null;
-// Custom SVG icons for social providers (clean, modern style)
const GoogleIcon = ({ className }: { className?: string }) => (
<svg className={className} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
@@ -63,25 +63,21 @@ export default function AuthenticationStep({
const [passwordResetView, setPasswordResetView] = useState<PasswordResetView>(null);
const [resetToken, setResetToken] = useState<string | null>(null);
- // Track if we've already processed the OAuth callback
const oauthProcessedRef = useRef(false);
const resetProcessedRef = useRef(false);
- // Track if email verification was triggered (prevents auto-advance race condition)
const needsVerificationRef = useRef(false);
- // Check for OAuth callback verifier or password reset token in URL
useEffect(() => {
const params = new URLSearchParams(window.location.search);
const hasVerifier = params.has("neon_auth_session_verifier");
const token = params.get("token");
const isResetPassword = params.has("reset_password");
- // Handle password reset callback (user clicked link in email)
if (token && isResetPassword && !resetProcessedRef.current) {
resetProcessedRef.current = true;
setResetToken(token);
setPasswordResetView("reset");
- console.log("[Auth] Password reset token detected, showing reset form");
+ logger.debug("Password reset token detected, showing reset form", undefined, "auth");
return;
}
@@ -89,19 +85,9 @@ export default function AuthenticationStep({
oauthProcessedRef.current = true;
setIsSocialLoading("google");
- // CRITICAL: Activate grace period IMMEDIATELY when OAuth callback starts
- // Session cookies take 10-15 seconds to establish, so we need protection
- // from the very beginning, not after the first successful refresh
+ // Grace period: session cookies take ~10-15s to establish after OAuth
updateLastSignInTime();
-
- // Don't poll for session - it causes premature session state clearing.
- // Instead, proceed immediately to onboarding. The session cookies will
- // establish in the background (10-15 seconds), and withSessionRefresh()
- // will handle retries automatically when the user tries to use features.
- // The useEffect below will detect when session is ready via isSignedIn.
- console.log(
- "[Auth] OAuth callback detected, grace period active. Proceeding to onboarding..."
- );
+ logger.debug("OAuth callback detected, grace period active", undefined, "auth");
}
}, []);
@@ -116,13 +102,12 @@ export default function AuthenticationStep({
email: user.email,
name: user.name || null,
}),
- }).catch((err) => console.error("Failed to init user:", err));
+ }).catch((err) => logger.error("Failed to init user", err, "auth"));
}
onAuthComplete();
}
}, [isLoaded, isSignedIn, onAuthComplete]);
- // Reset social loading state when the window regains focus
useEffect(() => {
if (isSocialLoading === null) return;
@@ -178,7 +163,7 @@ export default function AuthenticationStep({
const data = await response.json().catch(() => ({}));
setAuthMode(data.exists ? "sign-in" : "sign-up");
} catch (err) {
- console.error("Error checking user existence:", err);
+ logger.error("Error checking user existence", err, "auth");
setAuthMode("sign-up");
} finally {
setIsCheckingEmail(false);
@@ -240,7 +225,7 @@ export default function AuthenticationStep({
}),
});
} catch (initErr) {
- console.error("Failed to init user:", initErr);
+ logger.error("Failed to init user", initErr, "auth");
}
}
@@ -261,7 +246,6 @@ export default function AuthenticationStep({
setError(result.error.message || "Invalid email or password");
}
} else {
- // Mark the sign-in time to enable grace period for session establishment
updateLastSignInTime();
onAuthComplete();
}
@@ -293,7 +277,6 @@ export default function AuthenticationStep({
setPasswordResetView(null);
setResetToken(null);
setError(null);
- // Clear URL params without reload
const url = new URL(window.location.href);
url.searchParams.delete("token");
url.searchParams.delete("reset_password");
@@ -387,7 +370,6 @@ export default function AuthenticationStep({
if (authMode !== null) {
return (
<div className="space-y-3">
- {/* Back button */}
<button
type="button"
onClick={handleBack}
@@ -397,7 +379,6 @@ export default function AuthenticationStep({
Back
</button>
- {/* Header — Refined */}
<div className="text-center mb-4">
<p className="text-sm text-muted-foreground/70 mb-2 leading-tight">{email}</p>
<p className="text-lg font-semibold text-foreground tracking-tight leading-tight">
@@ -405,7 +386,6 @@ export default function AuthenticationStep({
</p>
</div>
- {/* Password Form */}
<form onSubmit={handleSubmit} className="space-y-2">
{authMode === "sign-up" && (
<Input
@@ -447,7 +427,6 @@ export default function AuthenticationStep({
</button>
)}
- {/* Error Display */}
{error && (
<div className="px-2.5 py-1.5 rounded bg-destructive/5 border border-destructive/20 flex items-center gap-1.5">
<AlertCircle className="w-3 h-3 text-destructive shrink-0" />
@@ -455,7 +434,6 @@ export default function AuthenticationStep({
</div>
)}
- {/* Submit Button */}
<Button type="submit" disabled={isSubmitting || !password} className="w-full h-9">
{isSubmitting ? (
<>
@@ -472,7 +450,6 @@ export default function AuthenticationStep({
</Button>
</form>
- {/* Toggle Auth Mode */}
<div className="text-center">
<button
type="button"
@@ -498,7 +475,6 @@ export default function AuthenticationStep({
// Main welcome view
return (
<div className="space-y-3">
- {/* Logo & Brand Header — Premium, refined */}
<div className="text-center mb-4">
<img
src={logoIcon}
@@ -513,7 +489,6 @@ export default function AuthenticationStep({
</p>
</div>
- {/* Google Sign In */}
<Button
type="button"
variant="social"
@@ -536,7 +511,6 @@ export default function AuthenticationStep({
)}
</Button>
- {/* Divider — Minimal */}
<div className="flex items-center gap-2">
<div className="flex-1 h-px bg-border/50" />
<span className="text-[9px] font-medium text-muted-foreground/40 uppercase tracking-widest px-1">
@@ -545,7 +519,6 @@ export default function AuthenticationStep({
<div className="flex-1 h-px bg-border/50" />
</div>
- {/* Email Input + Continue */}
<form
onSubmit={(e) => {
e.preventDefault();
@@ -579,7 +552,6 @@ export default function AuthenticationStep({
</Button>
</form>
- {/* Error Display */}
{error && (
<div className="px-3 py-2 rounded-md bg-destructive/5 border border-destructive/20 flex items-center gap-2">
<AlertCircle className="w-3.5 h-3.5 text-destructive shrink-0" />
@@ -587,7 +559,6 @@ export default function AuthenticationStep({
</div>
)}
- {/* Skip Option — Subtle, compact */}
<div className="pt-1">
<button
type="button"
@@ -599,7 +570,6 @@ export default function AuthenticationStep({
</button>
</div>
- {/* Terms and Privacy Policy */}
<p className="text-[10px] text-muted-foreground/80 leading-tight text-center">
By continuing, you agree to our{" "}
<a
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index ea711bfec..54afecb2d 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -50,6 +50,7 @@ import { Skeleton } from "./ui/skeleton";
import { Progress } from "./ui/progress";
import { useToast } from "./ui/Toast";
import { useTheme } from "../hooks/useTheme";
+import logger from "../utils/logger";
import { SettingsRow } from "./ui/SettingsSection";
import { useUsage } from "../hooks/useUsage";
import { cn } from "./lib/utils";
@@ -743,7 +744,7 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage
const enabled = await window.electronAPI.getAutoStartEnabled();
setAutoStartEnabled(enabled);
} catch (error) {
- console.error("Failed to get auto-start status:", error);
+ logger.error("Failed to get auto-start status", error, "settings");
}
}
setAutoStartLoading(false);
@@ -760,7 +761,7 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage
setAutoStartEnabled(enabled);
}
} catch (error) {
- console.error("Failed to set auto-start:", error);
+ logger.error("Failed to set auto-start", error, "settings");
} finally {
setAutoStartLoading(false);
}
@@ -796,7 +797,7 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage
setActivationMode("tap");
}
} catch (error) {
- console.error("Failed to check hotkey mode:", error);
+ logger.error("Failed to check hotkey mode", error, "settings");
}
};
checkHotkeyMode();
@@ -906,7 +907,7 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage
// Reload the app to show onboarding/auth
window.location.reload();
} catch (error) {
- console.error("Sign out failed:", error);
+ logger.error("Sign out failed", error, "auth");
showAlertDialog({
title: "Sign Out Failed",
description: "Unable to sign out. Please try again.",
diff --git a/src/lib/neonAuth.ts b/src/lib/neonAuth.ts
index 83cb2e934..319241aa1 100644
--- a/src/lib/neonAuth.ts
+++ b/src/lib/neonAuth.ts
@@ -2,6 +2,7 @@ import { createAuthClient } from "@neondatabase/auth";
import { BetterAuthReactAdapter } from "@neondatabase/auth/react";
import { OPENWHISPR_API_URL } from "../config/constants";
import { openExternalLink } from "../utils/externalLinks";
+import logger from "../utils/logger";
export const NEON_AUTH_URL = import.meta.env.VITE_NEON_AUTH_URL || "";
export const authClient = NEON_AUTH_URL
@@ -83,19 +84,13 @@ function markSignedOutState(): void {
clearLastSignInTime();
}
-/**
- * Updates the last sign-in timestamp. Call this after successful OAuth.
- */
export function updateLastSignInTime(): void {
const now = Date.now();
lastSignInTime = now;
persistLastSignInTime(now);
}
-/**
- * Check if we're within the grace period after sign-in.
- * Exported so useAuth can also suppress premature sign-outs.
- */
+/** Exported so useAuth can suppress premature sign-outs during grace period. */
export function isWithinGracePeriod(): boolean {
const startedAt = getLastSignInTime();
if (!startedAt) return false;
@@ -104,11 +99,6 @@ export function isWithinGracePeriod(): boolean {
return elapsed < GRACE_PERIOD_MS;
}
-/**
- * Attempts to refresh the current session by calling getSession().
- * The Neon Auth SDK automatically refreshes expired tokens when this is called.
- * Returns true if a valid session exists after refresh, false otherwise.
- */
export async function refreshSession(): Promise<boolean> {
if (!authClient) {
return false;
@@ -122,40 +112,24 @@ export async function refreshSession(): Promise<boolean> {
}
}
-/**
- * Signs out the user and clears all session cookies.
- * This is useful when session refresh fails and we need to fully clear the stale session.
- */
export async function signOut(): Promise<void> {
try {
- // Clear session cookies via IPC
if (window.electronAPI?.authClearSession) {
await window.electronAPI.authClearSession();
}
-
- // Sign out via auth client if available
if (authClient) {
await authClient.signOut();
}
-
- // Clear local storage
markSignedOutState();
} catch {
- // Fallback: at minimum clear local storage
markSignedOutState();
}
}
/**
- * Utility to wrap API calls that may fail due to expired session.
- * Automatically retries AUTH_EXPIRED calls during OAuth grace, then attempts a
- * single session refresh before surfacing the auth error to the caller.
- *
- * During the grace period, retries the operation with exponential backoff to wait
- * for session cookies to establish.
- *
- * @param operation - The async operation to perform
- * @returns The result of the operation
+ * Wraps API calls with automatic retry on AUTH_EXPIRED errors.
+ * During grace period: retries with exponential backoff while cookies establish.
+ * Otherwise: attempts a single session refresh before surfacing the error.
*/
export async function withSessionRefresh<T>(operation: () => Promise<T>): Promise<T> {
const startedInGracePeriod = isWithinGracePeriod();
@@ -227,7 +201,7 @@ export async function signInWithSocial(provider: SocialProvider): Promise<{ erro
const text = await response.text();
if (!response.ok) {
- console.error(`[Auth] Social sign-in failed: ${response.status}`, text.slice(0, 200));
+ logger.error(`Social sign-in failed: ${response.status}`, text.slice(0, 200), "auth");
return { error: new Error("Failed to initiate sign-in") };
}
@@ -235,7 +209,7 @@ export async function signInWithSocial(provider: SocialProvider): Promise<{ erro
try {
data = JSON.parse(text);
} catch {
- console.error("[Auth] Non-JSON response from auth server:", text.slice(0, 200));
+ logger.error("Non-JSON response from auth server", text.slice(0, 200), "auth");
return { error: new Error("Unexpected response from auth server") };
}
@@ -253,10 +227,6 @@ export async function signInWithSocial(provider: SocialProvider): Promise<{ erro
}
}
-/**
- * Requests a password reset email. Routes through the API proxy when available,
- * falls back to direct Neon Auth for web environments.
- */
export async function requestPasswordReset(email: string): Promise<{ error?: Error }> {
if (!authClient) {
return { error: new Error("Auth not configured") };
@@ -278,7 +248,6 @@ export async function requestPasswordReset(email: string): Promise<{ error?: Err
return {};
}
- // Fallback: direct Neon Auth (web environments with proper URLs)
const base = window.location.href.split("?")[0].split("#")[0];
const redirectTo = `${base}?panel=true&reset_password=true`;
@@ -293,10 +262,6 @@ export async function requestPasswordReset(email: string): Promise<{ error?: Err
}
}
-/**
- * Resets the user's password using the token from the reset email.
- * After successful reset, the user is automatically signed in.
- */
export async function resetPassword(
newPassword: string,
token: string
@@ -311,7 +276,6 @@ export async function resetPassword(
token,
});
- // Mark sign-in time for grace period after password reset
updateLastSignInTime();
return {};