Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix: deduplicate types, populate metadata, memoize tool registry
Gabriel Stein728cd21672bd
diff --git a/preload.js b/preload.jsindex 77e923e21..31f07eb82 100644--- a/preload.js+++ b/preload.js@@ -579,9 +579,16 @@ contextBridge.exposeInMainWorld("electronAPI", {releaseRecordingLock: (pipeline) => ipcRenderer.invoke("release-recording-lock", pipeline),// Agent cloud streaming (event-based for real-time chunks)- startAgentStream: (messages, opts) => ipcRenderer.send("cloud-agent-stream-start", messages, opts),- onAgentStreamChunk: registerListener("cloud-agent-stream-chunk", (callback) => (_event, chunk) => callback(chunk)),- onAgentStreamError: registerListener("cloud-agent-stream-error", (callback) => (_event, error) => callback(error)),+ startAgentStream: (messages, opts) =>+ ipcRenderer.send("cloud-agent-stream-start", messages, opts),+ onAgentStreamChunk: registerListener(+ "cloud-agent-stream-chunk",+ (callback) => (_event, chunk) => callback(chunk)+ ),+ onAgentStreamError: registerListener(+ "cloud-agent-stream-error",+ (callback) => (_event, error) => callback(error)+ ),onAgentStreamEnd: registerListener("cloud-agent-stream-end", (callback) => () => callback()),// Agent cloud tools@@ -595,8 +602,8 @@ contextBridge.exposeInMainWorld("electronAPI", {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),+ addAgentMessage: (conversationId, role, content, metadata) =>+ ipcRenderer.invoke("db-add-agent-message", conversationId, role, content, metadata),getAgentMessages: (conversationId) => ipcRenderer.invoke("db-get-agent-messages", conversationId),// Google Calendardiff --git a/src/components/AgentOverlay.tsx b/src/components/AgentOverlay.tsxindex 65c3b7001..938587fba 100644--- a/src/components/AgentOverlay.tsx+++ b/src/components/AgentOverlay.tsx@@ -2,13 +2,14 @@ import { useState, useEffect, useRef, useCallback } from "react";import { useTranslation } from "react-i18next";import { cn } from "./lib/utils";import { AgentTitleBar } from "./agent/AgentTitleBar";-import { AgentChat } from "./agent/AgentChat";+import { AgentChat, type Message } from "./agent/AgentChat";import { AgentInput } from "./agent/AgentInput";import AudioManager from "../helpers/audioManager";import ReasoningService, { type AgentStreamChunk } from "../services/ReasoningService";import { getSettings } from "../stores/settingsStore";import { getAgentSystemPrompt } from "../config/prompts";import { createToolRegistry } from "../services/tools";+import type { ToolRegistry } from "../services/tools/ToolRegistry";type AgentState =| "idle"@@ -18,22 +19,6 @@ type AgentState =| "streaming"| "tool-executing";-interface ToolCallEntry {- id: string;- name: string;- arguments: string;- status: "executing" | "completed" | "error";- result?: string;-}--interface Message {- id: string;- role: "user" | "assistant" | "tool";- content: string;- isStreaming: boolean;- toolCalls?: ToolCallEntry[];-}-const MIN_HEIGHT = 200;const MIN_WIDTH = 360;@@ -49,6 +34,7 @@ export default function AgentOverlay() {const agentStateRef = useRef<AgentState>("idle");const conversationIdRef = useRef<number | null>(null);const mountedRef = useRef(true);+ const toolRegistryRef = useRef<{ key: string; registry: ToolRegistry } | null>(null);useEffect(() => {messagesRef.current = messages;@@ -115,13 +101,20 @@ export default function AgentOverlay() {const toolSupportedProviders = ["openai", "groq", "custom", "anthropic", "gemini"];const supportsTools = isCloudAgent || toolSupportedProviders.includes(settings.agentProvider);- const registry = supportsTools- ? createToolRegistry({+ let registry: ToolRegistry | null = null;+ if (supportsTools) {+ const cacheKey = `${settings.isSignedIn}-${settings.gcalConnected}-${settings.cloudBackupEnabled}`;+ if (toolRegistryRef.current?.key === cacheKey) {+ registry = toolRegistryRef.current.registry;+ } else {+ registry = createToolRegistry({isSignedIn: settings.isSignedIn,gcalConnected: settings.gcalConnected,cloudBackupEnabled: settings.cloudBackupEnabled,- })- : null;+ });+ toolRegistryRef.current = { key: cacheKey, registry };+ }+ }const systemPrompt = getAgentSystemPrompt(registry?.getAll().map((t) => t.name));const llmMessages = [@@ -259,10 +252,13 @@ export default function AgentOverlay() {);if (conversationIdRef.current) {+ const finalMsg = messagesRef.current.find((m) => m.id === assistantId);+ const toolCalls = finalMsg?.toolCalls;window.electronAPI?.addAgentMessage?.(conversationIdRef.current,"assistant",- fullContent+ fullContent,+ toolCalls?.length ? { toolCalls } : undefined);}} catch (error) {@@ -410,6 +406,7 @@ export default function AgentOverlay() {setToolStatus("");setActiveToolName("");conversationIdRef.current = null;+ toolRegistryRef.current = null;}, []);const handleClose = useCallback(() => {diff --git a/src/helpers/database.js b/src/helpers/database.jsindex 1eaf1aaf4..f0ae9bc31 100644--- a/src/helpers/database.js+++ b/src/helpers/database.js@@ -937,12 +937,15 @@ class DatabaseManager {}}- addAgentMessage(conversationId, role, content) {+ addAgentMessage(conversationId, role, content, metadata) {try {if (!this.db) throw new Error("Database not initialized");+ const metadataStr = metadata ? JSON.stringify(metadata) : null;const result = this.db- .prepare("INSERT INTO agent_messages (conversation_id, role, content) VALUES (?, ?, ?)")- .run(conversationId, role, content);+ .prepare(+ "INSERT INTO agent_messages (conversation_id, role, content, metadata) VALUES (?, ?, ?, ?)"+ )+ .run(conversationId, role, content, metadataStr);this.db.prepare("UPDATE agent_conversations SET updated_at = CURRENT_TIMESTAMP WHERE id = ?").run(conversationId);diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex 3210f0641..e940220f1 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -667,9 +667,12 @@ class IPCHandlers {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-add-agent-message",+ async (event, conversationId, role, content, metadata) => {+ return this.databaseManager.addAgentMessage(conversationId, role, content, metadata);+ }+ );ipcMain.handle("db-get-agent-messages", async (event, conversationId) => {return this.databaseManager.getAgentMessages(conversationId);diff --git a/src/types/electron.ts b/src/types/electron.tsindex 3c18a2137..078350eb6 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -1017,12 +1017,14 @@ declare global {addAgentMessage?: (conversationId: number,role: "user" | "assistant" | "system",- content: string+ content: string,+ metadata?: Record<string, unknown>) => Promise<{id: number;conversation_id: number;role: string;content: string;+ metadata?: string;created_at: string;}>;getAgentMessages?: (conversationId: number) => Promise<