Skip to content

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

refactor: settings refactor

Gabriel Stein8aa234ed68f9
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsx
index b7cba1888..029c5ea8f 100644
--- a/src/components/ControlPanel.tsx
+++ b/src/components/ControlPanel.tsx
@@ -2,12 +2,13 @@ import React, { useState, useEffect } from "react";
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card";
import { Button } from "./ui/button";
import { Trash2, RefreshCw, Settings, FileText, Mic } from "lucide-react";
-import SettingsPage from "./SettingsPage";
+import SettingsModal from "./SettingsModal";
import TitleBar from "./TitleBar";
import TranscriptionItem from "./ui/TranscriptionItem";
import { ConfirmDialog, AlertDialog } from "./ui/dialog";
import { useDialogs } from "../hooks/useDialogs";
import { useHotkey } from "../hooks/useHotkey";
+import { useToast } from "./ui/Toast";
import type { TranscriptionItem as TranscriptionItemType } from "../types/electron";
export default function ControlPanel() {
@@ -15,6 +16,7 @@ export default function ControlPanel() {
const [isLoading, setIsLoading] = useState(true);
const [showSettings, setShowSettings] = useState(false);
const { hotkey } = useHotkey();
+ const { toast } = useToast();
const [updateStatus, setUpdateStatus] = useState({
updateAvailable: false,
updateDownloaded: false,
@@ -74,11 +76,19 @@ export default function ControlPanel() {
const copyToClipboard = async (text: string) => {
try {
await navigator.clipboard.writeText(text);
- showAlertDialog({
+ toast({
title: "Copied!",
- description: "Text copied to your clipboard!",
+ description: "Text copied to your clipboard",
+ variant: "success",
+ duration: 2000,
});
- } catch (err) {}
+ } catch (err) {
+ toast({
+ title: "Copy Failed",
+ description: "Failed to copy text to clipboard",
+ variant: "destructive",
+ });
+ }
};
const clearHistory = async () => {
@@ -182,105 +192,97 @@ export default function ControlPanel() {
}
/>
+ <SettingsModal open={showSettings} onOpenChange={setShowSettings} />
+
{/* Main content */}
<div className="p-6">
- {showSettings ? (
- <SettingsPage onBack={() => setShowSettings(false)} />
- ) : (
- <div className="space-y-6 max-w-4xl mx-auto">
- <Card>
- <CardHeader>
- <div className="flex items-center justify-between">
- <CardTitle className="flex items-center gap-2">
- <FileText size={18} className="text-indigo-600" />
- Recent Transcriptions
- </CardTitle>
- <div className="flex gap-2">
+ <div className="space-y-6 max-w-4xl mx-auto">
+ <Card>
+ <CardHeader>
+ <div className="flex items-center justify-between">
+ <CardTitle className="flex items-center gap-2">
+ <FileText size={18} className="text-indigo-600" />
+ Recent Transcriptions
+ </CardTitle>
+ <div className="flex gap-2">
+ <Button onClick={refreshHistory} variant="ghost" size="icon">
+ <RefreshCw size={16} />
+ </Button>
+ {history.length > 0 && (
<Button
- onClick={refreshHistory}
+ onClick={clearHistory}
variant="ghost"
size="icon"
+ className="text-red-600 hover:text-red-700 hover:bg-red-50"
>
- <RefreshCw size={16} />
+ <Trash2 size={16} />
</Button>
- {history.length > 0 && (
- <Button
- onClick={clearHistory}
- variant="ghost"
- size="icon"
- className="text-red-600 hover:text-red-700 hover:bg-red-50"
- >
- <Trash2 size={16} />
- </Button>
- )}
- </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>
+ </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>
- ) : history.length === 0 ? (
- <div className="text-center py-12">
- <div className="w-16 h-16 mx-auto mb-4 bg-neutral-100 rounded-full flex items-center justify-center">
- <Mic className="w-8 h-8 text-neutral-400" />
- </div>
- <h3 className="text-lg font-medium text-neutral-900 mb-2">
- No transcriptions yet
- </h3>
- <p className="text-neutral-600 mb-4 max-w-sm mx-auto">
- Press your hotkey to start recording and create your first
- transcription.
- </p>
- <div className="bg-neutral-50 border border-neutral-200 rounded-lg p-4 max-w-md mx-auto">
- <h4 className="font-medium text-neutral-800 mb-2">
- Quick Start:
- </h4>
- <ol className="text-sm text-neutral-600 text-left space-y-1">
- <li>1. Click in any text field</li>
- <li>
- 2. Press{" "}
- <kbd className="bg-white px-2 py-1 rounded text-xs font-mono border border-neutral-300">
- {hotkey}
- </kbd>{" "}
- to start recording
- </li>
- <li>3. Speak your text</li>
- <li>
- 4. Press{" "}
- <kbd className="bg-white px-2 py-1 rounded text-xs font-mono border border-neutral-300">
- {hotkey}
- </kbd>{" "}
- again to stop
- </li>
- <li>5. Your text will appear automatically!</li>
- </ol>
- </div>
+ <p className="text-neutral-600">Loading transcriptions...</p>
+ </div>
+ ) : history.length === 0 ? (
+ <div className="text-center py-12">
+ <div className="w-16 h-16 mx-auto mb-4 bg-neutral-100 rounded-full flex items-center justify-center">
+ <Mic className="w-8 h-8 text-neutral-400" />
</div>
- ) : (
- <div className="space-y-3 max-h-80 overflow-y-auto">
- {history.map((item, index) => (
- <TranscriptionItem
- key={item.id}
- item={item}
- index={index}
- total={history.length}
- onCopy={copyToClipboard}
- onDelete={deleteTranscription}
- />
- ))}
+ <h3 className="text-lg font-medium text-neutral-900 mb-2">
+ No transcriptions yet
+ </h3>
+ <p className="text-neutral-600 mb-4 max-w-sm mx-auto">
+ Press your hotkey to start recording and create your first
+ transcription.
+ </p>
+ <div className="bg-neutral-50 border border-neutral-200 rounded-lg p-4 max-w-md mx-auto">
+ <h4 className="font-medium text-neutral-800 mb-2">
+ Quick Start:
+ </h4>
+ <ol className="text-sm text-neutral-600 text-left space-y-1">
+ <li>1. Click in any text field</li>
+ <li>
+ 2. Press{" "}
+ <kbd className="bg-white px-2 py-1 rounded text-xs font-mono border border-neutral-300">
+ {hotkey}
+ </kbd>{" "}
+ to start recording
+ </li>
+ <li>3. Speak your text</li>
+ <li>
+ 4. Press{" "}
+ <kbd className="bg-white px-2 py-1 rounded text-xs font-mono border border-neutral-300">
+ {hotkey}
+ </kbd>{" "}
+ again to stop
+ </li>
+ <li>5. Your text will appear automatically!</li>
+ </ol>
</div>
- )}
- </CardContent>
- </Card>
- </div>
- )}
+ </div>
+ ) : (
+ <div className="space-y-3 max-h-80 overflow-y-auto">
+ {history.map((item, index) => (
+ <TranscriptionItem
+ key={item.id}
+ item={item}
+ index={index}
+ total={history.length}
+ onCopy={copyToClipboard}
+ onDelete={deleteTranscription}
+ />
+ ))}
+ </div>
+ )}
+ </CardContent>
+ </Card>
+ </div>
</div>
</div>
);
diff --git a/src/components/OnboardingFlow.tsx b/src/components/OnboardingFlow.tsx
index 7fbfce469..047675940 100644
--- a/src/components/OnboardingFlow.tsx
+++ b/src/components/OnboardingFlow.tsx
@@ -34,6 +34,7 @@ import { useClipboard } from "../hooks/useClipboard";
import { useSettings } from "../hooks/useSettings";
import { getLanguageLabel, getReasoningModelLabel } from "../utils/languages";
import LanguageSelector from "./ui/LanguageSelector";
+import InteractiveKeyboard from "./ui/Keyboard";
import { setAgentName as saveAgentName } from "../utils/agentName";
interface OnboardingFlowProps {
@@ -464,23 +465,9 @@ export default function OnboardingFlow({ onComplete }: OnboardingFlowProps) {
<div className="bg-gray-50 p-4 rounded-lg">
<h4 className="font-medium text-gray-900 mb-3">
- Popular Choices:
+ Click any key to select it:
</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>
+ <InteractiveKeyboard selectedKey={hotkey} setSelectedKey={setHotkey} />
</div>
</div>
</div>
diff --git a/src/components/SettingsModal.tsx b/src/components/SettingsModal.tsx
new file mode 100644
index 000000000..004ed19a0
--- /dev/null
+++ b/src/components/SettingsModal.tsx
@@ -0,0 +1,37 @@
+import React from "react";
+import { Settings, Mic, Brain, User } from "lucide-react";
+import SidebarModal, { SidebarItem } from "./ui/SidebarModal";
+import SettingsPage, { SettingsSectionType } from "./SettingsPage";
+
+interface SettingsModalProps {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+}
+
+export default function SettingsModal({
+ open,
+ onOpenChange,
+}: SettingsModalProps) {
+ const sidebarItems: SidebarItem<SettingsSectionType>[] = [
+ { id: "general", label: "General", icon: Settings },
+ { id: "transcription", label: "Transcription Mode", icon: Mic },
+ { id: "aiModels", label: "AI Models", icon: Brain },
+ { id: "agentConfig", label: "Agent Configuration", icon: User },
+ ];
+
+ const [activeSection, setActiveSection] =
+ React.useState<SettingsSectionType>("general");
+
+ return (
+ <SidebarModal<SettingsSectionType>
+ open={open}
+ onOpenChange={onOpenChange}
+ title="Settings"
+ sidebarItems={sidebarItems}
+ activeSection={activeSection}
+ onSectionChange={setActiveSection}
+ >
+ <SettingsPage activeSection={activeSection} />
+ </SidebarModal>
+ );
+}
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index aa1a56d34..7cab6379b 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -1,21 +1,7 @@
import React, { useState, useCallback, useEffect } from "react";
import { Button } from "./ui/button";
import { Input } from "./ui/input";
-import { Card, CardContent } from "./ui/card";
-import {
- RefreshCw,
- Download,
- Settings,
- Keyboard,
- Info,
- ArrowLeft,
- Mic,
- Brain,
- Shield,
- ChevronRight,
- User,
-} from "lucide-react";
-import TitleBar from "./TitleBar";
+import { RefreshCw, Download, Keyboard, Mic, Shield } from "lucide-react";
import WhisperModelPicker from "./WhisperModelPicker";
import ProcessingModeSelector from "./ui/ProcessingModeSelector";
import ApiKeyInput from "./ui/ApiKeyInput";
@@ -28,23 +14,21 @@ import { usePermissions } from "../hooks/usePermissions";
import { useClipboard } from "../hooks/useClipboard";
import { REASONING_PROVIDERS } from "../utils/languages";
import LanguageSelector from "./ui/LanguageSelector";
+const InteractiveKeyboard = React.lazy(() => import("./ui/Keyboard"));
-interface SettingsPageProps {
- onBack: () => void;
-}
-
-type SettingsSectionType =
+export type SettingsSectionType =
+ | "general"
| "transcription"
- | "reasoning"
- | "hotkey"
- | "agentName"
- | "updates"
- | "about";
+ | "aiModels"
+ | "agentConfig";
-export default function SettingsPage({ onBack }: SettingsPageProps) {
- const [activeSection, setActiveSection] =
- useState<SettingsSectionType>("transcription");
+interface SettingsPageProps {
+ activeSection?: SettingsSectionType;
+}
+export default function SettingsPage({
+ activeSection = "general",
+}: SettingsPageProps) {
// Use custom hooks
const {
confirmDialog,
@@ -106,24 +90,27 @@ export default function SettingsPage({ onBack }: SettingsPageProps) {
const { pasteFromClipboardWithFallback } = useClipboard(showAlertDialog);
const { agentName, setAgentName } = useAgentName();
+ // Defer heavy operations for better performance
useEffect(() => {
- whisperHook.checkWhisperInstallation();
- whisperHook.setupProgressListener();
-
- const initializeUpdateData = async () => {
- try {
- const versionResult = await window.electronAPI?.getAppVersion();
- if (versionResult) setCurrentVersion(versionResult.version);
-
- const statusResult = await window.electronAPI?.getUpdateStatus();
- if (statusResult) setUpdateStatus(statusResult);
- } catch (error) {
- console.error("Error initializing update data:", error);
+ // Defer version and update checks to improve initial render
+ const timer = setTimeout(async () => {
+ const versionResult = await window.electronAPI?.getAppVersion();
+ if (versionResult) setCurrentVersion(versionResult.version);
+
+ const statusResult = await window.electronAPI?.getUpdateStatus();
+ if (statusResult) {
+ setUpdateStatus(statusResult);
+ subscribeToUpdates();
}
- };
- initializeUpdateData();
+ // Check whisper after initial render
+ whisperHook.checkWhisperInstallation();
+ }, 100);
+ return () => clearTimeout(timer);
+ }, [whisperHook]);
+
+ const subscribeToUpdates = () => {
if (window.electronAPI) {
window.electronAPI.onUpdateAvailable?.((event, info) => {
setUpdateStatus((prev) => ({ ...prev, updateAvailable: true }));
@@ -149,7 +136,7 @@ export default function SettingsPage({ onBack }: SettingsPageProps) {
console.error("Update error:", error);
});
}
- }, [whisperHook]);
+ };
const saveReasoningSettings = useCallback(() => {
updateReasoningSettings({ useReasoningModel, reasoningModel });
@@ -258,37 +245,296 @@ export default function SettingsPage({ onBack }: SettingsPageProps) {
}
};
- const sidebarItems = [
- {
- id: "transcription" as SettingsSectionType,
- label: "Transcription Setup",
- icon: Settings,
- },
- {
- id: "reasoning" as SettingsSectionType,
- label: "Reasoning Setup",
- icon: Brain,
- },
- {
- id: "hotkey" as SettingsSectionType,
- label: "Hotkey Setup",
- icon: Keyboard,
- },
- {
- id: "agentName" as SettingsSectionType,
- label: "Agent Name",
- icon: User,
- },
- {
- id: "updates" as SettingsSectionType,
- label: "App Updates",
- icon: RefreshCw,
- },
- { id: "about" as SettingsSectionType, label: "About", icon: Info },
- ];
-
const renderSectionContent = () => {
switch (activeSection) {
+ case "general":
+ return (
+ <div className="space-y-8">
+ {/* App Updates Section */}
+ <div className="space-y-6">
+ <div>
+ <h3 className="text-lg font-semibold text-gray-900 mb-2">
+ App Updates
+ </h3>
+ <p className="text-sm text-gray-600 mb-4">
+ Keep OpenWispr up to date with the latest features and
+ improvements.
+ </p>
+ </div>
+ <div className="flex items-center justify-between p-4 bg-neutral-50 rounded-lg">
+ <div>
+ <p className="text-sm font-medium text-neutral-800">
+ Current Version
+ </p>
+ <p className="text-xs text-neutral-600">
+ {currentVersion || "Loading..."}
+ </p>
+ </div>
+ <div className="flex items-center gap-2">
+ {updateStatus.isDevelopment ? (
+ <span className="text-xs text-amber-600 bg-amber-100 px-2 py-1 rounded-full">
+ Development Mode
+ </span>
+ ) : updateStatus.updateAvailable ? (
+ <span className="text-xs text-green-600 bg-green-100 px-2 py-1 rounded-full">
+ Update Available
+ </span>
+ ) : (
+ <span className="text-xs text-neutral-600 bg-neutral-100 px-2 py-1 rounded-full">
+ Up to Date
+ </span>
+ )}
+ </div>
+ </div>
+ <div className="space-y-3">
+ <Button
+ onClick={async () => {
+ setCheckingForUpdates(true);
+ try {
+ const result =
+ await window.electronAPI?.checkForUpdates();
+ if (result?.updateAvailable) {
+ setUpdateInfo({
+ version: result.version,
+ releaseDate: result.releaseDate,
+ releaseNotes: result.releaseNotes,
+ });
+ setUpdateStatus((prev) => ({
+ ...prev,
+ updateAvailable: true,
+ }));
+ showAlertDialog({
+ title: "Update Available",
+ description: `Update available: v${result.version}`,
+ });
+ } else {
+ showAlertDialog({
+ title: "No Updates",
+ description:
+ result?.message || "No updates available",
+ });
+ }
+ } catch (error: any) {
+ showAlertDialog({
+ title: "Update Check Failed",
+ description: `Error checking for updates: ${error.message}`,
+ });
+ } finally {
+ setCheckingForUpdates(false);
+ }
+ }}
+ disabled={checkingForUpdates || updateStatus.isDevelopment}
+ className="w-full"
+ >
+ {checkingForUpdates ? (
+ <>
+ <RefreshCw size={16} className="animate-spin mr-2" />
+ Checking for Updates...
+ </>
+ ) : (
+ <>
+ <RefreshCw size={16} className="mr-2" />
+ Check for Updates
+ </>
+ )}
+ </Button>
+ </div>
+ </div>
+
+ {/* Hotkey Section */}
+ <div className="border-t pt-8">
+ <div>
+ <h3 className="text-lg font-semibold text-gray-900 mb-2">
+ Dictation Hotkey
+ </h3>
+ <p className="text-sm text-gray-600 mb-6">
+ Configure the key you press to start and stop voice 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={dictationKey}
+ onChange={(e) => setDictationKey(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">
+ Click any key to select it:
+ </h4>
+ <React.Suspense
+ fallback={
+ <div className="h-32 flex items-center justify-center text-gray-500">
+ Loading keyboard...
+ </div>
+ }
+ >
+ <InteractiveKeyboard
+ selectedKey={dictationKey}
+ setSelectedKey={setDictationKey}
+ />
+ </React.Suspense>
+ </div>
+ <Button
+ onClick={saveKey}
+ disabled={!dictationKey.trim()}
+ className="w-full"
+ >
+ Save Hotkey
+ </Button>
+ </div>
+ </div>
+
+ {/* Permissions Section */}
+ <div className="border-t pt-8">
+ <div>
+ <h3 className="text-lg font-semibold text-gray-900 mb-2">
+ Permissions
+ </h3>
+ <p className="text-sm text-gray-600 mb-6">
+ Test and manage app permissions for microphone and
+ accessibility.
+ </p>
+ </div>
+ <div className="space-y-3">
+ <Button
+ onClick={permissionsHook.requestMicPermission}
+ variant="outline"
+ className="w-full"
+ >
+ <Mic className="mr-2 h-4 w-4" />
+ Test Microphone Permission
+ </Button>
+ <Button
+ onClick={permissionsHook.testAccessibilityPermission}
+ variant="outline"
+ className="w-full"
+ >
+ <Shield className="mr-2 h-4 w-4" />
+ Test Accessibility Permission
+ </Button>
+ <Button
+ onClick={resetAccessibilityPermissions}
+ variant="secondary"
+ className="w-full"
+ >
+ <span className="mr-2">βš™οΈ</span>
+ Fix Permission Issues
+ </Button>
+ </div>
+ </div>
+
+ {/* About Section */}
+ <div className="border-t pt-8">
+ <div>
+ <h3 className="text-lg font-semibold text-gray-900 mb-2">
+ About OpenWispr
+ </h3>
+ <p className="text-sm text-gray-600 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>
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm mb-6">
+ <div className="text-center p-4 border border-gray-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">
+ <Keyboard className="w-4 h-4 text-white" />
+ </div>
+ <p className="font-medium text-gray-800 mb-1">
+ Default Hotkey
+ </p>
+ <p className="text-gray-600 font-mono text-xs">
+ {dictationKey || "` (backtick)"}
+ </p>
+ </div>
+ <div className="text-center p-4 border border-gray-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-gray-800 mb-1">Version</p>
+ <p className="text-gray-600 text-xs">
+ {currentVersion || "0.1.0"}
+ </p>
+ </div>
+ <div className="text-center p-4 border border-gray-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-gray-800 mb-1">Status</p>
+ <p className="text-green-600 text-xs font-medium">Active</p>
+ </div>
+ </div>
+
+ {/* System Actions */}
+ <div className="space-y-3">
+ <Button
+ onClick={() => {
+ showConfirmDialog({
+ title: "Reset Onboarding",
+ description:
+ "Are you sure you want to reset the onboarding process? This will clear your setup and show the welcome flow again.",
+ onConfirm: () => {
+ localStorage.removeItem("onboardingCompleted");
+ window.location.reload();
+ },
+ variant: "destructive",
+ });
+ }}
+ 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>
+ <Button
+ onClick={() => {
+ showConfirmDialog({
+ title: "⚠️ DANGER: Cleanup App Data",
+ description:
+ "This will permanently delete ALL OpenWispr data including:\n\nβ€’ Database and transcriptions\nβ€’ Local storage settings\nβ€’ Downloaded Whisper models\nβ€’ Environment files\n\nYou will need to manually remove app permissions in System Settings.\n\nThis action cannot be undone. Are you sure?",
+ onConfirm: () => {
+ window.electronAPI
+ ?.cleanupApp()
+ .then(() => {
+ showAlertDialog({
+ title: "Cleanup Completed",
+ description:
+ "βœ… Cleanup completed! All app data has been removed.",
+ });
+ setTimeout(() => {
+ window.location.reload();
+ }, 1000);
+ })
+ .catch((error) => {
+ showAlertDialog({
+ title: "Cleanup Failed",
+ description: `❌ Cleanup failed: ${error.message}`,
+ });
+ });
+ },
+ variant: "destructive",
+ });
+ }}
+ variant="outline"
+ className="w-full text-red-600 border-red-300 hover:bg-red-50 hover:border-red-400"
+ >
+ <span className="mr-2">πŸ—‘οΈ</span>
+ Clean Up All App Data
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+
case "transcription":
return (
<div className="space-y-6">
@@ -367,7 +613,7 @@ export default function SettingsPage({ onBack }: SettingsPageProps) {
</div>
);
- case "reasoning":
+ case "aiModels":
return (
<div className="space-y-6">
<div>
@@ -380,6 +626,16 @@ export default function SettingsPage({ onBack }: SettingsPageProps) {
and fixes obvious errors while preserving your natural tone.
</p>
+ {useLocalWhisper && (
+ <div className="bg-amber-50 border border-amber-200 rounded-lg p-4 mb-6">
+ <p className="text-sm text-amber-800">
+ <span className="font-medium">Note:</span> AI text
+ enhancement requires API access and is currently only
+ available when using cloud-based providers.
+ </p>
+ </div>
+ )}
+
<div className="flex items-center justify-between p-4 bg-green-50 border border-green-200 rounded-xl">
<div>
<label className="text-sm font-medium text-green-800">
@@ -502,79 +758,21 @@ export default function SettingsPage({ onBack }: SettingsPageProps) {
)}
<Button onClick={saveReasoningSettings} className="w-full">
- Save Reasoning Settings
+ Save AI Model Settings
</Button>
</div>
);
- case "hotkey":
- return (
- <div className="space-y-6">
- <div>
- <h3 className="text-lg font-semibold text-gray-900 mb-2">
- Dictation Hotkey
- </h3>
- <p className="text-sm text-gray-600 mb-6">
- Configure the key you press to start and stop voice dictation.
- </p>
- </div>
-
- <div className="space-y-4 p-4 bg-blue-50 border border-blue-200 rounded-xl">
- <h4 className="font-medium text-blue-900">Activation Key</h4>
- <Input
- placeholder="Current: ` (backtick)"
- value={dictationKey}
- onChange={(e) => setDictationKey(e.target.value)}
- className="text-center text-lg font-mono"
- />
- <Button
- onClick={saveKey}
- disabled={!dictationKey.trim()}
- size="sm"
- >
- Save Hotkey
- </Button>
- </div>
-
- <div className="space-y-3">
- <Button
- onClick={permissionsHook.requestMicPermission}
- variant="outline"
- className="w-full"
- >
- <Mic className="mr-2 h-4 w-4" />
- Test Microphone Permission
- </Button>
- <Button
- onClick={permissionsHook.testAccessibilityPermission}
- variant="outline"
- className="w-full"
- >
- <Shield className="mr-2 h-4 w-4" />
- Test Accessibility Permission
- </Button>
- <Button
- onClick={resetAccessibilityPermissions}
- variant="secondary"
- className="w-full"
- >
- <span className="mr-2">βš™οΈ</span>
- Fix Permission Issues
- </Button>
- </div>
- </div>
- );
-
- case "agentName":
+ case "agentConfig":
return (
<div className="space-y-6">
<div>
<h3 className="text-lg font-semibold text-gray-900 mb-2">
- Agent Name Configuration
+ Agent Configuration
</h3>
<p className="text-sm text-gray-600 mb-6">
- Customize your agent's name to make interactions feel more
- personal and natural.
+ Customize your AI assistant's name and behavior to make
+ interactions more personal and effective.
</p>
</div>
@@ -652,295 +850,13 @@ export default function SettingsPage({ onBack }: SettingsPageProps) {
</div>
);
- case "updates":
- return (
- <div className="space-y-6">
- <div>
- <h3 className="text-lg font-semibold text-gray-900 mb-2">
- App Updates
- </h3>
- <p className="text-sm text-gray-600 mb-6">
- Keep OpenWispr up to date with the latest features and
- improvements.
- </p>
- </div>
- <div className="flex items-center justify-between p-4 bg-neutral-50 rounded-lg">
- <div>
- <p className="text-sm font-medium text-neutral-800">
- Current Version
- </p>
- <p className="text-xs text-neutral-600">
- {currentVersion || "Loading..."}
- </p>
- </div>
- <div className="flex items-center gap-2">
- {updateStatus.isDevelopment ? (
- <span className="text-xs text-amber-600 bg-amber-100 px-2 py-1 rounded-full">
- Development Mode
- </span>
- ) : updateStatus.updateAvailable ? (
- <span className="text-xs text-green-600 bg-green-100 px-2 py-1 rounded-full">
- Update Available
- </span>
- ) : (
- <span className="text-xs text-neutral-600 bg-neutral-100 px-2 py-1 rounded-full">
- Up to Date
- </span>
- )}
- </div>
- </div>
-
- <div className="space-y-3">
- <Button
- onClick={async () => {
- setCheckingForUpdates(true);
- try {
- const result = await window.electronAPI?.checkForUpdates();
- if (result?.updateAvailable) {
- setUpdateInfo({
- version: result.version,
- releaseDate: result.releaseDate,
- releaseNotes: result.releaseNotes,
- });
- setUpdateStatus((prev) => ({
- ...prev,
- updateAvailable: true,
- }));
- showAlertDialog({
- title: "Update Available",
- description: `Update available: v${result.version}`,
- });
- } else {
- showAlertDialog({
- title: "No Updates",
- description: result?.message || "No updates available",
- });
- }
- } catch (error: any) {
- showAlertDialog({
- title: "Update Check Failed",
- description: `Error checking for updates: ${error.message}`,
- });
- } finally {
- setCheckingForUpdates(false);
- }
- }}
- disabled={checkingForUpdates || updateStatus.isDevelopment}
- className="w-full"
- >
- {checkingForUpdates ? (
- <>
- <RefreshCw size={16} className="animate-spin mr-2" />
- Checking for Updates...
- </>
- ) : (
- <>
- <RefreshCw size={16} className="mr-2" />
- Check for Updates
- </>
- )}
- </Button>
-
- {updateStatus.updateAvailable &&
- !updateStatus.updateDownloaded && (
- <Button
- onClick={async () => {
- setDownloadingUpdate(true);
- try {
- await window.electronAPI?.downloadUpdate();
- setUpdateStatus((prev) => ({
- ...prev,
- updateDownloaded: true,
- }));
- showAlertDialog({
- title: "Update Downloaded",
- description:
- "Update downloaded successfully! You can now install it.",
- });
- } catch (error: any) {
- showAlertDialog({
- title: "Download Failed",
- description: `Error downloading update: ${error.message}`,
- });
- } finally {
- setDownloadingUpdate(false);
- }
- }}
- disabled={downloadingUpdate || updateStatus.isDevelopment}
- className="w-full"
- >
- {downloadingUpdate ? (
- <>
- <Download size={16} className="animate-bounce mr-2" />
- Downloading Update...
- </>
- ) : (
- <>
- <Download size={16} className="mr-2" />
- Download Update
- </>
- )}
- </Button>
- )}
-
- {updateStatus.updateDownloaded && (
- <Button
- onClick={async () => {
- try {
- await window.electronAPI?.installUpdate();
- } catch (error: any) {
- showAlertDialog({
- title: "Install Failed",
- description: `Error installing update: ${error.message}`,
- });
- }
- }}
- disabled={updateStatus.isDevelopment}
- className="w-full bg-green-600 hover:bg-green-700"
- >
- <span className="mr-2">πŸ”„</span>
- Install Update & Restart
- </Button>
- )}
-
- {updateInfo.version && (
- <div className="p-3 bg-blue-50 border border-blue-200 rounded-lg">
- <h4 className="font-medium text-blue-900 mb-1">
- Update Details
- </h4>
- <p className="text-sm text-blue-800 mb-1">
- Version: {updateInfo.version}
- </p>
- {updateInfo.releaseDate && (
- <p className="text-sm text-blue-700 mb-2">
- Released:{" "}
- {new Date(updateInfo.releaseDate).toLocaleDateString()}
- </p>
- )}
- {updateInfo.releaseNotes && (
- <details className="text-sm text-blue-700">
- <summary className="cursor-pointer font-medium">
- Release Notes
- </summary>
- <div className="mt-2 whitespace-pre-wrap">
- {updateInfo.releaseNotes}
- </div>
- </details>
- )}
- </div>
- )}
- </div>
- </div>
- );
-
- case "about":
- return (
- <div className="space-y-6">
- <div>
- <h3 className="text-lg font-semibold text-gray-900 mb-2">
- About OpenWispr
- </h3>
- <p className="text-sm text-gray-600 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>
-
- <div className="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm">
- <div className="text-center p-4 border border-gray-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">
- <Keyboard className="w-4 h-4 text-white" />
- </div>
- <p className="font-medium text-gray-800 mb-1">Default Hotkey</p>
- <p className="text-gray-600 font-mono text-xs">` (backtick)</p>
- </div>
- <div className="text-center p-4 border border-gray-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-gray-800 mb-1">Version</p>
- <p className="text-gray-600 text-xs">
- {currentVersion || "0.1.0"}
- </p>
- </div>
- <div className="text-center p-4 border border-gray-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-gray-800 mb-1">Status</p>
- <p className="text-green-600 text-xs font-medium">Active</p>
- </div>
- </div>
-
- {/* Reset Onboarding and Cleanup */}
- <div className="border-t border-gray-200 pt-4 space-y-3">
- <Button
- onClick={() => {
- showConfirmDialog({
- title: "Reset Onboarding",
- description:
- "Are you sure you want to reset the onboarding process? This will clear your setup and show the welcome flow again.",
- onConfirm: () => {
- localStorage.removeItem("onboardingCompleted");
- window.location.reload();
- },
- variant: "destructive",
- });
- }}
- 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>
-
- <Button
- onClick={() => {
- showConfirmDialog({
- title: "⚠️ DANGER: Cleanup App Data",
- description:
- "This will permanently delete ALL OpenWispr data including:\n\nβ€’ Database and transcriptions\nβ€’ Local storage settings\nβ€’ Downloaded Whisper models\nβ€’ Environment files\n\nYou will need to manually remove app permissions in System Settings.\n\nThis action cannot be undone. Are you sure?",
- onConfirm: () => {
- window.electronAPI
- ?.cleanupApp()
- .then(() => {
- showAlertDialog({
- title: "Cleanup Completed",
- description:
- "βœ… Cleanup completed! All app data has been removed.",
- });
- setTimeout(() => {
- window.location.reload();
- }, 1000);
- })
- .catch((error) => {
- showAlertDialog({
- title: "Cleanup Failed",
- description: `❌ Cleanup failed: ${error.message}`,
- });
- });
- },
- variant: "destructive",
- });
- }}
- variant="outline"
- className="w-full text-red-600 border-red-300 hover:bg-red-50 hover:border-red-400"
- >
- <span className="mr-2">πŸ—‘οΈ</span>
- Clean Up All App Data
- </Button>
- </div>
- </div>
- );
-
default:
return null;
}
};
return (
- <div className="min-h-screen bg-white">
+ <>
<ConfirmDialog
open={confirmDialog.open}
onOpenChange={(open) => !open && hideConfirmDialog()}
@@ -958,54 +874,7 @@ export default function SettingsPage({ onBack }: SettingsPageProps) {
onOk={() => {}}
/>
- <TitleBar
- title="Settings"
- showTitle={true}
- actions={
- <Button variant="ghost" size="icon" onClick={onBack}>
- <ArrowLeft size={16} />
- </Button>
- }
- />
-
- <div className="flex h-[calc(100vh-60px)]">
- {/* Sidebar */}
- <div className="w-64 bg-gray-50 border-r border-gray-200 p-4">
- <nav className="space-y-2">
- {sidebarItems.map((item) => {
- const Icon = item.icon;
- return (
- <button
- key={item.id}
- onClick={() => setActiveSection(item.id)}
- className={`w-full flex items-center gap-3 px-3 py-2 text-left text-sm rounded-lg transition-colors ${
- activeSection === item.id
- ? "bg-indigo-100 text-indigo-700"
- : "text-gray-700 hover:bg-gray-100"
- }`}
- >
- <Icon className="h-4 w-4" />
- {item.label}
- {activeSection === item.id && (
- <ChevronRight className="h-4 w-4 ml-auto" />
- )}
- </button>
- );
- })}
- </nav>
- </div>
-
- {/* Main Content */}
- <div className="flex-1 overflow-y-auto">
- <div className="max-w-2xl mx-auto p-6">
- <Card>
- <CardContent className="p-6">
- {renderSectionContent()}
- </CardContent>
- </Card>
- </div>
- </div>
- </div>
- </div>
+ {renderSectionContent()}
+ </>
);
}
diff --git a/src/components/ui/Keyboard.tsx b/src/components/ui/Keyboard.tsx
new file mode 100644
index 000000000..a217c0891
--- /dev/null
+++ b/src/components/ui/Keyboard.tsx
@@ -0,0 +1,223 @@
+import React, { useState } from "react";
+
+interface KeyboardProps {
+ selectedKey?: string;
+ setSelectedKey: (key: string) => void;
+}
+
+interface KeyProps {
+ keyValue: string;
+ isSelected: boolean;
+ onClick: () => void;
+ width?: string;
+ disabled?: boolean;
+}
+
+const Key: React.FC<KeyProps> = ({ keyValue, isSelected, onClick, width = "w-12", disabled = false }) => {
+ const [isPressed, setIsPressed] = useState(false);
+
+ const handleClick = () => {
+ if (disabled) return;
+ setIsPressed(true);
+ onClick();
+ setTimeout(() => setIsPressed(false), 150);
+ };
+
+ return (
+ <button
+ onClick={handleClick}
+ disabled={disabled}
+ className={`
+ ${width} h-12 rounded-lg font-mono text-sm font-medium
+ transition-all duration-150 ease-in-out
+ transform active:scale-95
+ ${isPressed ? 'translate-y-1 shadow-inner' : 'translate-y-0 shadow-lg'}
+ hover:translate-y-0.5 hover:shadow-md
+ focus:outline-none focus:ring-2 focus:ring-indigo-300
+ ${
+ isSelected
+ ? 'bg-indigo-500 text-white border-2 border-indigo-600'
+ : disabled
+ ? 'bg-gray-300 text-gray-500 cursor-not-allowed'
+ : 'bg-white text-gray-800 border-2 border-gray-300 hover:border-gray-400'
+ }
+ ${isPressed ? 'bg-gray-100' : ''}
+ `}
+ >
+ {keyValue === 'Space' ? '' : keyValue}
+ </button>
+ );
+};
+
+export default function Keyboard({ selectedKey, setSelectedKey }: KeyboardProps) {
+ const functionKeys = ['Esc', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12'];
+
+ const numberRow = ['`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '='];
+
+ const qwertyRow = ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', '\\'];
+
+ const asdfRow = ['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', "'"];
+
+ const zxcvRow = ['Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/'];
+
+ const handleKeyClick = (key: string) => {
+ setSelectedKey(key);
+ };
+
+ return (
+ <div className="p-6 bg-gradient-to-b from-gray-100 to-gray-200 rounded-2xl shadow-2xl border border-gray-300">
+ {/* Function Keys Row */}
+ <div className="flex justify-center gap-2 mb-4">
+ {functionKeys.map((key) => (
+ <Key
+ key={key}
+ keyValue={key}
+ isSelected={selectedKey === key}
+ onClick={() => handleKeyClick(key)}
+ width={key === 'Esc' ? 'w-14' : 'w-12'}
+ />
+ ))}
+ </div>
+
+ {/* Number Row */}
+ <div className="flex justify-center gap-1 mb-2">
+ {numberRow.map((key) => (
+ <Key
+ key={key}
+ keyValue={key}
+ isSelected={selectedKey === key}
+ onClick={() => handleKeyClick(key)}
+ />
+ ))}
+ <Key
+ keyValue="Backspace"
+ isSelected={selectedKey === 'Backspace'}
+ onClick={() => handleKeyClick('Backspace')}
+ width="w-20"
+ disabled
+ />
+ </div>
+
+ {/* QWERTY Row */}
+ <div className="flex justify-center gap-1 mb-2">
+ <Key
+ keyValue="Tab"
+ isSelected={selectedKey === 'Tab'}
+ onClick={() => handleKeyClick('Tab')}
+ width="w-16"
+ disabled
+ />
+ {qwertyRow.map((key) => (
+ <Key
+ key={key}
+ keyValue={key}
+ isSelected={selectedKey === key}
+ onClick={() => handleKeyClick(key)}
+ />
+ ))}
+ </div>
+
+ {/* ASDF Row */}
+ <div className="flex justify-center gap-1 mb-2">
+ <Key
+ keyValue="Caps"
+ isSelected={selectedKey === 'CapsLock'}
+ onClick={() => handleKeyClick('CapsLock')}
+ width="w-18"
+ disabled
+ />
+ {asdfRow.map((key) => (
+ <Key
+ key={key}
+ keyValue={key}
+ isSelected={selectedKey === key}
+ onClick={() => handleKeyClick(key)}
+ />
+ ))}
+ <Key
+ keyValue="Enter"
+ isSelected={selectedKey === 'Enter'}
+ onClick={() => handleKeyClick('Enter')}
+ width="w-20"
+ disabled
+ />
+ </div>
+
+ {/* ZXCV Row */}
+ <div className="flex justify-center gap-1 mb-2">
+ <Key
+ keyValue="Shift"
+ isSelected={selectedKey === 'Shift'}
+ onClick={() => handleKeyClick('Shift')}
+ width="w-24"
+ disabled
+ />
+ {zxcvRow.map((key) => (
+ <Key
+ key={key}
+ keyValue={key}
+ isSelected={selectedKey === key}
+ onClick={() => handleKeyClick(key)}
+ />
+ ))}
+ <Key
+ keyValue="Shift"
+ isSelected={false}
+ onClick={() => handleKeyClick('Shift')}
+ width="w-24"
+ disabled
+ />
+ </div>
+
+ {/* Bottom Row */}
+ <div className="flex justify-center gap-1">
+ <Key
+ keyValue="Ctrl"
+ isSelected={selectedKey === 'Ctrl'}
+ onClick={() => handleKeyClick('Ctrl')}
+ width="w-16"
+ disabled
+ />
+ <Key
+ keyValue="Alt"
+ isSelected={selectedKey === 'Alt'}
+ onClick={() => handleKeyClick('Alt')}
+ width="w-16"
+ disabled
+ />
+ <Key
+ keyValue="Space"
+ isSelected={selectedKey === 'Space'}
+ onClick={() => handleKeyClick('Space')}
+ width="w-64"
+ />
+ <Key
+ keyValue="Alt"
+ isSelected={false}
+ onClick={() => handleKeyClick('Alt')}
+ width="w-16"
+ disabled
+ />
+ <Key
+ keyValue="Ctrl"
+ isSelected={false}
+ onClick={() => handleKeyClick('Ctrl')}
+ width="w-16"
+ disabled
+ />
+ </div>
+
+ {/* Selected Key Display */}
+ {selectedKey && (
+ <div className="mt-6 text-center">
+ <div className="inline-flex items-center px-4 py-2 bg-indigo-100 border-2 border-indigo-300 rounded-lg">
+ <span className="text-sm text-indigo-700 mr-2">Selected:</span>
+ <kbd className="px-3 py-1 bg-white border border-indigo-200 rounded font-mono text-lg font-semibold text-indigo-900">
+ {selectedKey}
+ </kbd>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/src/components/ui/PromptStudio.tsx b/src/components/ui/PromptStudio.tsx
new file mode 100644
index 000000000..726b5cce4
--- /dev/null
+++ b/src/components/ui/PromptStudio.tsx
@@ -0,0 +1,468 @@
+import React, { useState, useEffect } from "react";
+import { Button } from "./button";
+import { Textarea } from "./textarea";
+import { Input } from "./input";
+import { Card, CardContent, CardHeader, CardTitle } from "./card";
+import {
+ Eye,
+ Edit3,
+ Play,
+ Save,
+ RotateCcw,
+ Copy,
+ Sparkles,
+ Zap,
+ BookOpen,
+ TestTube
+} from "lucide-react";
+import { AlertDialog } from "./dialog";
+import { useDialogs } from "../../hooks/useDialogs";
+import { useAgentName } from "../../utils/agentName";
+
+interface PromptStudioProps {
+ className?: string;
+}
+
+interface PromptTemplate {
+ id: string;
+ name: string;
+ description: string;
+ agentPrompt: string;
+ regularPrompt: string;
+ category: "creative" | "professional" | "casual" | "technical";
+}
+
+const DEFAULT_PROMPTS = {
+ agent: `You are {{agentName}}, an AI text formatting assistant. The user has addressed you by name and is giving you specific instructions to process their text.
+
+Your role:
+1. When addressed as "{{agentName}}" or "Hey {{agentName}}", you are being given instructions about how to format or process text
+2. Look for commands like:
+ - "{{agentName}}, make this more professional"
+ - "{{agentName}}, format this as a list"
+ - "{{agentName}}, write an email about..."
+ - "{{agentName}}, convert this to bullet points"
+3. Follow the user's formatting instructions while preserving their intent
+4. If asked to write content, create it based on their request
+5. Remove the agent name references from the final output (don't include "Hey {{agentName}}" in your response)
+6. For editing commands, apply the requested changes to the text that follows
+
+Transcript with instructions:
+"{{text}}"
+
+Processed text:`,
+
+ regular: `You are a text formatting assistant. Your job is to clean up and format voice-to-text transcriptions while preserving the speaker's natural tone and intent.
+
+Rules:
+1. If the speaker gives instructions like "scratch that", "ignore that", "delete the previous part", "never mind", or similar - follow them and remove the referenced content
+2. If the speaker says "put this in a list" or starts listing items, format as a proper list
+3. Fix obvious speech-to-text errors, punctuation, and capitalization
+4. Maintain the speaker's natural tone and style
+5. Don't add content - only clean up what's there
+6. If unclear, err on the side of minimal changes
+
+Transcript to format:
+"{{text}}"
+
+Formatted text:`
+};
+
+const PROMPT_TEMPLATES: PromptTemplate[] = [
+ {
+ id: "creative-writer",
+ name: "Creative Writer",
+ description: "Enhances text with creative flair and storytelling elements",
+ category: "creative",
+ agentPrompt: `You are {{agentName}}, a creative writing assistant. Help transform text into engaging, vivid content.
+
+When addressed:
+- Add descriptive language and imagery
+- Improve flow and rhythm
+- Suggest creative alternatives
+- Maintain the core message while making it more compelling
+
+Transform: "{{text}}"`,
+ regularPrompt: `Clean up this transcript while adding creative touches - better word choices, more engaging phrasing, improved flow.
+
+Original: "{{text}}"
+
+Enhanced:`
+ },
+ {
+ id: "professional-editor",
+ name: "Professional Editor",
+ description: "Formal, business-appropriate text processing",
+ category: "professional",
+ agentPrompt: `You are {{agentName}}, a professional business editor. Make text appropriate for corporate communication.
+
+When addressed:
+- Use formal, professional language
+- Structure content clearly
+- Remove casual expressions
+- Ensure proper business etiquette
+
+Polish: "{{text}}"`,
+ regularPrompt: `Convert this transcript to professional business language. Fix grammar, improve clarity, use formal tone.
+
+Transcript: "{{text}}"
+
+Professional version:`
+ },
+ {
+ id: "casual-friend",
+ name: "Casual Friend",
+ description: "Friendly, conversational tone for informal communication",
+ category: "casual",
+ agentPrompt: `You are {{agentName}}, a friendly assistant who keeps things casual and conversational.
+
+When addressed:
+- Keep the tone relaxed and natural
+- Use everyday language
+- Preserve personality and humor
+- Make it sound like a friend talking
+
+Refine: "{{text}}"`,
+ regularPrompt: `Clean up this transcript while keeping it casual and friendly. Fix errors but maintain the conversational tone.
+
+Raw transcript: "{{text}}"
+
+Cleaned up:`
+ }
+];
+
+export default function PromptStudio({ className = "" }: PromptStudioProps) {
+ const [activeTab, setActiveTab] = useState<"current" | "edit" | "templates" | "test">("current");
+ const [editedAgentPrompt, setEditedAgentPrompt] = useState(DEFAULT_PROMPTS.agent);
+ const [editedRegularPrompt, setEditedRegularPrompt] = useState(DEFAULT_PROMPTS.regular);
+ const [testText, setTestText] = useState("Hey Assistant, make this more professional: This is a test message that needs some work.");
+ const [testResult, setTestResult] = useState("");
+ const [isLoading, setIsLoading] = useState(false);
+ const [selectedTemplate, setSelectedTemplate] = useState<PromptTemplate | null>(null);
+
+ const { alertDialog, showAlertDialog, hideAlertDialog } = useDialogs();
+ const { agentName } = useAgentName();
+
+ // Load saved custom prompts from localStorage
+ useEffect(() => {
+ const savedPrompts = localStorage.getItem("customPrompts");
+ if (savedPrompts) {
+ try {
+ const parsed = JSON.parse(savedPrompts);
+ setEditedAgentPrompt(parsed.agent || DEFAULT_PROMPTS.agent);
+ setEditedRegularPrompt(parsed.regular || DEFAULT_PROMPTS.regular);
+ } catch (error) {
+ console.error("Failed to load custom prompts:", error);
+ }
+ }
+ }, []);
+
+ const savePrompts = () => {
+ const customPrompts = {
+ agent: editedAgentPrompt,
+ regular: editedRegularPrompt
+ };
+
+ localStorage.setItem("customPrompts", JSON.stringify(customPrompts));
+ showAlertDialog({
+ title: "Prompts Saved!",
+ description: "Your custom prompts have been saved and will be used for all future AI processing."
+ });
+ };
+
+ const resetToDefaults = () => {
+ setEditedAgentPrompt(DEFAULT_PROMPTS.agent);
+ setEditedRegularPrompt(DEFAULT_PROMPTS.regular);
+ localStorage.removeItem("customPrompts");
+ showAlertDialog({
+ title: "Reset Complete",
+ description: "Prompts have been reset to default values."
+ });
+ };
+
+ const applyTemplate = (template: PromptTemplate) => {
+ setEditedAgentPrompt(template.agentPrompt);
+ setEditedRegularPrompt(template.regularPrompt);
+ setSelectedTemplate(template);
+ setActiveTab("edit");
+ };
+
+ const testPrompt = async () => {
+ if (!testText.trim()) return;
+
+ setIsLoading(true);
+ try {
+ // Simulate AI processing with the custom prompt
+ const isAgentMode = testText.toLowerCase().includes(agentName.toLowerCase());
+ const prompt = isAgentMode ? editedAgentPrompt : editedRegularPrompt;
+
+ // Replace placeholders
+ const processedPrompt = prompt
+ .replace(/\{\{agentName\}\}/g, agentName)
+ .replace(/\{\{text\}\}/g, testText);
+
+ // This would normally call your AI service
+ // For now, just show the prompt that would be sent
+ setTestResult(`[PROMPT THAT WOULD BE SENT TO AI]\n\n${processedPrompt}\n\n[This is a preview - actual AI processing would happen here]`);
+
+ } catch (error) {
+ console.error("Test failed:", error);
+ setTestResult("Test failed: " + error.message);
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ const copyPrompt = (prompt: string) => {
+ navigator.clipboard.writeText(prompt);
+ showAlertDialog({
+ title: "Copied!",
+ description: "Prompt copied to clipboard."
+ });
+ };
+
+ const renderCurrentPrompts = () => (
+ <div className="space-y-6">
+ <div>
+ <h3 className="text-lg font-semibold mb-4 flex items-center gap-2">
+ <Eye className="w-5 h-5 text-blue-600" />
+ Current AI Prompts
+ </h3>
+ <p className="text-sm text-gray-600 mb-6">
+ These are the exact prompts currently being sent to your AI models. Understanding these helps you see how OpenWispr thinks!
+ </p>
+ </div>
+
+ <Card>
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2 text-base">
+ <Sparkles className="w-4 h-4 text-purple-600" />
+ Agent Mode Prompt (when you say "Hey {agentName}")
+ </CardTitle>
+ </CardHeader>
+ <CardContent>
+ <div className="bg-gray-50 border rounded-lg p-4 font-mono text-sm">
+ <pre className="whitespace-pre-wrap">{editedAgentPrompt.replace(/\{\{agentName\}\}/g, agentName)}</pre>
+ </div>
+ <Button
+ onClick={() => copyPrompt(editedAgentPrompt)}
+ variant="outline"
+ size="sm"
+ className="mt-3"
+ >
+ <Copy className="w-4 h-4 mr-2" />
+ Copy Prompt
+ </Button>
+ </CardContent>
+ </Card>
+
+ <Card>
+ <CardHeader>
+ <CardTitle className="flex items-center gap-2 text-base">
+ <Zap className="w-4 h-4 text-green-600" />
+ Regular Mode Prompt (for automatic cleanup)
+ </CardTitle>
+ </CardHeader>
+ <CardContent>
+ <div className="bg-gray-50 border rounded-lg p-4 font-mono text-sm">
+ <pre className="whitespace-pre-wrap">{editedRegularPrompt}</pre>
+ </div>
+ <Button
+ onClick={() => copyPrompt(editedRegularPrompt)}
+ variant="outline"
+ size="sm"
+ className="mt-3"
+ >
+ <Copy className="w-4 h-4 mr-2" />
+ Copy Prompt
+ </Button>
+ </CardContent>
+ </Card>
+ </div>
+ );
+
+ const renderEditPrompts = () => (
+ <div className="space-y-6">
+ <div>
+ <h3 className="text-lg font-semibold mb-4 flex items-center gap-2">
+ <Edit3 className="w-5 h-5 text-indigo-600" />
+ Customize Your AI Prompts
+ </h3>
+ <p className="text-sm text-gray-600 mb-6">
+ Edit these prompts to change how your AI behaves. Use <code>{"{{agentName}}"}</code> and <code>{"{{text}}"}</code> as placeholders.
+ </p>
+ </div>
+
+ <Card>
+ <CardHeader>
+ <CardTitle className="text-base">Agent Mode Prompt</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <Textarea
+ value={editedAgentPrompt}
+ onChange={(e) => setEditedAgentPrompt(e.target.value)}
+ rows={12}
+ className="font-mono text-sm"
+ placeholder="Enter your custom agent prompt..."
+ />
+ </CardContent>
+ </Card>
+
+ <Card>
+ <CardHeader>
+ <CardTitle className="text-base">Regular Mode Prompt</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <Textarea
+ value={editedRegularPrompt}
+ onChange={(e) => setEditedRegularPrompt(e.target.value)}
+ rows={12}
+ className="font-mono text-sm"
+ placeholder="Enter your custom regular prompt..."
+ />
+ </CardContent>
+ </Card>
+
+ <div className="flex gap-3">
+ <Button onClick={savePrompts} className="flex-1">
+ <Save className="w-4 h-4 mr-2" />
+ Save Custom Prompts
+ </Button>
+ <Button onClick={resetToDefaults} variant="outline">
+ <RotateCcw className="w-4 h-4 mr-2" />
+ Reset to Defaults
+ </Button>
+ </div>
+ </div>
+ );
+
+ const renderTemplates = () => (
+ <div className="space-y-6">
+ <div>
+ <h3 className="text-lg font-semibold mb-4 flex items-center gap-2">
+ <BookOpen className="w-5 h-5 text-purple-600" />
+ Prompt Templates
+ </h3>
+ <p className="text-sm text-gray-600 mb-6">
+ Pre-built prompt templates for different use cases. Click to apply and customize.
+ </p>
+ </div>
+
+ <div className="grid gap-4">
+ {PROMPT_TEMPLATES.map((template) => (
+ <Card key={template.id} className="cursor-pointer hover:shadow-lg transition-shadow" onClick={() => applyTemplate(template)}>
+ <CardContent className="p-4">
+ <div className="flex items-start justify-between">
+ <div>
+ <h4 className="font-semibold text-gray-900">{template.name}</h4>
+ <p className="text-sm text-gray-600 mt-1">{template.description}</p>
+ <span className={`inline-block mt-2 px-2 py-1 text-xs rounded-full ${
+ template.category === 'professional' ? 'bg-blue-100 text-blue-800' :
+ template.category === 'creative' ? 'bg-purple-100 text-purple-800' :
+ template.category === 'casual' ? 'bg-green-100 text-green-800' :
+ 'bg-gray-100 text-gray-800'
+ }`}>
+ {template.category}
+ </span>
+ </div>
+ <Button variant="outline" size="sm">
+ Apply Template
+ </Button>
+ </div>
+ </CardContent>
+ </Card>
+ ))}
+ </div>
+ </div>
+ );
+
+ const renderTestPlayground = () => (
+ <div className="space-y-6">
+ <div>
+ <h3 className="text-lg font-semibold mb-4 flex items-center gap-2">
+ <TestTube className="w-5 h-5 text-green-600" />
+ Test Your Prompts
+ </h3>
+ <p className="text-sm text-gray-600 mb-6">
+ Try your custom prompts with sample text to see how they work before saving.
+ </p>
+ </div>
+
+ <Card>
+ <CardContent className="p-6 space-y-4">
+ <div>
+ <label className="block text-sm font-medium mb-2">Test Input</label>
+ <Textarea
+ value={testText}
+ onChange={(e) => setTestText(e.target.value)}
+ rows={3}
+ placeholder="Enter text to test with your custom prompts..."
+ />
+ </div>
+
+ <Button
+ onClick={testPrompt}
+ disabled={!testText.trim() || isLoading}
+ className="w-full"
+ >
+ <Play className="w-4 h-4 mr-2" />
+ {isLoading ? "Testing..." : "Test Prompt"}
+ </Button>
+
+ {testResult && (
+ <div>
+ <label className="block text-sm font-medium mb-2">Result Preview</label>
+ <div className="bg-gray-50 border rounded-lg p-4 font-mono text-sm max-h-60 overflow-y-auto">
+ <pre className="whitespace-pre-wrap">{testResult}</pre>
+ </div>
+ </div>
+ )}
+ </CardContent>
+ </Card>
+ </div>
+ );
+
+ return (
+ <div className={className}>
+ <AlertDialog
+ open={alertDialog.open}
+ onOpenChange={(open) => !open && hideAlertDialog()}
+ title={alertDialog.title}
+ description={alertDialog.description}
+ onOk={() => {}}
+ />
+
+ {/* Tab Navigation */}
+ <div className="flex border-b border-gray-200 mb-6">
+ {[
+ { id: "current", label: "Current Prompts", icon: Eye },
+ { id: "edit", label: "Customize", icon: Edit3 },
+ { id: "templates", label: "Templates", icon: BookOpen },
+ { id: "test", label: "Test", icon: TestTube }
+ ].map((tab) => {
+ const Icon = tab.icon;
+ return (
+ <button
+ key={tab.id}
+ onClick={() => setActiveTab(tab.id as any)}
+ className={`flex items-center gap-2 px-4 py-2 border-b-2 transition-colors ${
+ activeTab === tab.id
+ ? "border-indigo-600 text-indigo-600"
+ : "border-transparent text-gray-600 hover:text-gray-900"
+ }`}
+ >
+ <Icon className="w-4 h-4" />
+ {tab.label}
+ </button>
+ );
+ })}
+ </div>
+
+ {/* Tab Content */}
+ {activeTab === "current" && renderCurrentPrompts()}
+ {activeTab === "edit" && renderEditPrompts()}
+ {activeTab === "templates" && renderTemplates()}
+ {activeTab === "test" && renderTestPlayground()}
+ </div>
+ );
+}
diff --git a/src/components/ui/SidebarModal.tsx b/src/components/ui/SidebarModal.tsx
new file mode 100644
index 000000000..5bdab24ce
--- /dev/null
+++ b/src/components/ui/SidebarModal.tsx
@@ -0,0 +1,88 @@
+import React from "react";
+import * as DialogPrimitive from "@radix-ui/react-dialog";
+import { X } from "lucide-react";
+
+export interface SidebarItem<T extends string> {
+ id: T;
+ label: string;
+ icon: React.ComponentType<{ className?: string }>;
+}
+
+interface SidebarModalProps<T extends string> {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ title: string;
+ sidebarItems: SidebarItem<T>[];
+ activeSection: T;
+ onSectionChange: (section: T) => void;
+ children: React.ReactNode;
+ sidebarWidth?: string;
+}
+
+export default function SidebarModal<T extends string>({
+ open,
+ onOpenChange,
+ title,
+ sidebarItems,
+ activeSection,
+ onSectionChange,
+ children,
+ sidebarWidth = "w-72",
+}: SidebarModalProps<T>) {
+ return (
+ <DialogPrimitive.Root open={open} onOpenChange={onOpenChange}>
+ <DialogPrimitive.Portal>
+ <DialogPrimitive.Overlay className="fixed inset-0 z-50 bg-black/30 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" />
+ <DialogPrimitive.Content className="fixed left-[50%] top-[50%] z-50 max-h-[90vh] w-[90vw] max-w-5xl translate-x-[-50%] translate-y-[-50%] rounded-2xl bg-white p-0 shadow-2xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] overflow-hidden">
+ <div className="relative h-full max-h-[90vh] overflow-hidden">
+ <DialogPrimitive.Close className="absolute right-6 top-6 z-10 rounded-full bg-gray-100 p-2 opacity-70 ring-offset-background transition-all hover:opacity-100 hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2">
+ <X className="h-4 w-4 text-gray-600" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+
+ <div className="flex h-[90vh]">
+ {/* Sidebar */}
+ <div
+ className={`${sidebarWidth} bg-gray-50 border-r border-gray-200 p-4`}
+ >
+ <h2 className="text-xl font-semibold text-gray-900 mb-4 px-2">
+ {title}
+ </h2>
+ <nav className="space-y-1">
+ {sidebarItems.map((item) => {
+ const Icon = item.icon;
+ return (
+ <button
+ key={item.id}
+ onClick={() => onSectionChange(item.id)}
+ className={`w-full flex items-center gap-2 px-3 py-2.5 text-left text-sm rounded-lg transition-all duration-200 ${
+ activeSection === item.id
+ ? "bg-white text-gray-900 shadow-sm border border-gray-200"
+ : "text-gray-600 hover:text-gray-900 hover:bg-gray-100"
+ }`}
+ >
+ <Icon
+ className={`h-4 w-4 flex-shrink-0 ${
+ activeSection === item.id ? "text-indigo-600" : ""
+ }`}
+ />
+ <span className="font-medium flex-1">{item.label}</span>
+ </button>
+ );
+ })}
+ </nav>
+ </div>
+
+ {/* Main Content */}
+ <div className="flex-1 overflow-y-auto bg-white">
+ <div className="p-8">
+ <div className="max-w-3xl">{children}</div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </DialogPrimitive.Content>
+ </DialogPrimitive.Portal>
+ </DialogPrimitive.Root>
+ );
+}
diff --git a/src/helpers/windowConfig.js b/src/helpers/windowConfig.js
index a6abaab43..b5cdb6d83 100644
--- a/src/helpers/windowConfig.js
+++ b/src/helpers/windowConfig.js
@@ -22,8 +22,8 @@ const MAIN_WINDOW_CONFIG = {
// Control panel window configuration
const CONTROL_PANEL_CONFIG = {
- width: 800,
- height: 700,
+ width: 1200,
+ height: 800,
webPreferences: {
preload: path.join(__dirname, "..", "..", "preload.js"),
nodeIntegration: false,
@@ -45,6 +45,7 @@ const CONTROL_PANEL_CONFIG = {
resizable: true,
show: false,
titleBarStyle: "hiddenInset",
+ trafficLightPosition: { x: 20, y: 20 },
frame: false,
transparent: false,
backgroundColor: "#ffffff",
diff --git a/src/services/ReasoningService.js b/src/services/ReasoningService.js
index 045b7c443..2fefbeba9 100644
--- a/src/services/ReasoningService.js
+++ b/src/services/ReasoningService.js
@@ -1,33 +1,28 @@
import { getModelProvider } from "../utils/languages.ts";
import { getAgentName } from "../utils/agentName.ts";
-const getReasoningPrompt = (text, agentName) => {
- const hasAgentReference =
- agentName &&
- (text.toLowerCase().includes(`hey ${agentName.toLowerCase()}`) ||
- text.toLowerCase().includes(agentName.toLowerCase()));
-
- if (hasAgentReference) {
- return `You are ${agentName}, an AI text formatting assistant. The user has addressed you by name and is giving you specific instructions to process their text.
+// Default prompts (fallback if no custom prompts are saved)
+const DEFAULT_PROMPTS = {
+ agent: `You are {{agentName}}, an AI text formatting assistant. The user has addressed you by name and is giving you specific instructions to process their text.
Your role:
-1. When addressed as "${agentName}" or "Hey ${agentName}", you are being given instructions about how to format or process text
+1. When addressed as "{{agentName}}" or "Hey {{agentName}}", you are being given instructions about how to format or process text
2. Look for commands like:
- - "${agentName}, make this more professional"
- - "${agentName}, format this as a list"
- - "${agentName}, write an email about..."
- - "${agentName}, convert this to bullet points"
+ - "{{agentName}}, make this more professional"
+ - "{{agentName}}, format this as a list"
+ - "{{agentName}}, write an email about..."
+ - "{{agentName}}, convert this to bullet points"
3. Follow the user's formatting instructions while preserving their intent
4. If asked to write content, create it based on their request
-5. Remove the agent name references from the final output (don't include "Hey ${agentName}" in your response)
+5. Remove the agent name references from the final output (don't include "Hey {{agentName}}" in your response)
6. For editing commands, apply the requested changes to the text that follows
Transcript with instructions:
"{{text}}"
-Processed text:`;
- } else {
- return `You are a text formatting assistant. Your job is to clean up and format voice-to-text transcriptions while preserving the speaker's natural tone and intent.
+Processed text:`,
+
+ regular: `You are a text formatting assistant. Your job is to clean up and format voice-to-text transcriptions while preserving the speaker's natural tone and intent.
Rules:
1. If the speaker gives instructions like "scratch that", "ignore that", "delete the previous part", "never mind", or similar - follow them and remove the referenced content
@@ -40,8 +35,35 @@ Rules:
Transcript to format:
"{{text}}"
-Formatted text:`;
+Formatted text:`
+};
+
+const getReasoningPrompt = (text, agentName) => {
+ // Try to load custom prompts from localStorage
+ let customPrompts;
+ try {
+ const saved = localStorage.getItem("customPrompts");
+ customPrompts = saved ? JSON.parse(saved) : null;
+ } catch (error) {
+ console.warn("Failed to load custom prompts, using defaults:", error);
+ customPrompts = null;
}
+
+ // Use custom prompts if available, otherwise use defaults
+ const prompts = customPrompts || DEFAULT_PROMPTS;
+
+ const hasAgentReference =
+ agentName &&
+ (text.toLowerCase().includes(`hey ${agentName.toLowerCase()}`) ||
+ text.toLowerCase().includes(agentName.toLowerCase()));
+
+ // Get the appropriate prompt template
+ const promptTemplate = hasAgentReference ? prompts.agent : prompts.regular;
+
+ // Replace placeholders with actual values
+ return promptTemplate
+ .replace(/\{\{agentName\}\}/g, agentName)
+ .replace(/\{\{text\}\}/g, text);
};
class ReasoningService {