Skip to content

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

feat: onboarding flow

Gabriel Steinbe2cf2c41340
diff --git a/src/App.jsx b/src/App.jsx
index 494b249bf..024d38e63 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -4,7 +4,7 @@ import { Button } from "./components/ui/button";
import { Card, CardContent } from "./components/ui/card";
import { Toast } from "./components/ui/Toast";
import { LoadingDots } from "./components/ui/LoadingDots";
-import { Mic } from "lucide-react";
+import { Mic, Settings } from "lucide-react";
// Sound Wave Icon Component (for idle/hover states)
const SoundWaveIcon = ({ size = 16 }) => {
@@ -287,7 +287,7 @@ export default function App() {
// Get microphone button properties based on state
const getMicButtonProps = () => {
- const baseClasses = 'rounded-full w-10 h-10 flex items-center justify-center relative overflow-hidden';
+ const baseClasses = 'rounded-full w-10 h-10 flex items-center justify-center relative overflow-hidden cursor-pointer';
switch (micState) {
case 'idle':
@@ -323,6 +323,15 @@ export default function App() {
return (
<>
+ {/* Fixed top-right settings button */}
+ <div className="fixed top-6 right-6 z-50">
+ <Tooltip content="Settings">
+ <button className="rounded-full w-10 h-10 flex items-center justify-center bg-black/40 backdrop-blur-md border border-white/20 cursor-pointer hover:bg-black/50 transition-colors duration-150">
+ <Settings size={18} className="text-white" />
+ </button>
+ </Tooltip>
+ </div>
+
{/* Fixed bottom-right voice button */}
<div className="fixed bottom-6 right-6 z-50">
<Tooltip
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsx
index ab718e138..b4cdbcb75 100644
--- a/src/components/ControlPanel.tsx
+++ b/src/components/ControlPanel.tsx
@@ -20,6 +20,7 @@ import {
ChevronLeft,
ChevronRight,
} from "lucide-react";
+import SettingsPage from "./SettingsPage";
// Type declaration for electronAPI
declare global {
@@ -112,78 +113,13 @@ interface TranscriptionItem {
}
export default function ControlPanel() {
- const [key, setKey] = useState("");
const [history, setHistory] = useState<TranscriptionItem[]>([]);
- const [apiKey, setApiKey] = useState("");
const [isLoading, setIsLoading] = useState(true);
- const [useLocalWhisper, setUseLocalWhisper] = useState(false);
- const [whisperModel, setWhisperModel] = useState("base");
- const [whisperInstalled, setWhisperInstalled] = useState(false);
- const [checkingWhisper, setCheckingWhisper] = useState(false);
- const [modelList, setModelList] = useState<
- Array<{ model: string; downloaded: boolean; size_mb?: number }>
- >([]);
- const [downloadingModel, setDownloadingModel] = useState<string | null>(null);
- const [downloadProgress, setDownloadProgress] = useState(0);
- const [loadingModels, setLoadingModels] = useState(false);
- const [installingWhisper, setInstallingWhisper] = useState(false);
- const [installProgress, setInstallProgress] = useState<string>("");
+ const [showSettings, setShowSettings] = useState(false);
useEffect(() => {
- // Load saved settings
- const savedKey = localStorage.getItem("dictationKey");
- if (savedKey) setKey(savedKey);
-
- // Load Whisper settings
- const savedUseLocal = localStorage.getItem("useLocalWhisper") === "true";
- const savedModel = localStorage.getItem("whisperModel") || "base";
- setUseLocalWhisper(savedUseLocal);
- setWhisperModel(savedModel);
-
- // Load API key from main process first, then fallback to localStorage
- const loadApiKey = async () => {
- try {
- const envApiKey = await window.electronAPI.getOpenAIKey();
- if (envApiKey && envApiKey !== "your_openai_api_key_here") {
- setApiKey(envApiKey);
- } else {
- const savedApiKey = localStorage.getItem("openaiApiKey");
- if (savedApiKey) setApiKey(savedApiKey);
- }
- } catch (error) {
- const savedApiKey = localStorage.getItem("openaiApiKey");
- if (savedApiKey) setApiKey(savedApiKey);
- }
- };
-
- loadApiKey();
-
// Load transcription history from database
loadTranscriptions();
-
- // Check Whisper installation
- checkWhisperInstallation();
-
- // Set up progress listener for Whisper installation
- window.electronAPI.onWhisperInstallProgress((event, data) => {
- setInstallProgress(data.message);
- });
-
- // Set up progress listener for model downloads
- window.electronAPI.onWhisperDownloadProgress((event, data) => {
- if (data.type === "progress") {
- // Force re-render by setting both state values
- setDownloadProgress(data.percentage || 0);
- } else if (data.type === "complete") {
- setDownloadingModel(null);
- setDownloadProgress(0);
- // Refresh model list after successful download
- loadModelList();
- } else if (data.type === "error") {
- setDownloadingModel(null);
- setDownloadProgress(0);
- }
- });
}, []);
const loadTranscriptions = async () => {
@@ -197,150 +133,6 @@ export default function ControlPanel() {
}
};
- const checkWhisperInstallation = async () => {
- try {
- setCheckingWhisper(true);
- const result = await window.electronAPI.checkWhisperInstallation();
- setWhisperInstalled(result.installed && result.working);
-
- // If Whisper is installed, also load model list
- if (result.installed && result.working) {
- loadModelList();
- }
- } catch (error) {
- setWhisperInstalled(false);
- } finally {
- setCheckingWhisper(false);
- }
- };
-
- const loadModelList = async () => {
- try {
- setLoadingModels(true);
- const result = await window.electronAPI.listWhisperModels();
- if (result.success) {
- setModelList(result.models);
- }
- } catch (error) {
- } finally {
- setLoadingModels(false);
- }
- };
-
- const installWhisper = async () => {
- try {
- setInstallingWhisper(true);
- setInstallProgress("Starting Whisper installation...");
-
- const result = await window.electronAPI.installWhisper();
-
- if (result.success) {
- alert(
- "✅ Whisper installed successfully! You can now download and use local models."
- );
- // Recheck installation status
- checkWhisperInstallation();
- } else {
- alert(`❌ Failed to install Whisper: ${result.message}`);
- }
- } catch (error) {
- alert(`❌ Failed to install Whisper: ${error}`);
- } finally {
- setInstallingWhisper(false);
- setInstallProgress("");
- }
- };
-
- const downloadModel = async (modelName: string) => {
- try {
- setDownloadingModel(modelName);
-
- const result = await window.electronAPI.downloadWhisperModel(modelName);
-
- if (result.success) {
- alert(
- `✅ Model "${modelName}" downloaded successfully! (${result.size_mb}MB)`
- );
- // Refresh model list
- loadModelList();
- } else {
- alert(`❌ Failed to download model "${modelName}": ${result.error}`);
- }
- } catch (error) {
- alert(`❌ Failed to download model "${modelName}": ${error}`);
- } finally {
- setDownloadingModel(null);
- }
- };
-
- const deleteModel = async (modelName: string) => {
- if (
- confirm(
- `Are you sure you want to delete the "${modelName}" model? This will free up disk space but you'll need to re-download it if you want to use it again.`
- )
- ) {
- try {
- const result = await window.electronAPI.deleteWhisperModel(modelName);
-
- if (result.success) {
- alert(
- `✅ Model "${modelName}" deleted successfully! Freed ${result.freed_mb}MB of disk space.`
- );
- // Refresh model list
- loadModelList();
- } else {
- alert(`❌ Failed to delete model "${modelName}": ${result.error}`);
- }
- } catch (error) {
- alert(`❌ Failed to delete model "${modelName}": ${error}`);
- }
- }
- };
-
- const saveKey = () => {
- localStorage.setItem("dictationKey", key);
- alert(`Dictation key inscribed: ${key}`);
- };
-
- const saveApiKey = async () => {
- try {
- // Save to main process (updates environment variable)
- await window.electronAPI.saveOpenAIKey(apiKey);
- // Also save to localStorage as backup
- localStorage.setItem("openaiApiKey", apiKey);
-
- // In production, try to create a .env file in user data directory
- try {
- await window.electronAPI.createProductionEnvFile(apiKey);
- alert(
- "OpenAI API key inscribed successfully! Your credentials have been securely recorded for transcription services."
- );
- } catch (envError) {
- console.log("Could not create production .env file:", envError);
- alert(
- "OpenAI API key saved successfully and will be available for transcription"
- );
- }
- } catch (error) {
- console.error("Failed to save API key:", error);
- // Fallback to localStorage only
- localStorage.setItem("openaiApiKey", apiKey);
- alert("OpenAI API key saved to localStorage (fallback mode)");
- }
- };
-
- const saveWhisperSettings = () => {
- localStorage.setItem("useLocalWhisper", useLocalWhisper.toString());
- localStorage.setItem("whisperModel", whisperModel);
- alert(
- `Whisper settings saved! ${
- useLocalWhisper
- ? `Using local model: ${whisperModel}`
- : "Using OpenAI API"
- }`
- );
- };
-
const copyToClipboard = async (text: string) => {
try {
await navigator.clipboard.writeText(text);
@@ -366,87 +158,6 @@ export default function ControlPanel() {
}
};
- const requestPermissions = async () => {
- try {
- await navigator.mediaDevices.getUserMedia({ audio: true });
- alert("Microphone access granted! Your voice may now be inscribed.");
- } catch (err) {
- alert("Please grant microphone permissions to enable voice inscription.");
- }
- };
-
- const requestAccessibilityPermissions = async () => {
- try {
- // Test if pasting works
- await window.electronAPI.pasteText(
- "Test inscription - please verify this appears in another application"
- );
- alert(
- "Accessibility permissions appear to be working! Check if the test inscription appeared in another app."
- );
- } catch (err) {
- alert(
- "Accessibility permissions required! The app will guide you through granting the necessary privileges for automatic text inscription."
- );
- }
- };
-
- const resetAccessibilityPermissions = () => {
- const message = `🔄 RESET ACCESSIBILITY PERMISSIONS
-
-If you've rebuilt or reinstalled OpenWispr and automatic inscription isn't functioning, you may have obsolete permissions from the previous version.
-
-📋 STEP-BY-STEP RESTORATION:
-
-1️⃣ Open System Settings (or System Preferences)
- • macOS Ventura+: Apple Menu → System Settings
- • Older macOS: Apple Menu → System Preferences
-
-2️⃣ Navigate to Privacy & Security → Accessibility
-
-3️⃣ Look for obsolete OpenWispr entries:
- • Any entries named "OpenWispr"
- • Any entries named "Electron"
- • Any entries with unclear or generic names
- • Entries pointing to old application locations
-
-4️⃣ Remove ALL obsolete entries:
- • Select each old entry
- • Click the minus (-) button
- • Enter your password if prompted
-
-5️⃣ Add the current OpenWispr:
- • Click the plus (+) button
- • Navigate to and select the CURRENT OpenWispr app
- • Ensure the checkbox is ENABLED
-
-6️⃣ Restart OpenWispr completely
-
-💡 This is very common during development when rebuilding applications!
-
-Click OK when you're ready to open System Settings.`;
-
- if (confirm(message)) {
- // Try to open the accessibility settings directly
- const commands = [
- 'open "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"',
- "open -b com.apple.systempreferences",
- 'open "/System/Library/PreferencePanes/Security.prefPane"',
- ];
-
- // We can't directly execute these from the renderer, but we can guide the user
- alert(
- "Opening System Settings... Look for the Accessibility section under Privacy & Security."
- );
-
- // Try the URL scheme approach
- window.open(
- "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility",
- "_blank"
- );
- }
- };
-
const deleteTranscription = async (id: number) => {
if (
confirm(
@@ -476,509 +187,50 @@ Click OK when you're ready to open System Settings.`;
await loadTranscriptions();
};
- // Enhanced keyboard paste handler for API key input
- const handleApiKeyKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
- // Handle Cmd+V on Mac or Ctrl+V on Windows/Linux
- if ((e.metaKey || e.ctrlKey) && e.key === "v") {
- e.preventDefault(); // Prevent default to handle manually
-
- // Try to paste from clipboard
- setTimeout(async () => {
- try {
- // Try Electron clipboard first
- const text = await window.electronAPI.readClipboard();
- if (text && text.trim()) {
- setApiKey(text.trim());
- } else {
- // Fallback to web clipboard API
- const webText = await navigator.clipboard.readText();
- if (webText && webText.trim()) {
- setApiKey(webText.trim());
- }
- }
- } catch (err) {}
- }, 0);
- }
- };
-
return (
<div className="min-h-screen bg-white">
- {/* Custom Title Bar - matching Wispr Flow style */}
+ {/* Custom Title Bar */}
<div className="bg-white border-b border-gray-100 select-none">
- <div
+ <div
className="flex items-center justify-between h-12 px-4"
style={{ WebkitAppRegion: "drag" }}
>
{/* Right section - minimal controls */}
- <div
+ <div
className="flex items-center gap-2"
style={{ WebkitAppRegion: "no-drag" }}
>
- {/* Could add settings or other controls here if needed */}
+ <Tooltip content="Open settings">
+ <Button variant="ghost" size="icon" onClick={() => setShowSettings(!showSettings)}>
+ <Settings size={16} />
+ </Button>
+ </Tooltip>
</div>
</div>
</div>
{/* Main content */}
- <div
- className="bg-gradient-to-br from-neutral-50 via-white to-indigo-50/30 p-6 relative"
- style={{
- backgroundImage: `repeating-linear-gradient(
- transparent,
- transparent 24px,
- #d1d5db 24px,
- #d1d5db 25px
- )`,
- }}
- >
- {/* Red margin line */}
- <div className="absolute left-12 top-0 bottom-0 w-px bg-red-300 z-0"></div>
-
- <div className="max-w-4xl mx-auto space-y-6">
- {/* Transcription Setup Card */}
- <Card className="bg-white relative z-10">
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <Settings size={18} className="text-indigo-600" />
- Transcription Setup
- </CardTitle>
- <p className="text-sm text-neutral-600 mt-2 leading-relaxed">
- Choose how you want to convert speech to text. You can always
- change this later.
- </p>
- </CardHeader>
- <CardContent className="space-y-6">
- <div className="space-y-4">
- {/* Processing Choice */}
- <div>
- <label className="block text-sm font-medium text-neutral-700 mb-4">
- Processing Method
- </label>
- <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
- <button
- onClick={() => setUseLocalWhisper(false)}
- className={`p-4 border-2 rounded-xl text-left transition-all ${
- !useLocalWhisper
- ? "border-indigo-500 bg-indigo-50"
- : "border-neutral-200 bg-white hover:border-neutral-300"
- }`}
- >
- <div className="flex items-center justify-between mb-2">
- <h4 className="font-medium text-neutral-900">
- Cloud Processing
- </h4>
- <span className="text-xs text-green-600 bg-green-100 px-2 py-1 rounded-full">
- Fastest
- </span>
- </div>
- <p className="text-sm text-neutral-600">
- Audio sent to OpenAI servers. Faster processing,
- requires API key.
- </p>
- </button>
-
- <button
- onClick={() => setUseLocalWhisper(true)}
- className={`p-4 border-2 rounded-xl text-left transition-all ${
- useLocalWhisper
- ? "border-indigo-500 bg-indigo-50"
- : "border-neutral-200 bg-white hover:border-neutral-300"
- }`}
- >
- <div className="flex items-center justify-between mb-2">
- <h4 className="font-medium text-neutral-900">
- Local Processing
- </h4>
- <span className="text-xs text-blue-600 bg-blue-100 px-2 py-1 rounded-full">
- Private
- </span>
- </div>
- <p className="text-sm text-neutral-600">
- Audio stays on your device. Complete privacy, works
- offline.
- </p>
- </button>
- </div>
- </div>
-
- {/* Cloud Configuration */}
- {!useLocalWhisper && (
- <div className="space-y-4 p-4 bg-blue-50 border border-blue-200 rounded-xl">
- <h4 className="font-medium text-blue-900">
- OpenAI API Setup
- </h4>
- <div>
- <label className="block text-sm font-medium text-blue-800 mb-2">
- API Key
- </label>
- <div className="flex gap-3">
- <Input
- type="password"
- placeholder="sk-..."
- value={apiKey}
- onChange={(e) => setApiKey(e.target.value)}
- className="flex-1"
- />
- <Button
- variant="outline"
- onClick={async () => {
- try {
- const text =
- await window.electronAPI.readClipboard();
- if (text && text.trim()) {
- setApiKey(text.trim());
- console.log(
- "Manual paste successful via Electron"
- );
- } else {
- const webText =
- await navigator.clipboard.readText();
- setApiKey(webText.trim());
- console.log(
- "Manual paste successful via Web API"
- );
- }
- } catch (err) {
- console.error("Manual paste failed:", err);
- alert(
- "Could not paste from clipboard. Please try typing or using Cmd+V/Ctrl+V."
- );
- }
- }}
- >
- Paste
- </Button>
- </div>
- <p className="text-xs text-blue-700 mt-2">
- Get your API key from platform.openai.com
- </p>
- </div>
- </div>
- )}
-
- {/* Local Configuration */}
- {useLocalWhisper && (
- <div className="space-y-4 p-4 bg-purple-50 border border-purple-200 rounded-xl">
- <div className="flex items-center justify-between">
- <h4 className="font-medium text-purple-900">
- Local Whisper Setup
- </h4>
- <div className="flex items-center space-x-2">
- {checkingWhisper ? (
- <span className="text-purple-600 text-sm">
- Checking...
- </span>
- ) : whisperInstalled ? (
- <span className="text-emerald-600 text-sm font-medium">
- ✓ Ready
- </span>
- ) : (
- <span className="text-amber-600 text-sm font-medium">
- ⚠ Not installed
- </span>
- )}
- </div>
- </div>
-
- {whisperInstalled ? (
- <div className="space-y-4">
- <div>
- <label className="block text-sm font-medium text-purple-800 mb-2">
- Model Quality
- </label>
- <select
- value={whisperModel}
- onChange={(e) => setWhisperModel(e.target.value)}
- className="w-full p-3 border border-purple-300 rounded-lg bg-white text-purple-900 focus:outline-none focus:ring-1 focus:ring-purple-500/20 focus:border-purple-500"
- >
- <option value="tiny">
- Tiny - Fastest, lower quality
- </option>
- <option value="base">
- Base - Good balance (recommended)
- </option>
- <option value="small">
- Small - Better quality, slower
- </option>
- <option value="medium">
- Medium - High quality
- </option>
- <option value="large">
- Large - Best quality, slowest
- </option>
- </select>
- <p className="text-xs text-purple-700 mt-2">
- Larger models need more memory but give better
- results.
- </p>
- </div>
-
- <div className="bg-white border border-purple-200 rounded-lg overflow-hidden">
- {/* Download Progress Bar */}
- {downloadingModel && (
- <div className="bg-purple-50 border-b border-purple-200 p-3">
- <div className="flex items-center justify-between mb-2">
- <span className="text-sm font-medium text-purple-900">
- Downloading {downloadingModel} model...
- </span>
- <span className="text-xs text-purple-700">
- {Math.round(downloadProgress)}%
- </span>
- </div>
- <div className="w-full bg-purple-200 rounded-full h-2">
- <div
- className="bg-gradient-to-r from-purple-500 to-purple-600 h-2 rounded-full transition-all duration-300 ease-out"
- style={{
- width: `${Math.min(
- downloadProgress,
- 100
- )}%`,
- }}
- ></div>
- </div>
- </div>
- )}
-
- <div className="p-4">
- <div className="flex items-center justify-between mb-3">
- <h5 className="font-medium text-purple-900">
- Available Models
- </h5>
- <Button
- onClick={() => setLoadingModels(!loadingModels)}
- variant="outline"
- size="sm"
- disabled={loadingModels}
- className="border-purple-300 text-purple-700 hover:bg-purple-50 hover:border-purple-600"
- >
- <RefreshCw
- size={14}
- className={
- loadingModels ? "animate-spin" : ""
- }
- />
- <span className="ml-1">
- {loadingModels ? "Checking..." : "Refresh"}
- </span>
- </Button>
- </div>
-
- <div className="space-y-2">
- {modelList.map((model) => (
- <div
- key={model.model}
- className="flex items-center justify-between p-3 bg-purple-50 rounded-lg border border-purple-200"
- >
- <div className="flex items-center space-x-3">
- <span className="font-medium text-purple-900 capitalize">
- {model.model}
- </span>
- {model.downloaded ? (
- <span className="text-xs text-emerald-600 bg-emerald-100 px-2 py-1 rounded-md">
- ✓ Downloaded ({model.size_mb}MB)
- </span>
- ) : (
- <span className="text-xs text-neutral-500 bg-neutral-100 px-2 py-1 rounded-md">
- Not downloaded
- </span>
- )}
- </div>
-
- <div className="flex gap-2">
- {model.downloaded && (
- <Button
- onClick={() => deleteModel(model.model)}
- size="sm"
- variant="outline"
- className="text-red-600 hover:text-red-700 hover:bg-red-50 border-red-200 hover:border-red-600"
- >
- <Trash2 size={14} />
- <span className="ml-1">Delete</span>
- </Button>
- )}
- {!model.downloaded && (
- <Button
- onClick={() =>
- downloadModel(model.model)
- }
- disabled={
- downloadingModel === model.model
- }
- size="sm"
- className="bg-purple-600 hover:bg-purple-700"
- >
- <Download size={14} />
- <span className="ml-1">
- {downloadingModel === model.model
- ? "Downloading..."
- : "Download"}
- </span>
- </Button>
- )}
- </div>
- </div>
- ))}
- </div>
- </div>
- </div>
- </div>
- ) : (
- <div className="bg-white border border-purple-200 rounded-lg p-6">
- <div className="text-center">
- <div className="text-3xl mb-4">📦 </div>
- <h5 className="font-medium text-purple-900 text-lg mb-2">
- Install Local Processing
- </h5>
- <p className="text-sm text-purple-700 mb-4 max-w-sm mx-auto">
- We'll install Whisper automatically. No technical
- setup required.
- </p>
-
- {installingWhisper ? (
- <div className="space-y-4">
- <div className="bg-purple-50 rounded-lg p-4 border border-purple-200">
- <div className="flex items-center justify-center space-x-3 mb-2">
- <div className="animate-spin rounded-full h-4 w-4 border-b-2 border-purple-600"></div>
- <span className="font-medium text-purple-900">
- Installing...
- </span>
- </div>
- {installProgress && (
- <div className="text-xs text-purple-600 bg-white p-2 rounded font-mono">
- {installProgress}
- </div>
- )}
- </div>
- <p className="text-xs text-purple-600">
- This takes a few minutes. Keep the app open.
- </p>
- </div>
- ) : (
- <div className="space-y-4">
- <Button
- onClick={installWhisper}
- className="bg-purple-600 hover:bg-purple-700"
- >
- Install Whisper
- </Button>
-
- <div className="flex items-center justify-center">
- <Button
- onClick={() =>
- setCheckingWhisper(!checkingWhisper)
- }
- variant="outline"
- size="sm"
- className="text-purple-600 border-purple-300 hover:bg-purple-50"
- >
- Check if already installed
- </Button>
- </div>
- </div>
- )}
- </div>
- </div>
- )}
- </div>
- )}
-
- <Button
- onClick={useLocalWhisper ? saveWhisperSettings : saveApiKey}
- className="w-full"
- disabled={!useLocalWhisper && !apiKey.trim()}
- >
- {useLocalWhisper ? "Save Whisper Settings" : "Save API Key"}
- </Button>
- </div>
- </CardContent>
- </Card>
-
- {/* Dictation Settings Card */}
- <Card className="bg-white relative z-10">
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <Keyboard size={18} className="text-indigo-600" />
- Dictation Setup
- </CardTitle>
- <p className="text-sm text-neutral-600 mt-2 leading-relaxed">
- Configure how you want to activate voice transcription.
- </p>
- </CardHeader>
- <CardContent className="space-y-5">
- <div className="space-y-5">
- <div>
- <label className="block text-sm font-medium text-neutral-700 mb-2">
- Activation Key
- </label>
- <Input
- placeholder="Current: ` (backtick)"
- value={key}
- onChange={(e) => setKey(e.target.value)}
- className="mb-3"
- />
- <Button
- onClick={saveKey}
- disabled={!key.trim()}
- variant="outline"
- size="sm"
- >
- Save Key
- </Button>
- </div>
-
- <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
- <Button onClick={requestPermissions} variant="outline">
- <span className="mr-2">🎤</span>
- Enable Microphone
- </Button>
- <Button
- onClick={requestAccessibilityPermissions}
- variant="outline"
- >
- <span className="mr-2">🔓</span>
- Check Permissions
- </Button>
- </div>
-
- <Button
- onClick={resetAccessibilityPermissions}
- variant="secondary"
- className="w-full"
- >
- <span className="mr-2">⚙️</span>
- Fix Permission Issues
- </Button>
- </div>
- </CardContent>
- </Card>
-
- {/* Recent Transcriptions Card */}
- <Card className="bg-white relative z-10">
- <CardHeader>
- <div className="flex flex-row items-center justify-between">
- <div>
- <CardTitle className="flex items-center gap-2">
- <FileText size={18} className="text-indigo-600" />
- Recent Transcriptions
- </CardTitle>
- <p className="text-sm text-neutral-600 mt-2">
- Your voice recordings, converted to text.
- </p>
- </div>
+ <div className="p-6">
+ {showSettings ? (
+ <SettingsPage onBack={() => setShowSettings(false)} />
+ ) : (
+ <div className="space-y-6 max-w-4xl mx-auto">
+ <Card>
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2">
+ <FileText size={18} className="text-indigo-600" />
+ Recent Transcriptions
+ </CardTitle>
<div className="flex gap-2">
<Tooltip content="Refresh history">
- <Button
- onClick={refreshHistory}
- variant="ghost"
- size="icon"
- >
+ <Button onClick={refreshHistory} variant="ghost" size="icon">
<RefreshCw size={16} />
</Button>
</Tooltip>
<Tooltip content="Clear all transcriptions">
- <Button
- onClick={clearHistory}
- variant="ghost"
+ <Button
+ onClick={clearHistory}
+ variant="ghost"
size="icon"
className="text-red-600 hover:text-red-700 hover:bg-red-50"
>
@@ -986,149 +238,150 @@ Click OK when you're ready to open System Settings.`;
</Button>
</Tooltip>
</div>
- </div>
- </CardHeader>
- <CardContent>
- {isLoading ? (
- <div className="text-center py-8">
- <div className="w-8 h-8 mx-auto mb-3 bg-indigo-600 rounded-lg flex items-center justify-center">
- <span className="text-white text-sm">📝</span>
+ </CardHeader>
+ <CardContent>
+ {isLoading ? (
+ <div className="text-center py-8">
+ <div className="w-8 h-8 mx-auto mb-3 bg-indigo-600 rounded-lg flex items-center justify-center">
+ <span className="text-white text-sm">📝</span>
+ </div>
+ <p className="text-neutral-600">Loading transcriptions...</p>
</div>
- <p className="text-neutral-600">Loading transcriptions...</p>
- </div>
- ) : (
- <div className="space-y-3 max-h-80 overflow-y-auto">
- {history.map((item, index) => (
- <div
- key={item.id}
- className="relative bg-gradient-to-b from-blue-50/30 to-white rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-shadow"
- >
- {/* Content */}
- <div className="p-6 pl-16" style={{ paddingTop: "8px" }}>
- <div className="flex items-start justify-between">
- <div className="flex-1 mr-3">
- <div
- className="flex items-center gap-2 mb-1"
- style={{
- marginTop: "2px",
- lineHeight: "24px",
- }}
- >
- <span className="text-indigo-600 text-xs font-medium">
- #{history.length - index}
- </span>
- <div className="w-px h-3 bg-neutral-300"></div>
- <span className="text-xs text-neutral-500">
- {new Date(item.timestamp).toLocaleString(
- "en-US",
- {
+ ) : (
+ <div className="space-y-3 max-h-80 overflow-y-auto">
+ {history.map((item, index) => (
+ <div
+ key={item.id}
+ className="relative bg-gradient-to-b from-blue-50/30 to-white rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-shadow"
+ >
+ <div className="p-6 pl-16" style={{ paddingTop: "8px" }}>
+ <div className="flex items-start justify-between">
+ <div className="flex-1 mr-3">
+ <div
+ className="flex items-center gap-2 mb-1"
+ style={{ marginTop: "2px", lineHeight: "24px" }}
+ >
+ <span className="text-indigo-600 text-xs font-medium">
+ #{history.length - index}
+ </span>
+ <div className="w-px h-3 bg-neutral-300"/>
+ <span className="text-xs text-neutral-500">
+ {new Date(item.timestamp).toLocaleString("en-US", {
month: "short",
day: "numeric",
hour: "2-digit",
- minute: "2-digit",
- }
- )}
- </span>
+ minute: "2-digit"
+ })}
+ </span>
+ </div>
+ <p
+ className="text-neutral-800 text-sm"
+ style={{
+ fontFamily: 'Noto Sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
+ lineHeight: "24px",
+ textAlign: "left",
+ marginTop: "2px",
+ paddingBottom: "2px"
+ }}
+ >
+ {item.text}
+ </p>
</div>
- <p
- className="text-neutral-800 text-sm"
- style={{
- fontFamily:
- 'Noto Sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
- lineHeight: "24px",
- textAlign: "left",
- marginTop: "2px",
- paddingBottom: "2px",
- }}
+ <div
+ className="flex gap-1 flex-shrink-0"
+ style={{ marginTop: "2px" }}
>
- {item.text}
- </p>
- </div>
- <div
- className="flex gap-1 flex-shrink-0"
- style={{ marginTop: "2px" }}
- >
- <Tooltip content="Copy to clipboard">
- <Button
- size="icon"
- variant="ghost"
- onClick={() => copyToClipboard(item.text)}
- className="h-7 w-7"
- >
- <Copy size={12} />
- </Button>
- </Tooltip>
- <Tooltip content="Delete transcription">
- <Button
- size="icon"
- variant="ghost"
- onClick={() => deleteTranscription(item.id)}
- className="h-7 w-7 text-red-600 hover:text-red-700 hover:bg-red-50"
- >
- <Trash2 size={12} />
- </Button>
- </Tooltip>
+ <Tooltip content="Copy to clipboard">
+ <Button
+ size="icon"
+ variant="ghost"
+ onClick={() => copyToClipboard(item.text)}
+ className="h-7 w-7"
+ >
+ <Copy size={12} />
+ </Button>
+ </Tooltip>
+ <Tooltip content="Delete transcription">
+ <Button
+ size="icon"
+ variant="ghost"
+ onClick={() => deleteTranscription(item.id)}
+ className="h-7 w-7 text-red-600 hover:text-red-700 hover:bg-red-50"
+ >
+ <Trash2 size={12} />
+ </Button>
+ </Tooltip>
+ </div>
</div>
</div>
</div>
+ ))}
+ </div>
+ )}
+ </CardContent>
+ </Card>
+
+ {/* About Section */}
+ <Card className="bg-white relative z-10">
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2">
+ <Info size={18} className="text-indigo-600" />
+ About
+ </CardTitle>
+ </CardHeader>
+ <CardContent>
+ <p className="text-neutral-600 text-sm leading-relaxed mb-6">
+ OpenWispr converts your speech to text using AI. Press your
+ hotkey, speak, and we'll type what you said wherever your cursor
+ is.
+ </p>
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm mb-6">
+ <div className="text-center p-4 border border-neutral-200 rounded-xl bg-white">
+ <div className="w-8 h-8 mx-auto mb-2 bg-indigo-600 rounded-lg flex items-center justify-center">
+ <span className="text-white text-sm">⌨️</span>
</div>
- ))}
- </div>
- )}
- </CardContent>
- </Card>
-
- {/* About Card */}
- <Card className="bg-white relative z-10">
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <Info size={18} className="text-indigo-600" />
- About
- </CardTitle>
- </CardHeader>
- <CardContent>
- <p className="text-neutral-600 text-sm leading-relaxed mb-6">
- OpenWispr converts your speech to text using AI. Press your
- hotkey, speak, and we'll type what you said wherever your cursor
- is.
- </p>
- <div className="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm">
- <div className="text-center p-4 border border-neutral-200 rounded-xl bg-white">
- <div className="w-8 h-8 mx-auto mb-2 bg-indigo-600 rounded-lg flex items-center justify-center">
- <span className="text-white text-sm">⌨️</span>
+ <p className="font-medium text-neutral-800 mb-1">
+ Default Hotkey
+ </p>
+ <p className="text-neutral-600 font-mono text-xs">
+ ` (backtick)
+ </p>
</div>
- <p className="font-medium text-neutral-800 mb-1">
- Default Hotkey
- </p>
- <p className="text-neutral-600 font-mono text-xs">
- ` (backtick)
- </p>
- </div>
- <div className="text-center p-4 border border-neutral-200 rounded-xl bg-white">
- <div className="w-8 h-8 mx-auto mb-2 bg-emerald-600 rounded-lg flex items-center justify-center">
- <span className="text-white text-sm">🏷️</span>
+ <div className="text-center p-4 border border-neutral-200 rounded-xl bg-white">
+ <div className="w-8 h-8 mx-auto mb-2 bg-emerald-600 rounded-lg flex items-center justify-center">
+ <span className="text-white text-sm">🏷️</span>
+ </div>
+ <p className="font-medium text-neutral-800 mb-1">Version</p>
+ <p className="text-neutral-600 text-xs">0.1.0</p>
</div>
- <p className="font-medium text-neutral-800 mb-1">Version</p>
- <p className="text-neutral-600 text-xs">0.1.0</p>
- </div>
- <div className="text-center p-4 border border-neutral-200 rounded-xl bg-white">
- <div className="w-8 h-8 mx-auto mb-2 bg-green-600 rounded-lg flex items-center justify-center">
- <span className="text-white text-sm">✓</span>
+ <div className="text-center p-4 border border-neutral-200 rounded-xl bg-white">
+ <div className="w-8 h-8 mx-auto mb-2 bg-green-600 rounded-lg flex items-center justify-center">
+ <span className="text-white text-sm">✓</span>
+ </div>
+ <p className="font-medium text-neutral-800 mb-1">Status</p>
+ <p className="text-green-600 text-xs font-medium">Active</p>
</div>
- <p className="font-medium text-neutral-800 mb-1">Status</p>
- <p className="text-green-600 text-xs font-medium">Active</p>
</div>
- </div>
- </CardContent>
- </Card>
-
- {/* Footer */}
- <div className="text-center py-6">
- <p className="text-neutral-500 text-sm">
- Built for thinkers who move at the speed of thought
- </p>
+ {/* Reset Onboarding */}
+ <div className="border-t border-neutral-200 pt-4">
+ <Button
+ onClick={() => {
+ if (confirm('Are you sure you want to reset the onboarding process? This will clear your setup and show the welcome flow again.')) {
+ localStorage.removeItem('onboardingCompleted');
+ window.location.reload();
+ }
+ }}
+ variant="outline"
+ className="w-full text-amber-600 border-amber-300 hover:bg-amber-50 hover:border-amber-400"
+ >
+ <span className="mr-2">🔄</span>
+ Reset Onboarding
+ </Button>
+ </div>
+ </CardContent>
+ </Card>
</div>
- </div>
+ )}
</div>
</div>
);
diff --git a/src/components/OnboardingFlow.tsx b/src/components/OnboardingFlow.tsx
new file mode 100644
index 000000000..eb5ae299d
--- /dev/null
+++ b/src/components/OnboardingFlow.tsx
@@ -0,0 +1,973 @@
+import React, { useState, useEffect } from "react";
+import { Card, CardContent, CardHeader, CardTitle } from "./ui/card";
+import { Button } from "./ui/button";
+import { Input } from "./ui/input";
+import {
+ ChevronRight,
+ ChevronLeft,
+ Check,
+ Settings,
+ Mic,
+ Download,
+ Key,
+ Zap,
+ RefreshCw,
+ Trash2,
+ Cloud,
+ Shield,
+ Keyboard,
+ TestTube,
+ Sparkles,
+ Globe,
+ Lock,
+ Play,
+ ArrowRight,
+ X,
+} from "lucide-react";
+
+// Type declaration for electronAPI
+declare global {
+ interface Window {
+ electronAPI: {
+ pasteText: (text: string) => Promise<void>;
+ hideWindow: () => Promise<void>;
+ onToggleDictation: (callback: () => void) => void;
+ saveTranscription: (text: string) => Promise<{ id: number; success: boolean }>;
+ getTranscriptions: (limit?: number) => Promise<any[]>;
+ clearTranscriptions: () => Promise<{ cleared: number; success: boolean }>;
+ deleteTranscription: (id: number) => Promise<{ success: boolean }>;
+ getOpenAIKey: () => Promise<string>;
+ saveOpenAIKey: (key: string) => Promise<{ success: boolean }>;
+ readClipboard: () => Promise<string>;
+ createProductionEnvFile: (key: string) => Promise<void>;
+ transcribeLocalWhisper: (audioBlob: Blob, options?: any) => Promise<any>;
+ checkWhisperInstallation: () => Promise<{
+ installed: boolean;
+ working: boolean;
+ error?: string;
+ }>;
+ installWhisper: () => Promise<{
+ success: boolean;
+ message: string;
+ output: string;
+ }>;
+ onWhisperInstallProgress: (
+ callback: (event: any, data: { type: string; message: string; output?: string }) => void
+ ) => void;
+ downloadWhisperModel: (modelName: string) => Promise<{
+ success: boolean;
+ model: string;
+ downloaded: boolean;
+ size_mb?: number;
+ error?: string;
+ }>;
+ onWhisperDownloadProgress: (
+ callback: (event: any, data: {
+ type: string;
+ model: string;
+ percentage?: number;
+ downloaded_bytes?: number;
+ total_bytes?: number;
+ error?: string;
+ result?: any;
+ }) => void
+ ) => void;
+ checkModelStatus: (modelName: string) => Promise<{
+ success: boolean;
+ model: string;
+ downloaded: boolean;
+ size_mb?: number;
+ error?: string;
+ }>;
+ listWhisperModels: () => Promise<{
+ success: boolean;
+ models: Array<{ model: string; downloaded: boolean; size_mb?: number }>;
+ cache_dir: string;
+ }>;
+ deleteWhisperModel: (modelName: string) => Promise<{
+ success: boolean;
+ model: string;
+ deleted: boolean;
+ freed_mb?: number;
+ error?: string;
+ }>;
+ windowMinimize: () => Promise<void>;
+ windowMaximize: () => Promise<void>;
+ windowClose: () => Promise<void>;
+ windowIsMaximized: () => Promise<boolean>;
+ };
+ }
+}
+
+interface OnboardingFlowProps {
+ onComplete: () => void;
+}
+
+export default function OnboardingFlow({ onComplete }: OnboardingFlowProps) {
+ const [currentStep, setCurrentStep] = useState(0);
+ const [useLocalWhisper, setUseLocalWhisper] = useState(false);
+ const [apiKey, setApiKey] = useState("");
+ const [whisperModel, setWhisperModel] = useState("base");
+ const [hotkey, setHotkey] = useState("`");
+ const [whisperInstalled, setWhisperInstalled] = useState(false);
+ const [installingWhisper, setInstallingWhisper] = useState(false);
+ const [installProgress, setInstallProgress] = useState("");
+ const [downloadingModel, setDownloadingModel] = useState<string | null>(null);
+ const [downloadProgress, setDownloadProgress] = useState(0);
+ const [modelList, setModelList] = useState<Array<{ model: string; downloaded: boolean; size_mb?: number }>>([]);
+ const [micPermissionGranted, setMicPermissionGranted] = useState(false);
+ const [accessibilityPermissionGranted, setAccessibilityPermissionGranted] = useState(false);
+ const [practiceText, setPracticeText] = useState("");
+ const [isRecording, setIsRecording] = useState(false);
+ const [isProcessing, setIsProcessing] = useState(false);
+ const [recordingBlob, setRecordingBlob] = useState<Blob | null>(null);
+ const [mediaRecorder, setMediaRecorder] = useState<MediaRecorder | null>(null);
+ const [audioChunks, setAudioChunks] = useState<Blob[]>([]);
+
+ const steps = [
+ { title: "Welcome", icon: Sparkles },
+ { title: "Choose Mode", icon: Globe },
+ { title: "Setup Processing", icon: Settings },
+ { title: "Permissions", icon: Shield },
+ { title: "Choose Hotkey", icon: Keyboard },
+ { title: "Test & Practice", icon: TestTube },
+ { title: "Complete", icon: Check },
+ ];
+
+ useEffect(() => {
+ // Set up progress listeners
+ window.electronAPI.onWhisperInstallProgress((event, data) => {
+ setInstallProgress(data.message);
+ });
+
+ window.electronAPI.onWhisperDownloadProgress((event, data) => {
+ if (data.type === "progress") {
+ setDownloadProgress(data.percentage || 0);
+ } else if (data.type === "complete") {
+ setDownloadingModel(null);
+ setDownloadProgress(0);
+ loadModelList();
+ } else if (data.type === "error") {
+ setDownloadingModel(null);
+ setDownloadProgress(0);
+ }
+ });
+
+ // Load initial model list if going local
+ if (useLocalWhisper) {
+ loadModelList();
+ }
+ }, [useLocalWhisper]);
+
+ const loadModelList = async () => {
+ try {
+ const result = await window.electronAPI.listWhisperModels();
+ if (result.success) {
+ setModelList(result.models);
+ }
+ } catch (error) {
+ console.error("Failed to load model list:", error);
+ }
+ };
+
+ const checkWhisperInstallation = async () => {
+ try {
+ const result = await window.electronAPI.checkWhisperInstallation();
+ setWhisperInstalled(result.installed && result.working);
+ if (result.installed && result.working) {
+ loadModelList();
+ }
+ } catch (error) {
+ setWhisperInstalled(false);
+ }
+ };
+
+ const installWhisper = async () => {
+ try {
+ setInstallingWhisper(true);
+ setInstallProgress("Starting Whisper installation...");
+
+ const result = await window.electronAPI.installWhisper();
+
+ if (result.success) {
+ setWhisperInstalled(true);
+ setInstallProgress("Installation complete!");
+ await loadModelList();
+ } else {
+ alert(`❌ Failed to install Whisper: ${result.message}`);
+ }
+ } catch (error) {
+ alert(`❌ Failed to install Whisper: ${error}`);
+ } finally {
+ setInstallingWhisper(false);
+ setInstallProgress("");
+ }
+ };
+
+ const downloadModel = async (modelName: string) => {
+ try {
+ setDownloadingModel(modelName);
+ setDownloadProgress(0);
+
+ const result = await window.electronAPI.downloadWhisperModel(modelName);
+
+ if (result.success) {
+ await loadModelList();
+ } else {
+ alert(`❌ Failed to download model "${modelName}": ${result.error}`);
+ }
+ } catch (error) {
+ alert(`❌ Failed to download model "${modelName}": ${error}`);
+ } finally {
+ setDownloadingModel(null);
+ setDownloadProgress(0);
+ }
+ };
+
+ const requestMicPermission = async () => {
+ try {
+ await navigator.mediaDevices.getUserMedia({ audio: true });
+ setMicPermissionGranted(true);
+ } catch (err) {
+ alert("Please grant microphone permissions to use voice dictation.");
+ }
+ };
+
+ const testAccessibilityPermission = async () => {
+ try {
+ await window.electronAPI.pasteText("OpenWispr accessibility test");
+ setAccessibilityPermissionGranted(true);
+ alert("✅ Accessibility permissions working! Check if the test text appeared in another app.");
+ } catch (err) {
+ alert("❌ Accessibility permissions needed! Please grant them in System Settings.");
+ }
+ };
+
+ const startPracticeRecording = async () => {
+ try {
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
+ const recorder = new MediaRecorder(stream);
+ const chunks: Blob[] = [];
+
+ recorder.ondataavailable = (event) => {
+ chunks.push(event.data);
+ };
+
+ recorder.onstop = async () => {
+ const blob = new Blob(chunks, { type: 'audio/wav' });
+ setRecordingBlob(blob);
+ setIsProcessing(true);
+
+ // Process the audio
+ try {
+ let result;
+ if (useLocalWhisper) {
+ result = await window.electronAPI.transcribeLocalWhisper(blob, { model: whisperModel });
+ } else {
+ // For demo purposes, we'll use a simple OpenAI API call
+ const formData = new FormData();
+ formData.append('file', blob, 'audio.wav');
+ formData.append('model', 'whisper-1');
+
+ const response = await fetch('https://api.openai.com/v1/audio/transcriptions', {
+ method: 'POST',
+ headers: {
+ 'Authorization': `Bearer ${apiKey}`
+ },
+ body: formData
+ });
+
+ if (response.ok) {
+ result = await response.json();
+ } else {
+ throw new Error('Transcription failed');
+ }
+ }
+
+ if (result.text || result.success) {
+ const text = result.text || result.transcript || "Transcription successful!";
+ setPracticeText(text);
+ // Test paste functionality
+ await window.electronAPI.pasteText(text);
+ }
+ } catch (error) {
+ alert("Transcription failed. Please try again.");
+ } finally {
+ setIsProcessing(false);
+ stream.getTracks().forEach(track => track.stop());
+ }
+ };
+
+ setMediaRecorder(recorder);
+ setAudioChunks(chunks);
+ recorder.start();
+ setIsRecording(true);
+ } catch (error) {
+ alert("Failed to start recording. Please check microphone permissions.");
+ }
+ };
+
+ const stopPracticeRecording = () => {
+ if (mediaRecorder && isRecording) {
+ mediaRecorder.stop();
+ setIsRecording(false);
+ }
+ };
+
+ const saveSettings = async () => {
+ // Save all settings
+ localStorage.setItem("useLocalWhisper", useLocalWhisper.toString());
+ localStorage.setItem("whisperModel", whisperModel);
+ localStorage.setItem("dictationKey", hotkey);
+ localStorage.setItem("onboardingCompleted", "true");
+
+ if (!useLocalWhisper && apiKey) {
+ await window.electronAPI.saveOpenAIKey(apiKey);
+ localStorage.setItem("openaiApiKey", apiKey);
+ }
+ };
+
+ const nextStep = () => {
+ if (currentStep < steps.length - 1) {
+ setCurrentStep(currentStep + 1);
+ }
+ };
+
+ const prevStep = () => {
+ if (currentStep > 0) {
+ setCurrentStep(currentStep - 1);
+ }
+ };
+
+ const finishOnboarding = async () => {
+ await saveSettings();
+ onComplete();
+ };
+
+ const renderStep = () => {
+ switch (currentStep) {
+ case 0: // Welcome
+ return (
+ <div className="text-center space-y-6">
+ <div className="w-16 h-16 mx-auto bg-indigo-100 rounded-full flex items-center justify-center">
+ <Sparkles className="w-8 h-8 text-indigo-600" />
+ </div>
+ <div>
+ <h2 className="text-2xl font-bold text-gray-900 mb-2">Welcome to OpenWispr</h2>
+ <p className="text-gray-600">
+ Let's set up your voice dictation in just a few simple steps.
+ </p>
+ </div>
+ <div className="bg-blue-50 p-4 rounded-lg">
+ <p className="text-sm text-blue-800">
+ 🎤 Turn your voice into text instantly<br />
+ ⚡ Works anywhere on your computer<br />
+ 🔒 Your privacy is protected
+ </p>
+ </div>
+ </div>
+ );
+
+ case 1: // Choose Mode
+ return (
+ <div className="space-y-6">
+ <div className="text-center">
+ <h2 className="text-2xl font-bold text-gray-900 mb-2">Choose Your Processing Mode</h2>
+ <p className="text-gray-600">
+ How would you like to convert your speech to text?
+ </p>
+ </div>
+
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
+ <button
+ onClick={() => setUseLocalWhisper(false)}
+ className={`p-6 border-2 rounded-xl text-left transition-all ${
+ !useLocalWhisper
+ ? "border-indigo-500 bg-indigo-50 shadow-md"
+ : "border-gray-200 bg-white hover:border-gray-300"
+ }`}
+ >
+ <div className="flex items-center justify-between mb-3">
+ <div className="flex items-center gap-3">
+ <Cloud className="w-6 h-6 text-indigo-600" />
+ <h3 className="font-semibold text-gray-900">Cloud Processing</h3>
+ </div>
+ <span className="text-xs text-green-600 bg-green-100 px-2 py-1 rounded-full">
+ Fastest
+ </span>
+ </div>
+ <p className="text-sm text-gray-600 mb-3">
+ Uses OpenAI's servers for lightning-fast transcription
+ </p>
+ <div className="text-xs text-gray-500">
+ ✓ Fastest processing<br />
+ ✓ Best accuracy<br />
+ • Requires internet<br />
+ • Needs API key
+ </div>
+ </button>
+
+ <button
+ onClick={() => setUseLocalWhisper(true)}
+ className={`p-6 border-2 rounded-xl text-left transition-all ${
+ useLocalWhisper
+ ? "border-indigo-500 bg-indigo-50 shadow-md"
+ : "border-gray-200 bg-white hover:border-gray-300"
+ }`}
+ >
+ <div className="flex items-center justify-between mb-3">
+ <div className="flex items-center gap-3">
+ <Lock className="w-6 h-6 text-indigo-600" />
+ <h3 className="font-semibold text-gray-900">Local Processing</h3>
+ </div>
+ <span className="text-xs text-blue-600 bg-blue-100 px-2 py-1 rounded-full">
+ Private
+ </span>
+ </div>
+ <p className="text-sm text-gray-600 mb-3">
+ Processes everything on your device for complete privacy
+ </p>
+ <div className="text-xs text-gray-500">
+ ✓ Complete privacy<br />
+ ✓ Works offline<br />
+ ✓ No monthly costs<br />
+ • Slower processing
+ </div>
+ </button>
+ </div>
+ </div>
+ );
+
+ case 2: // Setup Processing
+ return (
+ <div className="space-y-6">
+ <div className="text-center">
+ <h2 className="text-2xl font-bold text-gray-900 mb-2">
+ {useLocalWhisper ? "Local Processing Setup" : "Cloud Processing Setup"}
+ </h2>
+ <p className="text-gray-600">
+ {useLocalWhisper
+ ? "Let's install and configure Whisper on your device"
+ : "Enter your OpenAI API key to get started"}
+ </p>
+ </div>
+
+ {useLocalWhisper ? (
+ <div className="space-y-4">
+ {!whisperInstalled ? (
+ <div className="text-center space-y-4">
+ <div className="w-16 h-16 mx-auto bg-purple-100 rounded-full flex items-center justify-center">
+ <Download className="w-8 h-8 text-purple-600" />
+ </div>
+ <div>
+ <h3 className="font-semibold text-gray-900 mb-2">Install Whisper</h3>
+ <p className="text-sm text-gray-600 mb-4">
+ We'll automatically install Whisper for you. No technical setup required.
+ </p>
+ </div>
+
+ {installingWhisper ? (
+ <div className="bg-purple-50 p-4 rounded-lg">
+ <div className="flex items-center justify-center gap-3 mb-3">
+ <div className="animate-spin rounded-full h-5 w-5 border-b-2 border-purple-600"></div>
+ <span className="font-medium text-purple-900">Installing...</span>
+ </div>
+ {installProgress && (
+ <div className="text-xs text-purple-600 bg-white p-2 rounded font-mono">
+ {installProgress}
+ </div>
+ )}
+ <p className="text-xs text-purple-600 mt-2">
+ This may take a few minutes. Please keep the app open.
+ </p>
+ </div>
+ ) : (
+ <div className="space-y-3">
+ <Button onClick={installWhisper} className="w-full">
+ Install Whisper
+ </Button>
+ <Button
+ onClick={checkWhisperInstallation}
+ variant="outline"
+ size="sm"
+ className="w-full"
+ >
+ Check if already installed
+ </Button>
+ </div>
+ )}
+ </div>
+ ) : (
+ <div className="space-y-4">
+ <div className="text-center">
+ <div className="w-16 h-16 mx-auto bg-green-100 rounded-full flex items-center justify-center mb-4">
+ <Check className="w-8 h-8 text-green-600" />
+ </div>
+ <h3 className="font-semibold text-green-900 mb-2">Whisper Installed!</h3>
+ <p className="text-sm text-gray-600">Now choose your model quality:</p>
+ </div>
+
+ <div>
+ <label className="block text-sm font-medium text-gray-700 mb-2">
+ Model Quality
+ </label>
+ <select
+ value={whisperModel}
+ onChange={(e) => setWhisperModel(e.target.value)}
+ className="w-full p-3 border border-gray-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500"
+ >
+ <option value="tiny">Tiny - Fastest, lower quality</option>
+ <option value="base">Base - Good balance (recommended)</option>
+ <option value="small">Small - Better quality, slower</option>
+ <option value="medium">Medium - High quality</option>
+ <option value="large">Large - Best quality, slowest</option>
+ </select>
+ <p className="text-xs text-gray-500 mt-2">
+ You can download the model on the next step.
+ </p>
+ </div>
+
+ {modelList.length > 0 && (
+ <div className="bg-gray-50 p-4 rounded-lg">
+ <h4 className="font-medium text-gray-900 mb-3">Available Models</h4>
+ <div className="space-y-2">
+ {modelList.map((model) => (
+ <div key={model.model} className="flex items-center justify-between p-2 bg-white rounded border">
+ <span className="capitalize font-medium">{model.model}</span>
+ <div className="flex items-center gap-2">
+ {model.downloaded ? (
+ <span className="text-xs text-green-600 bg-green-100 px-2 py-1 rounded">
+ ✓ Downloaded
+ </span>
+ ) : (
+ <Button
+ onClick={() => downloadModel(model.model)}
+ size="sm"
+ disabled={downloadingModel === model.model}
+ >
+ {downloadingModel === model.model
+ ? `${Math.round(downloadProgress)}%`
+ : "Download"}
+ </Button>
+ )}
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ ) : (
+ <div className="space-y-4">
+ <div className="text-center">
+ <div className="w-16 h-16 mx-auto bg-blue-100 rounded-full flex items-center justify-center mb-4">
+ <Key className="w-8 h-8 text-blue-600" />
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-sm font-medium text-gray-700 mb-2">
+ OpenAI API Key
+ </label>
+ <div className="flex gap-3">
+ <Input
+ type="password"
+ placeholder="sk-..."
+ value={apiKey}
+ onChange={(e) => setApiKey(e.target.value)}
+ className="flex-1"
+ />
+ <Button
+ variant="outline"
+ onClick={async () => {
+ try {
+ const text = await window.electronAPI.readClipboard();
+ if (text && text.trim()) {
+ setApiKey(text.trim());
+ }
+ } catch (err) {
+ alert("Could not paste from clipboard.");
+ }
+ }}
+ >
+ Paste
+ </Button>
+ </div>
+ <p className="text-xs text-gray-500 mt-2">
+ Get your API key from <strong>platform.openai.com</strong>
+ </p>
+ </div>
+
+ <div className="bg-blue-50 p-4 rounded-lg">
+ <h4 className="font-medium text-blue-900 mb-2">How to get your API key:</h4>
+ <ol className="text-sm text-blue-800 space-y-1">
+ <li>1. Go to platform.openai.com</li>
+ <li>2. Sign in to your account</li>
+ <li>3. Navigate to API Keys</li>
+ <li>4. Create a new secret key</li>
+ <li>5. Copy and paste it here</li>
+ </ol>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+
+ case 3: // Permissions
+ return (
+ <div className="space-y-6">
+ <div className="text-center">
+ <h2 className="text-2xl font-bold text-gray-900 mb-2">Grant Permissions</h2>
+ <p className="text-gray-600">
+ OpenWispr needs a couple of permissions to work properly
+ </p>
+ </div>
+
+ <div className="space-y-4">
+ <div className="border rounded-lg p-4">
+ <div className="flex items-center justify-between mb-3">
+ <div className="flex items-center gap-3">
+ <Mic className="w-6 h-6 text-indigo-600" />
+ <div>
+ <h3 className="font-semibold text-gray-900">Microphone Access</h3>
+ <p className="text-sm text-gray-600">Required to record your voice</p>
+ </div>
+ </div>
+ {micPermissionGranted ? (
+ <div className="text-green-600">
+ <Check className="w-5 h-5" />
+ </div>
+ ) : (
+ <Button onClick={requestMicPermission} size="sm">
+ Grant Access
+ </Button>
+ )}
+ </div>
+ </div>
+
+ <div className="border rounded-lg p-4">
+ <div className="flex items-center justify-between mb-3">
+ <div className="flex items-center gap-3">
+ <Shield className="w-6 h-6 text-indigo-600" />
+ <div>
+ <h3 className="font-semibold text-gray-900">Accessibility Permission</h3>
+ <p className="text-sm text-gray-600">Required to paste text automatically</p>
+ </div>
+ </div>
+ {accessibilityPermissionGranted ? (
+ <div className="text-green-600">
+ <Check className="w-5 h-5" />
+ </div>
+ ) : (
+ <Button onClick={testAccessibilityPermission} size="sm">
+ Test & Grant
+ </Button>
+ )}
+ </div>
+ </div>
+ </div>
+
+ <div className="bg-amber-50 p-4 rounded-lg">
+ <h4 className="font-medium text-amber-900 mb-2">🔒 Privacy Note</h4>
+ <p className="text-sm text-amber-800">
+ OpenWispr only uses these permissions for dictation.
+ {useLocalWhisper ? " With local processing, your voice never leaves your device." : " Your voice is sent to OpenAI's servers for transcription."}
+ </p>
+ </div>
+ </div>
+ );
+
+ case 4: // Choose Hotkey
+ return (
+ <div className="space-y-6">
+ <div className="text-center">
+ <h2 className="text-2xl font-bold text-gray-900 mb-2">Choose Your Hotkey</h2>
+ <p className="text-gray-600">
+ Select which key you want to press to start/stop dictation
+ </p>
+ </div>
+
+ <div className="space-y-4">
+ <div>
+ <label className="block text-sm font-medium text-gray-700 mb-2">
+ Activation Key
+ </label>
+ <Input
+ placeholder="Default: ` (backtick)"
+ value={hotkey}
+ onChange={(e) => setHotkey(e.target.value)}
+ className="text-center text-lg font-mono"
+ />
+ <p className="text-xs text-gray-500 mt-2">
+ Press this key from anywhere to start/stop dictation
+ </p>
+ </div>
+
+ <div className="bg-gray-50 p-4 rounded-lg">
+ <h4 className="font-medium text-gray-900 mb-3">Popular Choices:</h4>
+ <div className="grid grid-cols-2 gap-2">
+ {['`', 'F1', 'F2', 'F3', 'F4'].map((key) => (
+ <button
+ key={key}
+ onClick={() => setHotkey(key)}
+ className={`p-2 text-sm font-mono rounded border transition-all ${
+ hotkey === key
+ ? 'border-indigo-500 bg-indigo-50 text-indigo-700'
+ : 'border-gray-200 bg-white hover:border-gray-300'
+ }`}
+ >
+ {key}
+ </button>
+ ))}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+
+ case 5: // Test & Practice
+ return (
+ <div className="space-y-6">
+ <div className="text-center">
+ <h2 className="text-2xl font-bold text-gray-900 mb-2">Test & Practice</h2>
+ <p className="text-gray-600">
+ Let's test your setup and practice using OpenWispr
+ </p>
+ </div>
+
+ <div className="space-y-6">
+ <div className="bg-blue-50 p-6 rounded-lg">
+ <h3 className="font-semibold text-blue-900 mb-3">Practice Recording</h3>
+ <p className="text-sm text-blue-800 mb-4">
+ Click the button below, then speak something. We'll transcribe it and paste it into the text area.
+ </p>
+
+ <div className="space-y-4">
+ <div className="flex justify-center">
+ <Button
+ onClick={isRecording ? stopPracticeRecording : startPracticeRecording}
+ className={`w-32 h-12 ${
+ isRecording
+ ? 'bg-red-500 hover:bg-red-600'
+ : isProcessing
+ ? 'bg-purple-500 hover:bg-purple-600'
+ : 'bg-indigo-500 hover:bg-indigo-600'
+ }`}
+ disabled={isProcessing}
+ >
+ {isProcessing ? (
+ <>
+ <div className="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div>
+ Processing...
+ </>
+ ) : isRecording ? (
+ <>
+ <div className="animate-pulse w-2 h-2 bg-white rounded-full mr-2"></div>
+ Stop Recording
+ </>
+ ) : (
+ <>
+ <Mic className="w-4 h-4 mr-2" />
+ Start Recording
+ </>
+ )}
+ </Button>
+ </div>
+
+ <div>
+ <label className="block text-sm font-medium text-gray-700 mb-2">
+ Transcribed Text (will be pasted automatically):
+ </label>
+ <textarea
+ value={practiceText}
+ onChange={(e) => setPracticeText(e.target.value)}
+ className="w-full p-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"
+ rows={4}
+ placeholder="Your transcribed text will appear here..."
+ />
+ </div>
+ </div>
+ </div>
+
+ <div className="bg-green-50 p-4 rounded-lg">
+ <h4 className="font-medium text-green-900 mb-2">💡 How to use OpenWispr:</h4>
+ <ol className="text-sm text-green-800 space-y-1">
+ <li>1. Click in any text field (email, document, etc.)</li>
+ <li>2. Press <kbd className="bg-white px-2 py-1 rounded text-xs font-mono">{hotkey}</kbd> to start recording</li>
+ <li>3. Speak your text clearly</li>
+ <li>4. Press <kbd className="bg-white px-2 py-1 rounded text-xs font-mono">{hotkey}</kbd> again to stop</li>
+ <li>5. Your text will automatically appear where you were typing!</li>
+ </ol>
+ </div>
+ </div>
+ </div>
+ );
+
+ case 6: // Complete
+ return (
+ <div className="text-center space-y-6">
+ <div className="w-16 h-16 mx-auto bg-green-100 rounded-full flex items-center justify-center">
+ <Check className="w-8 h-8 text-green-600" />
+ </div>
+ <div>
+ <h2 className="text-2xl font-bold text-gray-900 mb-2">You're All Set!</h2>
+ <p className="text-gray-600">
+ OpenWispr is now configured and ready to use.
+ </p>
+ </div>
+
+ <div className="bg-gradient-to-r from-indigo-50 to-purple-50 p-6 rounded-lg">
+ <h3 className="font-semibold text-gray-900 mb-3">Your Setup Summary:</h3>
+ <div className="space-y-2 text-sm">
+ <div className="flex justify-between">
+ <span>Processing:</span>
+ <span className="font-medium">
+ {useLocalWhisper ? `Local (${whisperModel})` : 'OpenAI Cloud'}
+ </span>
+ </div>
+ <div className="flex justify-between">
+ <span>Hotkey:</span>
+ <kbd className="bg-white px-2 py-1 rounded text-xs font-mono">{hotkey}</kbd>
+ </div>
+ <div className="flex justify-between">
+ <span>Permissions:</span>
+ <span className="font-medium text-green-600">
+ {micPermissionGranted && accessibilityPermissionGranted ? '✓ Granted' : '⚠ Review needed'}
+ </span>
+ </div>
+ </div>
+ </div>
+
+ <div className="bg-blue-50 p-4 rounded-lg">
+ <p className="text-sm text-blue-800">
+ <strong>Pro tip:</strong> You can always change these settings later in the Control Panel.
+ </p>
+ </div>
+ </div>
+ );
+
+ default:
+ return null;
+ }
+ };
+
+ const canProceed = () => {
+ switch (currentStep) {
+ case 0: return true;
+ case 1: return true; // Mode selection
+ case 2:
+ if (useLocalWhisper) {
+ return whisperInstalled && modelList.some(m => m.downloaded);
+ } else {
+ return apiKey.trim() !== '';
+ }
+ case 3: return micPermissionGranted && accessibilityPermissionGranted;
+ case 4: return hotkey.trim() !== '';
+ case 5: return practiceText.trim() !== '';
+ case 6: return true;
+ default: return false;
+ }
+ };
+
+ return (
+ <div className="min-h-screen bg-gradient-to-br from-indigo-50 via-white to-purple-50">
+ {/* Header */}
+ <div className="bg-white border-b border-gray-200 px-6 py-4">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-3">
+ <div className="w-8 h-8 bg-indigo-600 rounded-lg flex items-center justify-center">
+ <span className="text-white font-bold text-sm">OW</span>
+ </div>
+ <h1 className="text-lg font-semibold text-gray-900">OpenWispr Setup</h1>
+ </div>
+ <div className="text-sm text-gray-500">
+ Step {currentStep + 1} of {steps.length}
+ </div>
+ </div>
+ </div>
+
+ {/* Progress Bar */}
+ <div className="bg-white border-b border-gray-200 px-6 py-2">
+ <div className="flex items-center justify-between mb-2">
+ {steps.map((step, index) => {
+ const Icon = step.icon;
+ const isActive = index === currentStep;
+ const isCompleted = index < currentStep;
+
+ return (
+ <div key={index} className="flex items-center">
+ <div className={`flex items-center gap-2 ${
+ isActive ? 'text-indigo-600' : isCompleted ? 'text-green-600' : 'text-gray-400'
+ }`}>
+ <div className={`w-8 h-8 rounded-full flex items-center justify-center border-2 ${
+ isActive
+ ? 'border-indigo-600 bg-indigo-50'
+ : isCompleted
+ ? 'border-green-600 bg-green-50'
+ : 'border-gray-300 bg-white'
+ }`}>
+ {isCompleted ? (
+ <Check className="w-4 h-4" />
+ ) : (
+ <Icon className="w-4 h-4" />
+ )}
+ </div>
+ <span className="text-xs font-medium hidden md:block">{step.title}</span>
+ </div>
+ {index < steps.length - 1 && (
+ <div className={`w-8 h-0.5 mx-2 ${
+ isCompleted ? 'bg-green-600' : 'bg-gray-300'
+ }`} />
+ )}
+ </div>
+ );
+ })}
+ </div>
+ </div>
+
+ {/* Content */}
+ <div className="flex-1 px-6 py-8">
+ <div className="max-w-2xl mx-auto">
+ <Card className="bg-white shadow-lg">
+ <CardContent className="p-8">
+ {renderStep()}
+ </CardContent>
+ </Card>
+ </div>
+ </div>
+
+ {/* Footer */}
+ <div className="bg-white border-t border-gray-200 px-6 py-4">
+ <div className="max-w-2xl mx-auto flex items-center justify-between">
+ <Button
+ onClick={prevStep}
+ variant="outline"
+ disabled={currentStep === 0}
+ >
+ <ChevronLeft className="w-4 h-4 mr-2" />
+ Previous
+ </Button>
+
+ <div className="flex items-center gap-2">
+ {currentStep === steps.length - 1 ? (
+ <Button onClick={finishOnboarding} className="bg-green-600 hover:bg-green-700">
+ <Check className="w-4 h-4 mr-2" />
+ Finish Setup
+ </Button>
+ ) : (
+ <Button
+ onClick={nextStep}
+ disabled={!canProceed()}
+ >
+ Next
+ <ChevronRight className="w-4 h-4 ml-2" />
+ </Button>
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
new file mode 100644
index 000000000..5bd383aeb
--- /dev/null
+++ b/src/components/SettingsPage.tsx
@@ -0,0 +1,1083 @@
+import React, { useState, useEffect } from "react";
+import { Card, CardContent, CardHeader, CardTitle } from "./ui/card";
+import { Button } from "./ui/button";
+import { Input } from "./ui/input";
+import { Tooltip } from "./ui/tooltip";
+import {
+ Copy,
+ Trash2,
+ RefreshCw,
+ Download,
+ Check,
+ X,
+ Settings,
+ Keyboard,
+ FileText,
+ Info,
+ Mic,
+ Minus,
+ Square,
+ ChevronLeft,
+ ChevronRight,
+} from "lucide-react";
+
+// Type declaration for electronAPI
+declare global {
+ interface Window {
+ electronAPI: {
+ pasteText: (text: string) => Promise<void>;
+ hideWindow: () => Promise<void>;
+ onToggleDictation: (callback: () => void) => void;
+ saveTranscription: (
+ text: string
+ ) => Promise<{ id: number; success: boolean }>;
+ getTranscriptions: (limit?: number) => Promise<TranscriptionItem[]>;
+ clearTranscriptions: () => Promise<{ cleared: number; success: boolean }>;
+ deleteTranscription: (id: number) => Promise<{ success: boolean }>;
+ getOpenAIKey: () => Promise<string>;
+ saveOpenAIKey: (key: string) => Promise<{ success: boolean }>;
+ readClipboard: () => Promise<string>;
+ createProductionEnvFile: (key: string) => Promise<void>;
+ transcribeLocalWhisper: (audioBlob: Blob, options?: any) => Promise<any>;
+ checkWhisperInstallation: () => Promise<{
+ installed: boolean;
+ working: boolean;
+ error?: string;
+ }>;
+ installWhisper: () => Promise<{
+ success: boolean;
+ message: string;
+ output: string;
+ }>;
+ onWhisperInstallProgress: (
+ callback: (
+ event: any,
+ data: { type: string; message: string; output?: string }
+ ) => void
+ ) => void;
+ downloadWhisperModel: (modelName: string) => Promise<{
+ success: boolean;
+ model: string;
+ downloaded: boolean;
+ size_mb?: number;
+ error?: string;
+ }>;
+ onWhisperDownloadProgress: (
+ callback: (
+ event: any,
+ data: {
+ type: string;
+ model: string;
+ percentage?: number;
+ downloaded_bytes?: number;
+ total_bytes?: number;
+ error?: string;
+ result?: any;
+ }
+ ) => void
+ ) => void;
+ checkModelStatus: (modelName: string) => Promise<{
+ success: boolean;
+ model: string;
+ downloaded: boolean;
+ size_mb?: number;
+ error?: string;
+ }>;
+ listWhisperModels: () => Promise<{
+ success: boolean;
+ models: Array<{ model: string; downloaded: boolean; size_mb?: number }>;
+ cache_dir: string;
+ }>;
+ deleteWhisperModel: (modelName: string) => Promise<{
+ success: boolean;
+ model: string;
+ deleted: boolean;
+ freed_mb?: number;
+ error?: string;
+ }>;
+ // Window control functions
+ windowMinimize: () => Promise<void>;
+ windowMaximize: () => Promise<void>;
+ windowClose: () => Promise<void>;
+ windowIsMaximized: () => Promise<boolean>;
+ };
+ }
+}
+
+interface TranscriptionItem {
+ id: number;
+ text: string;
+ timestamp: string;
+ created_at: string;
+}
+
+export default function SettingsPage({ onClose }) {
+ const [key, setKey] = useState("");
+ const [apiKey, setApiKey] = useState("");
+ const [useLocalWhisper, setUseLocalWhisper] = useState(false);
+ const [whisperModel, setWhisperModel] = useState("base");
+ const [history, setHistory] = useState<TranscriptionItem[]>([]);
+ const [isLoading, setIsLoading] = useState(true);
+ const [whisperInstalled, setWhisperInstalled] = useState(false);
+ const [checkingWhisper, setCheckingWhisper] = useState(false);
+ const [modelList, setModelList] = useState<
+ Array<{ model: string; downloaded: boolean; size_mb?: number }>
+ >([]);
+ const [downloadingModel, setDownloadingModel] = useState<string | null>(null);
+ const [downloadProgress, setDownloadProgress] = useState(0);
+ const [loadingModels, setLoadingModels] = useState(false);
+ const [installingWhisper, setInstallingWhisper] = useState(false);
+ const [installProgress, setInstallProgress] = useState<string>("");
+
+ useEffect(() => {
+ // Load saved settings
+ const savedKey = localStorage.getItem("dictationKey");
+ if (savedKey) setKey(savedKey);
+
+ // Load Whisper settings
+ const savedUseLocal = localStorage.getItem("useLocalWhisper") === "true";
+ const savedModel = localStorage.getItem("whisperModel") || "base";
+ setUseLocalWhisper(savedUseLocal);
+ setWhisperModel(savedModel);
+
+ // Load API key from main process first, then fallback to localStorage
+ const loadApiKey = async () => {
+ try {
+ const envApiKey = await window.electronAPI.getOpenAIKey();
+ if (envApiKey && envApiKey !== "your_openai_api_key_here") {
+ setApiKey(envApiKey);
+ } else {
+ const savedApiKey = localStorage.getItem("openaiApiKey");
+ if (savedApiKey) setApiKey(savedApiKey);
+ }
+ } catch (error) {
+ const savedApiKey = localStorage.getItem("openaiApiKey");
+ if (savedApiKey) setApiKey(savedApiKey);
+ }
+ };
+
+ loadApiKey();
+
+ // Load transcription history from database
+ loadTranscriptions();
+
+ // Check Whisper installation
+ checkWhisperInstallation();
+
+ // Set up progress listener for Whisper installation
+ window.electronAPI.onWhisperInstallProgress((event, data) => {
+ setInstallProgress(data.message);
+ });
+
+ // Set up progress listener for model downloads
+ window.electronAPI.onWhisperDownloadProgress((event, data) => {
+ if (data.type === "progress") {
+ setDownloadProgress(data.percentage || 0);
+ } else if (data.type === "complete") {
+ setDownloadingModel(null);
+ setDownloadProgress(0);
+ loadModelList();
+ } else if (data.type === "error") {
+ setDownloadingModel(null);
+ setDownloadProgress(0);
+ }
+ });
+ }, []);
+
+ const loadTranscriptions = async () => {
+ try {
+ setIsLoading(true);
+ const transcriptions = await window.electronAPI.getTranscriptions(50);
+ setHistory(transcriptions);
+ } catch (error) {
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ const checkWhisperInstallation = async () => {
+ try {
+ setCheckingWhisper(true);
+ const result = await window.electronAPI.checkWhisperInstallation();
+ setWhisperInstalled(result.installed && result.working);
+
+ if (result.installed && result.working) {
+ loadModelList();
+ }
+ } catch (error) {
+ setWhisperInstalled(false);
+ } finally {
+ setCheckingWhisper(false);
+ }
+ };
+
+ const loadModelList = async () => {
+ try {
+ setLoadingModels(true);
+ const result = await window.electronAPI.listWhisperModels();
+ if (result.success) {
+ setModelList(result.models);
+ }
+ } catch (error) {
+ } finally {
+ setLoadingModels(false);
+ }
+ };
+
+ const installWhisper = async () => {
+ try {
+ setInstallingWhisper(true);
+ setInstallProgress("Starting Whisper installation...");
+
+ const result = await window.electronAPI.installWhisper();
+
+ if (result.success) {
+ alert(
+ "✅ Whisper installed successfully! You can now download and use local models."
+ );
+ checkWhisperInstallation();
+ } else {
+ alert(`❌ Failed to install Whisper: ${result.message}`);
+ }
+ } catch (error) {
+ alert(`❌ Failed to install Whisper: ${error}`);
+ } finally {
+ setInstallingWhisper(false);
+ setInstallProgress("");
+ }
+ };
+
+ const downloadModel = async (modelName: string) => {
+ try {
+ setDownloadingModel(modelName);
+
+ const result = await window.electronAPI.downloadWhisperModel(modelName);
+
+ if (result.success) {
+ alert(
+ `✅ Model "${modelName}" downloaded successfully! (${result.size_mb}MB)`
+ );
+ loadModelList();
+ } else {
+ alert(`❌ Failed to download model "${modelName}": ${result.error}`);
+ }
+ } catch (error) {
+ alert(`❌ Failed to download model "${modelName}": ${error}`);
+ } finally {
+ setDownloadingModel(null);
+ }
+ };
+
+ const deleteModel = async (modelName: string) => {
+ if (
+ confirm(
+ `Are you sure you want to delete the "${modelName}" model? This will free up disk space but you'll need to re-download it if you want to use it again.`
+ )
+ ) {
+ try {
+ const result = await window.electronAPI.deleteWhisperModel(modelName);
+
+ if (result.success) {
+ alert(
+ `✅ Model "${modelName}" deleted successfully! Freed ${result.freed_mb}MB of disk space.`
+ );
+ loadModelList();
+ } else {
+ alert(`❌ Failed to delete model "${modelName}": ${result.error}`);
+ }
+ } catch (error) {
+ alert(`❌ Failed to delete model "${modelName}": ${error}`);
+ }
+ }
+ };
+
+ const saveKey = () => {
+ localStorage.setItem("dictationKey", key);
+ alert(`Dictation key inscribed: ${key}`);
+ };
+
+ const saveApiKey = async () => {
+ try {
+ await window.electronAPI.saveOpenAIKey(apiKey);
+ localStorage.setItem("openaiApiKey", apiKey);
+
+ try {
+ await window.electronAPI.createProductionEnvFile(apiKey);
+ alert(
+ "OpenAI API key inscribed successfully! Your credentials have been securely recorded for transcription services."
+ );
+ } catch (envError) {
+ console.log("Could not create production .env file:", envError);
+ alert(
+ "OpenAI API key saved successfully and will be available for transcription"
+ );
+ }
+ } catch (error) {
+ console.error("Failed to save API key:", error);
+ localStorage.setItem("openaiApiKey", apiKey);
+ alert("OpenAI API key saved to localStorage (fallback mode)");
+ }
+ };
+
+ const saveWhisperSettings = () => {
+ localStorage.setItem("useLocalWhisper", useLocalWhisper.toString());
+ localStorage.setItem("whisperModel", whisperModel);
+ alert(
+ `Whisper settings saved! ${
+ useLocalWhisper
+ ? `Using local model: ${whisperModel}`
+ : "Using OpenAI API"
+ }`
+ );
+ };
+
+ const copyToClipboard = async (text: string) => {
+ try {
+ await navigator.clipboard.writeText(text);
+ alert("Text copied to your scribal collection!");
+ } catch (err) {}
+ };
+
+ const clearHistory = async () => {
+ if (
+ confirm(
+ "Are you certain you wish to clear all inscribed records? This action cannot be undone."
+ )
+ ) {
+ try {
+ const result = await window.electronAPI.clearTranscriptions();
+ setHistory([]);
+ alert(
+ `Successfully cleared ${result.cleared} transcriptions from your chronicles.`
+ );
+ } catch (error) {
+ alert("Failed to clear history. Please try again.");
+ }
+ }
+ };
+
+ const requestPermissions = async () => {
+ try {
+ await navigator.mediaDevices.getUserMedia({ audio: true });
+ alert("Microphone access granted! Your voice may now be inscribed.");
+ } catch (err) {
+ alert("Please grant microphone permissions to enable voice inscription.");
+ }
+ };
+
+ const requestAccessibilityPermissions = async () => {
+ try {
+ await window.electronAPI.pasteText(
+ "Test inscription - please verify this appears in another application"
+ );
+ alert(
+ "Accessibility permissions appear to be working! Check if the test inscription appeared in another app."
+ );
+ } catch (err) {
+ alert(
+ "Accessibility permissions required! The app will guide you through granting the necessary privileges for automatic text inscription."
+ );
+ }
+ };
+
+ const resetAccessibilityPermissions = () => {
+ const message = `🔄 RESET ACCESSIBILITY PERMISSIONS\n\nIf you've rebuilt or reinstalled OpenWispr and automatic inscription isn't functioning, you may have obsolete permissions from the previous version.\n\n📋 STEP-BY-STEP RESTORATION:\n\n1️⃣ Open System Settings (or System Preferences)\n • macOS Ventura+: Apple Menu → System Settings\n • Older macOS: Apple Menu → System Preferences\n\n2️⃣ Navigate to Privacy & Security → Accessibility\n\n3️⃣ Look for obsolete OpenWispr entries:\n • Any entries named "OpenWispr"\n • Any entries named "Electron"\n • Any entries with unclear or generic names\n • Entries pointing to old application locations\n\n4️⃣ Remove ALL obsolete entries:\n • Select each old entry\n • Click the minus (-) button\n • Enter your password if prompted\n\n5️⃣ Add the current OpenWispr:\n • Click the plus (+) button\n • Navigate to and select the CURRENT OpenWispr app\n • Ensure the checkbox is ENABLED\n\n6️⃣ Restart OpenWispr completely\n\n💡 This is very common during development when rebuilding applications!\n\nClick OK when you're ready to open System Settings.`;
+
+ if (confirm(message)) {
+ alert(
+ "Opening System Settings... Look for the Accessibility section under Privacy & Security."
+ );
+
+ window.open(
+ "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility",
+ "_blank"
+ );
+ }
+ };
+
+ const deleteTranscription = async (id: number) => {
+ if (
+ confirm(
+ "Are you certain you wish to remove this inscription from your records?"
+ )
+ ) {
+ try {
+ const result = await window.electronAPI.deleteTranscription(id);
+ if (result.success) {
+ setHistory((prev) => prev.filter((item) => item.id !== id));
+ console.log(`🗑️ Deleted transcription ${id}`);
+ } else {
+ alert(
+ "Failed to delete transcription. It may have already been removed."
+ );
+ }
+ } catch (error) {
+ console.error("❌ Failed to delete transcription:", error);
+ alert("Failed to delete transcription. Please try again.");
+ }
+ }
+ };
+
+ const refreshHistory = async () => {
+ console.log("🔄 Refreshing transcription history...");
+ await loadTranscriptions();
+ };
+
+ // Enhanced keyboard paste handler for API key input
+ const handleApiKeyKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
+ // Handle Cmd+V on Mac or Ctrl+V on Windows/Linux
+ if ((e.metaKey || e.ctrlKey) && e.key === "v") {
+ e.preventDefault(); // Prevent default to handle manually
+
+ // Try to paste from clipboard
+ setTimeout(async () => {
+ try {
+ // Try Electron clipboard first
+ const text = await window.electronAPI.readClipboard();
+ if (text && text.trim()) {
+ setApiKey(text.trim());
+ } else {
+ // Fallback to web clipboard API
+ const webText = await navigator.clipboard.readText();
+ if (webText && webText.trim()) {
+ setApiKey(webText.trim());
+ }
+ }
+ } catch (err) {}
+ }, 0);
+ }
+ };
+
+ return (
+ <div className="min-h-screen bg-white">
+ {/* Custom Title Bar - matching Wispr Flow style */}
+ <div className="bg-white border-b border-gray-100 select-none">
+ <div
+ className="flex items-center justify-between h-12 px-4"
+ style={{ WebkitAppRegion: "drag" }}
+ >
+ {/* Right section - minimal controls */}
+ <div
+ className="flex items-center gap-2"
+ style={{ WebkitAppRegion: "no-drag" }}
+ >
+ {/* Could add settings or other controls here if needed */}
+ </div>
+ </div>
+ </div>
+
+ {/* Main content */}
+ <div
+ className="bg-gradient-to-br from-neutral-50 via-white to-indigo-50/30 p-6 relative"
+ style={{
+ backgroundImage: `repeating-linear-gradient(
+ transparent,
+ transparent 24px,
+ #d1d5db 24px,
+ #d1d5db 25px
+ )`,
+ }}
+ >
+ {/* Red margin line */}
+ <div className="absolute left-12 top-0 bottom-0 w-px bg-red-300 z-0"></div>
+
+ <div className="max-w-4xl mx-auto space-y-6">
+ {/* Transcription Setup Card */}
+ <Card className="bg-white relative z-10">
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2">
+ <Settings size={18} className="text-indigo-600" />
+ Transcription Setup
+ </CardTitle>
+ <p className="text-sm text-neutral-600 mt-2 leading-relaxed">
+ Choose how you want to convert speech to text. You can always
+ change this later.
+ </p>
+ </CardHeader>
+ <CardContent className="space-y-6">
+ <div className="space-y-4">
+ {/* Processing Choice */}
+ <div>
+ <label className="block text-sm font-medium text-neutral-700 mb-4">
+ Processing Method
+ </label>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
+ <button
+ onClick={() => setUseLocalWhisper(false)}
+ className={`p-4 border-2 rounded-xl text-left transition-all ${
+ !useLocalWhisper
+ ? "border-indigo-500 bg-indigo-50"
+ : "border-neutral-200 bg-white hover:border-neutral-300"
+ }`}
+ >
+ <div className="flex items-center justify-between mb-2">
+ <h4 className="font-medium text-neutral-900">
+ Cloud Processing
+ </h4>
+ <span className="text-xs text-green-600 bg-green-100 px-2 py-1 rounded-full">
+ Fastest
+ </span>
+ </div>
+ <p className="text-sm text-neutral-600">
+ Audio sent to OpenAI servers. Faster processing,
+ requires API key.
+ </p>
+ </button>
+
+ <button
+ onClick={() => setUseLocalWhisper(true)}
+ className={`p-4 border-2 rounded-xl text-left transition-all ${
+ useLocalWhisper
+ ? "border-indigo-500 bg-indigo-50"
+ : "border-neutral-200 bg-white hover:border-neutral-300"
+ }`}
+ >
+ <div className="flex items-center justify-between mb-2">
+ <h4 className="font-medium text-neutral-900">
+ Local Processing
+ </h4>
+ <span className="text-xs text-blue-600 bg-blue-100 px-2 py-1 rounded-full">
+ Private
+ </span>
+ </div>
+ <p className="text-sm text-neutral-600">
+ Audio stays on your device. Complete privacy, works
+ offline.
+ </p>
+ </button>
+ </div>
+ </div>
+
+ {/* Cloud Configuration */}
+ {!useLocalWhisper && (
+ <div className="space-y-4 p-4 bg-blue-50 border border-blue-200 rounded-xl">
+ <h4 className="font-medium text-blue-900">
+ OpenAI API Setup
+ </h4>
+ <div>
+ <label className="block text-sm font-medium text-blue-800 mb-2">
+ API Key
+ </label>
+ <div className="flex gap-3">
+ <Input
+ type="password"
+ placeholder="sk-..."
+ value={apiKey}
+ onChange={(e) => setApiKey(e.target.value)}
+ className="flex-1"
+ />
+ <Button
+ variant="outline"
+ onClick={async () => {
+ try {
+ const text =
+ await window.electronAPI.readClipboard();
+ if (text && text.trim()) {
+ setApiKey(text.trim());
+ console.log(
+ "Manual paste successful via Electron"
+ );
+ } else {
+ const webText =
+ await navigator.clipboard.readText();
+ setApiKey(webText.trim());
+ console.log(
+ "Manual paste successful via Web API"
+ );
+ }
+ } catch (err) {
+ console.error("Manual paste failed:", err);
+ alert(
+ "Could not paste from clipboard. Please try typing or using Cmd+V/Ctrl+V."
+ );
+ }
+ }}
+ >
+ Paste
+ </Button>
+ </div>
+ <p className="text-xs text-blue-700 mt-2">
+ Get your API key from platform.openai.com
+ </p>
+ </div>
+ </div>
+ )}
+
+ {/* Local Configuration */}
+ {useLocalWhisper && (
+ <div className="space-y-4 p-4 bg-purple-50 border border-purple-200 rounded-xl">
+ <div className="flex items-center justify-between">
+ <h4 className="font-medium text-purple-900">
+ Local Whisper Setup
+ </h4>
+ <div className="flex items-center space-x-2">
+ {checkingWhisper ? (
+ <span className="text-purple-600 text-sm">
+ Checking...
+ </span>
+ ) : whisperInstalled ? (
+ <span className="text-emerald-600 text-sm font-medium">
+ ✓ Ready
+ </span>
+ ) : (
+ <span className="text-amber-600 text-sm font-medium">
+ ⚠ Not installed
+ </span>
+ )}
+ </div>
+ </div>
+
+ {whisperInstalled ? (
+ <div className="space-y-4">
+ <div>
+ <label className="block text-sm font-medium text-purple-800 mb-2">
+ Model Quality
+ </label>
+ <select
+ value={whisperModel}
+ onChange={(e) => setWhisperModel(e.target.value)}
+ className="w-full p-3 border border-purple-300 rounded-lg bg-white text-purple-900 focus:outline-none focus:ring-1 focus:ring-purple-500/20 focus:border-purple-500"
+ >
+ <option value="tiny">
+ Tiny - Fastest, lower quality
+ </option>
+ <option value="base">
+ Base - Good balance (recommended)
+ </option>
+ <option value="small">
+ Small - Better quality, slower
+ </option>
+ <option value="medium">
+ Medium - High quality
+ </option>
+ <option value="large">
+ Large - Best quality, slowest
+ </option>
+ </select>
+ <p className="text-xs text-purple-700 mt-2">
+ Larger models need more memory but give better
+ results.
+ </p>
+ </div>
+
+ <div className="bg-white border border-purple-200 rounded-lg overflow-hidden">
+ {/* Download Progress Bar */}
+ {downloadingModel && (
+ <div className="bg-purple-50 border-b border-purple-200 p-3">
+ <div className="flex items-center justify-between mb-2">
+ <span className="text-sm font-medium text-purple-900">
+ Downloading {downloadingModel} model...
+ </span>
+ <span className="text-xs text-purple-700">
+ {Math.round(downloadProgress)}%
+ </span>
+ </div>
+ <div className="w-full bg-purple-200 rounded-full h-2">
+ <div
+ className="bg-gradient-to-r from-purple-500 to-purple-600 h-2 rounded-full transition-all duration-300 ease-out"
+ style={{
+ width: `${Math.min(
+ downloadProgress,
+ 100
+ )}%`,
+ }}
+ ></div>
+ </div>
+ </div>
+ )}
+
+ <div className="p-4">
+ <div className="flex items-center justify-between mb-3">
+ <h5 className="font-medium text-purple-900">
+ Available Models
+ </h5>
+ <Button
+ onClick={() => setLoadingModels(!loadingModels)}
+ variant="outline"
+ size="sm"
+ disabled={loadingModels}
+ className="border-purple-300 text-purple-700 hover:bg-purple-50 hover:border-purple-600"
+ >
+ <RefreshCw
+ size={14}
+ className={
+ loadingModels ? "animate-spin" : ""
+ }
+ />
+ <span className="ml-1">
+ {loadingModels ? "Checking..." : "Refresh"}
+ </span>
+ </Button>
+ </div>
+
+ <div className="space-y-2">
+ {modelList.map((model) => (
+ <div
+ key={model.model}
+ className="flex items-center justify-between p-3 bg-purple-50 rounded-lg border border-purple-200"
+ >
+ <div className="flex items-center space-x-3">
+ <span className="font-medium text-purple-900 capitalize">
+ {model.model}
+ </span>
+ {model.downloaded ? (
+ <span className="text-xs text-emerald-600 bg-emerald-100 px-2 py-1 rounded-md">
+ ✓ Downloaded ({model.size_mb}MB)
+ </span>
+ ) : (
+ <span className="text-xs text-neutral-500 bg-neutral-100 px-2 py-1 rounded-md">
+ Not downloaded
+ </span>
+ )}
+ </div>
+
+ <div className="flex gap-2">
+ {model.downloaded && (
+ <Button
+ onClick={() => deleteModel(model.model)}
+ size="sm"
+ variant="outline"
+ className="text-red-600 hover:text-red-700 hover:bg-red-50 border-red-200 hover:border-red-600"
+ >
+ <Trash2 size={14} />
+ <span className="ml-1">Delete</span>
+ </Button>
+ )}
+ {!model.downloaded && (
+ <Button
+ onClick={() =>
+ downloadModel(model.model)
+ }
+ disabled={
+ downloadingModel === model.model
+ }
+ size="sm"
+ className="bg-purple-600 hover:bg-purple-700"
+ >
+ <Download size={14} />
+ <span className="ml-1">
+ {downloadingModel === model.model
+ ? "Downloading..."
+ : "Download"}
+ </span>
+ </Button>
+ )}
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ </div>
+ </div>
+ ) : (
+ <div className="bg-white border border-purple-200 rounded-lg p-6">
+ <div className="text-center">
+ <div className="text-3xl mb-4">📦 </div>
+ <h5 className="font-medium text-purple-900 text-lg mb-2">
+ Install Local Processing
+ </h5>
+ <p className="text-sm text-purple-700 mb-4 max-w-sm mx-auto">
+ We'll install Whisper automatically. No technical
+ setup required.
+ </p>
+
+ {installingWhisper ? (
+ <div className="space-y-4">
+ <div className="bg-purple-50 rounded-lg p-4 border border-purple-200">
+ <div className="flex items-center justify-center space-x-3 mb-2">
+ <div className="animate-spin rounded-full h-4 w-4 border-b-2 border-purple-600"></div>
+ <span className="font-medium text-purple-900">
+ Installing...
+ </span>
+ </div>
+ {installProgress && (
+ <div className="text-xs text-purple-600 bg-white p-2 rounded font-mono">
+ {installProgress}
+ </div>
+ )}
+ </div>
+ <p className="text-xs text-purple-600">
+ This takes a few minutes. Keep the app open.
+ </p>
+ </div>
+ ) : (
+ <div className="space-y-4">
+ <Button
+ onClick={installWhisper}
+ className="bg-purple-600 hover:bg-purple-700"
+ >
+ Install Whisper
+ </Button>
+
+ <div className="flex items-center justify-center">
+ <Button
+ onClick={() =>
+ setCheckingWhisper(!checkingWhisper)
+ }
+ variant="outline"
+ size="sm"
+ className="text-purple-600 border-purple-300 hover:bg-purple-50"
+ >
+ Check if already installed
+ </Button>
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ )}
+ </div>
+ )}
+
+ <Button
+ onClick={useLocalWhisper ? saveWhisperSettings : saveApiKey}
+ className="w-full"
+ disabled={!useLocalWhisper && !apiKey.trim()}
+ >
+ {useLocalWhisper ? "Save Whisper Settings" : "Save API Key"}
+ </Button>
+ </div>
+ </CardContent>
+ </Card>
+
+ {/* Dictation Settings Card */}
+ <Card className="bg-white relative z-10">
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2">
+ <Keyboard size={18} className="text-indigo-600" />
+ Dictation Setup
+ </CardTitle>
+ <p className="text-sm text-neutral-600 mt-2 leading-relaxed">
+ Configure how you want to activate voice transcription.
+ </p>
+ </CardHeader>
+ <CardContent className="space-y-5">
+ <div className="space-y-5">
+ <div>
+ <label className="block text-sm font-medium text-neutral-700 mb-2">
+ Activation Key
+ </label>
+ <Input
+ placeholder="Current: ` (backtick)"
+ value={key}
+ onChange={(e) => setKey(e.target.value)}
+ className="mb-3"
+ />
+ <Button
+ onClick={saveKey}
+ disabled={!key.trim()}
+ variant="outline"
+ size="sm"
+ >
+ Save Key
+ </Button>
+ </div>
+
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
+ <Button onClick={requestPermissions} variant="outline">
+ <span className="mr-2">🎤</span>
+ Enable Microphone
+ </Button>
+ <Button
+ onClick={requestAccessibilityPermissions}
+ variant="outline"
+ >
+ <span className="mr-2">🔓</span>
+ Check Permissions
+ </Button>
+ </div>
+
+ <Button
+ onClick={resetAccessibilityPermissions}
+ variant="secondary"
+ className="w-full"
+ >
+ <span className="mr-2">⚙️</span>
+ Fix Permission Issues
+ </Button>
+ </div>
+ </CardContent>
+ </Card>
+
+ {/* Recent Transcriptions Card */}
+ <Card className="bg-white relative z-10">
+ <CardHeader>
+ <div className="flex flex-row items-center justify-between">
+ <div>
+ <CardTitle className="flex items-center gap-2">
+ <FileText size={18} className="text-indigo-600" />
+ Recent Transcriptions
+ </CardTitle>
+ <p className="text-sm text-neutral-600 mt-2">
+ Your voice recordings, converted to text.
+ </p>
+ </div>
+ <div className="flex gap-2">
+ <Tooltip content="Refresh history">
+ <Button
+ onClick={refreshHistory}
+ variant="ghost"
+ size="icon"
+ >
+ <RefreshCw size={16} />
+ </Button>
+ </Tooltip>
+ <Tooltip content="Clear all transcriptions">
+ <Button
+ onClick={clearHistory}
+ variant="ghost"
+ size="icon"
+ className="text-red-600 hover:text-red-700 hover:bg-red-50"
+ >
+ <Trash2 size={16} />
+ </Button>
+ </Tooltip>
+ </div>
+ </div>
+ </CardHeader>
+ <CardContent>
+ {isLoading ? (
+ <div className="text-center py-8">
+ <div className="w-8 h-8 mx-auto mb-3 bg-indigo-600 rounded-lg flex items-center justify-center">
+ <span className="text-white text-sm">📝</span>
+ </div>
+ <p className="text-neutral-600">Loading transcriptions...</p>
+ </div>
+ ) : (
+ <div className="space-y-3 max-h-80 overflow-y-auto">
+ {history.map((item, index) => (
+ <div
+ key={item.id}
+ className="relative bg-gradient-to-b from-blue-50/30 to-white rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-shadow"
+ >
+ {/* Content */}
+ <div className="p-6 pl-16" style={{ paddingTop: "8px" }}>
+ <div className="flex items-start justify-between">
+ <div className="flex-1 mr-3">
+ <div
+ className="flex items-center gap-2 mb-1"
+ style={{
+ marginTop: "2px",
+ lineHeight: "24px",
+ }}
+ >
+ <span className="text-indigo-600 text-xs font-medium">
+ #{history.length - index}
+ </span>
+ <div className="w-px h-3 bg-neutral-300"></div>
+ <span className="text-xs text-neutral-500">
+ {new Date(item.timestamp).toLocaleString(
+ "en-US",
+ {
+ month: "short",
+ day: "numeric",
+ hour: "2-digit",
+ minute: "2-digit",
+ }
+ )}
+ </span>
+ </div>
+ <p
+ className="text-neutral-800 text-sm"
+ style={{
+ fontFamily:
+ 'Noto Sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
+ lineHeight: "24px",
+ textAlign: "left",
+ marginTop: "2px",
+ paddingBottom: "2px",
+ }}
+ >
+ {item.text}
+ </p>
+ </div>
+ <div
+ className="flex gap-1 flex-shrink-0"
+ style={{ marginTop: "2px" }}
+ >
+ <Tooltip content="Copy to clipboard">
+ <Button
+ size="icon"
+ variant="ghost"
+ onClick={() => copyToClipboard(item.text)}
+ className="h-7 w-7"
+ >
+ <Copy size={12} />
+ </Button>
+ </Tooltip>
+ <Tooltip content="Delete transcription">
+ <Button
+ size="icon"
+ variant="ghost"
+ onClick={() => deleteTranscription(item.id)}
+ className="h-7 w-7 text-red-600 hover:text-red-700 hover:bg-red-50"
+ >
+ <Trash2 size={12} />
+ </Button>
+ </Tooltip>
+ </div>
+ </div>
+ </div>
+ </div>
+ ))}
+ </div>
+ )}
+ </CardContent>
+ </Card>
+
+ {/* About Card */}
+ <Card className="bg-white relative z-10">
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2">
+ <Info size={18} className="text-indigo-600" />
+ About
+ </CardTitle>
+ </CardHeader>
+ <CardContent>
+ <p className="text-neutral-600 text-sm leading-relaxed mb-6">
+ OpenWispr converts your speech to text using AI. Press your
+ hotkey, speak, and we'll type what you said wherever your cursor
+ is.
+ </p>
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm">
+ <div className="text-center p-4 border border-neutral-200 rounded-xl bg-white">
+ <div className="w-8 h-8 mx-auto mb-2 bg-indigo-600 rounded-lg flex items-center justify-center">
+ <span className="text-white text-sm">⌨️</span>
+ </div>
+ <p className="font-medium text-neutral-800 mb-1">
+ Default Hotkey
+ </p>
+ <p className="text-neutral-600 font-mono text-xs">
+ ` (backtick)
+ </p>
+ </div>
+ <div className="text-center p-4 border border-neutral-200 rounded-xl bg-white">
+ <div className="w-8 h-8 mx-auto mb-2 bg-emerald-600 rounded-lg flex items-center justify-center">
+ <span className="text-white text-sm">🏷️</span>
+ </div>
+ <p className="font-medium text-neutral-800 mb-1">Version</p>
+ <p className="text-neutral-600 text-xs">0.1.0</p>
+ </div>
+ <div className="text-center p-4 border border-neutral-200 rounded-xl bg-white">
+ <div className="w-8 h-8 mx-auto mb-2 bg-green-600 rounded-lg flex items-center justify-center">
+ <span className="text-white text-sm">✓</span>
+ </div>
+ <p className="font-medium text-neutral-800 mb-1">Status</p>
+ <p className="text-green-600 text-xs font-medium">Active</p>
+ </div>
+ </div>
+ </CardContent>
+ </Card>
+
+ {/* Footer */}
+ <div className="text-center py-6">
+ <p className="text-neutral-500 text-sm">
+ Built for thinkers who move at the speed of thought
+ </p>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
+
diff --git a/src/main.jsx b/src/main.jsx
index 40dab96e2..6b07d93ff 100644
--- a/src/main.jsx
+++ b/src/main.jsx
@@ -1,17 +1,79 @@
-import React from 'react'
+import React, { useState, useEffect } from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import ControlPanel from './components/ControlPanel.tsx'
+import OnboardingFlow from './components/OnboardingFlow.tsx'
import './index.css'
-// Check if this is the control panel window
-const isControlPanel = window.location.pathname.includes('control') ||
- window.location.search.includes('panel=true');
-
-const AppComponent = isControlPanel ? ControlPanel : App;
+function AppRouter() {
+ const [showOnboarding, setShowOnboarding] = useState(false);
+ const [isLoading, setIsLoading] = useState(true);
+
+ // Check if this is the control panel window
+ const isControlPanel = window.location.pathname.includes('control') ||
+ window.location.search.includes('panel=true');
+
+ // Check if this is the dictation panel (main app)
+ const isDictationPanel = !isControlPanel;
+
+ useEffect(() => {
+ // Check if onboarding has been completed
+ const onboardingCompleted = localStorage.getItem('onboardingCompleted');
+
+ if (isControlPanel && !onboardingCompleted) {
+ // Show onboarding for control panel if not completed
+ setShowOnboarding(true);
+ }
+
+ setIsLoading(false);
+ }, [isControlPanel]);
+
+ const handleOnboardingComplete = () => {
+ setShowOnboarding(false);
+ localStorage.setItem('onboardingCompleted', 'true');
+ };
+
+ if (isLoading) {
+ return (
+ <div className="min-h-screen bg-gray-50 flex items-center justify-center">
+ <div className="text-center">
+ <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600 mx-auto mb-4"></div>
+ <p className="text-gray-600">Loading OpenWispr...</p>
+ </div>
+ </div>
+ );
+ }
+
+ // Hide dictation panel during onboarding
+ if (isDictationPanel && localStorage.getItem('onboardingCompleted') !== 'true') {
+ return (
+ <div className="min-h-screen bg-gray-900 flex items-center justify-center">
+ <div className="text-center text-white">
+ <div className="w-16 h-16 mx-auto bg-indigo-600 rounded-full flex items-center justify-center mb-4">
+ <span className="text-white font-bold text-lg">OW</span>
+ </div>
+ <h2 className="text-xl font-semibold mb-2">Setup in Progress</h2>
+ <p className="text-gray-300 mb-4">Please complete setup in the Control Panel first.</p>
+ <button
+ onClick={() => window.electronAPI?.hideWindow?.()}
+ className="text-sm text-indigo-400 hover:text-indigo-300"
+ >
+ Hide Window
+ </button>
+ </div>
+ </div>
+ );
+ }
+
+ if (isControlPanel && showOnboarding) {
+ return <OnboardingFlow onComplete={handleOnboardingComplete} />;
+ }
+
+ return isControlPanel ? <ControlPanel /> : <App />;
+}
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
- <AppComponent />
+ <AppRouter />
</React.StrictMode>,
)