Skip to main content

Module lifecycle

Module lifecycle 

Source
Expand description

Startup / shutdown order and RunEvent routing.

Startup (plugin setup, then Tauri creates windows):

  1. single-instance arbitration (a second launch forwards argv and exits before anything heavy)
  2. shared state managed, 3. native menu, 4. tray
  3. engine started off the UI thread (never blocks first paint), 6. watchdog
  4. each webview becomes ready: native hardening, saved geometry restored, window shown (unless launched with --background)
  5. deep links queued from argv are delivered when the frontend calls rk_shell_ready

Shutdown (quit -> ExitRequested -> Exit): mark exiting (new engine calls refused), save window geometry, stop the engine (bounded), remove the tray, release the single-instance service.

Donors: HeardRight tray.rs Quit (engine shutdown before exit), hub_window (close hides, Dock reopen restores), ViewRight RunEvent::Reopen, CodeRight window_state save hooks.

Structs§

ActivationTracker
Remembers the policy last applied so only real changes reach the OS.
ShowPolicy
The host’s say over window visibility, evaluated by ShowPolicy::mode.

Enums§

Activation
macOS activation policy, mirrored so the decision is testable on every host.
InstanceMode
How a launch takes part in single-instance arbitration.
RevealMode
What the guard allows for one reveal.
RevealSource
Why the shell is bringing a window up. Every source asks the same guard (reveal_mode).
Visibility
What happened to the main window.

Constants§

NEVER_SHOW_TRUTHY
The documented truthy values for a never-show environment variable, compared exactly (ASCII case-insensitive, no trimming).

Functions§

activation_for
The activation policy a hide or reveal asks for, when the host chose “hide to background”. other_visible: some other window is still on screen, so the app must stay in the Dock.
env_equals
True when the value is exactly expected (case-sensitive, no trimming).
env_means_never_show
True when an environment value means “never show”: exactly one of NEVER_SHOW_TRUTHY (1, true, yes, on), ASCII case-insensitive. Anything else (unset, empty, 0, padded or unrecognised text) is off.
instance_mode
Pure decision for InstanceMode.
launched_in_background
True when this launch asked to stay in the tray (--background).
never_show
True when the host forbade showing windows (builder flag or registered environment variable).
qa_background
qa_hidden
QA-only launch policy. The harness sets this before the frontend exists so every shell-owned show/reopen path can preserve the user’s foreground app. Compiled out of product releases: without debug assertions the selector is not read at all and the answer is always false, so a shipped binary carries no QA hidden/background switch.
quit
reopen_wants_reveal
A Dock reopen with no visible window is the only reopen that asks to reveal.
repair_cache_enabled
Whether the startup cache repair runs: the host’s explicit choice, else on, except under lifecycle_only where the host owns its cache.
reveal_mode
THE guard. Every path that shows, unminimises or focuses a window (reopen, opened, second instance, show-on-ready, tray, the window command, windows::open, windows::reveal, restore) asks this function and does exactly what the answer allows. Without ShellState (a standalone helper outside the plugin) the default policy applies.
show_on_ready_decision
Whether the main window is shown when its webview is ready.
show_on_ready_installed
Whether the ShowOnReady behaviour is installed. lifecycle_only turns the module off, and only the host’s explicit show_on_ready(true) brings it back; every other module set is decided by the module alone.