Skip to main content

Module runtime_mode

Module runtime_mode 

Source
Expand description

Runtime mode detection — single source of truth.

The launcher computes RuntimeMode::current once at startup and propagates the result to host + srv via the AGENTMUX_RUNTIME_MODE environment variable. No binary should call [current] more than once per process; downstream binaries read the env var via [from_env] instead.

Replaces the legacy mix of cfg!(debug_assertions), env::var ("AGENTMUX_DEV").is_ok(), and == Ok("1") checks across launcher, host, and sidecar — which were each correct in isolation but desynchronized in combination (see docs/specs/ SPEC_DATA_DIR_UNIFICATION_2026-05-05.md §2.1).

§Detection priority

  1. AGENTMUX_RUNTIME_MODE env override (testing, CI).
  2. Marker-based portable detection: an agentmux-portable.marker file written by scripts/package-portable.sh. Looked for next to the detecting exe, one level down in runtime/ (the packaging puts it there to keep the extract root clean; the launcher is at the root and the host/srv run from runtime/), and two levels up for macOS .app bundles.
  3. Path-based dev detection: exe is under a known dev-build dir (dist/cef-dev*/, target/debug/, target/release/).
  4. AGENTMUX_DEV_BRANCH env override (CI override for dev mode).
  5. Default: Installed.

Enums§

RuntimeMode
Where this AgentMux binary is running from. Determines data path layout (see crate::DataPaths).

Constants§

RECORDED_CHANNEL_FILE
The file in a portable’s runtime/ that names its data channel, when an upgrade carried one over (srv update/download.rs): a local build’s local-… channel, kept by the release it upgraded to, so the upgrade continues with that build’s windows, agents and settings.

Functions§

app_bundle_of
The .app bundle the binary at path (or its Contents/MacOS folder) belongs to, by the bundle layout rather than by name: the innermost *.app whose Contents/MacOS holds path, and, for a helper app nested in another app’s Contents/Helpers or Contents/Frameworks (srv, the CEF helpers), the app above it. A folder that merely ends in .app around the install is never taken for it.
appimage_channel_file
Where an upgrade records the data channel of an AppImage: beside it, as <file>.agentmux-channel, since the AppImage itself can’t be written.
derive_clone_id
Walk up from exe_dir looking for a workspace-root marker, then hash that absolute (canonical) path with FNV-1a and return a 16-char hex string. Used as the per-clone discriminator in ~/.agentmux/dev/<branch>/<clone_id>/. Returns None if no marker is found (extreme edge case — task dev always runs from inside a clone with .git/Cargo.toml/Taskfile.yml).
exe_dir_is_dev
Whether the binary in exe_dir is a source-tree build: what RuntimeMode::current_path_only answers Dev for, without building the mode. Building it finds the branch, which starts git and waits for it. A caller that only needs the yes or no must not pay for a process: the host asked through current_path_only on its UI thread at every page load, and a dev build froze for as long as git took to start (task #47585).
fnv1a_64
folder_others_can_change
Why an account other than this user, root or the admin group (whose members can become root anyway) could change the entries of the folder that holds an app, or None when none can. An in-place upgrade creates, checks and renames entries there, so anyone else who can rename them could swap a checked bundle for another. macOS also checks every folder above it, since renaming one of those moves the whole path.
git_branch_lookups
How many times the calling thread has started git to find a branch. For tests that a path stays free of process starts; per thread, so tests that run side by side do not count each other.
inside_appimage
Whether exe is under one of the AppImage roots ($APPDIR, the extraction).
is_dev_build_exe
True when this binary is running from one of our known dev-build output directories (dist/cef-dev*/, target/debug/, target/release/). Walks ancestors to handle nested cases (CEF subprocesses run from a runtime/ subdir even in dev). Path-only — does not read env.
is_dev_self
True iff THIS binary is a source-tree / task dev build, determined from the binary’s path + portable marker via RuntimeMode::current_path_only — NOT from AGENTMUX_RUNTIME_MODE. A running task dev AgentMux exports AGENTMUX_RUNTIME_MODE=dev:<branch> into its environment, which every descendant process inherits; a packaged build launched from a terminal / agent pane inside a dev instance would otherwise mis-identify as Dev (e.g. the “DEV” status-bar badge on a release build). Build identity is a property of the binary on disk, not of whoever launched it.
mac_app_channel_file
Where a macOS upgrade records the data channel of an .app: beside it, hidden, as .<name>.app.agentmux-channel, since writing inside the bundle would break its code signature.
portable_build_label
The ephemeral build label of a local portable, from the marker scripts/package-portable.sh writes into runtime/: AgentMux portable build <label>, e.g. 0.59.16+g2a5424fe2.20261008T234046.81801. Read at runtime, not baked, because it changes every build and a binary that wasn’t rebuilt would carry a stale one. exe_dir is the running binary’s directory: the marker sits next to the host and srv (both in runtime/), or one level up for older portables. None for released, installed and dev builds.
recorded_channel
The data channel the running binary’s install records: beside the AppImage it runs from, beside its .app on macOS, else in its portable folder (recorded_channel_in).
recorded_channel_in
The data channel the portable folder at or above exe_dir records: next to the host and srv (Windows: both in runtime/), in runtime/ below the launcher, or at the top of a Linux portable (AgentMux/, two levels above the binaries’ usr/bin/).
running_appimage
The AppImage the binary at exe runs from: $APPIMAGE, when exe is inside that AppImage’s mount ($APPDIR) or the folder AppRun extracted it to ($AGENTMUX_EXTRACTED_RUN). APPIMAGE alone isn’t enough: any other build started from an AppImage instance’s pane inherits it.