Skip to content

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

feat(notes): add save notes as files with folder hierarchy mirror

Gabriel Stein1bf54f094397
diff --git a/preload.js b/preload.js
index 09ea3d3e5..3688ff95d 100644
--- a/preload.js
+++ b/preload.js
@@ -102,6 +102,16 @@ contextBridge.exposeInMainWorld("electronAPI", {
renameFolder: (id, name) => ipcRenderer.invoke("db-rename-folder", id, name),
getFolderNoteCounts: () => ipcRenderer.invoke("db-get-folder-note-counts"),
+ // Note files (markdown mirror) functions
+ noteFilesSetEnabled: (enabled, customPath) =>
+ ipcRenderer.invoke("note-files-set-enabled", enabled, customPath),
+ noteFilesSetPath: (path) => ipcRenderer.invoke("note-files-set-path", path),
+ noteFilesRebuild: () => ipcRenderer.invoke("note-files-rebuild"),
+ noteFilesGetDefaultPath: () => ipcRenderer.invoke("note-files-get-default-path"),
+ noteFilesPickFolder: () => ipcRenderer.invoke("note-files-pick-folder"),
+ showNoteFile: (noteId) => ipcRenderer.invoke("show-note-file", noteId),
+ showFolderInExplorer: (folderName) => ipcRenderer.invoke("show-folder-in-explorer", folderName),
+
// Action functions
getActions: () => ipcRenderer.invoke("db-get-actions"),
getAction: (id) => ipcRenderer.invoke("db-get-action", id),
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index 82a69205a..122f33132 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -637,11 +637,13 @@ function GpuDeviceSelector({ purpose }: { purpose: "transcription" | "intelligen
Promise.all([
window.electronAPI?.listGpus?.() ?? Promise.resolve([]),
window.electronAPI?.getGpuDeviceIndex?.(purpose) ?? Promise.resolve("0"),
- ]).then(([gpuList, idx]) => {
- setGpus(gpuList);
- setSelectedIndex(idx);
- setLoaded(true);
- }).catch(() => setLoaded(true));
+ ])
+ .then(([gpuList, idx]) => {
+ setGpus(gpuList);
+ setSelectedIndex(idx);
+ setLoaded(true);
+ })
+ .catch(() => setLoaded(true));
}, [purpose]);
if (!loaded || gpus.length < 2) return null;
@@ -670,7 +672,18 @@ function GpuDeviceSelector({ purpose }: { purpose: "transcription" | "intelligen
</option>
))}
</select>
- <svg className="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="m6 9 6 6 6-6"/></svg>
+ <svg
+ className="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <path d="m6 9 6 6 6-6" />
+ </svg>
</div>
</SettingsPanelRow>
</SettingsPanel>
@@ -768,6 +781,10 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage
setDataRetentionEnabled,
customDictionary,
setCustomDictionary,
+ noteFilesEnabled,
+ setNoteFilesEnabled,
+ noteFilesPath,
+ setNoteFilesPath,
} = useSettings();
const agentKey = useSettingsStore((s) => s.agentKey);
@@ -1008,6 +1025,40 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage
}
};
+ const [noteFilesDefaultPath, setNoteFilesDefaultPath] = useState("");
+ const [noteFilesRebuilding, setNoteFilesRebuilding] = useState(false);
+
+ useEffect(() => {
+ if (!noteFilesEnabled) return;
+ window.electronAPI?.noteFilesGetDefaultPath?.().then((p) => {
+ if (p) setNoteFilesDefaultPath(p);
+ });
+ }, [noteFilesEnabled]);
+
+ const handleNoteFilesToggle = useCallback(
+ async (enabled: boolean) => {
+ setNoteFilesEnabled(enabled);
+ await window.electronAPI?.noteFilesSetEnabled?.(enabled, noteFilesPath || undefined);
+ },
+ [setNoteFilesEnabled, noteFilesPath]
+ );
+
+ const handleNoteFilesChangePath = useCallback(async () => {
+ const result = await window.electronAPI?.noteFilesPickFolder?.();
+ if (result?.canceled || !result?.path) return;
+ setNoteFilesPath(result.path);
+ await window.electronAPI?.noteFilesSetPath?.(result.path);
+ }, [setNoteFilesPath]);
+
+ const handleNoteFilesRebuild = useCallback(async () => {
+ setNoteFilesRebuilding(true);
+ try {
+ await window.electronAPI?.noteFilesRebuild?.();
+ } finally {
+ setNoteFilesRebuilding(false);
+ }
+ }, []);
+
useEffect(() => {
let mounted = true;
@@ -2212,6 +2263,60 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPage
</SettingsPanel>
</div>
+ {/* Save Notes as Files */}
+ <div>
+ <SectionHeader title={t("settings.noteFiles.title")} />
+ <SettingsPanel>
+ <SettingsPanelRow>
+ <SettingsRow
+ label={t("settings.noteFiles.title")}
+ description={t("settings.noteFiles.description")}
+ >
+ <Toggle checked={noteFilesEnabled} onChange={handleNoteFilesToggle} />
+ </SettingsRow>
+ </SettingsPanelRow>
+ {noteFilesEnabled && (
+ <>
+ <SettingsPanelRow>
+ <SettingsRow
+ label={t("settings.noteFiles.path")}
+ description={noteFilesPath || noteFilesDefaultPath || "..."}
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-7 text-xs"
+ onClick={handleNoteFilesChangePath}
+ >
+ {t("settings.noteFiles.changePath")}
+ </Button>
+ </SettingsRow>
+ </SettingsPanelRow>
+ <SettingsPanelRow>
+ <SettingsRow
+ label={t("settings.noteFiles.rebuild")}
+ description={t("settings.noteFiles.rebuildDescription")}
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-7 text-xs"
+ disabled={noteFilesRebuilding}
+ onClick={handleNoteFilesRebuild}
+ >
+ {noteFilesRebuilding ? (
+ <Loader2 className="h-3 w-3 animate-spin" />
+ ) : (
+ t("settings.noteFiles.rebuild")
+ )}
+ </Button>
+ </SettingsRow>
+ </SettingsPanelRow>
+ </>
+ )}
+ </SettingsPanel>
+ </div>
+
{/* Floating Icon */}
<div>
<SectionHeader
@@ -2823,7 +2928,6 @@ EOF`,
})()}
</div>
)}
-
</div>
);
@@ -3451,7 +3555,6 @@ EOF`,
</div>
)}
</div>
-
</div>
);
diff --git a/src/components/notes/NoteListItem.tsx b/src/components/notes/NoteListItem.tsx
index b096c4590..58b0be21e 100644
--- a/src/components/notes/NoteListItem.tsx
+++ b/src/components/notes/NoteListItem.tsx
@@ -1,6 +1,14 @@
import { useState, useMemo } from "react";
import { useTranslation } from "react-i18next";
-import { MoreHorizontal, FolderOpen, Trash2, Check, Plus, Search } from "lucide-react";
+import {
+ MoreHorizontal,
+ FolderOpen,
+ Trash2,
+ Check,
+ Plus,
+ Search,
+ ExternalLink,
+} from "lucide-react";
import { Button } from "../ui/button";
import {
DropdownMenu,
@@ -38,6 +46,7 @@ interface NoteListItemProps {
onDragEnd: () => void;
};
isDragging?: boolean;
+ noteFilesEnabled?: boolean;
}
function stripMarkdown(text: string): string {
@@ -81,6 +90,7 @@ export default function NoteListItem({
onCreateFolderAndMove,
dragHandlers,
isDragging,
+ noteFilesEnabled,
}: NoteListItemProps) {
const { t } = useTranslation();
const preview = stripMarkdown(note.content);
@@ -88,6 +98,12 @@ export default function NoteListItem({
const [newFolderName, setNewFolderName] = useState("");
const [isCreating, setIsCreating] = useState(false);
+ const fileManagerName = navigator.platform.startsWith("Mac")
+ ? "Finder"
+ : navigator.platform.startsWith("Win")
+ ? "Explorer"
+ : "Files";
+
const filteredFolders = useMemo(
() =>
folderSearch
@@ -142,6 +158,24 @@ export default function NoteListItem({
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" sideOffset={4} className="min-w-40">
+ {noteFilesEnabled && (
+ <>
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+ window.electronAPI?.showNoteFile?.(note.id);
+ }}
+ className="text-xs gap-2 rounded-lg px-2.5 py-1.5 cursor-pointer focus:bg-foreground/5"
+ >
+ <ExternalLink
+ size={12}
+ className="text-muted-foreground/80 dark:text-muted-foreground/60"
+ />
+ {t("notes.context.showInFileManager", { manager: fileManagerName })}
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ </>
+ )}
<DropdownMenuSub>
<DropdownMenuSubTrigger className="text-xs gap-2 rounded-lg px-2.5 py-1.5 cursor-pointer focus:bg-foreground/5 data-[state=open]:bg-foreground/5">
<FolderOpen
diff --git a/src/components/notes/PersonalNotesView.tsx b/src/components/notes/PersonalNotesView.tsx
index 37c0deb5d..293a58725 100644
--- a/src/components/notes/PersonalNotesView.tsx
+++ b/src/components/notes/PersonalNotesView.tsx
@@ -11,6 +11,7 @@ import {
SquarePen,
Search,
Sparkles,
+ ExternalLink,
} from "lucide-react";
import { Button } from "../ui/button";
import {
@@ -101,6 +102,12 @@ export default function PersonalNotesView({
const { toast } = useToast();
const isCloudMode = useSettingsStore(selectIsCloudReasoningMode);
const effectiveModelId = useSettingsStore((s) => s.reasoningModel);
+ const noteFilesEnabled = useSettingsStore((s) => s.noteFilesEnabled);
+ const fileManagerName = navigator.platform.startsWith("Mac")
+ ? "Finder"
+ : navigator.platform.startsWith("Win")
+ ? "Explorer"
+ : "Files";
const { isComplete: isOnboardingComplete, complete: completeOnboarding } = useNotesOnboarding();
const {
@@ -650,7 +657,7 @@ export default function PersonalNotesView({
{count > 0 ? count : ""}
</span>
)}
- {!folder.is_default && (
+ {(!folder.is_default || noteFilesEnabled) && (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<span
@@ -663,28 +670,45 @@ export default function PersonalNotesView({
</span>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" sideOffset={4} className="min-w-32">
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- setRenamingFolderId(folder.id);
- setRenameValue(folder.name);
- }}
- className="text-xs gap-2 rounded-md px-2 py-1"
- >
- <Pencil size={11} className="text-muted-foreground/60" />
- {t("notes.context.rename")}
- </DropdownMenuItem>
- <DropdownMenuSeparator />
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- handleDeleteFolder(folder.id);
- }}
- className="text-xs gap-2 rounded-md px-2 py-1 text-destructive focus:text-destructive focus:bg-destructive/10"
- >
- <Trash2 size={11} />
- {t("notes.context.delete")}
- </DropdownMenuItem>
+ {noteFilesEnabled && (
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+ window.electronAPI?.showFolderInExplorer?.(folder.name);
+ }}
+ className="text-xs gap-2 rounded-md px-2 py-1"
+ >
+ <ExternalLink size={11} className="text-muted-foreground/60" />
+ {t("notes.context.showInFileManager", { manager: fileManagerName })}
+ </DropdownMenuItem>
+ )}
+ {!folder.is_default && (
+ <>
+ {noteFilesEnabled && <DropdownMenuSeparator />}
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+ setRenamingFolderId(folder.id);
+ setRenameValue(folder.name);
+ }}
+ className="text-xs gap-2 rounded-md px-2 py-1"
+ >
+ <Pencil size={11} className="text-muted-foreground/60" />
+ {t("notes.context.rename")}
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+ handleDeleteFolder(folder.id);
+ }}
+ className="text-xs gap-2 rounded-md px-2 py-1 text-destructive focus:text-destructive focus:bg-destructive/10"
+ >
+ <Trash2 size={11} />
+ {t("notes.context.delete")}
+ </DropdownMenuItem>
+ </>
+ )}
</DropdownMenuContent>
</DropdownMenu>
)}
@@ -829,6 +853,7 @@ export default function PersonalNotesView({
onCreateFolderAndMove={handleCreateFolderAndMove}
dragHandlers={noteDragHandlers(note.id, note.title)}
isDragging={dragState.draggingNoteId === note.id}
+ noteFilesEnabled={noteFilesEnabled}
/>
))
)}
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 59a5250eb..87e22799c 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -117,6 +117,7 @@ class IPCHandlers {
this._activeRecordingPipeline = null;
this.audioStorageManager = new AudioStorageManager();
this._audioCleanupInterval = null;
+ this._noteFilesEnabled = false;
this._setupTextEditMonitor();
this._setupAudioCleanup();
this._logDetectedGpus();
@@ -147,6 +148,46 @@ class IPCHandlers {
});
}
+ _asyncMirrorWrite(note) {
+ if (!this._noteFilesEnabled) return;
+ setImmediate(() => {
+ const markdownMirror = require("./markdownMirror");
+ const folderName = this._getFolderName(note.folder_id);
+ markdownMirror.writeNote(note, folderName);
+ });
+ }
+
+ _asyncMirrorDelete(noteId) {
+ if (!this._noteFilesEnabled) return;
+ setImmediate(() => {
+ const markdownMirror = require("./markdownMirror");
+ markdownMirror.deleteNote(noteId);
+ });
+ }
+
+ _buildFolderMap() {
+ const folders = this.databaseManager.getFolders();
+ const map = {};
+ for (const f of folders) {
+ map[f.id] = f.name;
+ }
+ return map;
+ }
+
+ _rebuildMirror(basePath) {
+ const markdownMirror = require("./markdownMirror");
+ if (basePath) markdownMirror.init(basePath);
+ markdownMirror.rebuildAll(this.databaseManager.getNotes(null, 99999), this._buildFolderMap());
+ }
+
+ _getFolderName(folderId) {
+ if (!folderId) return "Personal";
+ const folder = this.databaseManager.db
+ .prepare("SELECT name FROM folders WHERE id = ?")
+ .get(folderId);
+ return folder?.name || "Personal";
+ }
+
_getDictionarySafe() {
try {
return this.databaseManager.getDictionary();
@@ -577,6 +618,7 @@ class IPCHandlers {
if (result?.success && result?.note) {
setImmediate(() => this.broadcastToWindows("note-added", result.note));
this._asyncVectorUpsert(result.note);
+ this._asyncMirrorWrite(result.note);
}
return result;
}
@@ -595,6 +637,7 @@ class IPCHandlers {
if (result?.success && result?.note) {
setImmediate(() => this.broadcastToWindows("note-updated", result.note));
this._asyncVectorUpsert(result.note);
+ this._asyncMirrorWrite(result.note);
}
return result;
});
@@ -604,6 +647,7 @@ class IPCHandlers {
if (result?.success) {
setImmediate(() => this.broadcastToWindows("note-deleted", { id }));
this._asyncVectorDelete(id);
+ this._asyncMirrorDelete(id);
}
return result;
});
@@ -683,26 +727,40 @@ class IPCHandlers {
if (result?.success && result?.folder) {
setImmediate(() => {
this.broadcastToWindows("folder-created", result.folder);
+ if (this._noteFilesEnabled) {
+ const markdownMirror = require("./markdownMirror");
+ markdownMirror.ensureFolder(result.folder.name);
+ }
});
}
return result;
});
ipcMain.handle("db-delete-folder", async (event, id) => {
+ const folderName = this._noteFilesEnabled ? this._getFolderName(id) : null;
const result = this.databaseManager.deleteFolder(id);
if (result?.success) {
setImmediate(() => {
this.broadcastToWindows("folder-deleted", { id });
+ if (this._noteFilesEnabled && folderName) {
+ const markdownMirror = require("./markdownMirror");
+ markdownMirror.deleteFolder(folderName, "Personal");
+ }
});
}
return result;
});
ipcMain.handle("db-rename-folder", async (event, id, name) => {
+ const oldName = this._noteFilesEnabled ? this._getFolderName(id) : null;
const result = this.databaseManager.renameFolder(id, name);
if (result?.success && result?.folder) {
setImmediate(() => {
this.broadcastToWindows("folder-renamed", result.folder);
+ if (this._noteFilesEnabled && oldName) {
+ const markdownMirror = require("./markdownMirror");
+ markdownMirror.renameFolder(oldName, name);
+ }
});
}
return result;
@@ -4796,6 +4854,98 @@ class IPCHandlers {
}
return { success: true };
});
+
+ // Note files (markdown mirror) handlers
+ ipcMain.handle("note-files-set-enabled", async (_event, enabled, customPath) => {
+ try {
+ this._noteFilesEnabled = !!enabled;
+ if (enabled) {
+ this._rebuildMirror(customPath || path.join(app.getPath("userData"), "notes"));
+ }
+ return { success: true };
+ } catch (error) {
+ debugLogger.error(
+ "Failed to set note-files enabled",
+ { error: error.message },
+ "note-files"
+ );
+ return { success: false, error: error.message };
+ }
+ });
+
+ ipcMain.handle("note-files-set-path", async (_event, newPath) => {
+ try {
+ if (!this._noteFilesEnabled) return { success: false, error: "Note files not enabled" };
+ this._rebuildMirror(newPath);
+ return { success: true };
+ } catch (error) {
+ debugLogger.error("Failed to set note-files path", { error: error.message }, "note-files");
+ return { success: false, error: error.message };
+ }
+ });
+
+ ipcMain.handle("note-files-rebuild", async () => {
+ try {
+ if (!this._noteFilesEnabled) return { success: false, error: "Note files not enabled" };
+ this._rebuildMirror();
+ return { success: true };
+ } catch (error) {
+ debugLogger.error("Failed to rebuild note files", { error: error.message }, "note-files");
+ return { success: false, error: error.message };
+ }
+ });
+
+ ipcMain.handle("note-files-get-default-path", async () => {
+ return path.join(app.getPath("userData"), "notes");
+ });
+
+ ipcMain.handle("show-note-file", async (_event, noteId) => {
+ try {
+ const markdownMirror = require("./markdownMirror");
+ const filePath = markdownMirror.getNotePath(noteId);
+ if (!filePath) return { success: false };
+ shell.showItemInFolder(filePath);
+ return { success: true };
+ } catch (error) {
+ debugLogger.error(
+ "Failed to show note file",
+ { noteId, error: error.message },
+ "note-files"
+ );
+ return { success: false };
+ }
+ });
+
+ ipcMain.handle("show-folder-in-explorer", async (_event, folderName) => {
+ try {
+ const markdownMirror = require("./markdownMirror");
+ const dirPath = markdownMirror.getFolderPath(folderName);
+ if (!dirPath) return { success: false };
+ await shell.openPath(dirPath);
+ return { success: true };
+ } catch (error) {
+ debugLogger.error(
+ "Failed to show folder",
+ { folderName, error: error.message },
+ "note-files"
+ );
+ return { success: false };
+ }
+ });
+
+ ipcMain.handle("note-files-pick-folder", async () => {
+ try {
+ const { dialog } = require("electron");
+ const result = await dialog.showOpenDialog({ properties: ["openDirectory"] });
+ if (result.canceled || !result.filePaths.length) {
+ return { canceled: true };
+ }
+ return { canceled: false, path: result.filePaths[0] };
+ } catch (error) {
+ debugLogger.error("Failed to pick folder", { error: error.message }, "note-files");
+ return { canceled: true };
+ }
+ });
}
broadcastToWindows(channel, payload) {
diff --git a/src/helpers/markdownMirror.js b/src/helpers/markdownMirror.js
new file mode 100644
index 000000000..45aad3f12
--- /dev/null
+++ b/src/helpers/markdownMirror.js
@@ -0,0 +1,196 @@
+const fs = require("fs");
+const path = require("path");
+const debugLogger = require("./debugLogger");
+
+class MarkdownMirror {
+ constructor() {
+ this._basePath = null;
+ }
+
+ init(basePath) {
+ this._basePath = basePath;
+ try {
+ fs.mkdirSync(basePath, { recursive: true });
+ debugLogger.debug("Markdown mirror initialized", { basePath }, "note-files");
+ } catch (err) {
+ debugLogger.error("Failed to init markdown mirror", { error: err.message }, "note-files");
+ }
+ }
+
+ getBasePath() {
+ return this._basePath;
+ }
+
+ _slugify(title) {
+ return (title || "Untitled")
+ .replace(/[/\\?%*:|"<>]/g, "-")
+ .trim()
+ .replace(/\s+/g, "-")
+ .toLowerCase()
+ .slice(0, 60);
+ }
+
+ _buildFrontmatter(note, folderName) {
+ const escYaml = (str) => {
+ if (!str) return '""';
+ if (/[:#{}[\],&*?|>!%@`]/.test(str) || str.includes('"') || str.includes("'")) {
+ return `"${str.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
+ }
+ return str;
+ };
+ const lines = [
+ "---",
+ `id: ${note.id}`,
+ `title: ${escYaml(note.title)}`,
+ `type: ${note.note_type || "personal"}`,
+ `folder: ${escYaml(folderName || "Personal")}`,
+ `created: ${note.created_at || new Date().toISOString()}`,
+ `updated: ${note.updated_at || new Date().toISOString()}`,
+ "---",
+ ];
+ return lines.join("\n");
+ }
+
+ writeNote(note, folderName) {
+ if (!this._basePath) return;
+ try {
+ const dirName = folderName || "Personal";
+ const dirPath = path.join(this._basePath, dirName);
+ fs.mkdirSync(dirPath, { recursive: true });
+
+ // Remove stale files (title changed or note moved to different folder)
+ const glob = this._globNoteFiles(note.id);
+ const slug = this._slugify(note.title);
+ const newFileName = `${note.id}-${slug}.md`;
+ const newFilePath = path.join(dirPath, newFileName);
+ for (const existing of glob) {
+ if (existing !== newFilePath) {
+ try {
+ fs.unlinkSync(existing);
+ } catch {}
+ }
+ }
+
+ const frontmatter = this._buildFrontmatter(note, dirName);
+ const body = note.enhanced_content || note.content || "";
+ fs.writeFileSync(newFilePath, `${frontmatter}\n\n${body}`, "utf-8");
+ } catch (err) {
+ debugLogger.error(
+ "Failed to write note file",
+ { noteId: note.id, error: err.message },
+ "note-files"
+ );
+ }
+ }
+
+ deleteNote(noteId) {
+ if (!this._basePath) return;
+ try {
+ const files = this._globNoteFiles(noteId);
+ for (const f of files) {
+ fs.unlinkSync(f);
+ }
+ } catch (err) {
+ debugLogger.error("Failed to delete note file", { noteId, error: err.message }, "note-files");
+ }
+ }
+
+ ensureFolder(folderName) {
+ if (!this._basePath) return;
+ try {
+ fs.mkdirSync(path.join(this._basePath, folderName), { recursive: true });
+ } catch (err) {
+ debugLogger.error(
+ "Failed to ensure folder",
+ { folderName, error: err.message },
+ "note-files"
+ );
+ }
+ }
+
+ renameFolder(oldName, newName) {
+ if (!this._basePath) return;
+ try {
+ const oldPath = path.join(this._basePath, oldName);
+ const newPath = path.join(this._basePath, newName);
+ if (fs.existsSync(oldPath)) {
+ fs.renameSync(oldPath, newPath);
+ }
+ } catch (err) {
+ debugLogger.error(
+ "Failed to rename folder",
+ { oldName, newName, error: err.message },
+ "note-files"
+ );
+ }
+ }
+
+ deleteFolder(folderName, targetName) {
+ if (!this._basePath) return;
+ try {
+ const srcDir = path.join(this._basePath, folderName);
+ const destDir = path.join(this._basePath, targetName || "Personal");
+ fs.mkdirSync(destDir, { recursive: true });
+ if (fs.existsSync(srcDir)) {
+ const files = fs.readdirSync(srcDir);
+ for (const file of files) {
+ fs.renameSync(path.join(srcDir, file), path.join(destDir, file));
+ }
+ fs.rmdirSync(srcDir);
+ }
+ } catch (err) {
+ debugLogger.error(
+ "Failed to delete folder",
+ { folderName, error: err.message },
+ "note-files"
+ );
+ }
+ }
+
+ rebuildAll(notes, folderMap) {
+ if (!this._basePath) return;
+ try {
+ for (const note of notes) {
+ const folderName = folderMap[note.folder_id] || "Personal";
+ this.writeNote(note, folderName);
+ }
+ debugLogger.info("Markdown mirror rebuild complete", { count: notes.length }, "note-files");
+ } catch (err) {
+ debugLogger.error("Failed to rebuild all note files", { error: err.message }, "note-files");
+ }
+ }
+
+ getNotePath(noteId) {
+ if (!this._basePath) return null;
+ const files = this._globNoteFiles(noteId);
+ return files.length > 0 ? files[0] : null;
+ }
+
+ getFolderPath(folderName) {
+ if (!this._basePath) return null;
+ const dirPath = path.join(this._basePath, folderName);
+ return fs.existsSync(dirPath) ? dirPath : null;
+ }
+
+ _globNoteFiles(noteId) {
+ if (!this._basePath) return [];
+ const results = [];
+ try {
+ const prefix = `${noteId}-`;
+ const dirs = fs.readdirSync(this._basePath, { withFileTypes: true });
+ for (const dir of dirs) {
+ if (!dir.isDirectory()) continue;
+ const dirPath = path.join(this._basePath, dir.name);
+ const files = fs.readdirSync(dirPath);
+ for (const file of files) {
+ if (file.startsWith(prefix) && file.endsWith(".md")) {
+ results.push(path.join(dirPath, file));
+ }
+ }
+ }
+ } catch {}
+ return results;
+ }
+}
+
+module.exports = new MarkdownMirror();
diff --git a/src/hooks/useSettings.ts b/src/hooks/useSettings.ts
index 7c563be18..fe3968bdf 100644
--- a/src/hooks/useSettings.ts
+++ b/src/hooks/useSettings.ts
@@ -243,6 +243,10 @@ function useSettingsInternal() {
setAutoLearnCorrections,
keepTranscriptionInClipboard: store.keepTranscriptionInClipboard,
setKeepTranscriptionInClipboard: store.setKeepTranscriptionInClipboard,
+ noteFilesEnabled: store.noteFilesEnabled,
+ setNoteFilesEnabled: store.setNoteFilesEnabled,
+ noteFilesPath: store.noteFilesPath,
+ setNoteFilesPath: store.setNoteFilesPath,
cloudBackupEnabled: store.cloudBackupEnabled,
setCloudBackupEnabled: store.setCloudBackupEnabled,
telemetryEnabled: store.telemetryEnabled,
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index e98bf6180..424a26834 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -7,6 +7,14 @@
"uiDescription": "Wählen Sie die Sprache für die OpenWhispr-Oberfläche",
"transcriptionLabel": "Transkriptionssprache",
"transcriptionDescription": "Wählen Sie die Sprache, die Sie sprechen, für genauere Transkription"
+ },
+ "noteFiles": {
+ "title": "Notizen als Dateien speichern",
+ "description": "Notizen automatisch als .md-Dateien auf der Festplatte speichern, nach Ordner sortiert",
+ "path": "Speicherort",
+ "changePath": "Speicherort ändern",
+ "rebuild": "Alle Dateien neu erstellen",
+ "rebuildDescription": "Alle Notizen erneut auf die Festplatte synchronisieren"
}
},
"tray": {
@@ -1644,7 +1652,8 @@
"rename": "Umbenennen",
"searchFolders": "Ordner suchen...",
"noResults": "Keine Ordner gefunden",
- "newFolder": "Neuer Ordner"
+ "newFolder": "Neuer Ordner",
+ "showInFileManager": "Im {{manager}} anzeigen"
},
"actions": {
"manage": "Aktionen verwalten...",
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index c718f2ea8..17e436cf6 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -7,6 +7,14 @@
"uiDescription": "Choose the language used throughout OpenWhispr's interface",
"transcriptionLabel": "Transcription language",
"transcriptionDescription": "Choose the language you speak for more accurate transcription"
+ },
+ "noteFiles": {
+ "title": "Save notes as files",
+ "description": "Automatically save notes as .md files on disk, organized by folder",
+ "path": "Save location",
+ "changePath": "Change location",
+ "rebuild": "Rebuild all files",
+ "rebuildDescription": "Re-sync all notes to disk"
}
},
"tray": {
@@ -1769,7 +1777,8 @@
"rename": "Rename",
"searchFolders": "Search folders...",
"noResults": "No folders found",
- "newFolder": "New folder"
+ "newFolder": "New folder",
+ "showInFileManager": "Show in {{manager}}"
},
"actions": {
"done": "Done",
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index 449dbab7b..de34b7991 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -7,6 +7,14 @@
"uiDescription": "Elige el idioma usado en la interfaz de OpenWhispr",
"transcriptionLabel": "Idioma de transcripción",
"transcriptionDescription": "Elige el idioma que hablas para mejorar la precisión"
+ },
+ "noteFiles": {
+ "title": "Guardar notas como archivos",
+ "description": "Guardar notas automáticamente como archivos .md en disco, organizadas por carpeta",
+ "path": "Ubicación de guardado",
+ "changePath": "Cambiar ubicación",
+ "rebuild": "Reconstruir todos los archivos",
+ "rebuildDescription": "Resincronizar todas las notas al disco"
}
},
"tray": {
@@ -1644,7 +1652,8 @@
"rename": "Renombrar",
"searchFolders": "Buscar carpetas...",
"noResults": "No se encontraron carpetas",
- "newFolder": "Nueva carpeta"
+ "newFolder": "Nueva carpeta",
+ "showInFileManager": "Mostrar en {{manager}}"
},
"actions": {
"manage": "Gestionar acciones...",
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index 9c247f9a6..4b7aea1fa 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -7,6 +7,14 @@
"uiDescription": "Choisissez la langue utilisée dans l'interface OpenWhispr",
"transcriptionLabel": "Langue de transcription",
"transcriptionDescription": "Choisissez la langue que vous parlez pour une transcription plus précise"
+ },
+ "noteFiles": {
+ "title": "Enregistrer les notes en fichiers",
+ "description": "Enregistrer automatiquement les notes en fichiers .md sur le disque, organisées par dossier",
+ "path": "Emplacement de sauvegarde",
+ "changePath": "Changer l'emplacement",
+ "rebuild": "Reconstruire tous les fichiers",
+ "rebuildDescription": "Resynchroniser toutes les notes sur le disque"
}
},
"tray": {
@@ -1721,7 +1729,8 @@
"rename": "Renommer",
"searchFolders": "Rechercher des dossiers...",
"noResults": "Aucun dossier trouvé",
- "newFolder": "Nouveau dossier"
+ "newFolder": "Nouveau dossier",
+ "showInFileManager": "Afficher dans {{manager}}"
},
"actions": {
"done": "Terminé",
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index 41743fe44..ff2ba81e7 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -7,6 +7,14 @@
"uiDescription": "Scegli la lingua usata nell'interfaccia di OpenWhispr",
"transcriptionLabel": "Lingua di trascrizione",
"transcriptionDescription": "Scegli la lingua che parli per una trascrizione più accurata"
+ },
+ "noteFiles": {
+ "title": "Salva note come file",
+ "description": "Salva automaticamente le note come file .md su disco, organizzate per cartella",
+ "path": "Percorso di salvataggio",
+ "changePath": "Cambia percorso",
+ "rebuild": "Ricostruisci tutti i file",
+ "rebuildDescription": "Risincronizza tutte le note su disco"
}
},
"tray": {
@@ -1644,7 +1652,8 @@
"rename": "Rinomina",
"searchFolders": "Cerca cartelle...",
"noResults": "Nessuna cartella trovata",
- "newFolder": "Nuova cartella"
+ "newFolder": "Nuova cartella",
+ "showInFileManager": "Mostra in {{manager}}"
},
"actions": {
"manage": "Gestisci azioni...",
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 3d00b980b..e70819edd 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -7,6 +7,14 @@
"uiDescription": "OpenWhispr のインターフェースで使用する言語を選択",
"transcriptionLabel": "文字起こし言語",
"transcriptionDescription": "より正確な文字起こしのために話す言語を選択"
+ },
+ "noteFiles": {
+ "title": "ノートをファイルとして保存",
+ "description": "ノートを .md ファイルとしてディスクに自動保存し、フォルダごとに整理",
+ "path": "保存先",
+ "changePath": "保存先を変更",
+ "rebuild": "すべてのファイルを再構築",
+ "rebuildDescription": "すべてのノートをディスクに再同期"
}
},
"tray": {
@@ -1504,7 +1512,8 @@
"rename": "名前を変更",
"searchFolders": "フォルダを検索...",
"noResults": "フォルダが見つかりません",
- "newFolder": "新しいフォルダ"
+ "newFolder": "新しいフォルダ",
+ "showInFileManager": "{{manager}}で表示"
},
"actions": {
"manage": "アクションを管理...",
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 8875089b3..c5bac4c42 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -7,6 +7,14 @@
"uiDescription": "Escolha o idioma usado na interface do OpenWhispr",
"transcriptionLabel": "Idioma de transcrição",
"transcriptionDescription": "Escolha o idioma que você fala para maior precisão"
+ },
+ "noteFiles": {
+ "title": "Salvar notas como arquivos",
+ "description": "Salvar notas automaticamente como arquivos .md no disco, organizadas por pasta",
+ "path": "Local de salvamento",
+ "changePath": "Alterar local",
+ "rebuild": "Reconstruir todos os arquivos",
+ "rebuildDescription": "Ressincronizar todas as notas no disco"
}
},
"tray": {
@@ -1644,7 +1652,8 @@
"rename": "Renomear",
"searchFolders": "Pesquisar pastas...",
"noResults": "Nenhuma pasta encontrada",
- "newFolder": "Nova pasta"
+ "newFolder": "Nova pasta",
+ "showInFileManager": "Mostrar no {{manager}}"
},
"actions": {
"manage": "Gerenciar ações...",
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index 1bce90d74..1b11b0d37 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -7,6 +7,14 @@
"uiDescription": "Выберите язык интерфейса OpenWhispr",
"transcriptionLabel": "Язык транскрипции",
"transcriptionDescription": "Выберите язык, на котором вы говорите, для более точной транскрипции"
+ },
+ "noteFiles": {
+ "title": "Сохранять заметки как файлы",
+ "description": "Автоматически сохранять заметки как файлы .md на диск с группировкой по папкам",
+ "path": "Расположение",
+ "changePath": "Изменить расположение",
+ "rebuild": "Пересоздать все файлы",
+ "rebuildDescription": "Повторно синхронизировать все заметки на диск"
}
},
"tray": {
@@ -1644,7 +1652,8 @@
"rename": "Переименовать",
"searchFolders": "Поиск папок...",
"noResults": "Папки не найдены",
- "newFolder": "Новая папка"
+ "newFolder": "Новая папка",
+ "showInFileManager": "Показать в {{manager}}"
},
"actions": {
"manage": "Управление действиями...",
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index a3df2b57f..0c6f93f43 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -7,6 +7,14 @@
"uiDescription": "选择 OpenWhispr 界面使用的语言",
"transcriptionLabel": "转录语言",
"transcriptionDescription": "选择你说话的语言,以提高转录准确率"
+ },
+ "noteFiles": {
+ "title": "将笔记保存为文件",
+ "description": "自动将笔记保存为 .md 文件到磁盘,按文件夹分类",
+ "path": "保存位置",
+ "changePath": "更改位置",
+ "rebuild": "重建所有文件",
+ "rebuildDescription": "将所有笔记重新同步到磁盘"
}
},
"tray": {
@@ -1639,7 +1647,8 @@
"rename": "重命名",
"searchFolders": "搜索文件夹...",
"noResults": "未找到文件夹",
- "newFolder": "新建文件夹"
+ "newFolder": "新建文件夹",
+ "showInFileManager": "在{{manager}}中显示"
},
"actions": {
"manage": "管理操作...",
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index b11ea4e29..4dc5e884e 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -7,6 +7,14 @@
"uiDescription": "選擇 OpenWhispr 介面使用的語言",
"transcriptionLabel": "轉錄語言",
"transcriptionDescription": "選擇你說話的語言,以提高轉錄準確度"
+ },
+ "noteFiles": {
+ "title": "將筆記儲存為檔案",
+ "description": "自動將筆記儲存為 .md 檔案到磁碟,按資料夾分類",
+ "path": "儲存位置",
+ "changePath": "變更位置",
+ "rebuild": "重建所有檔案",
+ "rebuildDescription": "將所有筆記重新同步到磁碟"
}
},
"tray": {
@@ -1639,7 +1647,8 @@
"rename": "重新命名",
"searchFolders": "搜尋資料夾...",
"noResults": "找不到資料夾",
- "newFolder": "新增資料夾"
+ "newFolder": "新增資料夾",
+ "showInFileManager": "在{{manager}}中顯示"
},
"actions": {
"manage": "管理動作...",
diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.ts
index 85321b4cc..bf0b3b457 100644
--- a/src/stores/settingsStore.ts
+++ b/src/stores/settingsStore.ts
@@ -65,6 +65,7 @@ const BOOLEAN_SETTINGS = new Set([
"agentEnabled",
"keepTranscriptionInClipboard",
"dataRetentionEnabled",
+ "noteFilesEnabled",
]);
const ARRAY_SETTINGS = new Set(["customDictionary", "gcalAccounts"]);
@@ -105,6 +106,8 @@ export interface SettingsState
meetingAudioDetection: boolean;
panelStartPosition: "bottom-right" | "center" | "bottom-left";
keepTranscriptionInClipboard: boolean;
+ noteFilesEnabled: boolean;
+ noteFilesPath: string;
setUseLocalWhisper: (value: boolean) => void;
setWhisperModel: (value: string) => void;
@@ -156,6 +159,8 @@ export interface SettingsState
setMeetingAudioDetection: (value: boolean) => void;
setPanelStartPosition: (position: "bottom-right" | "center" | "bottom-left") => void;
setKeepTranscriptionInClipboard: (value: boolean) => void;
+ setNoteFilesEnabled: (value: boolean) => void;
+ setNoteFilesPath: (value: string) => void;
setIsSignedIn: (value: boolean) => void;
setAgentModel: (value: string) => void;
@@ -308,6 +313,8 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({
return "bottom-right" as const;
})(),
keepTranscriptionInClipboard: readBoolean("keepTranscriptionInClipboard", false),
+ noteFilesEnabled: readBoolean("noteFilesEnabled", false),
+ noteFilesPath: readString("noteFilesPath", ""),
isSignedIn: readBoolean("isSignedIn", false),
agentModel: readString("agentModel", "openai/gpt-oss-120b"),
@@ -499,6 +506,8 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({
},
setKeepTranscriptionInClipboard: createBooleanSetter("keepTranscriptionInClipboard"),
+ setNoteFilesEnabled: createBooleanSetter("noteFilesEnabled"),
+ setNoteFilesPath: createStringSetter("noteFilesPath"),
setIsSignedIn: (value: boolean) => {
if (isBrowser) localStorage.setItem("isSignedIn", String(value));
diff --git a/src/types/electron.ts b/src/types/electron.ts
index 341e6edf4..c783003d9 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -418,6 +418,18 @@ declare global {
) => Promise<{ success: boolean; folder?: FolderItem; error?: string }>;
getFolderNoteCounts: () => Promise<Array<{ folder_id: number; count: number }>>;
+ // Note files (markdown mirror)
+ noteFilesSetEnabled?: (
+ enabled: boolean,
+ customPath?: string
+ ) => Promise<{ success: boolean; error?: string }>;
+ noteFilesSetPath?: (path: string) => Promise<{ success: boolean; error?: string }>;
+ noteFilesRebuild?: () => Promise<{ success: boolean; error?: string }>;
+ noteFilesGetDefaultPath?: () => Promise<string>;
+ noteFilesPickFolder?: () => Promise<{ canceled: boolean; path?: string }>;
+ showNoteFile?: (noteId: number) => Promise<{ success: boolean }>;
+ showFolderInExplorer?: (folderName: string) => Promise<{ success: boolean }>;
+
// Action operations
getActions: () => Promise<ActionItem[]>;
getAction: (id: number) => Promise<ActionItem | null>;
@@ -1206,9 +1218,7 @@ declare global {
gcalGetUpcomingEvents?: (
windowMinutes?: number
) => Promise<{ success: boolean; events: any[] }>;
- gcalGetEvent?: (
- eventId: string
- ) => Promise<{
+ gcalGetEvent?: (eventId: string) => Promise<{
success: boolean;
event: {
id: string;