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-07 16:20)

Ruben Lütke5eb411e9e0be
diff --git a/jarvis/ui/web/frontend/src/views/sub-agents/DepartureBoard.tsx b/jarvis/ui/web/frontend/src/views/sub-agents/DepartureBoard.tsx
index 35e04a65e7..cf1cb820a8 100644
--- a/jarvis/ui/web/frontend/src/views/sub-agents/DepartureBoard.tsx
+++ b/jarvis/ui/web/frontend/src/views/sub-agents/DepartureBoard.tsx
@@ -13,8 +13,11 @@ import {
} from "lucide-react";
import type { SubAgentNode, ToolCallEntry } from "@/store/jarvisAgents";
+import type { SectionHealth } from "@/hooks/useProviders";
import { cn } from "@/lib/utils";
import { useEventStore } from "@/store/events";
+import { useT } from "@/i18n";
+import { failureLabel } from "./failureLabel";
const STATUS_COLOR: Record<SubAgentNode["status"], string> = {
running: "text-primary",
diff --git a/jarvis/ui/web/frontend/src/views/sub-agents/failureLabel.test.ts b/jarvis/ui/web/frontend/src/views/sub-agents/failureLabel.test.ts
new file mode 100644
index 0000000000..2c5970ccae
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/sub-agents/failureLabel.test.ts
@@ -0,0 +1,33 @@
+import { describe, expect, it } from "vitest";
+
+import { failureLabel } from "./failureLabel";
+
+const t = (key: string) => `[${key}]`; // identity-ish stub: proves the key used
+
+describe("failureLabel", () => {
+ it("maps a known error_class to its i18n message and appends the detail", () => {
+ expect(
+ failureLabel(
+ { error: "Failed to authenticate. API Error: 401", error_class: "provider_auth" },
+ t,
+ ),
+ ).toBe("[subagents_view.error_class.provider_auth] (Failed to authenticate. API Error: 401)");
+ });
+
+ it("falls back to the raw error when the class is unknown/legacy", () => {
+ expect(failureLabel({ error: "task_error", error_class: "OrchestratorCrash" }, t)).toBe(
+ "task_error",
+ );
+ expect(failureLabel({ error: "task_error", error_class: null }, t)).toBe("task_error");
+ });
+
+ it("returns null when there is no error at all", () => {
+ expect(failureLabel({ error: null, error_class: null }, t)).toBeNull();
+ });
+
+ it("uses the mapped message alone when no detail text exists", () => {
+ expect(failureLabel({ error: null, error_class: "worker_timeout" }, t)).toBe(
+ "[subagents_view.error_class.worker_timeout]",
+ );
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/sub-agents/failureLabel.ts b/jarvis/ui/web/frontend/src/views/sub-agents/failureLabel.ts
new file mode 100644
index 0000000000..d3abfda4c3
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/sub-agents/failureLabel.ts
@@ -0,0 +1,26 @@
+import type { SubAgentNode } from "@/store/jarvisAgents";
+
+/** i18n keys for the closed MissionErrorClass vocabulary (parity-tested
+ * against jarvis/missions/events.py MISSION_ERROR_CLASSES). Legacy/unknown
+ * classes fall back to the raw error text. */
+const ERROR_CLASS_KEYS: Record<string, string> = {
+ provider_auth: "subagents_view.error_class.provider_auth",
+ provider_quota: "subagents_view.error_class.provider_quota",
+ provider_unreachable: "subagents_view.error_class.provider_unreachable",
+ worker_timeout: "subagents_view.error_class.worker_timeout",
+};
+
+/** Human failure label for a sub-agent node: the i18n message for a known
+ * error_class (with the upstream detail in parentheses), else the raw error
+ * text, else null (no failure to show). */
+export function failureLabel(
+ node: Pick<SubAgentNode, "error" | "error_class">,
+ t: (key: string) => string,
+): string | null {
+ const key = node.error_class ? ERROR_CLASS_KEYS[node.error_class] : undefined;
+ if (key) {
+ const msg = t(key);
+ return node.error ? `${msg} (${node.error})` : msg;
+ }
+ return node.error ?? null;
+}
diff --git a/tests/missions/workers/test_codex_quota_state.py b/tests/missions/workers/test_codex_quota_state.py
new file mode 100644
index 0000000000..64674cc3a6
--- /dev/null
+++ b/tests/missions/workers/test_codex_quota_state.py
@@ -0,0 +1,49 @@
+"""Process-local codex (ChatGPT) quota-cooldown flag.
+
+Live pattern (mission_019f3cd8 + the wall of failed missions, 2026-07-07):
+the codex ChatGPT plan hit its usage cap ("You've hit your usage limit …
+try again at Jul 31st"), but `codex status` still reported connected=True.
+The worker factory therefore re-picked codex on EVERY mission and retry,
+each spawn burning ~28 s before the cap error came back — and the in-worker
+fallback then died on a dead Claude login, so no mission ever reached the
+healthy OpenRouter key (AP-22). This flag is the codex mirror of
+``claude_quota_state``: a usage-capped codex arms a TIME-based, self-expiring
+cooldown; while armed the factory skips codex and crosses families. A codex
+success clears it immediately.
+"""
+from __future__ import annotations
+
+import jarvis.codex_quota_state as qs
+
+
+def test_default_not_in_cooldown() -> None:
+ qs.clear_codex_quota_cooldown()
+ assert qs.codex_in_quota_cooldown() is False
+
+
+def test_mark_sets_cooldown() -> None:
+ clock = [1000.0]
+ qs.mark_codex_quota_cooldown(now_fn=lambda: clock[0], cooldown_s=600.0)
+ assert qs.codex_in_quota_cooldown(now_fn=lambda: clock[0]) is True
+ qs.clear_codex_quota_cooldown()
+
+
+def test_cooldown_expires_after_window() -> None:
+ clock = [1000.0]
+ qs.mark_codex_quota_cooldown(now_fn=lambda: clock[0], cooldown_s=600.0)
+ # Still inside the window.
+ assert qs.codex_in_quota_cooldown(now_fn=lambda: 1300.0) is True
+ # Past the window -> auto-expires (no manual clear, cap reset re-probes).
+ assert qs.codex_in_quota_cooldown(now_fn=lambda: 1601.0) is False
+ qs.clear_codex_quota_cooldown()
+
+
+def test_clear_resets_immediately() -> None:
+ clock = [1000.0]
+ qs.mark_codex_quota_cooldown(now_fn=lambda: clock[0], cooldown_s=600.0)
+ qs.clear_codex_quota_cooldown()
+ assert qs.codex_in_quota_cooldown(now_fn=lambda: clock[0]) is False
+
+
+def test_default_cooldown_is_twenty_minutes() -> None:
+ assert qs._DEFAULT_COOLDOWN_S == 20 * 60.0
diff --git a/tests/unit/install/test_full_extra_contents.py b/tests/unit/install/test_full_extra_contents.py
index d72aca9433..ef70775786 100644
--- a/tests/unit/install/test_full_extra_contents.py
+++ b/tests/unit/install/test_full_extra_contents.py
@@ -4,9 +4,8 @@
Whisper wake/STT runtime; pvporcupine (dead, proprietary-keyed, branded
built-in keywords) must be gone from the dependency surface entirely.
"""
-from pathlib import Path
-
import tomllib
+from pathlib import Path
_PYPROJECT = Path(__file__).resolve().parents[3] / "pyproject.toml"