Skip to content

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

feat: add Agent Mode with glassmorphism chat overlay

Gabriel Steinbd72e9d3e5f1
diff --git a/main.js b/main.js
index 27cd0245c..5f8851a81 100644
--- a/main.js
+++ b/main.js
@@ -492,6 +492,28 @@ async function startApp() {
await windowManager.createMainWindow();
await windowManager.createControlPanelWindow();
+ // Create agent window (hidden) and set up agent hotkey
+ await windowManager.createAgentWindow();
+
+ const agentHotkeyCallback = () => {
+ if (hotkeyManager.isInListeningMode()) return;
+ windowManager.toggleAgentOverlay();
+ };
+ windowManager._agentHotkeyCallback = agentHotkeyCallback;
+
+ const savedAgentKey = environmentManager.getAgentKey?.() || "";
+ if (savedAgentKey) {
+ hotkeyManager.registerSlot("agent", savedAgentKey, agentHotkeyCallback);
+ }
+
+ ipcMain.on("agent-hotkey-changed", (_event, hotkey) => {
+ if (hotkey) {
+ hotkeyManager.registerSlot("agent", hotkey, agentHotkeyCallback);
+ } else {
+ hotkeyManager.unregisterSlot("agent");
+ }
+ });
+
// Phase 2: Initialize remaining managers after windows are visible
initializeDeferredManagers();
@@ -585,7 +607,13 @@ async function startApp() {
} else {
debugLogger?.debug("[Globe] Ignored — mainWindow not live");
}
- } else {
+ }
+
+ // Check agent slot for Globe/Fn key
+ const agentHotkey = hotkeyManager.getSlotHotkey("agent");
+ if (agentHotkey && isGlobeLikeHotkey(agentHotkey)) {
+ windowManager.toggleAgentOverlay();
+ } else if (!isGlobeLikeHotkey(currentHotkey)) {
debugLogger?.debug("[Globe] Ignored — hotkey is not GLOBE", { currentHotkey });
}
});
@@ -628,6 +656,13 @@ async function startApp() {
globeKeyManager.on("right-modifier-down", async (modifier) => {
const currentHotkey = hotkeyManager.getCurrentHotkey && hotkeyManager.getCurrentHotkey();
+
+ // Check agent slot for right-modifier
+ const agentHotkey = hotkeyManager.getSlotHotkey("agent");
+ if (agentHotkey === modifier) {
+ windowManager.toggleAgentOverlay();
+ }
+
if (currentHotkey !== modifier) return;
if (!isLiveWindow(windowManager.mainWindow)) return;
@@ -916,6 +951,9 @@ if (gotSingleInstanceLock) {
authBridgeServer.close();
authBridgeServer = null;
}
+ if (windowManager && isLiveWindow(windowManager.agentWindow)) {
+ windowManager.agentWindow.destroy();
+ }
if (hotkeyManager) {
hotkeyManager.unregisterAll();
} else {
diff --git a/preload.js b/preload.js
index f8ece6a88..58ba3d48c 100644
--- a/preload.js
+++ b/preload.js
@@ -451,4 +451,32 @@ contextBridge.exposeInMainWorld("electronAPI", {
// Auto-start management
getAutoStartEnabled: () => ipcRenderer.invoke("get-auto-start-enabled"),
setAutoStartEnabled: (enabled) => ipcRenderer.invoke("set-auto-start-enabled", enabled),
+
+ // Agent mode
+ notifyAgentHotkeyChanged: (hotkey) => ipcRenderer.send("agent-hotkey-changed", hotkey),
+ getAgentKey: () => ipcRenderer.invoke("get-agent-key"),
+ saveAgentKey: (key) => ipcRenderer.invoke("save-agent-key", key),
+ onAgentStartRecording: registerListener("agent-start-recording", (callback) => () => callback()),
+ onAgentStopRecording: registerListener("agent-stop-recording", (callback) => () => callback()),
+ toggleAgentOverlay: () => ipcRenderer.invoke("toggle-agent-overlay"),
+ hideAgentOverlay: () => ipcRenderer.invoke("hide-agent-overlay"),
+ resizeAgentWindow: (width, height) => ipcRenderer.invoke("resize-agent-window", width, height),
+ acquireRecordingLock: (pipeline) => ipcRenderer.invoke("acquire-recording-lock", pipeline),
+ releaseRecordingLock: (pipeline) => ipcRenderer.invoke("release-recording-lock", pipeline),
+
+ // Agent conversation persistence
+ createAgentConversation: (title) =>
+ ipcRenderer.invoke("db-create-agent-conversation", title),
+ getAgentConversations: (limit) =>
+ ipcRenderer.invoke("db-get-agent-conversations", limit),
+ getAgentConversation: (id) =>
+ ipcRenderer.invoke("db-get-agent-conversation", id),
+ deleteAgentConversation: (id) =>
+ ipcRenderer.invoke("db-delete-agent-conversation", id),
+ updateAgentConversationTitle: (id, title) =>
+ ipcRenderer.invoke("db-update-agent-conversation-title", id, title),
+ addAgentMessage: (conversationId, role, content) =>
+ ipcRenderer.invoke("db-add-agent-message", conversationId, role, content),
+ getAgentMessages: (conversationId) =>
+ ipcRenderer.invoke("db-get-agent-messages", conversationId),
});
diff --git a/src/components/AgentOverlay.tsx b/src/components/AgentOverlay.tsx
new file mode 100644
index 000000000..db456a0aa
--- /dev/null
+++ b/src/components/AgentOverlay.tsx
@@ -0,0 +1,221 @@
+import { useState, useEffect, useRef, useCallback } from "react";
+import { cn } from "./lib/utils";
+import { AgentTitleBar } from "./agent/AgentTitleBar";
+import { AgentChat } from "./agent/AgentChat";
+import { AgentInput } from "./agent/AgentInput";
+import AudioManager from "../helpers/audioManager";
+import ReasoningService from "../services/ReasoningService";
+import { getSettings } from "../stores/settingsStore";
+import { getAgentSystemPrompt } from "../config/prompts";
+
+type AgentState = "idle" | "listening" | "transcribing" | "thinking" | "streaming";
+
+interface Message {
+ id: string;
+ role: "user" | "assistant";
+ content: string;
+ isStreaming: boolean;
+}
+
+const MIN_HEIGHT = 200;
+const MAX_HEIGHT = 700;
+const WIDTH = 420;
+
+export default function AgentOverlay() {
+ const [messages, setMessages] = useState<Message[]>([]);
+ const [agentState, setAgentState] = useState<AgentState>("idle");
+ const [partialTranscript, setPartialTranscript] = useState("");
+ const containerRef = useRef<HTMLDivElement>(null);
+ const audioManagerRef = useRef<InstanceType<typeof AudioManager> | null>(null);
+ const messagesRef = useRef<Message[]>([]);
+ const conversationIdRef = useRef<number | null>(null);
+
+ useEffect(() => {
+ messagesRef.current = messages;
+ }, [messages]);
+
+ const addSystemMessage = useCallback((content: string) => {
+ setMessages((prev) => [
+ ...prev,
+ { id: crypto.randomUUID(), role: "assistant" as const, content, isStreaming: false },
+ ]);
+ }, []);
+
+ const handleTranscriptionComplete = useCallback(async (text: string) => {
+ if (!text.trim()) {
+ setAgentState("idle");
+ return;
+ }
+
+ // Create conversation on first message
+ if (!conversationIdRef.current) {
+ const conv = await window.electronAPI?.createAgentConversation?.("New conversation");
+ conversationIdRef.current = conv?.id ?? null;
+ }
+
+ const userMsg: Message = { id: crypto.randomUUID(), role: "user", content: text, isStreaming: false };
+ setMessages((prev) => [...prev, userMsg]);
+
+ if (conversationIdRef.current) {
+ window.electronAPI?.addAgentMessage?.(conversationIdRef.current, "user", text);
+ }
+
+ // Auto-title after first user message
+ const allMessages = messagesRef.current;
+ if (conversationIdRef.current && allMessages.length === 0) {
+ const title = text.slice(0, 50) + (text.length > 50 ? "..." : "");
+ window.electronAPI?.updateAgentConversationTitle?.(conversationIdRef.current, title);
+ }
+
+ setAgentState("thinking");
+
+ const settings = getSettings();
+ const systemPrompt = getAgentSystemPrompt();
+
+ const llmMessages = [
+ { role: "system", content: systemPrompt },
+ ...[...allMessages, userMsg].slice(-20).map((m) => ({ role: m.role, content: m.content })),
+ ];
+
+ const assistantId = crypto.randomUUID();
+ setMessages((prev) => [...prev, { id: assistantId, role: "assistant", content: "", isStreaming: true }]);
+ setAgentState("streaming");
+
+ try {
+ let fullContent = "";
+
+ for await (const chunk of ReasoningService.processTextStreaming(
+ llmMessages,
+ settings.agentModel,
+ settings.agentProvider,
+ { systemPrompt }
+ )) {
+ fullContent += chunk;
+ setMessages((prev) =>
+ prev.map((m) => (m.id === assistantId ? { ...m, content: fullContent } : m))
+ );
+ }
+
+ setMessages((prev) =>
+ prev.map((m) => (m.id === assistantId ? { ...m, isStreaming: false } : m))
+ );
+
+ if (conversationIdRef.current) {
+ window.electronAPI?.addAgentMessage?.(conversationIdRef.current, "assistant", fullContent);
+ }
+ } catch (error) {
+ setMessages((prev) =>
+ prev.map((m) =>
+ m.id === assistantId
+ ? { ...m, content: `Error: ${(error as Error).message}`, isStreaming: false }
+ : m
+ )
+ );
+ }
+
+ setAgentState("idle");
+ }, []);
+
+ useEffect(() => {
+ const am = new AudioManager();
+ am.setSkipReasoning(true);
+ am.setContext("agent");
+ am.setCallbacks({
+ onStateChange: ({ isRecording, isProcessing }: { isRecording: boolean; isProcessing: boolean }) => {
+ if (isRecording) setAgentState("listening");
+ else if (isProcessing) setAgentState("transcribing");
+ },
+ onError: (error: { message?: string }) => {
+ addSystemMessage(`Error: ${error.message || String(error)}`);
+ setAgentState("idle");
+ },
+ onTranscriptionComplete: (result: { text: string }) => {
+ handleTranscriptionComplete(result.text);
+ },
+ onPartialTranscript: (text: string) => {
+ setPartialTranscript(text);
+ },
+ onStreamingCommit: undefined,
+ });
+ audioManagerRef.current = am;
+ return () => {
+ window.removeEventListener("api-key-changed", (am as any)._onApiKeyChanged);
+ };
+ }, [addSystemMessage, handleTranscriptionComplete]);
+
+ const resizeToContent = useCallback(() => {
+ const el = containerRef.current;
+ if (!el) return;
+ const height = Math.max(MIN_HEIGHT, Math.min(el.scrollHeight, MAX_HEIGHT));
+ window.electronAPI?.resizeAgentWindow?.(WIDTH, height);
+ }, []);
+
+ useEffect(() => {
+ resizeToContent();
+ }, [messages, agentState, resizeToContent]);
+
+ useEffect(() => {
+ const observer = new ResizeObserver(() => {
+ resizeToContent();
+ });
+ if (containerRef.current) {
+ observer.observe(containerRef.current);
+ }
+ return () => observer.disconnect();
+ }, [resizeToContent]);
+
+ useEffect(() => {
+ const handleKeyDown = (e: KeyboardEvent) => {
+ if (e.key === "Escape") {
+ window.electronAPI?.hideAgentOverlay?.();
+ }
+ };
+ document.addEventListener("keydown", handleKeyDown);
+ return () => document.removeEventListener("keydown", handleKeyDown);
+ }, []);
+
+ useEffect(() => {
+ const unsubStart = window.electronAPI?.onAgentStartRecording?.(() => {
+ audioManagerRef.current?.startRecording();
+ });
+
+ const unsubStop = window.electronAPI?.onAgentStopRecording?.(() => {
+ audioManagerRef.current?.stopRecording();
+ });
+
+ return () => {
+ unsubStart?.();
+ unsubStop?.();
+ };
+ }, []);
+
+ const handleNewChat = useCallback(() => {
+ setMessages([]);
+ setAgentState("idle");
+ setPartialTranscript("");
+ conversationIdRef.current = null;
+ }, []);
+
+ const handleClose = useCallback(() => {
+ window.electronAPI?.hideAgentOverlay?.();
+ }, []);
+
+ return (
+ <div className="agent-overlay-window w-screen h-screen bg-transparent">
+ <div
+ ref={containerRef}
+ className={cn(
+ "flex flex-col w-full h-full",
+ "bg-surface-1/75 backdrop-blur-2xl",
+ "border border-border/40 rounded-lg",
+ "shadow-[var(--shadow-elevated)]",
+ "overflow-hidden"
+ )}
+ >
+ <AgentTitleBar onNewChat={handleNewChat} onClose={handleClose} />
+ <AgentChat messages={messages} />
+ <AgentInput agentState={agentState} partialTranscript={partialTranscript} />
+ </div>
+ </div>
+ );
+}
diff --git a/src/components/SettingsModal.tsx b/src/components/SettingsModal.tsx
index b1f889b7a..8bf26afc3 100644
--- a/src/components/SettingsModal.tsx
+++ b/src/components/SettingsModal.tsx
@@ -9,6 +9,7 @@ import {
Keyboard,
CreditCard,
Shield,
+ MessageSquare,
} from "lucide-react";
import SidebarModal, { SidebarItem } from "./ui/SidebarModal";
import SettingsPage, { SettingsSectionType } from "./SettingsPage";
@@ -78,6 +79,13 @@ export default function SettingsModal({ open, onOpenChange, initialSection }: Se
description: t("settingsModal.sections.intelligence.description"),
group: t("settingsModal.groups.speechAi"),
},
+ {
+ id: "agentMode",
+ label: t("settingsModal.sections.agentMode.label"),
+ icon: MessageSquare,
+ description: t("settingsModal.sections.agentMode.description"),
+ group: t("settingsModal.groups.speechAi"),
+ },
{
id: "privacyData",
label: t("settingsModal.sections.privacyData.label"),
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index 49e265165..1c4166053 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -52,6 +52,7 @@ import { getDefaultHotkey, formatHotkeyLabel } from "../utils/hotkeys";
import { ActivationModeSelector } from "./ui/ActivationModeSelector";
import { Toggle } from "./ui/toggle";
import DeveloperSection from "./DeveloperSection";
+import AgentModeSettings from "./settings/AgentModeSettings";
import LanguageSelector from "./ui/LanguageSelector";
import { Skeleton } from "./ui/skeleton";
import { Progress } from "./ui/progress";
@@ -75,7 +76,8 @@ export type SettingsSectionType =
| "dictionary"
| "aiModels"
| "agentConfig"
- | "prompts";
+ | "prompts"
+ | "agentMode";
interface SettingsPageProps {
activeSection?: SettingsSectionType;
@@ -2738,6 +2740,9 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage
</div>
);
+ case "agentMode":
+ return <AgentModeSettings />;
+
default:
return null;
}
diff --git a/src/components/agent/AgentChat.tsx b/src/components/agent/AgentChat.tsx
new file mode 100644
index 000000000..7fab08faa
--- /dev/null
+++ b/src/components/agent/AgentChat.tsx
@@ -0,0 +1,56 @@
+import { useRef, useEffect } from "react";
+import { useTranslation } from "react-i18next";
+import { cn } from "../lib/utils";
+import { AgentMessage } from "./AgentMessage";
+
+interface Message {
+ id: string;
+ role: "user" | "assistant";
+ content: string;
+ isStreaming: boolean;
+}
+
+interface AgentChatProps {
+ messages: Message[];
+}
+
+export function AgentChat({ messages }: AgentChatProps) {
+ const { t } = useTranslation();
+ const scrollRef = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ const el = scrollRef.current;
+ if (el) {
+ el.scrollTop = el.scrollHeight;
+ }
+ }, [messages]);
+
+ return (
+ <div
+ ref={scrollRef}
+ className={cn(
+ "flex-1 overflow-y-auto agent-chat-scroll",
+ "px-3 py-2"
+ )}
+ >
+ {messages.length === 0 ? (
+ <div className="flex items-center justify-center h-full">
+ <p className="text-[12px] text-muted-foreground/60 text-center select-none">
+ {t("agentMode.chat.emptyState")}
+ </p>
+ </div>
+ ) : (
+ <div className="flex flex-col gap-2">
+ {messages.map((msg) => (
+ <AgentMessage
+ key={msg.id}
+ role={msg.role}
+ content={msg.content}
+ isStreaming={msg.isStreaming}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/src/components/agent/AgentInput.tsx b/src/components/agent/AgentInput.tsx
new file mode 100644
index 000000000..8020ba1d1
--- /dev/null
+++ b/src/components/agent/AgentInput.tsx
@@ -0,0 +1,97 @@
+import { Mic } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { cn } from "../lib/utils";
+
+type AgentState = "idle" | "listening" | "transcribing" | "thinking" | "streaming";
+
+interface AgentInputProps {
+ agentState: AgentState;
+ partialTranscript: string;
+}
+
+function WaveBars() {
+ return (
+ <div className="flex items-center justify-center gap-[3px] h-4">
+ {[0, 1, 2, 3].map((i) => (
+ <div
+ key={i}
+ className="w-[3px] bg-primary rounded-full origin-center"
+ style={{
+ animation: `waveform-bar 0.8s ease-in-out ${i * 0.12}s infinite`,
+ height: "16px",
+ }}
+ />
+ ))}
+ </div>
+ );
+}
+
+function InputLoadingDots() {
+ return (
+ <div className="flex items-center gap-1">
+ {[0, 1, 2].map((i) => (
+ <div
+ key={i}
+ className="w-1.5 h-1.5 rounded-full bg-muted-foreground/60"
+ style={{
+ animation: `agent-loading-dot 1.2s ease-in-out ${i * 0.2}s infinite`,
+ }}
+ />
+ ))}
+ </div>
+ );
+}
+
+export function AgentInput({ agentState, partialTranscript }: AgentInputProps) {
+ const { t } = useTranslation();
+
+ return (
+ <div
+ className={cn(
+ "flex items-center gap-3 h-12 px-3 py-2 shrink-0",
+ "bg-surface-1/50 backdrop-blur-xl border-t border-border/20"
+ )}
+ >
+ {agentState === "idle" && (
+ <>
+ <div
+ className="text-muted-foreground/50"
+ style={{ animation: "agent-mic-pulse 2.5s ease-in-out infinite" }}
+ >
+ <Mic size={16} />
+ </div>
+ <span className="text-[12px] text-muted-foreground/50 select-none">
+ {t("agentMode.input.idle")}
+ </span>
+ </>
+ )}
+
+ {agentState === "listening" && (
+ <>
+ <WaveBars />
+ <span className="text-[12px] text-foreground/80 truncate flex-1">
+ {partialTranscript || t("agentMode.input.listening")}
+ </span>
+ </>
+ )}
+
+ {agentState === "transcribing" && (
+ <>
+ <InputLoadingDots />
+ <span className="text-[12px] text-muted-foreground select-none">
+ {t("agentMode.input.transcribing")}
+ </span>
+ </>
+ )}
+
+ {(agentState === "thinking" || agentState === "streaming") && (
+ <>
+ <InputLoadingDots />
+ <span className="text-[12px] text-muted-foreground select-none">
+ {t("agentMode.input.thinking")}
+ </span>
+ </>
+ )}
+ </div>
+ );
+}
diff --git a/src/components/agent/AgentMessage.tsx b/src/components/agent/AgentMessage.tsx
new file mode 100644
index 000000000..aa2f5005c
--- /dev/null
+++ b/src/components/agent/AgentMessage.tsx
@@ -0,0 +1,82 @@
+import { useState } from "react";
+import { Copy, Check } from "lucide-react";
+import { cn } from "../lib/utils";
+import { MarkdownRenderer } from "../ui/MarkdownRenderer";
+
+interface AgentMessageProps {
+ role: "user" | "assistant";
+ content: string;
+ isStreaming: boolean;
+}
+
+export function AgentMessage({ role, content, isStreaming }: AgentMessageProps) {
+ const [copied, setCopied] = useState(false);
+
+ const handleCopy = async () => {
+ try {
+ await navigator.clipboard.writeText(content);
+ setCopied(true);
+ setTimeout(() => setCopied(false), 1500);
+ } catch {
+ // clipboard unavailable
+ }
+ };
+
+ if (role === "user") {
+ return (
+ <div
+ className="flex justify-end"
+ style={{ animation: "agent-message-in 200ms ease-out both" }}
+ >
+ <div
+ className={cn(
+ "max-w-[85%] px-3 py-2 rounded-lg rounded-br-sm",
+ "bg-primary/90 text-primary-foreground",
+ "text-[13px] leading-relaxed"
+ )}
+ >
+ {content}
+ </div>
+ </div>
+ );
+ }
+
+ return (
+ <div
+ className="group/msg flex justify-start"
+ style={{ animation: "agent-message-in 200ms ease-out both" }}
+ >
+ <div
+ className={cn(
+ "relative max-w-[85%] px-3 py-2 rounded-lg rounded-bl-sm",
+ "bg-surface-2/80 backdrop-blur-lg border border-border/40 text-foreground",
+ "text-[13px] leading-relaxed"
+ )}
+ >
+ <button
+ onClick={handleCopy}
+ className={cn(
+ "absolute top-1.5 right-1.5 p-1 rounded-sm",
+ "text-muted-foreground hover:text-foreground hover:bg-foreground/10",
+ "opacity-0 group-hover/msg:opacity-100 transition-opacity duration-150",
+ "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring/30"
+ )}
+ >
+ {copied ? <Check size={14} /> : <Copy size={14} />}
+ </button>
+
+ <MarkdownRenderer
+ content={content}
+ className="text-[13px] leading-relaxed [&_p]:text-[13px] [&_li]:text-[13px]"
+ />
+
+ {isStreaming && (
+ <span
+ className="inline-block w-[2px] h-[14px] bg-foreground align-middle ml-0.5"
+ style={{ animation: "agent-cursor-blink 800ms steps(1) infinite" }}
+ />
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/src/components/agent/AgentTitleBar.tsx b/src/components/agent/AgentTitleBar.tsx
new file mode 100644
index 000000000..341c922a8
--- /dev/null
+++ b/src/components/agent/AgentTitleBar.tsx
@@ -0,0 +1,57 @@
+import { Plus, X } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { cn } from "../lib/utils";
+
+interface AgentTitleBarProps {
+ onNewChat: () => void;
+ onClose: () => void;
+}
+
+export function AgentTitleBar({ onNewChat, onClose }: AgentTitleBarProps) {
+ const { t } = useTranslation();
+
+ return (
+ <div
+ className={cn(
+ "flex items-center justify-between h-8 px-3",
+ "bg-transparent border-b border-border/20",
+ "select-none"
+ )}
+ style={{ WebkitAppRegion: "drag" } as React.CSSProperties}
+ >
+ <span className="text-[11px] text-muted-foreground font-medium tracking-wide uppercase">
+ {t("agentMode.titleBar.label")}
+ </span>
+
+ <div
+ className="flex items-center gap-0.5"
+ style={{ WebkitAppRegion: "no-drag" } as React.CSSProperties}
+ >
+ <button
+ onClick={onNewChat}
+ className={cn(
+ "p-1 rounded-sm",
+ "text-muted-foreground hover:text-foreground hover:bg-foreground/10",
+ "transition-colors duration-150",
+ "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring/30"
+ )}
+ aria-label={t("agentMode.titleBar.newChat")}
+ >
+ <Plus size={14} />
+ </button>
+ <button
+ onClick={onClose}
+ className={cn(
+ "p-1 rounded-sm",
+ "text-muted-foreground hover:text-foreground hover:bg-foreground/10",
+ "transition-colors duration-150",
+ "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring/30"
+ )}
+ aria-label={t("agentMode.titleBar.close")}
+ >
+ <X size={14} />
+ </button>
+ </div>
+ </div>
+ );
+}
diff --git a/src/components/settings/AgentModeSettings.tsx b/src/components/settings/AgentModeSettings.tsx
new file mode 100644
index 000000000..145132a4c
--- /dev/null
+++ b/src/components/settings/AgentModeSettings.tsx
@@ -0,0 +1,149 @@
+import { useTranslation } from "react-i18next";
+import { useSettingsStore } from "../../stores/settingsStore";
+import { HotkeyInput } from "../ui/HotkeyInput";
+import { Toggle } from "../ui/toggle";
+import { SettingsRow, SettingsPanel, SettingsPanelRow, SectionHeader } from "../ui/SettingsSection";
+import { ProviderTabs } from "../ui/ProviderTabs";
+import { REASONING_PROVIDERS } from "../../models/ModelRegistry";
+import { getProviderIcon, isMonochromeProvider } from "../../utils/providerIcons";
+import { cn } from "../lib/utils";
+
+export default function AgentModeSettings() {
+ const { t } = useTranslation();
+ const {
+ agentEnabled,
+ setAgentEnabled,
+ agentKey,
+ setAgentKey,
+ agentModel,
+ setAgentModel,
+ agentProvider,
+ setAgentProvider,
+ agentSystemPrompt,
+ setAgentSystemPrompt,
+ } = useSettingsStore();
+
+ const providerTabs = Object.entries(REASONING_PROVIDERS)
+ .filter(([id]) => id !== "local")
+ .map(([id, provider]) => ({
+ id,
+ name: provider.name,
+ }));
+
+ const currentProviderModels = REASONING_PROVIDERS[agentProvider]?.models ?? [];
+
+ return (
+ <div className="space-y-6">
+ <SectionHeader
+ title={t("agentMode.settings.title")}
+ description={t("agentMode.settings.description")}
+ />
+
+ {/* Enable/Disable */}
+ <SettingsPanel>
+ <SettingsPanelRow>
+ <SettingsRow
+ label={t("agentMode.settings.enabled")}
+ description={t("agentMode.settings.enabledDescription")}
+ >
+ <Toggle checked={agentEnabled} onChange={setAgentEnabled} />
+ </SettingsRow>
+ </SettingsPanelRow>
+ </SettingsPanel>
+
+ {agentEnabled && (
+ <>
+ {/* Agent Hotkey */}
+ <div>
+ <SectionHeader
+ title={t("agentMode.settings.hotkey")}
+ description={t("agentMode.settings.hotkeyDescription")}
+ />
+ <HotkeyInput value={agentKey} onChange={setAgentKey} />
+ </div>
+
+ {/* Agent Model */}
+ <div>
+ <SectionHeader
+ title={t("agentMode.settings.model")}
+ description={t("agentMode.settings.modelDescription")}
+ />
+
+ <div className="space-y-3">
+ <ProviderTabs
+ providers={providerTabs}
+ selectedId={agentProvider}
+ onSelect={(id) => {
+ setAgentProvider(id);
+ const models = REASONING_PROVIDERS[id]?.models;
+ if (models && models.length > 0) {
+ setAgentModel(models[0].value);
+ }
+ }}
+ renderIcon={(providerId) => {
+ const icon = getProviderIcon(providerId);
+ if (!icon) return null;
+ return (
+ <img
+ src={icon}
+ alt=""
+ className={cn(
+ "w-3.5 h-3.5",
+ isMonochromeProvider(providerId) && "dark:invert"
+ )}
+ />
+ );
+ }}
+ colorScheme="dynamic"
+ scrollable
+ />
+
+ <SettingsPanel>
+ <SettingsPanelRow>
+ <div className="space-y-1.5">
+ {currentProviderModels.map((model) => (
+ <button
+ key={model.value}
+ onClick={() => setAgentModel(model.value)}
+ className={cn(
+ "w-full text-left px-3 py-2 rounded-md text-xs transition-colors",
+ agentModel === model.value
+ ? "bg-primary/10 dark:bg-primary/15 text-primary border border-primary/20"
+ : "hover:bg-muted/60 dark:hover:bg-surface-raised text-foreground border border-transparent"
+ )}
+ >
+ <span className="font-medium">{model.label}</span>
+ {model.description && (
+ <span className="text-muted-foreground ml-1.5">{model.description}</span>
+ )}
+ </button>
+ ))}
+ </div>
+ </SettingsPanelRow>
+ </SettingsPanel>
+ </div>
+ </div>
+
+ {/* Custom System Prompt */}
+ <div>
+ <SectionHeader
+ title={t("agentMode.settings.systemPrompt")}
+ description={t("agentMode.settings.systemPromptDescription")}
+ />
+ <SettingsPanel>
+ <SettingsPanelRow>
+ <textarea
+ value={agentSystemPrompt}
+ onChange={(e) => setAgentSystemPrompt(e.target.value)}
+ placeholder={t("agentMode.settings.systemPromptPlaceholder")}
+ rows={4}
+ className="w-full text-xs bg-transparent border border-border/50 rounded-md px-3 py-2 resize-y focus:outline-none focus:ring-2 focus:ring-ring/40 focus:border-primary/30 placeholder:text-muted-foreground/50"
+ />
+ </SettingsPanelRow>
+ </SettingsPanel>
+ </div>
+ </>
+ )}
+ </div>
+ );
+}
diff --git a/src/components/ui/SettingsSection.tsx b/src/components/ui/SettingsSection.tsx
index 875aed2cb..ec176d7e5 100644
--- a/src/components/ui/SettingsSection.tsx
+++ b/src/components/ui/SettingsSection.tsx
@@ -78,3 +78,40 @@ export const SettingsRow: React.FC<SettingsRowProps> = ({
</div>
);
};
+
+export function SettingsPanel({
+ children,
+ className = "",
+}: {
+ children: React.ReactNode;
+ className?: string;
+}) {
+ return (
+ <div
+ className={`rounded-lg border border-border/50 dark:border-border-subtle/70 bg-card/50 dark:bg-surface-2/50 backdrop-blur-sm divide-y divide-border/30 dark:divide-border-subtle/50 ${className}`}
+ >
+ {children}
+ </div>
+ );
+}
+
+export function SettingsPanelRow({
+ children,
+ className = "",
+}: {
+ children: React.ReactNode;
+ className?: string;
+}) {
+ return <div className={`px-4 py-3 ${className}`}>{children}</div>;
+}
+
+export function SectionHeader({ title, description }: { title: string; description?: string }) {
+ return (
+ <div className="mb-3">
+ <h3 className="text-xs font-semibold text-foreground tracking-tight">{title}</h3>
+ {description && (
+ <p className="text-xs text-muted-foreground/80 mt-0.5 leading-relaxed">{description}</p>
+ )}
+ </div>
+ );
+}
diff --git a/src/config/prompts.ts b/src/config/prompts.ts
index 7cef3fcbc..007e8d7f2 100644
--- a/src/config/prompts.ts
+++ b/src/config/prompts.ts
@@ -81,11 +81,25 @@ export function getWordBoost(customDictionary?: string[]): string[] {
return customDictionary.filter((w) => w.trim());
}
+const DEFAULT_AGENT_SYSTEM_PROMPT =
+ "You are a helpful voice assistant. Respond concisely and conversationally. " +
+ "Keep answers brief unless the user asks for detail. " +
+ "You may be given a transcription of spoken input, so handle informal phrasing gracefully.";
+
+export function getAgentSystemPrompt(): string {
+ if (typeof window !== "undefined" && window.localStorage) {
+ const custom = window.localStorage.getItem("agentSystemPrompt");
+ if (custom) return custom;
+ }
+ return DEFAULT_AGENT_SYSTEM_PROMPT;
+}
+
export default {
CLEANUP_PROMPT,
FULL_PROMPT,
UNIFIED_SYSTEM_PROMPT,
getSystemPrompt,
getWordBoost,
+ getAgentSystemPrompt,
LEGACY_PROMPTS,
};
diff --git a/src/helpers/database.js b/src/helpers/database.js
index 423c8faa7..d4cd294fd 100644
--- a/src/helpers/database.js
+++ b/src/helpers/database.js
@@ -120,6 +120,29 @@ class DatabaseManager {
if (!err.message.includes("duplicate column")) throw err;
}
+ this.db.exec(`
+ CREATE TABLE IF NOT EXISTS agent_conversations (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ title TEXT NOT NULL DEFAULT 'Untitled',
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
+ )
+ `);
+
+ this.db.exec(`
+ CREATE TABLE IF NOT EXISTS agent_messages (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ conversation_id INTEGER NOT NULL REFERENCES agent_conversations(id) ON DELETE CASCADE,
+ role TEXT NOT NULL CHECK(role IN ('user', 'assistant', 'system')),
+ content TEXT NOT NULL,
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP
+ )
+ `);
+
+ this.db.exec(
+ "CREATE INDEX IF NOT EXISTS idx_agent_messages_conversation ON agent_messages(conversation_id)"
+ );
+
const actionCount = this.db.prepare("SELECT COUNT(*) as count FROM actions").get();
if (actionCount.count === 0) {
this.db
@@ -530,6 +553,141 @@ class DatabaseManager {
}
}
+ createAgentConversation(title = "Untitled") {
+ try {
+ if (!this.db) throw new Error("Database not initialized");
+ const result = this.db
+ .prepare("INSERT INTO agent_conversations (title) VALUES (?)")
+ .run(title);
+ return this.db
+ .prepare("SELECT * FROM agent_conversations WHERE id = ?")
+ .get(result.lastInsertRowid);
+ } catch (error) {
+ debugLogger.error(
+ "Error creating agent conversation",
+ { error: error.message },
+ "database"
+ );
+ throw error;
+ }
+ }
+
+ getAgentConversations(limit = 50) {
+ try {
+ if (!this.db) throw new Error("Database not initialized");
+ return this.db
+ .prepare("SELECT * FROM agent_conversations ORDER BY updated_at DESC LIMIT ?")
+ .all(limit);
+ } catch (error) {
+ debugLogger.error(
+ "Error getting agent conversations",
+ { error: error.message },
+ "database"
+ );
+ throw error;
+ }
+ }
+
+ getAgentConversation(id) {
+ try {
+ if (!this.db) throw new Error("Database not initialized");
+ const conversation = this.db
+ .prepare("SELECT * FROM agent_conversations WHERE id = ?")
+ .get(id);
+ if (!conversation) return null;
+ const messages = this.db
+ .prepare("SELECT * FROM agent_messages WHERE conversation_id = ? ORDER BY created_at ASC")
+ .all(id);
+ return { ...conversation, messages };
+ } catch (error) {
+ debugLogger.error(
+ "Error getting agent conversation",
+ { error: error.message },
+ "database"
+ );
+ throw error;
+ }
+ }
+
+ deleteAgentConversation(id) {
+ try {
+ if (!this.db) throw new Error("Database not initialized");
+ this.db.prepare("DELETE FROM agent_messages WHERE conversation_id = ?").run(id);
+ const result = this.db
+ .prepare("DELETE FROM agent_conversations WHERE id = ?")
+ .run(id);
+ return { success: result.changes > 0 };
+ } catch (error) {
+ debugLogger.error(
+ "Error deleting agent conversation",
+ { error: error.message },
+ "database"
+ );
+ throw error;
+ }
+ }
+
+ updateAgentConversationTitle(id, title) {
+ try {
+ if (!this.db) throw new Error("Database not initialized");
+ this.db
+ .prepare(
+ "UPDATE agent_conversations SET title = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?"
+ )
+ .run(title, id);
+ return { success: true };
+ } catch (error) {
+ debugLogger.error(
+ "Error updating agent conversation title",
+ { error: error.message },
+ "database"
+ );
+ throw error;
+ }
+ }
+
+ addAgentMessage(conversationId, role, content) {
+ try {
+ if (!this.db) throw new Error("Database not initialized");
+ const result = this.db
+ .prepare(
+ "INSERT INTO agent_messages (conversation_id, role, content) VALUES (?, ?, ?)"
+ )
+ .run(conversationId, role, content);
+ this.db
+ .prepare(
+ "UPDATE agent_conversations SET updated_at = CURRENT_TIMESTAMP WHERE id = ?"
+ )
+ .run(conversationId);
+ return this.db
+ .prepare("SELECT * FROM agent_messages WHERE id = ?")
+ .get(result.lastInsertRowid);
+ } catch (error) {
+ debugLogger.error(
+ "Error adding agent message",
+ { error: error.message },
+ "database"
+ );
+ throw error;
+ }
+ }
+
+ getAgentMessages(conversationId) {
+ try {
+ if (!this.db) throw new Error("Database not initialized");
+ return this.db
+ .prepare("SELECT * FROM agent_messages WHERE conversation_id = ? ORDER BY created_at ASC")
+ .all(conversationId);
+ } catch (error) {
+ debugLogger.error(
+ "Error getting agent messages",
+ { error: error.message },
+ "database"
+ );
+ throw error;
+ }
+ }
+
cleanup() {
try {
const dbPath = path.join(
diff --git a/src/helpers/environment.js b/src/helpers/environment.js
index e9ca5e741..32b8d4110 100644
--- a/src/helpers/environment.js
+++ b/src/helpers/environment.js
@@ -131,6 +131,16 @@ class EnvironmentManager {
return result;
}
+ getAgentKey() {
+ return this._getKey("AGENT_KEY");
+ }
+
+ saveAgentKey(key) {
+ const result = this._saveKey("AGENT_KEY", key);
+ this.saveAllKeysToEnvFile().catch(() => {});
+ return result;
+ }
+
getActivationMode() {
const mode = this._getKey("ACTIVATION_MODE");
return mode === "push" ? "push" : "tap";
diff --git a/src/helpers/hotkeyManager.js b/src/helpers/hotkeyManager.js
index f19db216f..996fb43e7 100644
--- a/src/helpers/hotkeyManager.js
+++ b/src/helpers/hotkeyManager.js
@@ -58,12 +58,34 @@ const SUGGESTED_HOTKEYS = {
class HotkeyManager {
constructor() {
- this.currentHotkey = process.platform === "darwin" ? "GLOBE" : "Control+Super";
+ this.slots = new Map();
+ const defaultDictation = process.platform === "darwin" ? "GLOBE" : "Control+Super";
+ this.slots.set("dictation", { hotkey: defaultDictation, callback: null, accelerator: null });
this.isInitialized = false;
this.isListeningMode = false;
this.gnomeManager = null;
this.useGnome = false;
- this.hotkeyCallback = null;
+ }
+
+ // Backward-compatible property accessors
+ get currentHotkey() {
+ return this.slots.get("dictation")?.hotkey ?? null;
+ }
+
+ set currentHotkey(value) {
+ const slot = this.slots.get("dictation") || { hotkey: null, callback: null, accelerator: null };
+ slot.hotkey = value;
+ this.slots.set("dictation", slot);
+ }
+
+ get hotkeyCallback() {
+ return this.slots.get("dictation")?.callback ?? null;
+ }
+
+ set hotkeyCallback(value) {
+ const slot = this.slots.get("dictation") || { hotkey: null, callback: null, accelerator: null };
+ slot.callback = value;
+ this.slots.set("dictation", slot);
}
setListeningMode(enabled) {
@@ -117,42 +139,78 @@ class HotkeyManager {
return suggestions.filter((s) => s !== failedHotkey).slice(0, 3);
}
- setupShortcuts(hotkey = "Control+Super", callback) {
+ registerSlot(slotName, hotkey, callback) {
+ this.unregisterSlot(slotName);
+ const result = this.setupShortcuts(hotkey, callback, slotName);
+ if (result.success) {
+ const slot = this.slots.get(slotName) || {};
+ slot.callback = callback;
+ this.slots.set(slotName, slot);
+ }
+ return result;
+ }
+
+ unregisterSlot(slotName) {
+ const slot = this.slots.get(slotName);
+ if (!slot || !slot.hotkey) return;
+
+ const hk = slot.hotkey;
+ if (
+ !isGlobeLikeHotkey(hk) &&
+ !isRightSideModifier(hk) &&
+ !isModifierOnlyHotkey(hk)
+ ) {
+ const accel = normalizeToAccelerator(hk);
+ try {
+ globalShortcut.unregister(accel);
+ } catch {
+ // already unregistered
+ }
+ }
+ slot.hotkey = null;
+ slot.accelerator = null;
+ }
+
+ getSlotHotkey(slotName) {
+ return this.slots.get(slotName)?.hotkey ?? null;
+ }
+
+ setupShortcuts(hotkey = "Control+Super", callback, slotName = "dictation") {
if (!callback) {
throw new Error(i18nMain.t("hotkey.errors.callbackRequired"));
}
- debugLogger.log(`[HotkeyManager] Setting up hotkey: "${hotkey}"`);
+ const slot = this.slots.get(slotName) || { hotkey: null, callback: null, accelerator: null };
+ this.slots.set(slotName, slot);
+
+ debugLogger.log(`[HotkeyManager] Setting up hotkey: "${hotkey}" for slot "${slotName}"`);
debugLogger.log(`[HotkeyManager] Platform: ${process.platform}, Arch: ${process.arch}`);
- debugLogger.log(`[HotkeyManager] Current hotkey: "${this.currentHotkey}"`);
+ debugLogger.log(`[HotkeyManager] Current hotkey for slot: "${slot.hotkey}"`);
- // If we're already using this hotkey AND it's actually registered, return success
- // Note: We need to check isRegistered because on first run, currentHotkey is set to the
- // default value but it's not actually registered yet.
const checkAccelerator = normalizeToAccelerator(hotkey);
if (
- hotkey === this.currentHotkey &&
+ hotkey === slot.hotkey &&
!isGlobeLikeHotkey(hotkey) &&
!isRightSideModifier(hotkey) &&
!isModifierOnlyHotkey(hotkey) &&
globalShortcut.isRegistered(checkAccelerator)
) {
debugLogger.log(
- `[HotkeyManager] Hotkey "${hotkey}" is already the current hotkey and registered, no change needed`
+ `[HotkeyManager] Hotkey "${hotkey}" is already registered for slot "${slotName}", no change needed`
);
return { success: true, hotkey };
}
- const previousHotkey = this.currentHotkey;
+ const previousHotkey = slot.hotkey;
- // Unregister the previous hotkey (skip native-listener-only hotkeys)
+ // Unregister the previous hotkey for this slot (skip native-listener-only hotkeys)
if (
- this.currentHotkey &&
- !isGlobeLikeHotkey(this.currentHotkey) &&
- !isRightSideModifier(this.currentHotkey) &&
- !isModifierOnlyHotkey(this.currentHotkey)
+ previousHotkey &&
+ !isGlobeLikeHotkey(previousHotkey) &&
+ !isRightSideModifier(previousHotkey) &&
+ !isModifierOnlyHotkey(previousHotkey)
) {
- const prevAccelerator = normalizeToAccelerator(this.currentHotkey);
+ const prevAccelerator = normalizeToAccelerator(previousHotkey);
try {
debugLogger.log(`[HotkeyManager] Unregistering previous hotkey: "${prevAccelerator}"`);
globalShortcut.unregister(prevAccelerator);
@@ -172,23 +230,24 @@ class HotkeyManager {
error: i18nMain.t("hotkey.errors.globeOnlyMac"),
};
}
- this.currentHotkey = hotkey;
+ slot.hotkey = hotkey;
+ slot.accelerator = null;
debugLogger.log(`[HotkeyManager] GLOBE/Fn key "${hotkey}" set successfully`);
return { success: true, hotkey };
}
- // Right-side single modifiers are handled by native listeners (Swift/C), not globalShortcut
if (isRightSideModifier(hotkey)) {
- this.currentHotkey = hotkey;
+ slot.hotkey = hotkey;
+ slot.accelerator = null;
debugLogger.log(
`[HotkeyManager] Right-side modifier "${hotkey}" set - using native listener`
);
return { success: true, hotkey };
}
- // Modifier-only combos use the native keyboard hook on Windows
if (isModifierOnlyHotkey(hotkey) && process.platform === "win32") {
- this.currentHotkey = hotkey;
+ slot.hotkey = hotkey;
+ slot.accelerator = null;
debugLogger.log(
`[HotkeyManager] Modifier-only "${hotkey}" set - using Windows native listener`
);
@@ -210,7 +269,8 @@ class HotkeyManager {
debugLogger.log(`[HotkeyManager] Registration result for "${hotkey}": ${success}`);
if (success) {
- this.currentHotkey = hotkey;
+ slot.hotkey = hotkey;
+ slot.accelerator = accelerator;
debugLogger.log(`[HotkeyManager] Hotkey "${hotkey}" registered successfully`);
return { success: true, hotkey };
} else {
@@ -542,6 +602,13 @@ class HotkeyManager {
this.gnomeManager = null;
this.useGnome = false;
}
+ for (const slotName of this.slots.keys()) {
+ const slot = this.slots.get(slotName);
+ if (slot) {
+ slot.hotkey = null;
+ slot.accelerator = null;
+ }
+ }
globalShortcut.unregisterAll();
}
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index b6f4a95d3..4b624f0f9 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -106,6 +106,7 @@ class IPCHandlers {
this._autoLearnDebounceTimer = null;
this._autoLearnLatestData = null;
this._textEditHandler = null;
+ this._activeRecordingPipeline = null;
this._setupTextEditMonitor();
this.setupHandlers();
@@ -522,6 +523,35 @@ class IPCHandlers {
return result;
});
+ // Agent conversation handlers
+ ipcMain.handle("db-create-agent-conversation", async (event, title) => {
+ return this.databaseManager.createAgentConversation(title);
+ });
+
+ ipcMain.handle("db-get-agent-conversations", async (event, limit) => {
+ return this.databaseManager.getAgentConversations(limit);
+ });
+
+ ipcMain.handle("db-get-agent-conversation", async (event, id) => {
+ return this.databaseManager.getAgentConversation(id);
+ });
+
+ ipcMain.handle("db-delete-agent-conversation", async (event, id) => {
+ return this.databaseManager.deleteAgentConversation(id);
+ });
+
+ ipcMain.handle("db-update-agent-conversation-title", async (event, id, title) => {
+ return this.databaseManager.updateAgentConversationTitle(id, title);
+ });
+
+ ipcMain.handle("db-add-agent-message", async (event, conversationId, role, content) => {
+ return this.databaseManager.addAgentMessage(conversationId, role, content);
+ });
+
+ ipcMain.handle("db-get-agent-messages", async (event, conversationId) => {
+ return this.databaseManager.getAgentMessages(conversationId);
+ });
+
ipcMain.handle("export-note", async (event, noteId, format) => {
try {
const note = this.databaseManager.getNote(noteId);
@@ -2869,6 +2899,54 @@ class IPCHandlers {
}
return this.deepgramStreaming.getStatus();
});
+
+ // Agent mode handlers
+ ipcMain.handle("update-agent-hotkey", async (_event, hotkey) => {
+ const hotkeyManager = this.windowManager.hotkeyManager;
+ const agentCallback = this.windowManager._agentHotkeyCallback;
+ if (!agentCallback) {
+ return { success: false, message: "Agent hotkey callback not initialized" };
+ }
+ return hotkeyManager.registerSlot("agent", hotkey, agentCallback);
+ });
+
+ ipcMain.handle("get-agent-key", async () => {
+ return this.environmentManager.getAgentKey?.() || "";
+ });
+
+ ipcMain.handle("save-agent-key", async (_event, key) => {
+ return this.environmentManager.saveAgentKey?.(key) || { success: true };
+ });
+
+ ipcMain.handle("toggle-agent-overlay", async () => {
+ this.windowManager.toggleAgentOverlay();
+ return { success: true };
+ });
+
+ ipcMain.handle("hide-agent-overlay", async () => {
+ this.windowManager.hideAgentOverlay();
+ return { success: true };
+ });
+
+ ipcMain.handle("resize-agent-window", async (_event, width, height) => {
+ this.windowManager.resizeAgentWindow(width, height);
+ return { success: true };
+ });
+
+ ipcMain.handle("acquire-recording-lock", async (_event, pipeline) => {
+ if (this._activeRecordingPipeline && this._activeRecordingPipeline !== pipeline) {
+ return { success: false, holder: this._activeRecordingPipeline };
+ }
+ this._activeRecordingPipeline = pipeline;
+ return { success: true };
+ });
+
+ ipcMain.handle("release-recording-lock", async (_event, pipeline) => {
+ if (this._activeRecordingPipeline === pipeline) {
+ this._activeRecordingPipeline = null;
+ }
+ return { success: true };
+ });
}
broadcastToWindows(channel, payload) {
diff --git a/src/helpers/windowConfig.js b/src/helpers/windowConfig.js
index 4ce7867d2..db0d45687 100644
--- a/src/helpers/windowConfig.js
+++ b/src/helpers/windowConfig.js
@@ -104,9 +104,41 @@ class WindowPositionUtil {
}
}
+const AGENT_OVERLAY_CONFIG = {
+ width: 420,
+ height: 300,
+ minWidth: 360,
+ minHeight: 200,
+ maxWidth: 600,
+ maxHeight: 700,
+ frame: false,
+ alwaysOnTop: true,
+ transparent: true,
+ show: false,
+ skipTaskbar: true,
+ hasShadow: false,
+ focusable: true,
+ resizable: false,
+ fullScreenable: false,
+ acceptsFirstMouse: true,
+ type:
+ process.platform === "darwin" ? "panel" : process.platform === "linux" ? "toolbar" : "normal",
+ visibleOnAllWorkspaces: process.platform !== "win32",
+ webPreferences: {
+ preload: path.join(__dirname, "..", "..", "preload.js"),
+ nodeIntegration: false,
+ contextIsolation: true,
+ sandbox: false,
+ webSecurity: false,
+ spellcheck: false,
+ backgroundThrottling: false,
+ },
+};
+
module.exports = {
MAIN_WINDOW_CONFIG,
CONTROL_PANEL_CONFIG,
+ AGENT_OVERLAY_CONFIG,
WINDOW_SIZES,
WindowPositionUtil,
};
diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.js
index 9dd234773..b71a42f4f 100644
--- a/src/helpers/windowManager.js
+++ b/src/helpers/windowManager.js
@@ -10,6 +10,7 @@ const { DEV_SERVER_PORT } = DevServerManager;
const {
MAIN_WINDOW_CONFIG,
CONTROL_PANEL_CONFIG,
+ AGENT_OVERLAY_CONFIG,
WINDOW_SIZES,
WindowPositionUtil,
} = require("./windowConfig");
@@ -18,6 +19,7 @@ class WindowManager {
constructor() {
this.mainWindow = null;
this.controlPanelWindow = null;
+ this.agentWindow = null;
this.tray = null;
this.hotkeyManager = new HotkeyManager();
this.dragManager = new DragManager();
@@ -124,18 +126,24 @@ class WindowManager {
return { success: true, bounds: { x: newX, y: newY, ...newSize } };
}
- async loadWindowContent(window, isControlPanel = false) {
+ async loadWindowContent(window, isControlPanel = false, isAgent = false) {
if (process.env.NODE_ENV === "development") {
- const appUrl = DevServerManager.getAppUrl(isControlPanel);
+ let appUrl = DevServerManager.getAppUrl(isControlPanel);
+ if (isAgent) {
+ appUrl = `${DevServerManager.getAppUrl(false)}?agent=true`;
+ }
await DevServerManager.waitForDevServer();
await window.loadURL(appUrl);
} else {
- // Production: use loadFile() for better compatibility with Electron 36+
const fileInfo = DevServerManager.getAppFilePath(isControlPanel);
if (!fileInfo) {
throw new Error("Failed to get app file path");
}
+ if (isAgent) {
+ fileInfo.query = { agent: "true" };
+ }
+
const fs = require("fs");
if (!fs.existsSync(fileInfo.path)) {
throw new Error(`HTML file not found: ${fileInfo.path}`);
@@ -561,6 +569,95 @@ class WindowManager {
await this.loadWindowContent(this.controlPanelWindow, true);
}
+ async createAgentWindow() {
+ if (this.agentWindow && !this.agentWindow.isDestroyed()) {
+ return;
+ }
+
+ this.agentWindow = new BrowserWindow(AGENT_OVERLAY_CONFIG);
+
+ this.agentWindow.once("ready-to-show", () => {
+ WindowPositionUtil.setupAlwaysOnTop(this.agentWindow);
+ });
+
+ this.agentWindow.on("closed", () => {
+ this.agentWindow = null;
+ });
+
+ await this.loadWindowContent(this.agentWindow, false, true);
+ }
+
+ toggleAgentOverlay() {
+ if (!this.agentWindow || this.agentWindow.isDestroyed()) return;
+
+ if (this.agentWindow.isVisible()) {
+ this.hideAgentOverlay();
+ } else {
+ this.showAgentOverlay();
+ }
+ }
+
+ showAgentOverlay() {
+ if (!this.agentWindow || this.agentWindow.isDestroyed()) return;
+
+ this._positionAgentWindow();
+ WindowPositionUtil.setupAlwaysOnTop(this.agentWindow);
+
+ if (typeof this.agentWindow.showInactive === "function") {
+ this.agentWindow.showInactive();
+ } else {
+ this.agentWindow.show();
+ }
+
+ this.agentWindow.webContents.send("agent-start-recording");
+ }
+
+ hideAgentOverlay() {
+ if (!this.agentWindow || this.agentWindow.isDestroyed()) return;
+
+ this.agentWindow.webContents.send("agent-stop-recording");
+ this.agentWindow.hide();
+ }
+
+ resizeAgentWindow(width, height) {
+ if (!this.agentWindow || this.agentWindow.isDestroyed()) return;
+
+ const clamped = {
+ width: Math.max(AGENT_OVERLAY_CONFIG.minWidth, Math.min(width, AGENT_OVERLAY_CONFIG.maxWidth)),
+ height: Math.max(AGENT_OVERLAY_CONFIG.minHeight, Math.min(height, AGENT_OVERLAY_CONFIG.maxHeight)),
+ };
+
+ const bounds = this.agentWindow.getBounds();
+ this.agentWindow.setBounds({
+ x: bounds.x,
+ y: bounds.y,
+ width: clamped.width,
+ height: clamped.height,
+ });
+ }
+
+ _positionAgentWindow() {
+ if (!this.mainWindow || this.mainWindow.isDestroyed()) return;
+ if (!this.agentWindow || this.agentWindow.isDestroyed()) return;
+
+ const mainBounds = this.mainWindow.getBounds();
+ const agentBounds = this.agentWindow.getBounds();
+ const MARGIN = 8;
+
+ const x = mainBounds.x + Math.round((mainBounds.width - agentBounds.width) / 2);
+ const y = mainBounds.y - agentBounds.height - MARGIN;
+
+ const display = screen.getDisplayNearestPoint({ x: mainBounds.x, y: mainBounds.y });
+ const workArea = display.workArea || display.bounds;
+
+ this.agentWindow.setBounds({
+ x: Math.max(workArea.x, Math.min(x, workArea.x + workArea.width - agentBounds.width)),
+ y: Math.max(workArea.y, y),
+ width: agentBounds.width,
+ height: agentBounds.height,
+ });
+ }
+
showDictationPanel(options = {}) {
const { focus = false } = options;
if (this.mainWindow && !this.mainWindow.isDestroyed()) {
diff --git a/src/hooks/useSettings.ts b/src/hooks/useSettings.ts
index 230576d8f..5e7fb52ed 100644
--- a/src/hooks/useSettings.ts
+++ b/src/hooks/useSettings.ts
@@ -59,6 +59,14 @@ export interface ThemeSettings {
theme: "light" | "dark" | "auto";
}
+export interface AgentModeSettings {
+ agentModel: string;
+ agentProvider: string;
+ agentKey: string;
+ agentSystemPrompt: string;
+ agentEnabled: boolean;
+}
+
function useSettingsInternal() {
const store = useSettingsStore();
diff --git a/src/index.css b/src/index.css
index d99400912..934888ebb 100644
--- a/src/index.css
+++ b/src/index.css
@@ -793,3 +793,84 @@ a:hover {
::-webkit-scrollbar-corner {
background: transparent;
}
+
+/* ---- Agent Overlay ---- */
+
+body:has(.agent-overlay-window) {
+ background: transparent;
+}
+
+body:has(.agent-overlay-window) #root {
+ background: transparent;
+}
+
+@keyframes agent-message-in {
+ from {
+ opacity: 0;
+ transform: translateY(4px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+
+@keyframes agent-cursor-blink {
+ 0%,
+ 50% {
+ opacity: 1;
+ }
+ 51%,
+ 100% {
+ opacity: 0;
+ }
+}
+
+@keyframes agent-mic-pulse {
+ 0%,
+ 100% {
+ opacity: 0.5;
+ transform: scale(1);
+ }
+ 50% {
+ opacity: 1;
+ transform: scale(1.05);
+ }
+}
+
+@keyframes agent-loading-dot {
+ 0%,
+ 80%,
+ 100% {
+ opacity: 0.3;
+ transform: scale(0.8);
+ }
+ 40% {
+ opacity: 1;
+ transform: scale(1);
+ }
+}
+
+.agent-chat-scroll::-webkit-scrollbar {
+ width: 4px;
+}
+
+.agent-chat-scroll::-webkit-scrollbar-track {
+ background: transparent;
+}
+
+.agent-chat-scroll::-webkit-scrollbar-thumb {
+ background: oklch(0.5 0 0 / 0.2);
+ border-radius: 2px;
+}
+
+.agent-chat-scroll::-webkit-scrollbar-thumb:hover {
+ background: oklch(0.5 0 0 / 0.3);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .agent-overlay-window * {
+ animation-duration: 0.01ms !important;
+ animation-iteration-count: 1 !important;
+ }
+}
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index 10d5d1a29..844ba3877 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -831,6 +831,10 @@
"system": {
"description": "Updates, Speicher & Entwicklertools",
"label": "System"
+ },
+ "agentMode": {
+ "label": "Agent-Modus",
+ "description": "Sprach-Chat-Assistent"
}
},
"title": "Einstellungen"
@@ -1588,5 +1592,42 @@
"redirectTitle": "Weiterleitung zur App...",
"closeTab": "Du kannst diesen Tab schließen."
}
+ },
+ "agentMode": {
+ "settings": {
+ "title": "Agent-Modus",
+ "description": "Sprach-Chat-Assistent mit separatem KI-Modell",
+ "enabled": "Agent-Modus aktivieren",
+ "enabledDescription": "Verwende eine separate Tastenkombination, um ein Sprach-Chat-Overlay zu öffnen",
+ "hotkey": "Agent-Tastenkombination",
+ "hotkeyDescription": "Tastenkombination zum Umschalten des Agent-Overlays",
+ "model": "Agent-Modell",
+ "modelDescription": "KI-Modell für Agent-Unterhaltungen",
+ "systemPrompt": "System-Prompt",
+ "systemPromptDescription": "Benutzerdefinierte Anweisungen für den Agenten",
+ "systemPromptPlaceholder": "Benutzerdefinierten System-Prompt eingeben..."
+ },
+ "chat": {
+ "placeholder": "Drücke {{hotkey}} zum Sprechen",
+ "thinking": "Denkt nach...",
+ "transcribing": "Transkribiert...",
+ "listening": "Hört zu...",
+ "newConversation": "Neu",
+ "copyToClipboard": "In Zwischenablage kopieren",
+ "copied": "Kopiert!",
+ "emptyState": "Drücke die Agent-Tastenkombination, um eine Unterhaltung zu starten",
+ "errorPrefix": "Fehler"
+ },
+ "titleBar": {
+ "label": "Agent",
+ "newChat": "Neues Gespräch",
+ "close": "Schließen"
+ },
+ "input": {
+ "idle": "Taste gedrückt halten zum Sprechen",
+ "listening": "Hört zu...",
+ "transcribing": "Transkribiert...",
+ "thinking": "Denkt nach..."
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 37825d11d..3de810dc2 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -831,6 +831,10 @@
"system": {
"description": "Updates, storage & developer tools",
"label": "System"
+ },
+ "agentMode": {
+ "label": "Agent Mode",
+ "description": "Voice chat assistant"
}
},
"title": "Settings"
@@ -1588,5 +1592,42 @@
"redirectTitle": "Redirecting to app...",
"closeTab": "You can close this tab."
}
+ },
+ "agentMode": {
+ "settings": {
+ "title": "Agent Mode",
+ "description": "Voice chat assistant with a separate AI model",
+ "enabled": "Enable Agent Mode",
+ "enabledDescription": "Use a separate hotkey to open a voice chat overlay",
+ "hotkey": "Agent Hotkey",
+ "hotkeyDescription": "Hotkey to toggle the agent overlay",
+ "model": "Agent Model",
+ "modelDescription": "AI model used for agent conversations",
+ "systemPrompt": "System Prompt",
+ "systemPromptDescription": "Custom instructions for the agent",
+ "systemPromptPlaceholder": "Enter custom system prompt..."
+ },
+ "chat": {
+ "placeholder": "Press {{hotkey}} to speak",
+ "thinking": "Thinking...",
+ "transcribing": "Transcribing...",
+ "listening": "Listening...",
+ "newConversation": "New",
+ "copyToClipboard": "Copy to clipboard",
+ "copied": "Copied!",
+ "emptyState": "Press your agent hotkey to start a conversation",
+ "errorPrefix": "Error"
+ },
+ "titleBar": {
+ "label": "Agent",
+ "newChat": "New conversation",
+ "close": "Close"
+ },
+ "input": {
+ "idle": "Hold hotkey to speak",
+ "listening": "Listening...",
+ "transcribing": "Transcribing...",
+ "thinking": "Thinking..."
+ }
}
}
\ No newline at end of file
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index 1a0ea2f03..ea85cb57d 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -831,6 +831,10 @@
"system": {
"description": "Actualizaciones, almacenamiento y herramientas de desarrollo",
"label": "Sistema"
+ },
+ "agentMode": {
+ "label": "Modo Agente",
+ "description": "Asistente de chat por voz"
}
},
"title": "Ajustes"
@@ -1588,5 +1592,42 @@
"redirectTitle": "Redirigiendo a la app...",
"closeTab": "Puedes cerrar esta pestaña."
}
+ },
+ "agentMode": {
+ "settings": {
+ "title": "Modo Agente",
+ "description": "Asistente de chat por voz con un modelo de IA separado",
+ "enabled": "Activar Modo Agente",
+ "enabledDescription": "Usa una tecla de acceso rápido separada para abrir una superposición de chat por voz",
+ "hotkey": "Tecla del Agente",
+ "hotkeyDescription": "Tecla de acceso rápido para alternar la superposición del agente",
+ "model": "Modelo del Agente",
+ "modelDescription": "Modelo de IA utilizado para conversaciones del agente",
+ "systemPrompt": "Prompt del Sistema",
+ "systemPromptDescription": "Instrucciones personalizadas para el agente",
+ "systemPromptPlaceholder": "Introduce un prompt de sistema personalizado..."
+ },
+ "chat": {
+ "placeholder": "Presiona {{hotkey}} para hablar",
+ "thinking": "Pensando...",
+ "transcribing": "Transcribiendo...",
+ "listening": "Escuchando...",
+ "newConversation": "Nuevo",
+ "copyToClipboard": "Copiar al portapapeles",
+ "copied": "¡Copiado!",
+ "emptyState": "Presiona la tecla del agente para iniciar una conversación",
+ "errorPrefix": "Error"
+ },
+ "titleBar": {
+ "label": "Agente",
+ "newChat": "Nueva conversación",
+ "close": "Cerrar"
+ },
+ "input": {
+ "idle": "Mantén la tecla para hablar",
+ "listening": "Escuchando...",
+ "transcribing": "Transcribiendo...",
+ "thinking": "Pensando..."
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index 17faf125f..285358819 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -831,6 +831,10 @@
"system": {
"description": "Mises à jour, stockage & outils de développement",
"label": "Système"
+ },
+ "agentMode": {
+ "label": "Mode Agent",
+ "description": "Assistant vocal de chat"
}
},
"title": "Paramètres"
@@ -1588,5 +1592,42 @@
"redirectTitle": "Redirection vers l'app...",
"closeTab": "Vous pouvez fermer cet onglet."
}
+ },
+ "agentMode": {
+ "settings": {
+ "title": "Mode Agent",
+ "description": "Assistant vocal de chat avec un modèle IA séparé",
+ "enabled": "Activer le Mode Agent",
+ "enabledDescription": "Utiliser un raccourci clavier séparé pour ouvrir une fenêtre de chat vocal",
+ "hotkey": "Raccourci Agent",
+ "hotkeyDescription": "Raccourci clavier pour basculer la fenêtre agent",
+ "model": "Modèle Agent",
+ "modelDescription": "Modèle IA utilisé pour les conversations agent",
+ "systemPrompt": "Prompt système",
+ "systemPromptDescription": "Instructions personnalisées pour l'agent",
+ "systemPromptPlaceholder": "Entrez un prompt système personnalisé..."
+ },
+ "chat": {
+ "placeholder": "Appuyez sur {{hotkey}} pour parler",
+ "thinking": "Réflexion...",
+ "transcribing": "Transcription...",
+ "listening": "Écoute...",
+ "newConversation": "Nouveau",
+ "copyToClipboard": "Copier dans le presse-papiers",
+ "copied": "Copié !",
+ "emptyState": "Appuyez sur le raccourci agent pour démarrer une conversation",
+ "errorPrefix": "Erreur"
+ },
+ "titleBar": {
+ "label": "Agent",
+ "newChat": "Nouvelle conversation",
+ "close": "Fermer"
+ },
+ "input": {
+ "idle": "Maintenez la touche pour parler",
+ "listening": "Écoute...",
+ "transcribing": "Transcription...",
+ "thinking": "Réflexion..."
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index a58b515c4..68a9f5ccc 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -831,6 +831,10 @@
"system": {
"description": "Aggiornamenti, archiviazione e strumenti di sviluppo",
"label": "Sistema"
+ },
+ "agentMode": {
+ "label": "Modalità Agente",
+ "description": "Assistente vocale chat"
}
},
"title": "Impostazioni"
@@ -1588,5 +1592,42 @@
"redirectTitle": "Reindirizzamento all'app...",
"closeTab": "Puoi chiudere questa scheda."
}
+ },
+ "agentMode": {
+ "settings": {
+ "title": "Modalità Agente",
+ "description": "Assistente vocale chat con un modello IA separato",
+ "enabled": "Abilita Modalità Agente",
+ "enabledDescription": "Usa un tasto di scelta rapida separato per aprire un overlay di chat vocale",
+ "hotkey": "Tasto Agente",
+ "hotkeyDescription": "Tasto di scelta rapida per alternare l'overlay agente",
+ "model": "Modello Agente",
+ "modelDescription": "Modello IA utilizzato per le conversazioni agente",
+ "systemPrompt": "Prompt di Sistema",
+ "systemPromptDescription": "Istruzioni personalizzate per l'agente",
+ "systemPromptPlaceholder": "Inserisci un prompt di sistema personalizzato..."
+ },
+ "chat": {
+ "placeholder": "Premi {{hotkey}} per parlare",
+ "thinking": "Pensando...",
+ "transcribing": "Trascrivendo...",
+ "listening": "Ascoltando...",
+ "newConversation": "Nuovo",
+ "copyToClipboard": "Copia negli appunti",
+ "copied": "Copiato!",
+ "emptyState": "Premi il tasto agente per iniziare una conversazione",
+ "errorPrefix": "Errore"
+ },
+ "titleBar": {
+ "label": "Agente",
+ "newChat": "Nuova conversazione",
+ "close": "Chiudi"
+ },
+ "input": {
+ "idle": "Tieni premuto il tasto per parlare",
+ "listening": "Ascolto...",
+ "transcribing": "Trascrizione...",
+ "thinking": "Pensiero..."
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 4ec6a93e1..8acbdf07f 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -831,6 +831,10 @@
"system": {
"description": "更新、ストレージ、開発者ツール",
"label": "システム"
+ },
+ "agentMode": {
+ "label": "エージェントモード",
+ "description": "音声チャットアシスタント"
}
},
"title": "設定"
@@ -1588,5 +1592,42 @@
"redirectTitle": "アプリにリダイレクト中...",
"closeTab": "このタブを閉じてください。"
}
+ },
+ "agentMode": {
+ "settings": {
+ "title": "エージェントモード",
+ "description": "別のAIモデルを使用する音声チャットアシスタント",
+ "enabled": "エージェントモードを有効にする",
+ "enabledDescription": "別のホットキーを使用して音声チャットオーバーレイを開く",
+ "hotkey": "エージェントホットキー",
+ "hotkeyDescription": "エージェントオーバーレイを切り替えるホットキー",
+ "model": "エージェントモデル",
+ "modelDescription": "エージェント会話に使用するAIモデル",
+ "systemPrompt": "システムプロンプト",
+ "systemPromptDescription": "エージェントへのカスタム指示",
+ "systemPromptPlaceholder": "カスタムシステムプロンプトを入力..."
+ },
+ "chat": {
+ "placeholder": "{{hotkey}}を押して話す",
+ "thinking": "考え中...",
+ "transcribing": "文字起こし中...",
+ "listening": "聞いています...",
+ "newConversation": "新規",
+ "copyToClipboard": "クリップボードにコピー",
+ "copied": "コピーしました!",
+ "emptyState": "エージェントホットキーを押して会話を開始",
+ "errorPrefix": "エラー"
+ },
+ "titleBar": {
+ "label": "エージェント",
+ "newChat": "新しい会話",
+ "close": "閉じる"
+ },
+ "input": {
+ "idle": "ホットキーを押し続けて話す",
+ "listening": "聞いています...",
+ "transcribing": "文字起こし中...",
+ "thinking": "考え中..."
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 420d6a5fd..5946894ef 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -803,6 +803,10 @@
"system": {
"description": "Atualizações, armazenamento e ferramentas de desenvolvimento",
"label": "Sistema"
+ },
+ "agentMode": {
+ "label": "Modo Agente",
+ "description": "Assistente de chat por voz"
}
},
"title": "Configurações"
@@ -1588,5 +1592,42 @@
"redirectTitle": "Redirecionando para o app...",
"closeTab": "Você pode fechar esta aba."
}
+ },
+ "agentMode": {
+ "settings": {
+ "title": "Modo Agente",
+ "description": "Assistente de chat por voz com um modelo de IA separado",
+ "enabled": "Ativar Modo Agente",
+ "enabledDescription": "Usar uma tecla de atalho separada para abrir uma sobreposição de chat por voz",
+ "hotkey": "Tecla do Agente",
+ "hotkeyDescription": "Tecla de atalho para alternar a sobreposição do agente",
+ "model": "Modelo do Agente",
+ "modelDescription": "Modelo de IA usado para conversas do agente",
+ "systemPrompt": "Prompt do Sistema",
+ "systemPromptDescription": "Instruções personalizadas para o agente",
+ "systemPromptPlaceholder": "Digite um prompt de sistema personalizado..."
+ },
+ "chat": {
+ "placeholder": "Pressione {{hotkey}} para falar",
+ "thinking": "Pensando...",
+ "transcribing": "Transcrevendo...",
+ "listening": "Ouvindo...",
+ "newConversation": "Novo",
+ "copyToClipboard": "Copiar para área de transferência",
+ "copied": "Copiado!",
+ "emptyState": "Pressione a tecla do agente para iniciar uma conversa",
+ "errorPrefix": "Erro"
+ },
+ "titleBar": {
+ "label": "Agente",
+ "newChat": "Nova conversa",
+ "close": "Fechar"
+ },
+ "input": {
+ "idle": "Segure a tecla para falar",
+ "listening": "Ouvindo...",
+ "transcribing": "Transcrevendo...",
+ "thinking": "Pensando..."
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index 84efeda1b..9cbf6e1e4 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -831,6 +831,10 @@
"system": {
"description": "Обновления, хранилище и инструменты разработчика",
"label": "Система"
+ },
+ "agentMode": {
+ "label": "Режим агента",
+ "description": "Голосовой чат-ассистент"
}
},
"title": "Настройки"
@@ -1588,5 +1592,42 @@
"redirectTitle": "Перенаправление в приложение...",
"closeTab": "Можете закрыть эту вкладку."
}
+ },
+ "agentMode": {
+ "settings": {
+ "title": "Режим агента",
+ "description": "Голосовой чат-ассистент с отдельной моделью ИИ",
+ "enabled": "Включить режим агента",
+ "enabledDescription": "Используйте отдельную горячую клавишу для открытия наложения голосового чата",
+ "hotkey": "Горячая клавиша агента",
+ "hotkeyDescription": "Горячая клавиша для переключения наложения агента",
+ "model": "Модель агента",
+ "modelDescription": "Модель ИИ для разговоров с агентом",
+ "systemPrompt": "Системный промпт",
+ "systemPromptDescription": "Пользовательские инструкции для агента",
+ "systemPromptPlaceholder": "Введите пользовательский системный промпт..."
+ },
+ "chat": {
+ "placeholder": "Нажмите {{hotkey}} чтобы говорить",
+ "thinking": "Думаю...",
+ "transcribing": "Транскрибирую...",
+ "listening": "Слушаю...",
+ "newConversation": "Новый",
+ "copyToClipboard": "Копировать в буфер обмена",
+ "copied": "Скопировано!",
+ "emptyState": "Нажмите горячую клавишу агента, чтобы начать разговор",
+ "errorPrefix": "Ошибка"
+ },
+ "titleBar": {
+ "label": "Агент",
+ "newChat": "Новый разговор",
+ "close": "Закрыть"
+ },
+ "input": {
+ "idle": "Удерживайте клавишу для разговора",
+ "listening": "Слушаю...",
+ "transcribing": "Транскрибирую...",
+ "thinking": "Думаю..."
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index 0611cee66..ddc115932 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -831,6 +831,10 @@
"system": {
"description": "更新、存储与开发者工具",
"label": "系统"
+ },
+ "agentMode": {
+ "label": "智能助手模式",
+ "description": "语音聊天助手"
}
},
"title": "设置"
@@ -1588,5 +1592,42 @@
"redirectTitle": "正在跳转到应用...",
"closeTab": "您可以关闭此标签页。"
}
+ },
+ "agentMode": {
+ "settings": {
+ "title": "智能助手模式",
+ "description": "使用独立AI模型的语音聊天助手",
+ "enabled": "启用智能助手模式",
+ "enabledDescription": "使用独立热键打开语音聊天覆盖层",
+ "hotkey": "助手热键",
+ "hotkeyDescription": "切换助手覆盖层的热键",
+ "model": "助手模型",
+ "modelDescription": "用于助手对话的AI模型",
+ "systemPrompt": "系统提示词",
+ "systemPromptDescription": "助手的自定义指令",
+ "systemPromptPlaceholder": "输入自定义系统提示词..."
+ },
+ "chat": {
+ "placeholder": "按 {{hotkey}} 开始说话",
+ "thinking": "思考中...",
+ "transcribing": "转录中...",
+ "listening": "正在聆听...",
+ "newConversation": "新建",
+ "copyToClipboard": "复制到剪贴板",
+ "copied": "已复制!",
+ "emptyState": "按下助手热键开始对话",
+ "errorPrefix": "错误"
+ },
+ "titleBar": {
+ "label": "助手",
+ "newChat": "新对话",
+ "close": "关闭"
+ },
+ "input": {
+ "idle": "按住快捷键说话",
+ "listening": "正在聆听...",
+ "transcribing": "正在转录...",
+ "thinking": "正在思考..."
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index 141114741..e0feb1a50 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -831,6 +831,10 @@
"system": {
"description": "更新、儲存與開發者工具",
"label": "系統"
+ },
+ "agentMode": {
+ "label": "智慧助手模式",
+ "description": "語音聊天助手"
}
},
"title": "設定"
@@ -941,7 +945,11 @@
"enterprise": {
"name": "企業版",
"price": "自訂",
- "features": ["雲端同步", "團隊功能(即將推出)", "SSO 與合規"],
+ "features": [
+ "雲端同步",
+ "團隊功能(即將推出)",
+ "SSO 與合規"
+ ],
"cta": "聯絡我們"
},
"currentPlan": "目前方案"
@@ -1584,5 +1592,42 @@
"redirectTitle": "正在跳轉到應用程式...",
"closeTab": "您可以關閉此分頁。"
}
+ },
+ "agentMode": {
+ "settings": {
+ "title": "智慧助手模式",
+ "description": "使用獨立AI模型的語音聊天助手",
+ "enabled": "啟用智慧助手模式",
+ "enabledDescription": "使用獨立熱鍵開啟語音聊天覆蓋層",
+ "hotkey": "助手熱鍵",
+ "hotkeyDescription": "切換助手覆蓋層的熱鍵",
+ "model": "助手模型",
+ "modelDescription": "用於助手對話的AI模型",
+ "systemPrompt": "系統提示詞",
+ "systemPromptDescription": "助手的自訂指令",
+ "systemPromptPlaceholder": "輸入自訂系統提示詞..."
+ },
+ "chat": {
+ "placeholder": "按 {{hotkey}} 開始說話",
+ "thinking": "思考中...",
+ "transcribing": "轉錄中...",
+ "listening": "正在聆聽...",
+ "newConversation": "新建",
+ "copyToClipboard": "複製到剪貼簿",
+ "copied": "已複製!",
+ "emptyState": "按下助手熱鍵開始對話",
+ "errorPrefix": "錯誤"
+ },
+ "titleBar": {
+ "label": "助手",
+ "newChat": "新對話",
+ "close": "關閉"
+ },
+ "input": {
+ "idle": "按住快捷鍵說話",
+ "listening": "正在聆聽...",
+ "transcribing": "正在轉錄...",
+ "thinking": "正在思考..."
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/main.jsx b/src/main.jsx
index 1ab95172e..7c88dbb6d 100644
--- a/src/main.jsx
+++ b/src/main.jsx
@@ -15,8 +15,10 @@ import "./index.css";
const controlPanelImport = () => import("./components/ControlPanel.tsx");
const onboardingFlowImport = () => import("./components/OnboardingFlow.tsx");
+const agentOverlayImport = () => import("./components/AgentOverlay.tsx");
const ControlPanel = React.lazy(controlPanelImport);
const OnboardingFlow = React.lazy(onboardingFlowImport);
+const AgentOverlay = React.lazy(agentOverlayImport);
let root = null;
@@ -276,19 +278,23 @@ function AppRouter() {
const [needsReauth, setNeedsReauth] = useState(false);
const [isLoading, setIsLoading] = useState(true);
+ const isAgentPanel = window.location.search.includes("agent=true");
const isControlPanel =
- window.location.pathname.includes("control") || window.location.search.includes("panel=true");
- const isDictationPanel = !isControlPanel;
+ !isAgentPanel &&
+ (window.location.pathname.includes("control") || window.location.search.includes("panel=true"));
+ const isDictationPanel = !isControlPanel && !isAgentPanel;
// Preload lazy chunks while waiting for auth so Suspense resolves instantly
useEffect(() => {
- if (isControlPanel) {
+ if (isAgentPanel) {
+ agentOverlayImport().catch(() => {});
+ } else if (isControlPanel) {
controlPanelImport().catch(() => {});
if (!localStorage.getItem("onboardingCompleted")) {
onboardingFlowImport().catch(() => {});
}
}
- }, [isControlPanel]);
+ }, [isControlPanel, isAgentPanel]);
useEffect(() => {
if (!authLoaded) return;
@@ -329,6 +335,14 @@ function AppRouter() {
localStorage.setItem("onboardingCompleted", "true");
};
+ if (isAgentPanel) {
+ return (
+ <Suspense fallback={<LoadingFallback />}>
+ <AgentOverlay />
+ </Suspense>
+ );
+ }
+
if (isLoading) {
return <LoadingFallback />;
}
diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.ts
index 2fd68e13c..e32251ca1 100644
--- a/src/services/ReasoningService.ts
+++ b/src/services/ReasoningService.ts
@@ -1085,6 +1085,105 @@ class ReasoningService extends BaseReasoningService {
}
}
+ async *processTextStreaming(
+ messages: Array<{ role: string; content: string }>,
+ model: string,
+ provider: string,
+ config: ReasoningConfig & { systemPrompt: string }
+ ): AsyncGenerator<string, void, unknown> {
+ const providerKey = provider as "openai" | "groq" | "gemini" | "anthropic" | "custom";
+ const apiKey = await this.getApiKey(providerKey);
+
+ let endpoint: string;
+ switch (providerKey) {
+ case "groq":
+ endpoint = buildApiUrl(API_ENDPOINTS.GROQ_BASE, "/chat/completions");
+ break;
+ case "openai":
+ case "custom":
+ endpoint = buildApiUrl(this.getConfiguredOpenAIBase(), "/chat/completions");
+ break;
+ default:
+ endpoint = buildApiUrl(API_ENDPOINTS.OPENAI_BASE, "/chat/completions");
+ break;
+ }
+
+ const requestBody: Record<string, unknown> = {
+ model,
+ messages,
+ stream: true,
+ temperature: config.temperature ?? 0.3,
+ max_tokens:
+ config.maxTokens ||
+ Math.max(4096, TOKEN_LIMITS.MAX_TOKENS),
+ };
+
+ logger.logReasoning("AGENT_STREAM_REQUEST", {
+ endpoint,
+ model,
+ provider,
+ messageCount: messages.length,
+ });
+
+ const response = await fetch(endpoint, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${apiKey}`,
+ },
+ body: JSON.stringify(requestBody),
+ });
+
+ if (!response.ok) {
+ const errorText = await response.text();
+ let errorMessage: string;
+ try {
+ const errorData = JSON.parse(errorText);
+ errorMessage =
+ errorData.error?.message || errorData.message || errorData.error || `API error: ${response.status}`;
+ } catch {
+ errorMessage = errorText || `API error: ${response.status}`;
+ }
+ logger.logReasoning("AGENT_STREAM_ERROR", { status: response.status, errorMessage });
+ throw new Error(errorMessage);
+ }
+
+ const reader = response.body?.getReader();
+ if (!reader) throw new Error("No response body");
+
+ const decoder = new TextDecoder();
+ let buffer = "";
+
+ try {
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+
+ buffer += decoder.decode(value, { stream: true });
+ const lines = buffer.split("\n");
+ buffer = lines.pop() || "";
+
+ for (const line of lines) {
+ const trimmed = line.trim();
+ if (!trimmed || !trimmed.startsWith("data: ")) continue;
+
+ const data = trimmed.slice(6);
+ if (data === "[DONE]") return;
+
+ try {
+ const parsed = JSON.parse(data);
+ const content = parsed.choices?.[0]?.delta?.content;
+ if (content) yield content;
+ } catch {
+ // skip malformed SSE chunks
+ }
+ }
+ }
+ } finally {
+ reader.releaseLock();
+ }
+ }
+
async isAvailable(): Promise<boolean> {
try {
if (isCloudReasoningMode()) {
diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.ts
index 583487d2f..65119c1b3 100644
--- a/src/stores/settingsStore.ts
+++ b/src/stores/settingsStore.ts
@@ -13,6 +13,7 @@ import type {
ApiKeySettings,
PrivacySettings,
ThemeSettings,
+ AgentModeSettings,
} from "../hooks/useSettings";
let _ReasoningService: typeof import("../services/ReasoningService").default | null = null;
@@ -56,6 +57,7 @@ const BOOLEAN_SETTINGS = new Set([
"audioCuesEnabled",
"floatingIconAutoHide",
"isSignedIn",
+ "agentEnabled",
]);
const ARRAY_SETTINGS = new Set(["customDictionary"]);
@@ -80,7 +82,8 @@ export interface SettingsState
MicrophoneSettings,
ApiKeySettings,
PrivacySettings,
- ThemeSettings {
+ ThemeSettings,
+ AgentModeSettings {
isSignedIn: boolean;
audioCuesEnabled: boolean;
floatingIconAutoHide: boolean;
@@ -127,9 +130,16 @@ export interface SettingsState
setFloatingIconAutoHide: (enabled: boolean) => void;
setIsSignedIn: (value: boolean) => void;
+ setAgentModel: (value: string) => void;
+ setAgentProvider: (value: string) => void;
+ setAgentKey: (key: string) => void;
+ setAgentSystemPrompt: (value: string) => void;
+ setAgentEnabled: (value: boolean) => void;
+
updateTranscriptionSettings: (settings: Partial<TranscriptionSettings>) => void;
updateReasoningSettings: (settings: Partial<ReasoningSettings>) => void;
updateApiKeys: (keys: Partial<ApiKeySettings>) => void;
+ updateAgentModeSettings: (settings: Partial<AgentModeSettings>) => void;
}
function createStringSetter(key: string) {
@@ -238,6 +248,12 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({
floatingIconAutoHide: readBoolean("floatingIconAutoHide", false),
isSignedIn: readBoolean("isSignedIn", false),
+ agentModel: readString("agentModel", "openai/gpt-oss-120b"),
+ agentProvider: readString("agentProvider", "groq"),
+ agentKey: readString("agentKey", ""),
+ agentSystemPrompt: readString("agentSystemPrompt", ""),
+ agentEnabled: readBoolean("agentEnabled", true),
+
setUseLocalWhisper: createBooleanSetter("useLocalWhisper"),
setWhisperModel: createStringSetter("whisperModel"),
setLocalTranscriptionProvider: (value: LocalTranscriptionProvider) => {
@@ -374,6 +390,18 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({
set({ isSignedIn: value });
},
+ setAgentModel: createStringSetter("agentModel"),
+ setAgentProvider: createStringSetter("agentProvider"),
+ setAgentKey: (key: string) => {
+ if (isBrowser) localStorage.setItem("agentKey", key);
+ useSettingsStore.setState({ agentKey: key });
+ if (isBrowser) {
+ window.electronAPI?.notifyAgentHotkeyChanged?.(key);
+ }
+ },
+ setAgentSystemPrompt: createStringSetter("agentSystemPrompt"),
+ setAgentEnabled: createBooleanSetter("agentEnabled"),
+
updateTranscriptionSettings: (settings: Partial<TranscriptionSettings>) => {
const s = useSettingsStore.getState();
if (settings.useLocalWhisper !== undefined) s.setUseLocalWhisper(settings.useLocalWhisper);
@@ -428,6 +456,16 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({
if (keys.customReasoningApiKey !== undefined)
s.setCustomReasoningApiKey(keys.customReasoningApiKey);
},
+
+ updateAgentModeSettings: (settings: Partial<AgentModeSettings>) => {
+ const s = useSettingsStore.getState();
+ if (settings.agentModel !== undefined) s.setAgentModel(settings.agentModel);
+ if (settings.agentProvider !== undefined) s.setAgentProvider(settings.agentProvider);
+ if (settings.agentKey !== undefined) s.setAgentKey(settings.agentKey);
+ if (settings.agentSystemPrompt !== undefined)
+ s.setAgentSystemPrompt(settings.agentSystemPrompt);
+ if (settings.agentEnabled !== undefined) s.setAgentEnabled(settings.agentEnabled);
+ },
}));
// --- Selectors (derived state, not stored) ---
diff --git a/src/types/electron.ts b/src/types/electron.ts
index f6e26ace8..1df3d6740 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -862,6 +862,65 @@ declare global {
}>;
}>;
+ // Agent Mode
+ notifyAgentHotkeyChanged?: (hotkey: string) => void;
+ getAgentKey?: () => Promise<string>;
+ saveAgentKey?: (key: string) => Promise<void>;
+ createAgentConversation?: (title: string) => Promise<{
+ id: number;
+ title: string;
+ created_at: string;
+ updated_at: string;
+ }>;
+ getAgentConversations?: (limit?: number) => Promise<
+ Array<{
+ id: number;
+ title: string;
+ created_at: string;
+ updated_at: string;
+ }>
+ >;
+ getAgentConversation?: (id: number) => Promise<{
+ id: number;
+ title: string;
+ created_at: string;
+ updated_at: string;
+ messages: Array<{
+ id: number;
+ conversation_id: number;
+ role: "user" | "assistant" | "system";
+ content: string;
+ created_at: string;
+ }>;
+ } | null>;
+ deleteAgentConversation?: (id: number) => Promise<{ success: boolean }>;
+ updateAgentConversationTitle?: (
+ id: number,
+ title: string
+ ) => Promise<{ success: boolean }>;
+ addAgentMessage?: (
+ conversationId: number,
+ role: "user" | "assistant" | "system",
+ content: string
+ ) => Promise<{
+ id: number;
+ conversation_id: number;
+ role: string;
+ content: string;
+ created_at: string;
+ }>;
+ getAgentMessages?: (
+ conversationId: number
+ ) => Promise<
+ Array<{
+ id: number;
+ conversation_id: number;
+ role: "user" | "assistant" | "system";
+ content: string;
+ created_at: string;
+ }>
+ >;
+
// Deepgram Streaming
deepgramStreamingWarmup?: (options?: { sampleRate?: number; language?: string }) => Promise<{
success: boolean;
@@ -892,6 +951,12 @@ declare global {
onDeepgramSessionEnd?: (
callback: (data: { audioDuration?: number; text?: string }) => void
) => () => void;
+
+ // Agent overlay
+ resizeAgentWindow?: (width: number, height: number) => Promise<void>;
+ hideAgentOverlay?: () => Promise<void>;
+ onAgentStartRecording?: (callback: () => void) => () => void;
+ onAgentStopRecording?: (callback: () => void) => () => void;
};
api?: {