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.

chore: auto-save WIP via Claude stop-hook safety net (2026-07-02 09:23)

Ruben Lütke5700e3897d26
diff --git a/assets/brand/social-preview.html b/assets/brand/social-preview.html
new file mode 100644
index 0000000000..fca8dabebf
--- /dev/null
+++ b/assets/brand/social-preview.html
@@ -0,0 +1,78 @@
+<!doctype html>
+<!-- Social preview card (GitHub repo settings), 1280x640.
+ Rasterize: pwsh assets/brand/render.ps1 -In social-preview.html -Out social-preview.png -W 1280 -H 640 -Scale 2
+ (then downscale the 2x shot to exactly 1280x640 — see marketing/launch/github-setup.md) -->
+<html lang="en">
+<head>
+<meta charset="utf-8" />
+<style>
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&family=JetBrains+Mono:wght@500&display=swap');
+ * { margin: 0; padding: 0; box-sizing: border-box; }
+ html, body { width: 1280px; height: 640px; overflow: hidden; }
+ body {
+ background: #0A0A0A;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+ /* one soft gold glow from above — the brand's single accent, never a fill */
+ .glow {
+ position: absolute; inset: 0;
+ background:
+ radial-gradient(ellipse 90% 55% at 50% -8%, rgba(255, 214, 10, 0.10), transparent 62%),
+ radial-gradient(ellipse 120% 40% at 50% 112%, rgba(255, 214, 10, 0.04), transparent 60%);
+ }
+ .card {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 26px;
+ }
+ .mascot-wrap { position: relative; width: 128px; height: 128px; }
+ .mascot-wrap .ring {
+ position: absolute; border-radius: 50%;
+ border: 1px solid rgba(255, 214, 10, 0.32);
+ }
+ .ring.r1 { inset: -14px; }
+ .ring.r2 { inset: -30px; border-color: rgba(255, 214, 10, 0.16); }
+ .mascot {
+ width: 128px; height: 128px; object-fit: contain;
+ filter: drop-shadow(0 0 26px rgba(255, 214, 10, 0.30));
+ }
+ .wordmark {
+ width: 760px; display: block;
+ /* the banner raster carries its own near-black stage — feather its edges
+ so it melts into the matte-black card instead of reading as a box */
+ -webkit-mask-image: radial-gradient(ellipse 72% 74% at 50% 50%, #000 52%, transparent 88%);
+ mask-image: radial-gradient(ellipse 72% 74% at 50% 50%, #000 52%, transparent 88%);
+ }
+ .tagline {
+ font-family: 'Inter', sans-serif;
+ font-size: 27px; font-weight: 600;
+ color: #F4F4F5; letter-spacing: -0.01em;
+ text-align: center;
+ }
+ .tagline .gold { color: #FFD60A; }
+ .meta {
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 16px; font-weight: 500;
+ letter-spacing: 0.22em;
+ color: #FFD60A;
+ }
+</style>
+</head>
+<body>
+ <div class="glow"></div>
+ <div class="card">
+ <div class="mascot-wrap">
+ <div class="ring r1"></div>
+ <div class="ring r2"></div>
+ <img class="mascot" src="../icons/jarvis-gigi-256.png" alt="" />
+ </div>
+ <img class="wordmark" src="banner.png" alt="Personal Jarvis" />
+ <div class="tagline">Talk to your computer — <span class="gold">and watch it do the work.</span></div>
+ <div class="meta">OPEN SOURCE · MIT · LINUX · MACOS · WINDOWS</div>
+ </div>
+</body>
+</html>
diff --git a/assets/brand/social-preview.png b/assets/brand/social-preview.png
new file mode 100644
index 0000000000..fb49eb7cf2
Binary files /dev/null and b/assets/brand/social-preview.png differ
diff --git a/jarvis/cu/engine.py b/jarvis/cu/engine.py
index 16dd5f0d31..4b87a38b90 100644
--- a/jarvis/cu/engine.py
+++ b/jarvis/cu/engine.py
@@ -416,8 +416,9 @@ async def run_cu_loop(
done_rejects = 0
guard_hits = 0
observe_failures = 0
- recent_shas: list[str] = []
- progressed_since_sha_repeat = True
+ prev_sha: str | None = None
+ fruitless_steps = 0 # steps with zero successful actions on an unchanged screen
+ last_step_had_success = False
while step_idx < max_steps:
step_idx += 1
@@ -470,16 +471,20 @@ async def run_cu_loop(
)
return
- # No-progress guard: the same screen N times without any successful
- # action in between means we are circling — judge once, then stop.
- recent_shas.append(frame.sha256)
- if len(recent_shas) > _STUCK_FRAMES:
- recent_shas.pop(0)
+ # No-progress guard: several consecutive steps that produced no
+ # successful action while the screen never changed means we are
+ # circling — judge once (the goal may in fact be met), then stop.
if (
- len(recent_shas) == _STUCK_FRAMES
- and len(set(recent_shas)) == 1
- and not progressed_since_sha_repeat
+ prev_sha is not None
+ and frame.sha256 == prev_sha
+ and not last_step_had_success
):
+ fruitless_steps += 1
+ else:
+ fruitless_steps = 0
+ prev_sha = frame.sha256
+ last_step_had_success = False
+ if fruitless_steps >= _STUCK_FRAMES:
done, proof = await _judge_done(
ctx, goal, monitor, image_cfg, output_language,
)
@@ -496,7 +501,6 @@ async def run_cu_loop(
exit_code=_EXIT_FAIL,
)
return
- progressed_since_sha_repeat = False
# ---- decide ---------------------------------------------------------
t0 = time.monotonic()
@@ -837,7 +841,7 @@ async def run_cu_loop(
summary = _summarize_action(action)
if ok:
consecutive_failures = 0
- progressed_since_sha_repeat = True
+ last_step_had_success = True
history.append(
f"step {step_idx}: {summary} -> OK"
+ (f" ({detail[:120]})" if detail else ""),
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.py
index 11e03879eb..087cf1f3b5 100644
--- a/jarvis/ui/desktop_app.py
+++ b/jarvis/ui/desktop_app.py
@@ -2422,12 +2422,36 @@ class DesktopApp:
wake_plan.phrase or wake_plan.oww_keyword or "?",
)
if getattr(self, "_bp", False):
- # Honest wake-armed anchor on the same clock as BOOT_READY_MS.
+ # Pipeline-task-started mark (kept as a SECONDARY anchor). This
+ # fires before the deferred loaders warm the wake model / VAD /
+ # TTS, so it is NOT "the user can talk now".
print(
f"VOICE_READY_MS={(time.perf_counter() - self._bp_t0) * 1000.0:.1f}",
flush=True,
)
+ # HONEST usable anchor: VoiceBootStatus(ready=True) is published
+ # exactly once the wake model is warmed AND VAD AND the TTS
+ # client are up (the end of _warmup_deferred_loaders — the
+ # "it says ready but I can't talk" contract, 2026-06-29). The
+ # TTU benchmark (measure_desktop_boot.py --voice) anchors on
+ # THIS print; anchoring on the pipeline start above measured a
+ # cosmetic ready state (TTU forensic 2026-07-02).
+ from jarvis.core.events import VoiceBootStatus as _VBS
+
+ _usable_printed = [False]
+
+ async def _print_voice_usable(evt: _VBS) -> None:
+ if getattr(evt, "ready", False) and not _usable_printed[0]:
+ _usable_printed[0] = True
+ print(
+ "VOICE_USABLE_MS="
+ f"{(time.perf_counter() - self._bp_t0) * 1000.0:.1f}",
+ flush=True,
+ )
+
+ bus.subscribe(_VBS, _print_voice_usable)
+
# Wake-model GIL-priority gate: signal the heavy backend (brain/mcp)
# to resume as soon as the LIGHT base/cpu wake model has loaded — or
# immediately if there is no local wake model (e.g. the OWW path), so
diff --git a/tests/unit/cu/test_engine_loop.py b/tests/unit/cu/test_engine_loop.py
new file mode 100644
index 0000000000..5fcff06ce1
--- /dev/null
+++ b/tests/unit/cu/test_engine_loop.py
@@ -0,0 +1,290 @@
+"""CU v2 engine state-machine tests — scripted FakeBrain, fake tool layer.
+
+Each test encodes one of the observed live failure classes the rebuild must
+kill: duplicate actions on an unchanged screen, blind typing after a missed
+focus click, a second stale pointer action in one batch, and unverified
+"done" claims.
+"""
+from __future__ import annotations
+
+from pathlib import Path
+from types import SimpleNamespace
+from typing import Any
+
+import pytest
+
+pytest.importorskip("PIL", reason="pillow required for frame handling")
+
+import jarvis.cu.engine as engine_mod
+from jarvis.cu.capture import capture_stable_frame
+from jarvis.cu.geometry import MonitorInfo
+
+MONITOR = MonitorInfo(left=0, top=0, width=192, height=108)
+
+
+class FakeBrain:
+ """Scripted ``complete_text`` manager: pops one reply per call."""
+
+ def __init__(self, replies: list[str]) -> None:
+ self.replies = list(replies)
+ self.calls: list[tuple[str, str]] = []
+
+ async def complete_text(self, *, system: str, user: str) -> str:
+ self.calls.append((system, user))
+ if not self.replies:
+ return '{"action": "wait", "ms": 1}'
+ return self.replies.pop(0)
+
+
+class FakeExecutor:
+ """Records every dispatched tool call; scriptable per-tool success."""
+
+ def __init__(self, failures: set[str] | None = None) -> None:
+ self.calls: list[tuple[str, dict[str, Any]]] = []
+ self.failures = failures or set()
+
+ async def execute(self, tool, args, *, user_utterance, trace_id):
+ name = tool["name"]
+ self.calls.append((name, dict(args)))
+ if name in self.failures:
+ return SimpleNamespace(success=False, output=None, error=f"{name} broke")
+ return SimpleNamespace(success=True, output=f"{name} ok")
+
+
+def _tools() -> dict[str, Any]:
+ return {
+ name: {"name": name}
+ for name in (
+ "click", "type_text", "hotkey", "scroll", "drag",
+ "open_app", "switch_window", "click_element",
+ )
+ }
+
+
+def _ctx(brain: FakeBrain, executor: FakeExecutor) -> SimpleNamespace:
+ return SimpleNamespace(
+ brain_manager=brain,
+ tool_executor=executor,
+ tools=_tools(),
+ bus=None,
+ step_budget=30,
+ monitor="primary",
+ main_monitor="primary",
+ settle_scale=0.0, # no real sleeps in tests
+ strict_verify=True,
+ image_max_dimension=192,
+ coordinate_space="auto",
+ )
+
+
+def _solid(shade: int = 30) -> tuple[tuple[int, int], bytes]:
+ return ((192, 108), bytes((shade, shade, shade)) * (192 * 108))
+
+
+def patched(monkeypatch, tmp_path):
+ """Patch every OS touchpoint of the engine to deterministic fakes."""
+ state = SimpleNamespace(
+ screen_shade=30,
+ typed_lands=True,
+ region_changes_after_click=True,
+ clicks_seen=0,
+ )
+
+ def fake_select_monitor(policy, *, main_monitor="primary"):
+ return MONITOR
+
+ def fake_capture(monitor, *, max_dimension, blob_dir=None, **kw):
+ return capture_stable_frame(
+ monitor,
+ grab=lambda bbox: _solid(state.screen_shade),
+ sleep=lambda s: None,
+ max_dimension=max_dimension,
+ blob_dir=Path(tmp_path),
+ )
+
+ def fake_grab_region(bbox, *, grab=None):
+ # After a click the "post" grab differs when the fake says so.
+ if state.region_changes_after_click and state.clicks_seen % 2 == 1:
+ state.clicks_seen += 1
+ return _solid(state.screen_shade + 40)
+ state.clicks_seen += 1
+ return _solid(state.screen_shade)
+
+ async def fake_snapshot(*a, **kw):
+ return [], "", None
+
+ async def fake_verify_typed(text):
+ return state.typed_lands
+
+ monkeypatch.setattr(engine_mod, "select_monitor", fake_select_monitor)
+ monkeypatch.setattr(engine_mod, "capture_stable_frame", fake_capture)
+ monkeypatch.setattr(engine_mod, "grab_region", fake_grab_region)
+ monkeypatch.setattr(engine_mod, "foreground_ui_snapshot", fake_snapshot)
+ monkeypatch.setattr(engine_mod, "verify_typed_text", fake_verify_typed)
+ monkeypatch.setattr(engine_mod, "_foreground_title", lambda: "Test Window")
+ return state
+
+
+async def _run(ctx) -> list:
+ task = SimpleNamespace(prompt="open the thing", env={}, timeout_s=60)
+ return [
+ chunk
+ async for chunk in engine_mod.run_cu_loop(task, ctx, cancel_token=None)
+ ]
+
+
+def _final(chunks):
+ finals = [c for c in chunks if c.is_final]
+ assert len(finals) == 1
+ return finals[0]
+
+
+# ---------------------------------------------------------------------------
+
+
+async def test_done_is_verified_and_proof_flows_to_stdout(patched):
+ brain = FakeBrain([
+ '{"action": "done", "reason": "it is visible"}', # decide
+ '{"done": true, "proof": "the calculator shows 8"}', # judge
+ ])
+ chunks = await _run(_ctx(brain, FakeExecutor()))
+ final = _final(chunks)
+ assert final.exit_code == 0
+ assert "[cu] done (verified: the calculator shows 8)" in final.stdout
+
+
+async def test_rejected_done_feeds_history_and_eventually_fails(patched):
+ brain = FakeBrain(
+ ['{"action": "done", "reason": "sure"}',
+ '{"done": false, "proof": "the window is not open"}'] * 3,
+ )
+ chunks = await _run(_ctx(brain, FakeExecutor()))
+ final = _final(chunks)
+ assert final.exit_code == 5
+ assert "could not be verified" in final.stderr
+ # The judge's rejection reached the model as history.
+ assert any("done REJECTED" in user for (_, user) in brain.calls)
+
+
+async def test_duplicate_click_on_unchanged_screen_is_refused(patched):
+ patched.region_changes_after_click = True
+ brain = FakeBrain([
+ '{"action": "click", "x": 500, "y": 500, "target": "play"}',
+ '{"action": "click", "x": 502, "y": 498, "target": "play"}', # same spot
+ '{"action": "done", "reason": "toggled"}',
+ '{"done": true, "proof": "playback is running"}',
+ ])
+ executor = FakeExecutor()
+ chunks = await _run(_ctx(brain, executor))
+ final = _final(chunks)
+ assert final.exit_code == 0
+ clicks = [c for c in executor.calls if c[0] == "click"]
+ assert len(clicks) == 1, "the near-identical re-click must be refused"
+ assert any("REFUSED" in user for (_, user) in brain.calls)
+
+
+async def test_type_that_does_not_land_blocks_the_rest_of_the_batch(patched):
+ patched.typed_lands = False
+ brain = FakeBrain([
+ # Blind batch: type + enter. The type read-back fails -> enter must NOT run.
+ '[{"action":"type","text":"https://example.com"},'
+ '{"action":"key","keys":["enter"]}]',
+ '{"action": "fail", "reason": "cannot focus the address bar"}',
+ ])
+ executor = FakeExecutor()
+ chunks = await _run(_ctx(brain, executor))
+ final = _final(chunks)
+ assert final.exit_code == 5
+ tool_names = [name for (name, _) in executor.calls]
+ assert "type_text" in tool_names
+ assert "hotkey" not in tool_names, "enter after a failed type is the blind-action bug"
+ assert any("did NOT land" in user for (_, user) in brain.calls)
+
+
+async def test_second_pointer_action_in_one_batch_is_skipped(patched):
+ brain = FakeBrain([
+ '[{"action":"click","x":100,"y":100},'
+ '{"action":"click","x":900,"y":900}]',
+ '{"action": "done", "reason": "clicked"}',
+ '{"done": true, "proof": "both dialogs handled"}',
+ ])
+ executor = FakeExecutor()
+ chunks = await _run(_ctx(brain, executor))
+ assert _final(chunks).exit_code == 0
+ clicks = [c for c in executor.calls if c[0] == "click"]
+ assert len(clicks) == 1, "a second stale-frame pointer action must not execute"
+ assert any("only one pointer action" in user for (_, user) in brain.calls)
+
+
+async def test_missed_click_no_visible_change_is_reported_as_failure(patched):
+ patched.region_changes_after_click = False # click voids: nothing changes
+ brain = FakeBrain([
+ '{"action": "click", "x": 500, "y": 500, "target": "button"}',
+ '{"action": "fail", "reason": "the button does not react"}',
+ ])
+ executor = FakeExecutor()
+ chunks = await _run(_ctx(brain, executor))
+ final = _final(chunks)
+ assert final.exit_code == 5
+ assert any("NO visible change" in user for (_, user) in brain.calls)
+
+
+async def test_clear_first_sends_platform_select_all(patched):
+ brain = FakeBrain([
+ '{"action":"type","text":"example.com","clear_first":true}',
+ '{"action": "done", "reason": "typed"}',
+ '{"done": true, "proof": "the address bar shows example.com"}',
+ ])
+ executor = FakeExecutor()
+ chunks = await _run(_ctx(brain, executor))
+ assert _final(chunks).exit_code == 0
+ hotkeys = [args for (name, args) in executor.calls if name == "hotkey"]
+ assert hotkeys and hotkeys[0]["keys"][-1] == "a"
+
+
+async def test_cancelled_token_stops_immediately(patched):
+ token = SimpleNamespace(is_cancelled=lambda: True, reason="hangup")
+ brain = FakeBrain([])
+ task = SimpleNamespace(prompt="anything", env={}, timeout_s=60)
+ chunks = [
+ c async for c in engine_mod.run_cu_loop(
+ task, _ctx(brain, FakeExecutor()), cancel_token=token,
+ )
+ ]
+ final = _final(chunks)
+ assert final.exit_code == 130
+ assert "[cu] cancelled" in final.stderr
+ assert not brain.calls
+
+
+async def test_unparseable_replies_exhaust_llm_budget(patched):
+ brain = FakeBrain(["gibberish", "more gibberish", "still gibberish"])
+ chunks = await _run(_ctx(brain, FakeExecutor()))
+ final = _final(chunks)
+ assert final.exit_code == 2
+
+
+async def test_tool_failures_exhaust_consecutive_budget(patched):
+ brain = FakeBrain(
+ ['{"action":"open_app","name":"spotify"}'] * 8,
+ )
+ executor = FakeExecutor(failures={"open_app"})
+ chunks = await _run(_ctx(brain, executor))
+ final = _final(chunks)
+ # Either the consecutive-failure cap (8) or the duplicate guard (5) ends
+ # it — both are honest failures, never silent grinding.
+ assert final.exit_code in (5, 8)
+
+
+async def test_handoff_screen_fails_fast_with_speakable_reason(patched, monkeypatch):
+ async def snapshot_with_captcha(*a, **kw):
+ return [], "", "captcha challenge"
+
+ monkeypatch.setattr(engine_mod, "foreground_ui_snapshot", snapshot_with_captcha)
+ brain = FakeBrain([])
+ chunks = await _run(_ctx(brain, FakeExecutor()))
+ final = _final(chunks)
+ assert final.exit_code == 5
+ assert "captcha challenge" in final.stderr
+ assert not brain.calls, "no model call may happen on a handoff screen"