lietzsche;noether
Pages

updated 2026-11-26·11 min read

Native Runtime & Platform Bridge

Complete breakdown of Noether's Tauri v2 desktop runtime, 64 native Rust IPC commands, three-tier atomic saves, Win32 memory trimming, and lossless Markdown round-tripping.

Bundling Chromium via Electron drags installer sizes past 120 MB and leaves idle RAM sitting around 600 MB to 1.5 GB. Noether uses Tauri v2 and a compiled Rust backend over the OS webview (WebView2 on Windows, WebKit on macOS/Linux), exposing 64 IPC commands for atomic saves, rusqlite queries, local Git snapshots, and Windows working-set trimming.

1. Native Desktop Architecture with Tauri v2

┌─────────────────────────────────────────────────────────────────┐
│                    Webview Frontend (React 19)                  │
│   TipTap Editor • Force Graph • Zustand Stores • Tailwind UI   │
└────────────────────────────────┬────────────────────────────────┘
                                 │ Tauri IPC Commands
                                 ▼
┌─────────────────────────────────────────────────────────────────┐
│                   Compiled Rust Backend (Tauri v2)              │
│   • rusqlite WAL Engine        • Crash-Safe Atomic Saves        │
│   • Asynchronous File Watcher  • Win32 Memory Trimmer           │
│   • Native Git Version Control • Dynamic Icon Tinting           │
└────────────────────────────────┬────────────────────────────────┘
                                 │ Direct OS Calls
                                 ▼
┌─────────────────────────────────────────────────────────────────┐
│                       Local File System                         │
│   • Plain Text *.md Notes      • .noether/noether.sqlite        │
└─────────────────────────────────────────────────────────────────┘

The frontend interfaces with the operating system through Tauri IPC commands declared in src-tauri/src/ (vault.rs, db.rs, vcs.rs, icon_tint.rs, and lib.rs).

2. Native Rust Tauri IPC Commands Catalog (64 Commands)

Below is the complete catalog of native Rust commands registered via tauri::generate_handler! in src-tauri/src/lib.rs:

