Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(relauncher): stop fossilizing JARVIS__* env overrides across restarts
Ruben Lütke2303ea111336
diff --git a/jarvis/ui/relauncher.py b/jarvis/ui/relauncher.pyindex 654dde8cc8..aa8e6dfcfc 100644--- a/jarvis/ui/relauncher.py+++ b/jarvis/ui/relauncher.py@@ -68,6 +68,66 @@ def build_launch_command(executable: str) -> list[str]:return fallback+def _read_windows_user_jarvis_env() -> dict[str, str] | None:+ """The ``JARVIS__*`` config overrides persisted in the user's CURRENT+ Windows environment (HKCU\\Environment), or ``None`` when unavailable.++ ``None`` (non-Windows host, unreadable registry) means "no fresher source+ than the inherited environment exists" — the caller keeps it unchanged.+ POSIX hosts have no persisted user-env registry to re-read; their inherited+ environment is already the freshest source, so this is an honest no-op.+ """+ if sys.platform != "win32":+ return None+ try:+ import winreg++ persisted: dict[str, str] = {}+ with winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Environment") as key:+ index = 0+ while True:+ try:+ name, value, _kind = winreg.EnumValue(key, index)+ except OSError:+ break+ index += 1+ if isinstance(name, str) and name.upper().startswith("JARVIS__"):+ persisted[name] = str(value)+ return persisted+ except OSError:+ return None+++def fresh_user_env(+ base: dict[str, str] | None = None, *, _read_persisted=_read_windows_user_jarvis_env+) -> dict[str, str]:+ """Environment for the NEW launcher, with ``JARVIS__*`` overrides re-read+ from the user's currently persisted environment.++ Without this, the restart chain FOSSILIZES the env config layer: each+ restarted process inherits the ``JARVIS__*`` values captured when the+ first tray process started, so a config fix that updates all three pinned+ layers (jarvis.toml + config-soll.json + user env) keeps being overridden # i18n-allow: config-soll.json is a filename+ by the stale inherited copy on every ``restart-app`` — live case+ 2026-07-17: the TTS voice pin kept resurrecting a replaced voice. Only+ ``JARVIS__*`` keys (the pydantic config-override namespace) are refreshed;+ everything else stays inherited.+ """+ env = dict(os.environ if base is None else base)+ persisted = _read_persisted()+ if persisted is None:+ return env+ # Drop every inherited JARVIS__* key first (Windows env names are+ # case-insensitive, so spelling variants must not survive alongside the+ # refreshed names), then lay down the persisted set verbatim.+ for stale in [+ k for k in env if k.upper().startswith("JARVIS__") and k not in persisted+ ]:+ del env[stale]+ env.update(persisted)+ return env++def detached_creationflags() -> int:"""Windows creationflags that make a child outlive its parent, windowless.@@ -454,6 +514,9 @@ def main(cwd = argv[1]kwargs: dict[str, object] = {"cwd": cwd, "close_fds": True}+ # Fresh JARVIS__* overrides for the new instance — never the dying+ # process's fossilized copy (see fresh_user_env).+ kwargs["env"] = fresh_user_env()if sys.platform == "win32":kwargs["creationflags"] = detached_creationflags()else:diff --git a/tests/unit/ui/test_relauncher_fresh_env.py b/tests/unit/ui/test_relauncher_fresh_env.pynew file mode 100644index 0000000000..22843c4bc1--- /dev/null+++ b/tests/unit/ui/test_relauncher_fresh_env.py@@ -0,0 +1,76 @@+"""The relauncher must NOT fossilize the ``JARVIS__*`` env config layer.++Live case (2026-07-17): every restarted app inherited the ``JARVIS__TTS__*``+values captured when the FIRST tray process started. A voice fix that updated+all three pinned config layers (jarvis.toml + config-soll.json + the user's # i18n-allow: config-soll.json is a filename+persisted environment) kept being overridden by the stale inherited copy on+every ``restart-app`` — the replaced TTS voice resurrected after each restart.++``fresh_user_env`` re-reads the persisted ``JARVIS__*`` overrides (Windows:+HKCU Environment) for the NEW launcher; ``main`` passes that environment to+the spawn. On hosts with no persisted user env (POSIX) the inherited env is+already the freshest source and stays untouched.+"""+from __future__ import annotations++from types import SimpleNamespace++from jarvis.ui import relauncher+++def test_fresh_env_replaces_stale_jarvis_overrides():+ base = {+ "PATH": r"C:\bin",+ "JARVIS__TTS__VOICE_DE": "Kore", # fossilized in the dying process+ "JARVIS__TTS__VOICE_EN": "Kore",+ }+ persisted = {+ "JARVIS__TTS__VOICE_DE": "Charon", # what the user's env says NOW+ "JARVIS__TTS__VOICE_EN": "Charon",+ }+ env = relauncher.fresh_user_env(base, _read_persisted=lambda: persisted)+ assert env["JARVIS__TTS__VOICE_DE"] == "Charon"+ assert env["JARVIS__TTS__VOICE_EN"] == "Charon"+ assert env["PATH"] == r"C:\bin" # non-JARVIS keys stay inherited+++def test_fresh_env_drops_jarvis_keys_deleted_from_the_persisted_env():+ base = {"JARVIS__TTS__SEED": "7", "HOME": "/home/u"}+ env = relauncher.fresh_user_env(base, _read_persisted=dict)+ assert "JARVIS__TTS__SEED" not in env+ assert env["HOME"] == "/home/u"+++def test_fresh_env_is_a_no_op_without_a_persisted_source():+ base = {"JARVIS__TTS__VOICE_DE": "Kore", "PATH": "/bin"}+ env = relauncher.fresh_user_env(base, _read_persisted=lambda: None)+ assert env == base # POSIX / unreadable registry → inherited env unchanged+++def test_fresh_env_key_matching_is_case_insensitive():+ base = {"jarvis__tts__voice_de": "Kore"}+ persisted = {"JARVIS__TTS__VOICE_DE": "Charon"}+ env = relauncher.fresh_user_env(base, _read_persisted=lambda: persisted)+ assert env.get("JARVIS__TTS__VOICE_DE") == "Charon"+ assert "jarvis__tts__voice_de" not in env+++def test_main_spawns_the_new_launcher_with_the_fresh_env(monkeypatch):+ fresh = {"JARVIS__TTS__VOICE_DE": "Charon", "PATH": "/bin"}+ monkeypatch.setattr(relauncher, "fresh_user_env", lambda *a, **k: dict(fresh))+ spawned: list[dict] = []++ def fake_spawn(cmd, **kwargs):+ spawned.append({"cmd": cmd, "kwargs": kwargs})+ return SimpleNamespace(pid=999)++ rc = relauncher.main(+ ["4242", "repo"],+ _wait=lambda pid, **_kw: True,+ _spawn=fake_spawn,+ _sleep=lambda _s: None,+ _alive=lambda _p: True,+ _finalize_update=lambda _cwd: True,+ )+ assert rc == 0+ assert spawned[0]["kwargs"]["env"] == fresh