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
feat(chat): note-scoped conversations with per-note chat history
Gabriel Stein38e265a45aa9
diff --git a/preload.js b/preload.jsindex 5b7509c9f..747103e26 100644--- a/preload.js+++ b/preload.js@@ -623,7 +623,8 @@ contextBridge.exposeInMainWorld("electronAPI", {agentOpenNote: (noteId) => ipcRenderer.invoke("agent-open-note", noteId),// Agent conversation persistence- createAgentConversation: (title) => ipcRenderer.invoke("db-create-agent-conversation", title),+ createAgentConversation: (title, noteId) =>+ ipcRenderer.invoke("db-create-agent-conversation", title, noteId),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),@@ -636,6 +637,8 @@ contextBridge.exposeInMainWorld("electronAPI", {ipcRenderer.invoke("db-get-agent-conversations-with-preview", limit, offset, includeArchived),searchAgentConversations: (query, limit) =>ipcRenderer.invoke("db-search-agent-conversations", query, limit),+ getConversationsForNote: (noteId, limit) =>+ ipcRenderer.invoke("db-get-conversations-for-note", noteId, limit),archiveAgentConversation: (id) => ipcRenderer.invoke("db-archive-agent-conversation", id),unarchiveAgentConversation: (id) => ipcRenderer.invoke("db-unarchive-agent-conversation", id),updateAgentConversationCloudId: (id, cloudId) =>diff --git a/src/components/chat/ChatMessage.tsx b/src/components/chat/ChatMessage.tsxindex 1fa7a0319..187a00a99 100644--- a/src/components/chat/ChatMessage.tsx+++ b/src/components/chat/ChatMessage.tsx@@ -185,7 +185,13 @@ function extractNoteCards(toolCalls?: ToolCallInfo[]): Array<{ noteId: number; treturn cards;}-export function ChatMessage({ role, content, isStreaming, toolCalls, onOpenNote }: ChatMessageProps) {+export function ChatMessage({+ role,+ content,+ isStreaming,+ toolCalls,+ onOpenNote,+}: ChatMessageProps) {const { t } = useTranslation();const [copied, setCopied] = useState(false);@@ -206,6 +212,7 @@ export function ChatMessage({ role, content, isStreaming, toolCalls, onOpenNotestyle={{ animation: "agent-message-in 200ms ease-out both" }}><div+ data-chat-bubbleclassName={cn("max-w-[80%] px-3 py-2 rounded-lg rounded-br-sm","bg-primary/90 text-primary-foreground",@@ -228,6 +235,7 @@ export function ChatMessage({ role, content, isStreaming, toolCalls, onOpenNotestyle={{ animation: "agent-message-in 200ms ease-out both" }}><div+ data-chat-bubbleclassName={cn("max-w-[85%] px-3 py-2 rounded-lg rounded-bl-sm","bg-surface-1 border border-border/30 text-foreground",diff --git a/src/components/chat/useChatPersistence.ts b/src/components/chat/useChatPersistence.tsindex 1ed040015..2804be888 100644--- a/src/components/chat/useChatPersistence.ts+++ b/src/components/chat/useChatPersistence.ts@@ -10,7 +10,7 @@ export interface ChatPersistence {messages: Message[];setMessages: React.Dispatch<React.SetStateAction<Message[]>>;conversationId: number | null;- createConversation: (title: string) => Promise<number>;+ createConversation: (title: string, noteId?: number | null) => Promise<number>;loadConversation: (id: number) => Promise<void>;saveUserMessage: (text: string) => Promise<void>;saveAssistantMessage: (content: string, toolCalls?: ToolCallInfo[]) => Promise<void>;@@ -22,8 +22,8 @@ export function useChatPersistence(options: UseChatPersistenceOptions = {}): Chaconst conversationIdRef = useRef<number | null>(options.conversationId ?? null);const createConversation = useCallback(- async (title: string): Promise<number> => {- const conv = await window.electronAPI?.createAgentConversation?.(title);+ async (title: string, noteId?: number | null): Promise<number> => {+ const conv = await window.electronAPI?.createAgentConversation?.(title, noteId ?? undefined);const id = conv?.id ?? 0;conversationIdRef.current = id;options.onConversationCreated?.(id, title);diff --git a/src/components/notes/EmbeddedChat.tsx b/src/components/notes/EmbeddedChat.tsxindex 1f79ed017..04c0b3733 100644--- a/src/components/notes/EmbeddedChat.tsx+++ b/src/components/notes/EmbeddedChat.tsx@@ -1,11 +1,19 @@import { useEffect, useCallback } from "react";import { useTranslation } from "react-i18next";-import { X, PanelRight, PanelRightClose } from "lucide-react";+import { X, PanelRight, PanelRightClose, ChevronDown, Plus } from "lucide-react";import { cn } from "../lib/utils";import { ChatMessages } from "../chat/ChatMessages";import { ChatInput } from "../chat/ChatInput";import type { Message, AgentState } from "../chat/types";import { setActiveNoteId, setActiveFolderId } from "../../stores/noteStore";+import { normalizeDbDate } from "../../utils/dateFormatting";+import {+ DropdownMenu,+ DropdownMenuTrigger,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuSeparator,+} from "../ui/dropdown-menu";export type EmbeddedChatMode = "hidden" | "floating" | "sidebar";@@ -16,6 +24,16 @@ interface EmbeddedChatProps {agentState: AgentState;onTextSubmit: (text: string) => void;onCancel: () => void;+ noteConversations?: Array<{+ id: number;+ title: string;+ created_at: string;+ updated_at: string;+ message_count: number;+ }>;+ activeConversationId?: number | null;+ onSwitchConversation?: (id: number) => void;+ onNewChat?: () => void;}function EmptyState() {@@ -29,6 +47,12 @@ function EmptyState() {);}+function formatConversationDate(dateStr: string): string {+ const date = normalizeDbDate(dateStr);+ if (Number.isNaN(date.getTime())) return "";+ return date.toLocaleDateString(undefined, { month: "short", day: "numeric" });+}+export default function EmbeddedChat({mode,onModeChange,@@ -36,6 +60,10 @@ export default function EmbeddedChat({agentState,onTextSubmit,onCancel,+ noteConversations,+ activeConversationId,+ onSwitchConversation,+ onNewChat,}: EmbeddedChatProps) {const { t } = useTranslation();@@ -61,9 +89,68 @@ export default function EmbeddedChat({if (mode === "hidden") return null;+ const hasConversationSelector =+ noteConversations !== undefined && onSwitchConversation !== undefined;++ const activeConversation = hasConversationSelector+ ? noteConversations.find((c) => c.id === activeConversationId)+ : undefined;++ const headerTitle = hasConversationSelector ? (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <button+ className="inline-flex items-center gap-1 text-xs font-medium text-foreground/50 hover:text-foreground/70 hover:bg-foreground/5 rounded-md px-1.5 py-0.5 -ml-1.5 transition-colors duration-150 outline-none"+ aria-label={t("embeddedChat.conversationSelector")}+ >+ <span className="truncate max-w-32">+ {activeConversation?.title || t("embeddedChat.newChat")}+ </span>+ <ChevronDown size={10} className="shrink-0 text-foreground/30" />+ </button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="start" sideOffset={4} className="min-w-44 max-w-56 p-1">+ <DropdownMenuItem+ onClick={() => onNewChat?.()}+ className="text-xs gap-2 rounded-md px-2 py-1.5"+ >+ <Plus size={10} className="text-foreground/40 shrink-0" />+ {t("embeddedChat.newChat")}+ </DropdownMenuItem>+ {noteConversations.length > 0 && (+ <>+ <DropdownMenuSeparator />+ {noteConversations.map((conv) => (+ <DropdownMenuItem+ key={conv.id}+ onClick={() => onSwitchConversation(conv.id)}+ className={cn(+ "text-xs gap-2 rounded-md px-2 py-1.5",+ conv.id === activeConversationId && "bg-foreground/4"+ )}+ >+ <span className="truncate flex-1">{conv.title}</span>+ <span className="text-[10px] text-foreground/30 shrink-0">+ {formatConversationDate(conv.updated_at)}+ </span>+ </DropdownMenuItem>+ ))}+ </>+ )}+ </DropdownMenuContent>+ </DropdownMenu>+ ) : (+ <span className="text-xs font-medium text-foreground/50">{t("embeddedChat.title")}</span>+ );+const header = (- <div className="h-9 flex items-center px-3 shrink-0">- <span className="text-xs font-medium text-foreground/50">{t("embeddedChat.title")}</span>+ <div+ className={cn(+ "h-9 flex items-center px-3 shrink-0",+ mode === "sidebar" && "border-b border-border/10 dark:border-white/5"+ )}+ >+ {headerTitle}<div className="flex-1" /><div className="flex items-center gap-0.5">{mode === "floating" ? (@@ -97,7 +184,9 @@ export default function EmbeddedChat({const chatContent = (<>{header}- <ChatMessages messages={messages} emptyState={<EmptyState />} onOpenNote={handleOpenNote} />+ <div className="flex-1 min-h-0 flex flex-col **:data-chat-bubble:max-w-full">+ <ChatMessages messages={messages} emptyState={<EmptyState />} onOpenNote={handleOpenNote} />+ </div><ChatInputagentState={agentState}partialTranscript=""@@ -111,8 +200,8 @@ export default function EmbeddedChat({return (<divclassName={cn(- "absolute bottom-20 right-4 z-20",- "w-95 max-h-120 min-h-50",+ "absolute bottom-4 left-5 right-5 z-20",+ "max-h-[calc(100%-2rem)] min-h-50","flex flex-col","bg-background/95 dark:bg-surface-2/95","border border-border/20 dark:border-white/8",@@ -131,7 +220,8 @@ export default function EmbeddedChat({<divclassName={cn("w-85 shrink-0",- "border-l border-border/15 dark:border-white/6",+ "border-l border-border/25 dark:border-white/10",+ "bg-surface-1 dark:bg-surface-2","flex flex-col","min-h-0")}diff --git a/src/components/notes/NoteBottomBar.tsx b/src/components/notes/NoteBottomBar.tsxindex 29f1d1a0a..afdf1b0e5 100644--- a/src/components/notes/NoteBottomBar.tsx+++ b/src/components/notes/NoteBottomBar.tsx@@ -11,8 +11,10 @@ interface NoteBottomBarProps {onStartRecording: () => void;onStopRecording: () => void;onAskSubmit: (text: string) => void;+ onInputFocus?: () => void;askDisabled?: boolean;actionPicker?: React.ReactNode;+ hideInput?: boolean;}export default function NoteBottomBar({@@ -21,8 +23,10 @@ export default function NoteBottomBar({onStartRecording,onStopRecording,onAskSubmit,+ onInputFocus,askDisabled,actionPicker,+ hideInput,}: NoteBottomBarProps) {const { t } = useTranslation();const [inputText, setInputText] = useState("");@@ -69,7 +73,8 @@ export default function NoteBottomBar({const handleInputFocus = useCallback(() => {setIsExpanded(true);- }, []);+ onInputFocus?.();+ }, [onInputFocus]);useEffect(() => {if (!isExpanded) return;@@ -87,11 +92,13 @@ export default function NoteBottomBar({ref={containerRef}className="absolute bottom-0 left-0 right-0 z-10 px-5 pb-4 pt-3 pointer-events-none bg-background">- <div className="flex items-end gap-2 pointer-events-auto">+ <div+ className={cn("flex items-end gap-2 pointer-events-auto", hideInput && "justify-center")}+ ><divclassName={cn("shrink-0 transition-all duration-300 ease-out overflow-hidden",- isExpanded && !isRecording ? "w-0 opacity-0" : "w-auto opacity-100"+ !hideInput && isExpanded && !isRecording ? "w-0 opacity-0" : "w-auto opacity-100")}>{isRecording ? (@@ -154,54 +161,56 @@ export default function NoteBottomBar({)}</div>- <div- className={cn(- "flex-1 min-w-0 flex items-center h-10 px-3 gap-2",- "rounded-xl",- "bg-foreground/3 dark:bg-white/4",- "border",- "transition-all duration-200",- isExpanded- ? "border-foreground/12 dark:border-white/10 shadow-[0_0_0_3px_rgba(0,0,0,0.02)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.02)]"- : "border-border/20 dark:border-white/6"- )}- >- <input- ref={inputRef}- type="text"- value={inputText}- onChange={(e) => setInputText(e.target.value)}- onKeyDown={handleKeyDown}- onFocus={handleInputFocus}- disabled={askDisabled}- placeholder={t("embeddedChat.askPlaceholder")}+ {!hideInput && (+ <divclassName={cn(- "input-inline flex-1 bg-transparent outline-none min-w-0 p-0",- "text-[13px] text-foreground",- "placeholder:text-foreground/25 dark:placeholder:text-foreground/15"+ "flex-1 min-w-0 flex items-center h-10 px-3 gap-2",+ "rounded-xl",+ "bg-foreground/3 dark:bg-white/4",+ "border",+ "transition-all duration-200",+ isExpanded+ ? "border-foreground/12 dark:border-white/10 shadow-[0_0_0_3px_rgba(0,0,0,0.02)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.02)]"+ : "border-border/20 dark:border-white/6")}- />-- {hasText ? (- <button- onClick={handleSubmit}+ >+ <input+ ref={inputRef}+ type="text"+ value={inputText}+ onChange={(e) => setInputText(e.target.value)}+ onKeyDown={handleKeyDown}+ onFocus={handleInputFocus}disabled={askDisabled}+ placeholder={t("embeddedChat.askPlaceholder")}className={cn(- "flex items-center justify-center w-6 h-6 rounded-md shrink-0",- "bg-foreground dark:bg-foreground/90 text-background",- "transition-all duration-150",- "hover:bg-foreground/85 dark:hover:bg-foreground/80",- "active:scale-90",- "disabled:opacity-30"+ "input-inline flex-1 bg-transparent outline-none min-w-0 p-0",+ "text-[13px] text-foreground",+ "placeholder:text-foreground/25 dark:placeholder:text-foreground/15")}- aria-label={t("embeddedChat.send")}- >- <ArrowUp size={13} strokeWidth={2.5} />- </button>- ) : !isExpanded ? (- <div className="shrink-0">{actionPicker}</div>- ) : null}- </div>+ />++ {hasText ? (+ <button+ onClick={handleSubmit}+ disabled={askDisabled}+ className={cn(+ "flex items-center justify-center w-6 h-6 rounded-md shrink-0",+ "bg-foreground dark:bg-foreground/90 text-background",+ "transition-all duration-150",+ "hover:bg-foreground/85 dark:hover:bg-foreground/80",+ "active:scale-90",+ "disabled:opacity-30"+ )}+ aria-label={t("embeddedChat.send")}+ >+ <ArrowUp size={13} strokeWidth={2.5} />+ </button>+ ) : !isExpanded ? (+ <div className="shrink-0">{actionPicker}</div>+ ) : null}+ </div>+ )}</div></div>);diff --git a/src/components/notes/NoteEditor.tsx b/src/components/notes/NoteEditor.tsxindex a9c575b9b..f8be1ec46 100644--- a/src/components/notes/NoteEditor.tsx+++ b/src/components/notes/NoteEditor.tsx@@ -133,6 +133,7 @@ export default function NoteEditor({});const titleRef = useRef<HTMLDivElement>(null);const prevNoteIdRef = useRef<number>(note.id);+ const autoShowDoneRef = useRef(false);const segmentContainerRef = useRef<HTMLDivElement>(null);const [indicatorStyle, setIndicatorStyle] = useState<React.CSSProperties>({ opacity: 0 });@@ -194,6 +195,8 @@ export default function NoteEditor({useEffect(() => {if (note.id !== prevNoteIdRef.current) {prevNoteIdRef.current = note.id;+ autoShowDoneRef.current = false;+ setChatMode("hidden");if (!isMeetingRecording) {setViewMode("raw");}@@ -204,6 +207,18 @@ export default function NoteEditor({}}, [note.id, isMeetingRecording]);+ // Auto-show chat when hook loads an existing conversation with messages+ useEffect(() => {+ if (+ !autoShowDoneRef.current &&+ embeddedChat.activeConversationId &&+ embeddedChat.messages.length > 0+ ) {+ autoShowDoneRef.current = true;+ setChatMode("floating");+ }+ }, [embeddedChat.activeConversationId, embeddedChat.messages.length]);+useEffect(() => {if (titleRef.current && titleRef.current.textContent !== note.title) {titleRef.current.textContent = note.title || "";@@ -272,239 +287,245 @@ export default function NoteEditor({[chatMode, embeddedChat]);+ const handleChatInputFocus = useCallback(() => {+ if (chatMode === "hidden") {+ setChatMode("floating");+ }+ }, [chatMode]);+const noteDate = formatNoteDate(note.created_at);const shortDate = formatShortDate(note.created_at);return (- <div className="flex flex-col h-full min-h-0">- <div className="px-5 pt-4 pb-0">- <div- ref={titleRef}- contentEditable- suppressContentEditableWarning- onInput={handleTitleInput}- onKeyDown={handleTitleKeyDown}- onPaste={handleTitlePaste}- data-placeholder={t("notes.editor.untitled")}- className="text-base font-semibold text-foreground bg-transparent outline-none tracking-[-0.01em] empty:before:content-[attr(data-placeholder)] empty:before:text-foreground/15 empty:before:pointer-events-none"- role="textbox"- aria-label={t("notes.editor.noteTitle")}- />- {/* Metadata + toolbar row */}- <div className="flex items-center gap-2 mt-1.5">- {shortDate && (- <span- className="inline-flex items-center gap-1.5 text-[11px] text-foreground/50 dark:text-foreground/35"- title={noteDate}- >- <Calendar size={11} className="shrink-0" />- {shortDate}- </span>- )}- {calendarEventName && (- <span className="inline-flex items-center gap-1.5 text-[11px] text-foreground/50 dark:text-foreground/35">- <LinkIcon size={11} className="shrink-0" />- <span className="truncate max-w-40">{calendarEventName}</span>- </span>- )}- {folders && onMoveToFolder && (- <DropdownMenu- onOpenChange={(open) => {- if (!open) {- setFolderSearch("");- setIsCreatingFolder(false);- setNewFolderName("");- }- }}- >- <DropdownMenuTrigger asChild>- <button className="inline-flex items-center gap-1.5 text-[11px] px-1.5 py-0.5 rounded-md border border-border/70 dark:border-white/25 text-foreground/50 dark:text-foreground/35 hover:text-foreground/60 hover:border-border/60 hover:bg-foreground/3 dark:hover:text-foreground/40 dark:hover:border-white/10 dark:hover:bg-white/3 transition-all duration-150 cursor-pointer outline-none">- <FolderOpen size={11} className="shrink-0" />- {folderName || t("notes.editor.noFolder")}- </button>- </DropdownMenuTrigger>- <DropdownMenuContent align="start" sideOffset={6} className="min-w-44 p-1">- {folders.length > 5 && (- <>- <div className="relative px-1.5 py-0.5">- <Search- size={9}- className="absolute left-3.5 top-1/2 -translate-y-1/2 text-foreground/15 pointer-events-none"- />- <input- value={folderSearch}- onChange={(e) => setFolderSearch(e.target.value)}- onKeyDown={(e) => e.stopPropagation()}- placeholder={t("notes.context.searchFolders")}- className="input-inline w-full pl-4.5 pr-1 py-0.5 text-xs text-foreground placeholder:text-foreground/15 outline-none border-none appearance-none"- />- </div>- <DropdownMenuSeparator />- </>- )}- <div className="overflow-y-auto max-h-48">- {filteredFolders.map((folder) => {- const isCurrent = folder.id === note.folder_id;- return (- <DropdownMenuItem- key={folder.id}- disabled={isCurrent}- onClick={() => onMoveToFolder(note.id, folder.id)}- className="text-xs gap-2 rounded-md px-2 py-1.5"- >- <FolderOpen size={11} className="text-foreground/30 shrink-0" />- <span className="truncate flex-1">{folder.name}</span>- {isCurrent && <Check size={9} className="text-primary shrink-0" />}- </DropdownMenuItem>- );- })}- {folderSearch && filteredFolders.length === 0 && (- <p className="text-xs text-foreground/20 text-center py-1.5">- {t("notes.context.noResults")}- </p>- )}- </div>- {onCreateFolderAndMove && (- <>- <DropdownMenuSeparator />- {isCreatingFolder ? (- <div className="px-1">+ <div className="flex h-full min-h-0">+ <div className="flex-1 min-w-0 flex flex-col">+ <div className="px-5 pt-4 pb-0">+ <div+ ref={titleRef}+ contentEditable+ suppressContentEditableWarning+ onInput={handleTitleInput}+ onKeyDown={handleTitleKeyDown}+ onPaste={handleTitlePaste}+ data-placeholder={t("notes.editor.untitled")}+ className="text-base font-semibold text-foreground bg-transparent outline-none tracking-[-0.01em] empty:before:content-[attr(data-placeholder)] empty:before:text-foreground/15 empty:before:pointer-events-none"+ role="textbox"+ aria-label={t("notes.editor.noteTitle")}+ />+ {/* Metadata + toolbar row */}+ <div className="flex items-center gap-2 mt-1.5">+ {shortDate && (+ <span+ className="inline-flex items-center gap-1.5 text-[11px] text-foreground/50 dark:text-foreground/35"+ title={noteDate}+ >+ <Calendar size={11} className="shrink-0" />+ {shortDate}+ </span>+ )}+ {calendarEventName && (+ <span className="inline-flex items-center gap-1.5 text-[11px] text-foreground/50 dark:text-foreground/35">+ <LinkIcon size={11} className="shrink-0" />+ <span className="truncate max-w-40">{calendarEventName}</span>+ </span>+ )}+ {folders && onMoveToFolder && (+ <DropdownMenu+ onOpenChange={(open) => {+ if (!open) {+ setFolderSearch("");+ setIsCreatingFolder(false);+ setNewFolderName("");+ }+ }}+ >+ <DropdownMenuTrigger asChild>+ <button className="inline-flex items-center gap-1.5 text-[11px] px-1.5 py-0.5 rounded-md border border-border/70 dark:border-white/25 text-foreground/50 dark:text-foreground/35 hover:text-foreground/60 hover:border-border/60 hover:bg-foreground/3 dark:hover:text-foreground/40 dark:hover:border-white/10 dark:hover:bg-white/3 transition-all duration-150 cursor-pointer outline-none">+ <FolderOpen size={11} className="shrink-0" />+ {folderName || t("notes.editor.noFolder")}+ </button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="start" sideOffset={6} className="min-w-44 p-1">+ {folders.length > 5 && (+ <>+ <div className="relative px-1.5 py-0.5">+ <Search+ size={9}+ className="absolute left-3.5 top-1/2 -translate-y-1/2 text-foreground/15 pointer-events-none"+ /><input- autoFocus- value={newFolderName}- onChange={(e) => setNewFolderName(e.target.value)}- onKeyDown={(e) => {- e.stopPropagation();- if (e.key === "Enter" && newFolderName.trim()) {- onCreateFolderAndMove(note.id, newFolderName.trim());- setNewFolderName("");- setIsCreatingFolder(false);- }- if (e.key === "Escape") {- setIsCreatingFolder(false);- setNewFolderName("");- }- }}- placeholder={t("notes.folders.folderName")}- className="input-inline w-full px-2 py-1.5 rounded-md bg-transparent text-xs text-foreground placeholder:text-foreground/20 outline-none border-none appearance-none"+ value={folderSearch}+ onChange={(e) => setFolderSearch(e.target.value)}+ onKeyDown={(e) => e.stopPropagation()}+ placeholder={t("notes.context.searchFolders")}+ className="input-inline w-full pl-4.5 pr-1 py-0.5 text-xs text-foreground placeholder:text-foreground/15 outline-none border-none appearance-none"/></div>- ) : (- <DropdownMenuItem- onSelect={(e) => {- e.preventDefault();- setIsCreatingFolder(true);- }}- className="text-xs gap-2 rounded-md px-2 py-1.5 text-foreground/40"- >- <Plus size={10} />- {t("notes.context.newFolder")}- </DropdownMenuItem>- )}- </>- )}- </DropdownMenuContent>- </DropdownMenu>- )}- {isSaving && (- <span className="inline-flex items-center gap-1 text-[11px] text-foreground/30 dark:text-foreground/15 tabular-nums">- <Loader2 size={8} className="animate-spin" />- {t("notes.editor.saving")}- </span>- )}- <div className="flex-1" />- <div className="flex items-center gap-1">- {(enhancement || hasMeetingTranscript || hasChatSegments || isMeetingRecording) && (- <div- ref={segmentContainerRef}- className="relative flex items-center shrink-0 rounded-md bg-foreground/3 dark:bg-white/3 p-0.5"- >- <div- className="absolute top-0.5 left-0 rounded bg-background dark:bg-surface-2 shadow-sm transition-[width,height,transform,opacity] duration-200 ease-out pointer-events-none"- style={indicatorStyle}- />- {(hasMeetingTranscript || hasChatSegments || isMeetingRecording) && (- <button- data-segment-button- data-segment-value="transcript"- onClick={() => setViewMode("transcript")}- className={cn(- "relative z-1 px-1.5 h-5 rounded text-xs font-medium transition-colors duration-150 flex items-center gap-1",- viewMode === "transcript"- ? "text-foreground/60"- : "text-foreground/25 hover:text-foreground/40"+ <DropdownMenuSeparator />+ </>+ )}+ <div className="overflow-y-auto max-h-48">+ {filteredFolders.map((folder) => {+ const isCurrent = folder.id === note.folder_id;+ return (+ <DropdownMenuItem+ key={folder.id}+ disabled={isCurrent}+ onClick={() => onMoveToFolder(note.id, folder.id)}+ className="text-xs gap-2 rounded-md px-2 py-1.5"+ >+ <FolderOpen size={11} className="text-foreground/30 shrink-0" />+ <span className="truncate flex-1">{folder.name}</span>+ {isCurrent && <Check size={9} className="text-primary shrink-0" />}+ </DropdownMenuItem>+ );+ })}+ {folderSearch && filteredFolders.length === 0 && (+ <p className="text-xs text-foreground/20 text-center py-1.5">+ {t("notes.context.noResults")}+ </p>)}- >- <MessageSquareText size={10} />- {t("notes.editor.transcript")}- </button>- )}- <button- data-segment-button- data-segment-value="raw"- onClick={() => setViewMode("raw")}- className={cn(- "relative z-1 px-1.5 h-5 rounded text-xs font-medium transition-colors duration-150 flex items-center gap-1",- viewMode === "raw"- ? "text-foreground/60"- : "text-foreground/25 hover:text-foreground/40"+ </div>+ {onCreateFolderAndMove && (+ <>+ <DropdownMenuSeparator />+ {isCreatingFolder ? (+ <div className="px-1">+ <input+ autoFocus+ value={newFolderName}+ onChange={(e) => setNewFolderName(e.target.value)}+ onKeyDown={(e) => {+ e.stopPropagation();+ if (e.key === "Enter" && newFolderName.trim()) {+ onCreateFolderAndMove(note.id, newFolderName.trim());+ setNewFolderName("");+ setIsCreatingFolder(false);+ }+ if (e.key === "Escape") {+ setIsCreatingFolder(false);+ setNewFolderName("");+ }+ }}+ placeholder={t("notes.folders.folderName")}+ className="input-inline w-full px-2 py-1.5 rounded-md bg-transparent text-xs text-foreground placeholder:text-foreground/20 outline-none border-none appearance-none"+ />+ </div>+ ) : (+ <DropdownMenuItem+ onSelect={(e) => {+ e.preventDefault();+ setIsCreatingFolder(true);+ }}+ className="text-xs gap-2 rounded-md px-2 py-1.5 text-foreground/40"+ >+ <Plus size={10} />+ {t("notes.context.newFolder")}+ </DropdownMenuItem>+ )}+ </>)}+ </DropdownMenuContent>+ </DropdownMenu>+ )}+ {isSaving && (+ <span className="inline-flex items-center gap-1 text-[11px] text-foreground/30 dark:text-foreground/15 tabular-nums">+ <Loader2 size={8} className="animate-spin" />+ {t("notes.editor.saving")}+ </span>+ )}+ <div className="flex-1" />+ <div className="flex items-center gap-1">+ {(enhancement || hasMeetingTranscript || hasChatSegments || isMeetingRecording) && (+ <div+ ref={segmentContainerRef}+ className="relative flex items-center shrink-0 rounded-md bg-foreground/3 dark:bg-white/3 p-0.5">- <AlignLeft size={10} />- {t("notes.editor.notes")}- </button>- {enhancement && (+ <div+ className="absolute top-0.5 left-0 rounded bg-background dark:bg-surface-2 shadow-sm transition-[width,height,transform,opacity] duration-200 ease-out pointer-events-none"+ style={indicatorStyle}+ />+ {(hasMeetingTranscript || hasChatSegments || isMeetingRecording) && (+ <button+ data-segment-button+ data-segment-value="transcript"+ onClick={() => setViewMode("transcript")}+ className={cn(+ "relative z-1 px-1.5 h-5 rounded text-xs font-medium transition-colors duration-150 flex items-center gap-1",+ viewMode === "transcript"+ ? "text-foreground/60"+ : "text-foreground/25 hover:text-foreground/40"+ )}+ >+ <MessageSquareText size={10} />+ {t("notes.editor.transcript")}+ </button>+ )}<buttondata-segment-button- data-segment-value="enhanced"- onClick={() => setViewMode("enhanced")}+ data-segment-value="raw"+ onClick={() => setViewMode("raw")}className={cn("relative z-1 px-1.5 h-5 rounded text-xs font-medium transition-colors duration-150 flex items-center gap-1",- viewMode === "enhanced"+ viewMode === "raw"? "text-foreground/60": "text-foreground/25 hover:text-foreground/40")}>- <Sparkles size={9} />- {t("notes.editor.enhanced")}- {enhancement.isStale && (- <span- className="w-1 h-1 rounded-full bg-amber-400/60"- title={t("notes.editor.staleIndicator")}- />- )}+ <AlignLeft size={10} />+ {t("notes.editor.notes")}</button>- )}- </div>- )}- {onExportNote && (- <DropdownMenu>- <DropdownMenuTrigger asChild>- <button- className="shrink-0 h-6 w-6 flex items-center justify-center rounded-md bg-foreground/4 dark:bg-white/5 text-foreground/50 dark:text-foreground/40 hover:text-foreground/70 hover:bg-foreground/8 dark:hover:text-foreground/60 dark:hover:bg-white/8 transition-colors duration-150"- aria-label={t("notes.editor.export")}- >- <Download size={11} />- </button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end" sideOffset={4}>- <DropdownMenuItem onClick={() => onExportNote("md")} className="text-xs gap-2">- <FileText size={13} className="text-foreground/40" />- {t("notes.editor.asMarkdown")}- </DropdownMenuItem>- <DropdownMenuItem onClick={() => onExportNote("txt")} className="text-xs gap-2">- <FileText size={13} className="text-foreground/40" />- {t("notes.editor.asPlainText")}- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- )}+ {enhancement && (+ <button+ data-segment-button+ data-segment-value="enhanced"+ onClick={() => setViewMode("enhanced")}+ className={cn(+ "relative z-1 px-1.5 h-5 rounded text-xs font-medium transition-colors duration-150 flex items-center gap-1",+ viewMode === "enhanced"+ ? "text-foreground/60"+ : "text-foreground/25 hover:text-foreground/40"+ )}+ >+ <Sparkles size={9} />+ {t("notes.editor.enhanced")}+ {enhancement.isStale && (+ <span+ className="w-1 h-1 rounded-full bg-amber-400/60"+ title={t("notes.editor.staleIndicator")}+ />+ )}+ </button>+ )}+ </div>+ )}+ {onExportNote && (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <button+ className="shrink-0 h-6 w-6 flex items-center justify-center rounded-md bg-foreground/4 dark:bg-white/5 text-foreground/50 dark:text-foreground/40 hover:text-foreground/70 hover:bg-foreground/8 dark:hover:text-foreground/60 dark:hover:bg-white/8 transition-colors duration-150"+ aria-label={t("notes.editor.export")}+ >+ <Download size={11} />+ </button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" sideOffset={4}>+ <DropdownMenuItem onClick={() => onExportNote("md")} className="text-xs gap-2">+ <FileText size={13} className="text-foreground/40" />+ {t("notes.editor.asMarkdown")}+ </DropdownMenuItem>+ <DropdownMenuItem onClick={() => onExportNote("txt")} className="text-xs gap-2">+ <FileText size={13} className="text-foreground/40" />+ {t("notes.editor.asPlainText")}+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ )}+ </div></div></div>- </div>- <div className="flex-1 relative min-h-0 flex">- <div className="flex-1 min-w-0 relative">+ <div className="flex-1 relative min-h-0"><div className="h-full overflow-y-auto">{viewMode === "transcript" && (hasChatSegments || isMeetingRecording) ? (<MeetingTranscriptChat@@ -544,7 +565,9 @@ export default function NoteEditor({isMeetingRecording ? (onStopMeetingRecording ?? onStopRecording) : onStopRecording}onAskSubmit={handleAskSubmit}+ onInputFocus={handleChatInputFocus}actionPicker={isMeetingRecording ? undefined : actionPicker}+ hideInput={chatMode !== "hidden"}/>{chatMode === "floating" && (<EmbeddedChat@@ -554,20 +577,28 @@ export default function NoteEditor({agentState={embeddedChat.agentState}onTextSubmit={embeddedChat.sendMessage}onCancel={embeddedChat.cancelStream}+ noteConversations={embeddedChat.noteConversations}+ activeConversationId={embeddedChat.activeConversationId}+ onSwitchConversation={embeddedChat.switchConversation}+ onNewChat={embeddedChat.startNewChat}/>)}</div>- {chatMode === "sidebar" && (- <EmbeddedChat- mode="sidebar"- onModeChange={setChatMode}- messages={embeddedChat.messages}- agentState={embeddedChat.agentState}- onTextSubmit={embeddedChat.sendMessage}- onCancel={embeddedChat.cancelStream}- />- )}</div>+ {chatMode === "sidebar" && (+ <EmbeddedChat+ mode="sidebar"+ onModeChange={setChatMode}+ messages={embeddedChat.messages}+ agentState={embeddedChat.agentState}+ onTextSubmit={embeddedChat.sendMessage}+ onCancel={embeddedChat.cancelStream}+ noteConversations={embeddedChat.noteConversations}+ activeConversationId={embeddedChat.activeConversationId}+ onSwitchConversation={embeddedChat.switchConversation}+ onNewChat={embeddedChat.startNewChat}+ />+ )}</div>);}diff --git a/src/helpers/database.js b/src/helpers/database.jsindex 40523b485..de78bf70c 100644--- a/src/helpers/database.js+++ b/src/helpers/database.js@@ -245,6 +245,14 @@ class DatabaseManager {} catch (err) {if (!err.message.includes("duplicate column")) throw err;}+ try {+ this.db.exec("ALTER TABLE agent_conversations ADD COLUMN note_id INTEGER");+ } catch (err) {+ if (!err.message.includes("duplicate column")) throw err;+ }+ this.db.exec(+ "CREATE INDEX IF NOT EXISTS idx_agent_conversations_note ON agent_conversations(note_id)"+ );const actionCount = this.db.prepare("SELECT COUNT(*) as count FROM actions").get();if (actionCount.count === 0) {@@ -822,12 +830,12 @@ class DatabaseManager {}}- createAgentConversation(title = "Untitled") {+ createAgentConversation(title = "Untitled", noteId = null) {try {if (!this.db) throw new Error("Database not initialized");const result = this.db- .prepare("INSERT INTO agent_conversations (title) VALUES (?)")- .run(title);+ .prepare("INSERT INTO agent_conversations (title, note_id) VALUES (?, ?)")+ .run(title, noteId);return this.db.prepare("SELECT * FROM agent_conversations WHERE id = ?").get(result.lastInsertRowid);@@ -837,6 +845,31 @@ class DatabaseManager {}}+ getConversationsForNote(noteId, limit = 20) {+ try {+ if (!this.db) throw new Error("Database not initialized");+ return this.db+ .prepare(+ `SELECT c.id, c.title, c.created_at, c.updated_at,+ COUNT(m.id) AS message_count+ FROM agent_conversations c+ LEFT JOIN agent_messages m ON m.conversation_id = c.id+ WHERE c.note_id = ?+ GROUP BY c.id+ ORDER BY c.updated_at DESC+ LIMIT ?`+ )+ .all(noteId, limit);+ } catch (error) {+ debugLogger.error(+ "Error getting conversations for note",+ { error: error.message },+ "database"+ );+ throw error;+ }+ }+getAgentConversations(limit = 50) {try {if (!this.db) throw new Error("Database not initialized");diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex d1722d7a3..5d124a5c0 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -809,8 +809,12 @@ class IPCHandlers {});// Agent conversation handlers- ipcMain.handle("db-create-agent-conversation", async (event, title) => {- return this.databaseManager.createAgentConversation(title);+ ipcMain.handle("db-create-agent-conversation", async (event, title, noteId) => {+ return this.databaseManager.createAgentConversation(title, noteId);+ });++ ipcMain.handle("db-get-conversations-for-note", async (event, noteId, limit) => {+ return this.databaseManager.getConversationsForNote(noteId, limit);});ipcMain.handle("db-get-agent-conversations", async (event, limit) => {diff --git a/src/hooks/useEmbeddedChat.ts b/src/hooks/useEmbeddedChat.tsindex 6cb1eb4a2..62ccfd262 100644--- a/src/hooks/useEmbeddedChat.ts+++ b/src/hooks/useEmbeddedChat.ts@@ -11,11 +11,23 @@ interface UseEmbeddedChatOptions {noteTranscript?: string;}+interface NoteConversationItem {+ id: number;+ title: string;+ created_at: string;+ updated_at: string;+ message_count: number;+}+interface UseEmbeddedChatReturn {messages: Message[];agentState: AgentState;sendMessage: (text: string) => Promise<void>;cancelStream: () => void;+ noteConversations: NoteConversationItem[];+ activeConversationId: number | null;+ switchConversation: (id: number) => Promise<void>;+ startNewChat: () => void;}export function useEmbeddedChat({@@ -26,6 +38,7 @@ export function useEmbeddedChat({noteTranscript,}: UseEmbeddedChatOptions): UseEmbeddedChatReturn {const [conversationId, setConversationId] = useState<number | null>(null);+ const [noteConversations, setNoteConversations] = useState<NoteConversationItem[]>([]);const noteIdRef = useRef(noteId);const persistence = useChatPersistence({@@ -55,21 +68,65 @@ export function useEmbeddedChat({},});- // Reset chat when noteId changes+ const fetchNoteConversations = useCallback(async () => {+ if (!noteId) return;+ const conversations = await window.electronAPI?.getConversationsForNote?.(noteId);+ if (noteIdRef.current !== noteId) return;+ setNoteConversations(conversations ?? []);+ return conversations ?? [];+ }, [noteId]);++ // Load conversations when noteId changesuseEffect(() => {- if (noteId !== noteIdRef.current) {- noteIdRef.current = noteId;+ noteIdRef.current = noteId;+ if (!noteId) {persistence.handleNewChat();setConversationId(null);+ setNoteConversations([]);+ return;}- }, [noteId, persistence]);++ let stale = false;+ (async () => {+ const conversations = await window.electronAPI?.getConversationsForNote?.(noteId);+ if (stale || noteIdRef.current !== noteId) return;+ setNoteConversations(conversations ?? []);+ if (conversations?.length) {+ const mostRecent = conversations[0];+ await persistence.loadConversation(mostRecent.id);+ if (stale || noteIdRef.current !== noteId) return;+ setConversationId(mostRecent.id);+ } else {+ persistence.handleNewChat();+ setConversationId(null);+ }+ })();++ return () => {+ stale = true;+ };+ }, [noteId]); // eslint-disable-line react-hooks/exhaustive-deps++ const switchConversation = useCallback(+ async (id: number) => {+ await persistence.loadConversation(id);+ setConversationId(id);+ },+ [persistence]+ );++ const startNewChat = useCallback(() => {+ persistence.handleNewChat();+ setConversationId(null);+ }, [persistence]);const sendMessage = useCallback(async (text: string) => {let convId = conversationId;if (!convId) {const title = `Note: ${noteTitle || "Untitled"}`;- convId = await persistence.createConversation(title);+ convId = await persistence.createConversation(title, noteId);+ fetchNoteConversations();}const userMsg: Message = {@@ -84,7 +141,7 @@ export function useEmbeddedChat({const allMessages = [...persistence.messages, userMsg];await streaming.sendToAI(text, allMessages);},- [conversationId, noteTitle, persistence, streaming]+ [conversationId, noteId, noteTitle, persistence, streaming, fetchNoteConversations]);return {@@ -92,5 +149,9 @@ export function useEmbeddedChat({agentState: streaming.agentState,sendMessage,cancelStream: streaming.cancelStream,+ noteConversations,+ activeConversationId: conversationId,+ switchConversation,+ startNewChat,};}diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex 7d493f595..35f89f9de 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -2085,6 +2085,8 @@"emptyState": "Stelle eine Frage zu dieser Notiz","dock": "In Seitenleiste andocken","undock": "Von Seitenleiste abdocken",- "close": "Chat schließen"+ "close": "Chat schließen",+ "newChat": "Neuer Chat",+ "conversationSelector": "Unterhaltung wechseln"}}diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex 80aac96c5..41cfcc141 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -2085,6 +2085,8 @@"emptyState": "Ask a question about this note","dock": "Dock to sidebar","undock": "Undock from sidebar",- "close": "Close chat"+ "close": "Close chat",+ "newChat": "New chat",+ "conversationSelector": "Switch conversation"}}diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex cee9aa72d..74937c3d9 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -2085,6 +2085,8 @@"emptyState": "Haz una pregunta sobre esta nota","dock": "Anclar a la barra lateral","undock": "Desanclar de la barra lateral",- "close": "Cerrar chat"+ "close": "Cerrar chat",+ "newChat": "Nuevo chat",+ "conversationSelector": "Cambiar conversación"}}diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex cb0d808c9..a50039437 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -2085,6 +2085,8 @@"emptyState": "Posez une question sur cette note","dock": "Ancrer dans la barre latérale","undock": "Détacher de la barre latérale",- "close": "Fermer le chat"+ "close": "Fermer le chat",+ "newChat": "Nouvelle discussion",+ "conversationSelector": "Changer de conversation"}}diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex 004057052..c19428aad 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -2085,6 +2085,8 @@"emptyState": "Fai una domanda su questa nota","dock": "Ancora nella barra laterale","undock": "Sgancia dalla barra laterale",- "close": "Chiudi chat"+ "close": "Chiudi chat",+ "newChat": "Nuova chat",+ "conversationSelector": "Cambia conversazione"}}diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex a6a107cad..5bc01c408 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -2085,6 +2085,8 @@"emptyState": "このノートについて質問してください","dock": "サイドバーに固定","undock": "サイドバーから外す",- "close": "チャットを閉じる"+ "close": "チャットを閉じる",+ "newChat": "新しいチャット",+ "conversationSelector": "会話を切り替え"}}diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex b80dcf0f2..67cd92517 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -2085,6 +2085,8 @@"emptyState": "Faça uma pergunta sobre esta nota","dock": "Fixar na barra lateral","undock": "Desafixar da barra lateral",- "close": "Fechar chat"+ "close": "Fechar chat",+ "newChat": "Novo chat",+ "conversationSelector": "Trocar conversa"}}diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 0068742e0..7642822ec 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -2085,6 +2085,8 @@"emptyState": "Задайте вопрос об этой заметке","dock": "Закрепить на боковой панели","undock": "Открепить от боковой панели",- "close": "Закрыть чат"+ "close": "Закрыть чат",+ "newChat": "Новый чат",+ "conversationSelector": "Сменить беседу"}}diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex 329b97e12..18540b31a 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -2080,6 +2080,8 @@"emptyState": "就这条笔记提个问题","dock": "固定到侧边栏","undock": "从侧边栏取消固定",- "close": "关闭聊天"+ "close": "关闭聊天",+ "newChat": "新对话",+ "conversationSelector": "切换对话"}}diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex 56b785606..d91cd0772 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -2080,6 +2080,8 @@"emptyState": "就這條筆記提個問題","dock": "固定到側邊欄","undock": "從側邊欄取消固定",- "close": "關閉聊天"+ "close": "關閉聊天",+ "newChat": "新對話",+ "conversationSelector": "切換對話"}}diff --git a/src/stores/chatStore.ts b/src/stores/chatStore.tsindex 0b118e518..74a466860 100644--- a/src/stores/chatStore.ts+++ b/src/stores/chatStore.ts@@ -5,6 +5,7 @@ interface ConversationItem {title: string;cloud_id?: string | null;archived_at?: string | null;+ note_id?: number | null;created_at: string;updated_at: string;}diff --git a/src/types/electron.ts b/src/types/electron.tsindex ff9a10ca8..3239790bb 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -1039,12 +1039,28 @@ declare global {updateAgentHotkey?: (hotkey: string) => Promise<{ success: boolean; message: string }>;getAgentKey?: () => Promise<string>;saveAgentKey?: (key: string) => Promise<void>;- createAgentConversation?: (title: string) => Promise<{+ createAgentConversation?: (+ title: string,+ noteId?: number+ ) => Promise<{id: number;title: string;+ note_id?: number | null;created_at: string;updated_at: string;}>;+ getConversationsForNote?: (+ noteId: number,+ limit?: number+ ) => Promise<+ Array<{+ id: number;+ title: string;+ created_at: string;+ updated_at: string;+ message_count: number;+ }>+ >;getAgentConversations?: (limit?: number) => Promise<Array<{id: number;