Skip to content

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.

fix(desktop): say why restart probes stay quiet

rubenluetke10-beep31f19cc4c0ec
diff --git a/jarvis/ui/relauncher.py b/jarvis/ui/relauncher.py
index c5fd0db17a..e0173c067d 100644
--- a/jarvis/ui/relauncher.py
+++ b/jarvis/ui/relauncher.py
@@ -272,7 +272,7 @@ def _existing_branded_launcher() -> Path | None:
if cand.is_file() and cand.stat().st_size > 0:
return cand
except OSError:
- continue
+ continue # unreadable candidate; try the next home
return None
@@ -318,7 +318,7 @@ def _restart_admin_port(cwd: str | Path | None = None) -> int:
if isinstance(port, int) and 1 <= port <= 65535:
base = port
except (OSError, UnicodeDecodeError, ValueError, TypeError, AttributeError):
- pass
+ pass # unreadable jarvis.toml → packaged default port
return current_instance().port(base)
@@ -344,7 +344,7 @@ def _desktop_is_serving(
with connect((host, port), timeout=timeout):
return True
except OSError:
- return False
+ return False # nothing accepted; that is the probe result
def pid_alive(pid: int) -> bool:
@@ -792,7 +792,6 @@ def main(
cmd = build_launch_command(sys.executable)
env = _apply_branded_launch_env(fresh_user_env(), cmd)
- kwargs = detached_popen_kwargs(cwd=cwd, env=env)
update_finalized = False
for attempt in range(attempts):
@@ -813,15 +812,7 @@ def main(
_finalize_update(cwd)
update_finalized = True
- try:
- proc = _spawn(cmd, **kwargs)
- except PermissionError:
- flags = int(kwargs.get("creationflags", 0) or 0)
- if sys.platform != "win32" or not (flags & _CREATE_BREAKAWAY_FROM_JOB):
- raise
- kwargs = dict(kwargs)
- kwargs["creationflags"] = flags & ~_CREATE_BREAKAWAY_FROM_JOB
- proc = _spawn(cmd, **kwargs)
+ proc = spawn_detached(cmd, cwd=cwd, env=env, _popen=_spawn)
new_pid = getattr(proc, "pid", None)
logging.getLogger(__name__).info(
"relauncher: spawn attempt %s pid=%s cmd=%s",
diff --git a/jarvis/ui/web/launcher.py b/jarvis/ui/web/launcher.py
index 23fdfd690f..1a04e6e243 100644
--- a/jarvis/ui/web/launcher.py
+++ b/jarvis/ui/web/launcher.py
@@ -1185,11 +1185,16 @@ def _recover_from_already_running(
)
return None
except Exception as exc: # noqa: BLE001
- logger.warning("launcher: focusing the booting instance failed: {}", exc)
- break
+ logger.warning(
+ "launcher: focusing the booting instance failed: {}", exc
+ )
+ # keep waiting; a transient focus miss is not "stuck"
try:
focused = bool(focus())
- except Exception: # noqa: BLE001
+ except Exception as exc: # noqa: BLE001
+ logger.warning(
+ "launcher: final focus of booting holder failed: {}", exc
+ )
focused = False
if focused:
return None
diff --git a/tests/unit/ui/test_launcher_boot_trace.py b/tests/unit/ui/test_launcher_boot_trace.py
index a752807f7d..8a120ff58f 100644
--- a/tests/unit/ui/test_launcher_boot_trace.py
+++ b/tests/unit/ui/test_launcher_boot_trace.py
@@ -105,7 +105,9 @@ def test_a_young_holder_is_waited_for_not_killed():
def focus(self):
self.focus_n += 1
- return self.focus_n >= 3
+ if self.focus_n == 2:
+ raise RuntimeError("transient focus miss")
+ return self.focus_n >= 4
calls = _Booting()
clock = {"t": 0.0}
@@ -124,7 +126,7 @@ def test_a_young_holder_is_waited_for_not_killed():
assert result is None
assert calls.asked == []
assert calls.terminated == []
- assert calls.focus_n >= 3
+ assert calls.focus_n >= 4
def test_a_young_holder_that_never_grows_a_window_is_still_asked():
diff --git a/tests/unit/ui/test_relauncher.py b/tests/unit/ui/test_relauncher.py
index 9bb088b492..8119034c1b 100644
--- a/tests/unit/ui/test_relauncher.py
+++ b/tests/unit/ui/test_relauncher.py
@@ -277,6 +277,37 @@ def test_apply_branded_launch_env_sets_the_loop_guard_only_for_the_branded_exe(
assert branded_env["JARVIS_BRANDED_LAUNCH"] == "1"
+def test_main_spawns_branded_exe_with_the_loop_guard(monkeypatch, tmp_path):
+ """The live Windows restart must be one branded process, not a python hop."""
+ from jarvis.core.instance import current_instance
+
+ branded = tmp_path / current_instance().windows_branded_launcher_file_name
+ branded.write_bytes(b"MZ")
+ monkeypatch.setattr(relauncher.sys, "platform", "win32")
+ monkeypatch.setattr(relauncher.sys, "executable", str(tmp_path / "python.exe"))
+ monkeypatch.setattr(relauncher.sys, "_base_executable", "", raising=False)
+ monkeypatch.delenv("LOCALAPPDATA", raising=False)
+ spawned: list[dict] = []
+
+ def fake_spawn(cmd, **kwargs):
+ spawned.append({"cmd": cmd, "kwargs": kwargs})
+ return SimpleNamespace(pid=999)
+
+ rc = relauncher.main(
+ ["4242", str(tmp_path)],
+ _wait=lambda pid, **_kw: True,
+ _spawn=fake_spawn,
+ _sleep=lambda _s: None,
+ _alive=lambda _p: True,
+ _serving=lambda: False,
+ _finalize_update=lambda _cwd: True,
+ )
+ assert rc == 0
+ assert len(spawned) == 1
+ assert spawned[0]["cmd"][0] == str(branded)
+ assert spawned[0]["kwargs"]["env"]["JARVIS_BRANDED_LAUNCH"] == "1"
+
+
def test_restart_quit_sequence_marks_quit_destroys_then_hard_exits():
order: list[object] = []