A. Vault & Filesystem Operations (vault.rs)
Command NameArgumentsDescription
get_current_vaultNoneReturns the active vault path, name, and recent vault list.
set_current_vaultvault_path: StringSwitches the active workspace vault, DB, and file watcher.
create_new_vaultname: String, parent_path: Option<String>Initializes a new vault directory structure.
rename_vaulttarget_path: String, new_name: StringRenames a vault root folder safely.
remove_recent_vaultvault_path: StringRemoves a vault from recent history.
open_vault_in_explorervault_path: Option<String>Opens the active or recent vault root in the OS file manager.
reveal_in_explorerpath: StringHighlights a specific file in the OS file manager.
open_in_default_apppath: StringLaunches the operating system default app for a file.
scan_vault_filescustom_vault_path: Option<String>, allowed_extensions: Option<Vec<String>>Fast recursive filesystem walk indexing notes and assets.
create_vault_folderrelative_path: StringCreates directory structure safely within the active vault.
save_markdown_filefilename: String, content: String, relative_path: Option<String>Atomic save pipeline with internal write fingerprint registration.
read_markdown_filefilename_or_path: StringReads UTF-8 CommonMark note text from the active vault.
read_binary_filefilename_or_path: StringReads binary media assets as Base64 strings.
set_file_attributesfilename_or_path: String, readonly: Option<bool>, _modified_time: Option<u64>Updates OS file read-only attributes.
delete_markdown_filefilename_or_path: StringBoundary-safe note deletion in the active vault.
rename_markdown_fileold_filename?: String, new_filename?: String, old_relative_path?: String, new_relative_path?: StringAtomically renames or moves a note on disk.
open_plugins_folderNoneOpens <vault>/.noether/extensions/ in the OS file manager.
open_trash_folderNoneOpens <vault>/.trash/ in the OS file manager.
save_trash_filefilename: String, content: String, relative_path: Option<String>Archives a note into <vault>/.trash/.
delete_trash_filefilename_or_path: StringPermanently deletes a note from <vault>/.trash/.
empty_trash_folderNonePurges all files inside <vault>/.trash/.
B. Extension Bundle Management (vault.rs)
Command NameArgumentsDescription
list_installed_pluginsNoneScans .noether/extensions/ (and legacy .noether/plugins/) and returns manifests.
read_plugin_bundleplugin_folder: StringReads compiled extension main.js bundle and CSS stylesheets.
install_plugin_bundleplugin_folder: String, manifest_json: String, main_js: String, styles_css?: StringWrites extension bundle files into .noether/extensions/<id>/.
uninstall_plugin_bundleplugin_folder: StringRemoves extension directory from disk.
C. Native SQLite Caching & FTS5 (db.rs)
Command NameArgumentsDescription
noether_db_initvault_path: Option<String>Initializes .noether/noether.sqlite in WAL mode with 256MB mmap.
noether_db_querysql: String, params: Option<Vec<Value>>Executes parameter-bound SQL queries returning JSON row arrays.
noether_db_executesql: String, params: Option<Vec<Value>>Executes SQL statements returning affected row counts.
noether_db_transactionqueries: Vec<DbQueryItem>Executes batch statements inside an atomic SQLite transaction.
noether_db_supports_fts5NoneValidates native compiled FTS5 module support.
D. Version Control & Snapshot Engine (vcs.rs)
Command NameArgumentsDescription
vcs_check_statusNoneChecks local Git repository availability and dirty file status.
vcs_init_vaultNoneInitializes a local Git tracking repository in the active vault.
vcs_create_snapshotrelative_path: Option<String>, message: Option<String>Creates an atomic Git commit snapshot of modified files.
vcs_get_file_historyrelative_path: String, limit: Option<usize>Returns commit history log for a note.
vcs_get_file_diffrelative_path: String, commit_a: String, commit_b: Option<String>Generates a unified diff against target commits.
vcs_get_historical_contentrelative_path: String, commit: StringRetrieves raw note text from a historical Git commit tree.
vcs_restore_filerelative_path: String, commit: StringReverts a note file to a historical commit state.
E. Window Management, Memory Trimming & System Services
Command NameArgumentsDescription
window_minimize / window_maximize / window_closeWindow handleStandard native window state controls.
window_is_maximized / window_is_minimized / window_is_fullscreenWindow handleQueries window display geometry flags.
window_set_fullscreenfullscreen: boolToggles window fullscreen mode.
window_start_draggingWindow handleInitiates native window dragging on custom title bars.
window_set_titletitle: StringUpdates OS native window title.
window_trim_memoryNoneCalls Win32 SetProcessWorkingSetSize to flush RAM below 150MB when idle.
notify_user_activityNoneResets idle activity signal from the frontend.
focus_main_windowNoneUnminimizes and brings the primary application window to foreground.
open_vault_window / close_vault_windowNoneControls secondary vault window state.
open_settings_window / close_settings_windowtab?: String / NoneControls dedicated settings window instances.
open_help_window / close_help_windowNoneControls dedicated help documentation window instances.
save_app_settings / load_app_settingssettings_json: String / NonePersists global application preferences in the OS config directory.
register_global_shortcut / unregister_global_shortcutid: String, shortcut: String / id: StringBinds system-wide OS hotkeys.
download_remote_texturl: StringFetches remote extension bundles and marketplace manifests natively.
read_clipboard_files / has_clipboard_files / copy_files_to_vaultNone / source_paths, target_relative_dir?Handles OS-level clipboard file pastes into the active vault.
set_accent_iconaccent_color: String (icon_tint.rs)Dynamically renders window taskbar icons tinted to theme accent.

3. Save Pipeline and Atomic File Writes

Writing straight over note.md with standard file truncation risks leaving a 0-byte file if power drops or Windows Search / antivirus holds a temporary handle. Noether splits document writes across three tiers:

  1. Tier 1 (Instant In-Memory Keystroke): Keystrokes mutate the local ProseMirror document state synchronously. Word count and character count update in the status bar without re-rendering unrelated panels.
  2. Tier 2 (Debounced Disk Flush & Content Cache, 400ms): When typing pauses for 400ms (extended to 800ms during active typing), the active buffer flushes to disk.
    • Atomic Write to Temp: Rust writes serialized CommonMark content to a process-scoped temporary file in the same directory (file_path.with_extension(format!("tmp.{}", std::process::id())), i.e., <filename>.tmp.<pid>).
    • Atomic Rename (fs::rename): Once written, the OS atomically replaces the destination file with the temp file so notes are never left half-written.
    • In-Place Store Patching: During pure content edits, saveDocumentById mutates existingDoc.content_json in place without creating a new documents array reference. That avoids cascading re-renders across the file tree, sidebars, and breadcrumbs.
  3. Tier 3 (Idle Secondary Indexing, 1200ms): Heavy secondary work (unlinked mention scanning across all notes and broken embed validation) waits on a 1200ms idle queue (scheduleIdleSecondaryIndexing) so the main thread stays clear while typing.

4. File Watcher Echo Filtering

