Files
Lumotia/docs/architecture-map/02-tauri-runtime/README.md
jars a1f3f3f134 docs: architecture map (initial 5-slice generation, 105 pages)
Five-slice navigable map of the entire codebase under
docs/architecture-map/. Each slice is a self-contained
breadcrumbed sub-tree:

  01-frontend (16)              Svelte/SvelteKit UI
  02-tauri-runtime (26)         src-tauri commands + lifecycle
  03-audio-transcription (16)   audio + transcription crates
  04-llm-formatting-mcp (19)    llm, ai-formatting, mcp, cloud
  05-core-storage-hotkey-build  core, storage, hotkey, workspace,
                          (26) CI, dev glue

Plus master README.md and data-flow-end-to-end.md tracing
audio bytes from microphone to FTS5 search to MCP read.

Generated by 5 parallel subagents on 2026/05/09 against
HEAD 3c47000. Each page has YAML frontmatter, file:line code
refs, sibling cross-links, plain-English summaries.

Aggregated debt surfaced (full lists in master README):
RB-08 macOS power assertion, schema head drift v14 vs v15,
VAD blocked on ort version conflict, streaming primitives
not wired into live.rs, no prompt versioning, MCP has no
auth, cloud-providers in-memory keystore, SettingsPage
2 484 LOC, commands/live.rs 1 737 LOC, dual theme system,
brand rename to Lumenote pending across the codebase.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 14:04:13 +01:00

9.2 KiB

name, type, slice, last_verified
name type slice last_verified
Slice 02 — Tauri runtime architecture-map-page 02-tauri-runtime 2026/05/09

Slice 02 — Tauri runtime

Where you are: Architecture map → Tauri runtime

Plain English summary. The Tauri runtime is the bridge between Magnotia's Svelte frontend and the Rust workspace crates. It owns app startup (database init, panic hook, plugin wiring, preferences injection), the system tray, the secondary windows (task float, transcript viewer, transcription preview), and the entire #[tauri::command] surface that the frontend invokes for audio capture, transcription, LLM cleanup, task and transcript CRUD, paste, TTS, hotkeys, diagnostics, and more. Everything that runs on the host process but is not pure crate logic lives here.

At a glance

  • Path: src-tauri/
  • Total LOC (Rust + Cargo + JSON, excluding gen/): ~8,690.
  • Tauri version: 2 (see src-tauri/Cargo.toml:44).
  • Bundle identifier: uk.co.corbel.magnotia (src-tauri/tauri.conf.json:5).
  • Plugins (always-on): tauri-plugin-opener, tauri-plugin-dialog, tauri-plugin-notification.
  • Plugins (desktop-only, gated cfg(not(target_os = "android"))): tauri-plugin-global-shortcut, tauri-plugin-autostart (LaunchAgent), tauri-plugin-window-state. The tray-icon Tauri feature is also desktop-only.
  • Workspace crates pulled in: magnotia-core, magnotia-audio, magnotia-transcription (default-features off, whisper re-enabled here), magnotia-ai-formatting, magnotia-storage, magnotia-cloud-providers, magnotia-hotkey, magnotia-llm.
  • Tauri commands exposed via invoke_handler in src-tauri/src/lib.rs:321: 71 commands.
  • Capability files: src-tauri/capabilities/main.json (main window) and src-tauri/capabilities/secondary-windows.json (task float, transcript viewer, transcription preview).
  • Command modules: 22 #[tauri::command] modules plus 3 utility modules (mod.rs, power.rs, security.rs).
  • Integration tests: src-tauri/tests/config_hardening.rs (3 tests guarding CSP, updater signing, secondary-window permissions).

Map of this slice

App boot, config, tests:

  • App lifecycle. src-tauri/src/main.rs and src-tauri/src/lib.rs. Run entry, AppState construction, plugin wiring, preferences injection, X11-on-Wayland workaround, panic hook, error-log pruning, command registration.
  • System tray. Desktop-only tray icon and menu (src-tauri/src/tray.rs).
  • Tauri config. tauri.conf.json plus the Linux native-decorations overlay; CSP, window defaults, bundle settings.
  • Capabilities and ACL. The two ACL files in capabilities/, what each scopes, and the Phase 9 high-risk-permission firewall.
  • Cargo and features. Cargo.toml, the whisper cargo feature, the per-target dependency blocks, build.rs, .cargo/config.toml.
  • Tests. Config-hardening regression tests.

Command modules (entry index):

Individual command pages (linked from the commands index):

