Skip to content

Rust/Tauri desktop and tray architecture

ClamUI is a Rust core plus a Tauri 2 desktop application with a React/TypeScript frontend. The core owns scanning, persistence, scheduling, host integration, and privilege-sensitive behavior; it has no Tauri or GTK widget dependency. The desktop owns WebKitGTK presentation, native dialogs, single-instance forwarding, and the pure-Rust StatusNotifierItem (SNI) tray.

On Linux, GTK application identity opt-in is enabled with the canonical public ID io.github.linx_systems.ClamUI, preserving the official desktop-file and logo association. It is separate from Tauri’s private bundle identifier.

ClamUI Rust/Tauri architectureA React frontend makes allowlisted requests to the Tauri native runtime, which calls the headless Rust core. Core events return over one event stream. The native runtime also owns in-process SNI and DBusMenu tray integration.

request operation + JSON args

allowlisted core dispatch

Event event + data

clamui-event

quick scan / update / profile / quit

React / TypeScript frontend

Tauri native runtime

clamui-core

Pure-Rust SNI + DBusMenu

ClamUI Rust/Tauri architectureA React frontend makes allowlisted requests to the Tauri native runtime, which calls the headless Rust core. Core events return over one event stream. The native runtime also owns in-process SNI and DBusMenu tray integration.

request operation + JSON args

allowlisted core dispatch

Event event + data

clamui-event

quick scan / update / profile / quit

React / TypeScript frontend

Tauri native runtime

clamui-core

Pure-Rust SNI + DBusMenu

Component Responsibility
crates/clamui-core Headless domain dispatch, XDG persistence, ClamAV host commands, scheduler, quarantine, i18n, and helper protocol
desktop/src-tauri Tauri commands, event bridge, native dialogs, safe external/path opening, single instance, lifecycle, and SNI tray
desktop/src React pages, navigation, i18n rendering, notifications, and typed frontend API
/usr/bin/clamui-apply-preferences Native privileged helper implementing the authenticated protocol-v4 host-configuration boundary

The core loads the gettext catalog listed in po/LINGUAS and passes it, with its plural rule, to the CLI, tray, and frontend. The About credits come from the embedded root AUTHORS file. Workflow: translation.

The frontend has one asynchronous request path:

request<T>(operation: string, args?: Record<string, unknown>): Promise<T>

The native request command routes only allowlisted core operations. There is no frontend filesystem, shell, process, arbitrary command, remote-navigation, or generic IPC permission. Operations use names such as scanner.scan, updater.update, quarantine.restore, and settings.update.

All runtime notifications share one event shape and one channel:

type ClamUIEvent = { event: string; data: unknown }
// Tauri event channel: "clamui-event"

Important scan and update events include scan-progress, scan-complete, update-progress, and update-complete. The frontend must unsubscribe listeners when unmounted. Long-running requests execute off the Tauri UI thread; cancellation is scoped to the operation ID and never cancels an unrelated scan.

The tray is an in-process pure-Rust SNI/DBusMenu implementation: no Python service, no stdin/stdout protocol, no libdbusmenu or GTK tray binding.

  • It publishes the StatusNotifierItem and DBusMenu endpoints when a watcher is available.
  • Menu: show/hide window, Quick Scan, Full Scan, saved profiles, database update, Quit.
  • States: normal/protected, warning, scanning, threat. The protected state sends the bundled logo in the SNI payload instead of relying on the host icon theme.
  • Without an SNI watcher, ClamUI stays fully usable and never hides a requested scan window.

User guide: system tray.

GNOME normally needs AppIndicator Support or another SNI watcher; KDE Plasma, Cinnamon, MATE, and Budgie commonly provide one.

The native runtime processes CLI arguments before GUI initialization. The seven clamui subcommands and clamui --help remain headless. For GUI launches, the single-instance handler forwards the working directory, decoded file:// paths, and multiple selected files. Normal file launches scan every path; --virustotal uses only the first file and makes ignored extras visible to the user.

The desktop exposes only native helper commands for choosing paths, saving exports, copying text, opening an explicitly requested existing path, opening approved external URLs, closing the app, and reading startup state. It enforces a strict content-security policy and rejects webview/new-window navigation.

ClamAV remains a host-owned engine and database. Flatpak invokes host tools through flatpak-spawn --host; no package format bundles or pretends to replace ClamAV. The core’s private, bounded host-probe runner is reused for read-only host inspections such as Audit checks and the Network socket snapshot, rather than exposing shell or process execution to the frontend. Protected host configuration uses the validated Rust helper, polkit, explicit destination allowlists, and PKEXEC_UID ownership checks. The protocol stays compatible with a trusted already-installed v4 helper during upgrades.

Core persistence stays compatible with the current XDG JSON and SQLite layouts. See configuration for locations and development for the full validation and packaging workflow.