When Noether saves a note to disk, the OS filesystem watcher fires a change event. Without filtering, that creates a reload loop: save note → watcher detects change → reload note → reset caret.

Noether prevents self-write loops using per-path content fingerprints in src-tauri/src/vault.rs:

  • Fingerprint Registration: Before fs::rename replaces the target file, save_markdown_file calls register_internal_write(&file_path, content.as_bytes()), storing the canonicalized path, byte size, xxh3_64 hash, and timestamp in WRITE_FINGERPRINTS.
  • Echo Verification: When the watcher thread receives an event, is_internal_echo() checks the file on disk against the stored size and xxh3_64 hash (within a 30-second cache window and a 3–5s fallback for transient Windows file locks). Matching writes are ignored.
  • External Change Detection: If an external modification occurs (from Git or another editor), the fingerprint does not match, so Rust emits vault-files-changed and Noether reloads the note without losing external changes.
  • Conflict Protection: While the editor holds focus and uncommitted edits, ProseMirror keeps authority over the active buffer so background sync does not jump the cursor.

5. Windows Memory Management

Electron Markdown apps routinely idle at 600 MB to 1.5 GB because Chromium clings to cached heaps, and even WebView2 holds working-set pages after heavy scans unless nudged.

Minimizing the window triggers window_trim_memory() immediately, while losing focus or hiding the window starts a 5-second (5000 ms) timer (scheduleTrimMemory in platformAdapter.ts). On Windows, window_trim_memory() calls SetProcessWorkingSetSize(GetCurrentProcess(), usize::MAX, usize::MAX), flushing unreferenced working-set pages back to the OS standby pool to hold idle RAM under 150 MB. Switching back within 5 seconds fires cancelTrimMemory() so Alt-Tabbing doesn’t cause paging churn.

6. Lossless Markdown Round-Trip & Source Mode Fidelity

ProseMirror wants a strict hierarchical node tree, whereas .md files on disk carry arbitrary indentation, mixed -/*/+ bullets, YAML comments, raw HTML tags, and multiline pipe tables. Noether keeps those intact across round-trips:

Verbatim Raw Frontmatter Preservation

When you open a note containing YAML frontmatter, parseFrontmatter captures the exact raw frontmatter string (_raw_frontmatter) alongside parsed key-value metadata:

  • Zero Syntax Alteration: YAML comments (# Author notes), custom multi-line indentation, folded scalars, and explicit YAML quote styles remain untouched.
  • Verbatim Serialization: When writing back to disk, if properties were not structurally altered via the UI metadata inspector, formatFrontmatter re-emits the exact raw frontmatter block byte-for-byte instead of reconstructing synthetic YAML.

AST List Marker Retention

Standard CommonMark serializers discard list bullet characters upon AST ingestion, defaulting to - for every item upon disk export. Noether preserves authored list markers through explicit node attributes:

  • Marker Extraction: During parsing, matchTaskListItemLine and list parsers extract the exact list marker (-, *, or +) and persist it into the list item’s AST attributes (attrs.marker).
  • Targeted Serialization: jsonToMarkdown inspects li.attrs?.marker when serializing bullet lists and task lists. Nested mixed-marker lists (* for top-level, - for sub-items) keep their original markers on disk.

Multiline Table Structure & Delimiter Escaping

Markdown pipe tables often break during AST conversions. Noether protects table cell integrity with delimiter normalization:

  • Multiline Cell Encoding: Line breaks within table cells are converted to <br> tags during serialization (replace(/\r?\n/g, '<br>')) rather than collapsing into single-line spaces. Upon ingestion, <br> tags convert back into hardBreak nodes.
  • Pipe Delimiter Escaping: Literal pipe characters within cell text are escaped (\|) during serialization and parsed via lookbehind splitters (split(/(?<!\\)\|/)), keeping column counts intact.

Direct Plaintext Source Mode Disk Bypass

When editing in Source Mode, you interact directly with the raw Markdown buffer:

  • AST Serialization Bypass: Keystrokes in Source Mode maintain a direct raw text ref (pendingRawMarkdownRef). When auto-save flushes, Noether pipes this raw string directly to disk via rawMarkdownOverride.
  • Zero Round-Trip Degradation: Because disk writes bypass jsonToMarkdown, custom indented code fences inside task lists, Setext headings, and raw HTML blocks stay untouched.
  • Asynchronous Search Indexing: While disk writes remain byte-for-byte identical to the raw buffer, SQLite blocks and full-text search (blocks_fts) still update asynchronously from the derived AST.

Search wiki and portfolio

type to search across all entries.