How this slice connects to others

  • Frontend (slice 01). Every #[tauri::command] is invoked from Svelte via @tauri-apps/api/core invoke(). Events emitted via app.emit(...) are consumed via listen() in the frontend. Live transcription uses typed tauri::ipc::Channel instead of plain events; the channel pair is created on the JS side and passed in as command args.
  • Audio + transcription (slice 03). commands::audio calls magnotia_audio::{MicrophoneCapture, WavWriter, decode_audio_file_limited, resample_to_16khz, probe_audio_duration_secs}. commands::transcription and commands::live call magnotia_transcription::LocalEngine plus magnotia_audio::StreamingResampler. commands::models calls magnotia_transcription::{model_manager, load_whisper, load_parakeet}.
  • LLM + formatting + MCP (slice 04). commands::llm calls magnotia_llm::{LlmEngine, model_manager, ContentTags, LlmModelId} and magnotia_ai_formatting::{llm_cleanup_text, LlmPromptPreset}. commands::tasks calls magnotia_llm::prompts::FeedbackExample and the engine's decompose_task_with_feedback / extract_tasks_with_feedback / extract_content_tags. commands::transcription and commands::live call magnotia_ai_formatting::{post_process_segments, FormatMode, PostProcessOptions}. commands::profiles calls magnotia_ai_formatting::extract_corrections for auto-learned vocabulary.
  • Core + storage + hotkey + build (slice 05). Everything DB-touching goes through magnotia_storage (init, database_path, get_setting, set_setting, prune_error_log, the full set of CRUD helpers, app_data_dir, crashes_dir, logs_dir, list_recent_errors, log_error). commands::hardware and commands::models call magnotia_core::{hardware, model_registry, recommendation, types, constants}. commands::meeting calls magnotia_core::process_watch. commands::hotkey is a thin Tauri wrapper around magnotia_hotkey::{EvdevHotkeyListener, HotkeyCombo, HotkeyEvent}. build.rs is the build-system half of the slice (CSP regression guard plus ggml multi-definition link arg).

Open questions / debt

  • commands/live.rs is 1,737 LOC. The runtime, loop state, speech gate, dedup, and chunking logic share the file. Splitting per concern would track against the broader refactor pass already mooted in the in-repo code review (docs/code-review-2026-04-22.md). See commands/live.md for the breakdown.
  • commands::update::install_update returns a hard-coded "Updates are disabled until release signing is configured." (src-tauri/src/commands/update.rs:15). The integration test updater_is_signed_or_absent (src-tauri/tests/config_hardening.rs:35) only asserts that if an updater config ships, it carries a non-empty pubkey. There is currently no updater config in tauri.conf.json, so the test is an empty no-op.
  • commands::power::PowerAssertion is a no-op on Linux and Windows (src-tauri/src/commands/power.rs:90). Only macOS has a real implementation via objc2. The doc comment promises SetThreadExecutionState (Windows) and logind inhibitors (Linux), but neither is wired up. Symptom: long live-dictation sessions on Linux can be idled by the compositor.
  • src-tauri/.cargo/config.toml hard-codes LIBCLANG_PATH = "C:\\Program Files\\LLVM\\bin" (Windows). It is harmless on non-Windows hosts (env var is just unused) but it is a foot-gun if someone moves Clang elsewhere on Windows. See Cargo and features.
  • The Linux Wayland workaround in lib.rs (ensure_x11_on_wayland) sets env vars before any threads spawn. This is the right pattern, but it ships even when the user is on a working DMA-BUF stack. The override knob is WEBKIT_DISABLE_DMABUF_RENDERER=0 set by the user; documented in the function header but not surfaced anywhere user-visible.
  • commands::diagnostics::install_panic_hook writes a "minimal text dump" without backtraces unless the user has RUST_BACKTRACE=1 set (src-tauri/src/commands/diagnostics.rs:42). The packaged binary does not set it, so production crash dumps will lack stack traces. Document or default-enable.
  • commands::audio::list_audio_devices is gated ensure_main_window but the secondary-windows capability does not invoke it, which is correct. The clipboard::copy_to_clipboard command, by contrast, has no main-window guard and any window with the core:default permission can call it; intentional, but worth flagging.

Existing in-repo docs

  • docs/code-review-2026-04-22.md. The MAJOR / MINOR review that motivated several of the safety helpers seen here (the parallel-mode loopback CSP guard in build.rs, secondary-window high-risk-permission test, RB-06 worker-join in commands::audio, RB-07 compose_accelerators in commands::models, RB-08 macOS App Nap power assertion in commands::power).
  • docs/issues/. Open issue threads, several of which the diagnostic-report bundler exists to feed.
  • docs/whisper-ecosystem/brief.md. Source of the numbered "brief items" cited in code comments (item #2 = loopback LLM CSP, item #9 = App Nap, items #10/#17 = paste / replace flows, item #19 = progressive WAV writer, item #28 = sequential-GPU mode).
  • docs/handovers/. Daily handover docs that cite specific command surfaces; useful when the in-source comments cite a "RB-NN review point".
  • docs/dev-setup.md. Linux + Windows + macOS toolchain setup, including the Vulkan loader install required for GPU-backed whisper.cpp.