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-06-30 18:51)

Ruben Lütke13e0d71dbc9a
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index cd3d9b6a78..8b52ad680e 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -60,6 +60,7 @@ from jarvis.core.turn_language import (
)
from jarvis.voice.action_phrases import (
CU_CANCEL_EXIT_CODE,
+ CU_TOOL_OUTCOME_LAYER,
OUTPUT_LANGUAGE_ENV_KEY,
action_phrase,
cu_failure_readback,
@@ -5145,6 +5146,33 @@ class BrainManager:
if len(history) > self._HISTORY_MAX:
self._history = history[-self._HISTORY_MAX:]
+ async def _on_cu_tool_completion(self, event: Any) -> None:
+ """Mirror a router-tier ``computer_use`` TOOL outcome into the history.
+
+ The voice fast-path grounds its CU outcome inline (``_run_computer_use_
+ background`` → :meth:`_append_cu_outcome_to_history`). The router-tier
+ ``computer_use`` tool runs in its own module with NO ``_history`` access,
+ so it tags its completion announcement with
+ ``source_layer=CU_TOOL_OUTCOME_LAYER`` and we mirror it here — same
+ grounding, so a text-chat / router-picked desktop action is in the
+ model's next-turn context too (no subsystem confusion). Only the tagged
+ CU-tool completion is mirrored; a mission / worker / other announcement is
+ ignored, so an unrelated background readback never pollutes the grounding.
+ Never raises — a bus subscriber that throws would break the pipeline
+ (AP-18). The fast-path leaves ``source_layer`` empty, so its outcome is
+ NOT double-recorded here.
+ """
+ try:
+ if getattr(event, "source_layer", "") != CU_TOOL_OUTCOME_LAYER:
+ return
+ self._append_cu_outcome_to_history(
+ user_request="",
+ outcome_text=getattr(event, "text", "") or "",
+ diagnostic=getattr(event, "detail", None),
+ )
+ except Exception: # noqa: BLE001
+ log.debug("CU-tool completion history mirror failed", exc_info=True)
+
async def _record_response_side_effects(
self,
*,
@@ -7392,11 +7420,17 @@ class BrainManager:
provider whose key was just set. Prevents a provider that already
failed with "no API key" from being excluded from the fallback chain
until the app is restarted.
+ - ``AnnouncementRequested`` (CU-tool-tagged) → mirror the router-tier
+ ``computer_use`` outcome into the live history (subsystem-confusion fix).
Called separately rather than in ``__init__`` so BrainManager can be
constructed for tests without a bus subscription.
"""
- from jarvis.core.events import BrainToolsChanged, SecretConfigured
+ from jarvis.core.events import (
+ AnnouncementRequested,
+ BrainToolsChanged,
+ SecretConfigured,
+ )
target_bus = bus or self._bus
if target_bus is None:
@@ -7407,6 +7441,7 @@ class BrainManager:
self.refresh_tools()
target_bus.subscribe(BrainToolsChanged, _on_tools_changed)
+ target_bus.subscribe(AnnouncementRequested, self._on_cu_tool_completion)
async def _on_secret_configured(ev: SecretConfigured) -> None:
if ev.action != "set":
diff --git a/jarvis/harness/computer_use_planner.py b/jarvis/harness/computer_use_planner.py
index f02d085cbc..da379eacdd 100644
--- a/jarvis/harness/computer_use_planner.py
+++ b/jarvis/harness/computer_use_planner.py
@@ -6,7 +6,11 @@ from collections.abc import Iterator
from dataclasses import dataclass, field
from typing import Any
-from jarvis.brain.manager import _classify_provider_error, _is_rate_limit_exc
+from jarvis.brain.manager import (
+ _DEAD_LIST_KINDS,
+ _classify_provider_error,
+ _is_rate_limit_exc,
+)
log = logging.getLogger(__name__)
@@ -103,7 +107,14 @@ class ComputerUsePlannerSelector:
mark_rate_limited(provider, model)
return
- if kind in ("missing_key", "account_blocked"):
+ # Dead-list a terminal-credential failure so it stops leading the chain.
+ # Use the SAME shared set the manager uses (_DEAD_LIST_KINDS) instead of a
+ # hardcoded subset — the manager added "bad_key" (a bare HTTP 401, e.g.
+ # "Error code: 401 - invalid x-api-key") on 2026-06-30, and a local subset
+ # silently dropped it here, so a 401 CU provider was re-tried every step
+ # instead of being skipped (drift bug: _looks_invalid_auth_error became
+ # dead code for any 401 that carried the numeric code).
+ if kind in _DEAD_LIST_KINDS:
dead_providers = getattr(self.manager, "_dead_providers", None)
if isinstance(dead_providers, set):
dead_providers.add(provider)
diff --git a/jarvis/plugins/tool/computer_use_tool.py b/jarvis/plugins/tool/computer_use_tool.py
index d646f4eaf9..b46d68389a 100644
--- a/jarvis/plugins/tool/computer_use_tool.py
+++ b/jarvis/plugins/tool/computer_use_tool.py
@@ -33,6 +33,7 @@ from jarvis.core.protocols import ExecutionContext, ToolResult
from jarvis.harness.manager import HarnessManager
from jarvis.plugins.tool.dispatch_to_harness import DispatchToHarnessTool
from jarvis.voice.action_phrases import (
+ CU_TOOL_OUTCOME_LAYER,
OUTPUT_LANGUAGE_ENV_KEY,
action_phrase,
cu_failure_readback,
@@ -244,6 +245,12 @@ class ComputerUseTool:
# so a failure is debuggable.
kind="completion",
detail=detail,
+ # Tag this so the BrainManager mirrors the outcome into the live
+ # conversation history. This tool runs in its own module with no
+ # _history access; without the mirror, a router/text-chat desktop
+ # action would vanish from the model's next-turn context (the same
+ # subsystem-confusion bug the voice fast-path fixes inline).
+ source_layer=CU_TOOL_OUTCOME_LAYER,
))
except Exception: # noqa: BLE001
log.debug("computer_use completion announce failed", exc_info=True)
diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx
index aa782795dc..abe4fd701a 100644
--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx
@@ -21,6 +21,13 @@ vi.mock("@/hooks/useOverlayStyle", () => ({
}),
}));
+// usePluginAttention polls /api/marketplace/plugins; mock it so the sidebar's
+// plugin reconnect dot is driven by the test, not a fetch.
+const pluginAttentionMock = vi.hoisted(() => ({ needsReconnect: false }));
+vi.mock("@/hooks/usePluginAttention", () => ({
+ usePluginAttention: () => pluginAttentionMock.needsReconnect,
+}));
+
describe("Sidebar voice header", () => {
beforeEach(() => {
useEventStore.setState({
@@ -192,6 +199,36 @@ describe("Sidebar assistant name header", () => {
});
});
+describe("Sidebar plugin reconnect indicator", () => {
+ beforeEach(() => {
+ useEventStore.setState({ connected: true, voiceReady: true });
+ });
+
+ afterEach(() => {
+ cleanup();
+ pluginAttentionMock.needsReconnect = false;
+ });
+
+ test("shows an amber dot on Skills & Tools when a plugin needs reconnect", () => {
+ // A revoked / expired plugin must be visible app-wide, not only on the
+ // Plugins page — the sidebar carries an amber dot on the row that fronts
+ // Plugins ("Skills & Tools", id "skills").
+ pluginAttentionMock.needsReconnect = true;
+
+ render(<Sidebar />);
+
+ expect(screen.getByTestId("nav-warn-skills")).toBeTruthy();
+ });
+
+ test("no amber dot when every plugin is healthy", () => {
+ pluginAttentionMock.needsReconnect = false;
+
+ render(<Sidebar />);
+
+ expect(screen.queryByTestId("nav-warn-skills")).toBeNull();
+ });
+});
+
describe("Sidebar voice-boot indicator", () => {
beforeEach(() => {
useEventStore.setState({
diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
index 369ec498a1..6fab336ef5 100644
--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
@@ -24,6 +24,7 @@ import {
import { useEventStore, type SectionId } from "@/store/events";
import { useVoiceReadiness } from "@/hooks/useVoiceReadiness";
import { useSectionHealth } from "@/hooks/useProviders";
+import { usePluginAttention } from "@/hooks/usePluginAttention";
import { cn } from "@/lib/utils";
import { useMemo } from "react";
import { useT } from "@/i18n";
@@ -146,6 +147,10 @@ export function Sidebar() {
() => Object.values(sectionHealth).some((h) => h?.status === "error"),
[sectionHealth],
);
+ // A connected marketplace plugin whose token was revoked/expired (needs_reauth)
+ // — surfaced as an amber dot on the row that fronts Plugins ("Skills & Tools"),
+ // so a dead connection is visible app-wide, not only on the Plugins page.
+ const pluginsNeedReconnect = usePluginAttention();
const agentsCount = useEventStore((s) =>
s.events.filter((e) => e.name === "AgentStateChange").length > 0 ? undefined : 0,
);
@@ -243,6 +248,8 @@ export function Sidebar() {
badge={item.id === "agents" ? agentsCount : undefined}
alert={item.id === "apikeys" ? apikeysHasError : false}
alertTitle={t("sidebar.apikeys_alert")}
+ warn={item.id === "skills" ? pluginsNeedReconnect : false}
+ warnTitle={t("sidebar.plugins_reconnect_alert")}
onClick={() => setActive(item.id)}
/>
))}
@@ -289,6 +296,8 @@ function NavRow({
badge,
alert = false,
alertTitle,
+ warn = false,
+ warnTitle,
onClick,
}: {
item: NavItem;
@@ -300,6 +309,11 @@ function NavRow({
alert?: boolean;
/** Plain-language hover text for the alert dot. */
alertTitle?: string;
+ /** Draw an amber status dot — a softer "needs attention" than `alert` (e.g. a
+ * connected plugin whose token was revoked and needs a one-click reconnect). */
+ warn?: boolean;
+ /** Plain-language hover text for the warn dot. */
+ warnTitle?: string;
onClick: () => void;
}) {
const Icon = item.icon;
@@ -308,7 +322,7 @@ function NavRow({
<button
type="button"
onClick={onClick}
- title={alert ? alertTitle : undefined}
+ title={alert ? alertTitle : warn ? warnTitle : undefined}
className={cn(
"group relative flex w-full items-center gap-3 rounded-lg px-3 py-2 text-sm transition-all",
"hover:bg-background/60",
@@ -332,6 +346,14 @@ function NavRow({
className="h-2 w-2 shrink-0 rounded-full bg-destructive ring-2 ring-background"
/>
)}
+ {!alert && warn && (
+ <span
+ data-testid={`nav-warn-${item.id}`}
+ role="status"
+ aria-label={warnTitle}
+ className="h-2 w-2 shrink-0 rounded-full bg-amber-500 ring-2 ring-background"
+ />
+ )}
{badge !== undefined && badge > 0 && (
<span className="rounded-full bg-primary/20 px-1.5 py-0.5 text-[10px] font-semibold text-primary">
{badge}
diff --git a/jarvis/ui/web/frontend/src/hooks/usePluginAttention.ts b/jarvis/ui/web/frontend/src/hooks/usePluginAttention.ts
new file mode 100644
index 0000000000..f585a3530a
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/hooks/usePluginAttention.ts
@@ -0,0 +1,46 @@
+import { useEffect, useState } from "react";
+
+/**
+ * Polls the marketplace plugin list and reports whether ANY connected plugin
+ * needs attention — a revoked/expired token (`needs_reauth`) or an `error`.
+ *
+ * Standalone (no React-Query) so it works in the Sidebar, which renders without
+ * a QueryClientProvider. Fully fault-tolerant: with no backend / no `fetch`, it
+ * stays calm (returns false) rather than throwing — a sidebar dot must never
+ * crash the shell.
+ */
+export function usePluginAttention(): boolean {
+ const [needsReconnect, setNeedsReconnect] = useState(false);
+
+ useEffect(() => {
+ let alive = true;
+
+ const check = async () => {
+ try {
+ const res = await fetch("/api/marketplace/plugins", {
+ cache: "no-store",
+ });
+ if (!res.ok) return;
+ const data = (await res.json()) as {
+ plugins?: { status?: string }[];
+ };
+ if (!alive) return;
+ const flag = (data.plugins ?? []).some(
+ (p) => p.status === "needs_reauth" || p.status === "error",
+ );
+ setNeedsReconnect(flag);
+ } catch {
+ // Offline / no backend / no fetch — stay calm, surface nothing.
+ }
+ };
+
+ void check();
+ const id = setInterval(check, 60_000);
+ return () => {
+ alive = false;
+ clearInterval(id);
+ };
+ }, []);
+
+ return needsReconnect;
+}
diff --git a/jarvis/voice/action_phrases.py b/jarvis/voice/action_phrases.py
index 814299cf57..2097377031 100644
--- a/jarvis/voice/action_phrases.py
+++ b/jarvis/voice/action_phrases.py
@@ -30,6 +30,15 @@ _SUPPORTED = ("de", "en", "es")
#: sites cannot drift apart.
OUTPUT_LANGUAGE_ENV_KEY = "JARVIS_OUTPUT_LANGUAGE"
+#: ``AnnouncementRequested.source_layer`` marker the router-tier ``computer_use``
+#: TOOL stamps on its background-mission completion. The tool runs in its own
+#: module with no access to ``BrainManager._history``, so it tags the outcome and
+#: the manager mirrors it into the live conversation history (a desktop action
+#: picked by the router / in text-chat must be grounded for the next turn too —
+#: the same fix the voice fast-path gets inline). Shared here so the producer
+#: (computer_use tool) and the consumer (BrainManager subscriber) cannot drift.
+CU_TOOL_OUTCOME_LAYER = "brain.computer_use_tool"
+
# key -> {lang -> template}. Templates may carry named ``{fields}``.
_PHRASES: dict[str, dict[str, str]] = {
# Computer-use background offload — outcome readbacks (announcement bus).
@@ -555,6 +564,8 @@ def cu_success_readback(lang: str, *, stdout: str | None) -> str:
__all__ = [
"CU_CANCEL_EXIT_CODE",
+ "CU_TOOL_OUTCOME_LAYER",
+ "OUTPUT_LANGUAGE_ENV_KEY",
"action_phrase",
"cu_failure_readback",
"cu_success_readback",
diff --git a/tests/unit/brain/test_computer_use_offload.py b/tests/unit/brain/test_computer_use_offload.py
index b750772ebf..a6c7088c5c 100644
--- a/tests/unit/brain/test_computer_use_offload.py
+++ b/tests/unit/brain/test_computer_use_offload.py
@@ -324,3 +324,72 @@ async def test_cu_user_cancel_writes_nothing_to_history(monkeypatch) -> None:
assert mgr._history == [], (
f"a silent user cancel must not write to history; got {mgr._history!r}"
)
+
+
+# ---------------------------------------------------------------------------
+# The router-tier `computer_use` TOOL path (computer_use_tool.py) runs in its own
+# module with NO _history access. It tags its completion announcement with a CU
+# source_layer; the BrainManager mirrors that tagged outcome into the live
+# history so a text-chat / router-picked desktop action is grounded for the next
+# turn too — same fix as the voice fast-path, the other CU entry point.
+# ---------------------------------------------------------------------------
+
+
+async def test_manager_mirrors_cu_tool_completion_into_history() -> None:
+ from jarvis.core.events import AnnouncementRequested
+ from jarvis.voice.action_phrases import CU_TOOL_OUTCOME_LAYER
+
+ mgr = _make_manager(_SlowHarnessExecutor(), _FakeBus())
+ await mgr._on_cu_tool_completion(AnnouncementRequested(
+ text="That didn't work on screen.",
+ kind="completion",
+ source_layer=CU_TOOL_OUTCOME_LAYER,
+ detail="exit 2 · provider chain failed: no vision-capable provider reachable",
+ ))
+
+ assert mgr._history, "a tool-path CU outcome must be mirrored into history"
+ content = str(mgr._history[-1].content).lower()
+ assert "screen" in content
+ assert "provider chain" in content
+
+
+async def test_cu_tool_completion_grounds_history_end_to_end() -> None:
+ """Full chain: attach_to_bus wires the subscriber, and a tool-tagged
+ completion published on the REAL bus lands in the live history."""
+ from jarvis.core.bus import EventBus
+ from jarvis.core.events import AnnouncementRequested
+ from jarvis.voice.action_phrases import CU_TOOL_OUTCOME_LAYER
+
+ bus = EventBus()
+ mgr = _make_manager(_SlowHarnessExecutor(), bus)
+ mgr.attach_to_bus(bus)
+
+ await bus.publish(AnnouncementRequested(
+ text="That didn't work on screen.",
+ kind="completion",
+ source_layer=CU_TOOL_OUTCOME_LAYER,
+ detail="exit 3 · no vision-capable provider reachable",
+ ))
+ await asyncio.sleep(0.01) # allow async dispatch to run
+
+ assert mgr._history, "the tool-path outcome must reach history via the bus"
+ assert "screen" in str(mgr._history[-1].content).lower()
+
+
+async def test_manager_ignores_non_cu_tool_completion() -> None:
+ """A mission / worker / other completion must NOT be mirrored — only a
+ CU-tool-tagged one — so an unrelated background readback never pollutes the
+ desktop-action grounding."""
+ from jarvis.core.events import AnnouncementRequested
+
+ mgr = _make_manager(_SlowHarnessExecutor(), _FakeBus())
+ await mgr._on_cu_tool_completion(AnnouncementRequested(
+ text="Your sub-agent finished.",
+ kind="completion",
+ source_layer="missions.announcer",
+ ))
+
+ assert mgr._history == []
diff --git a/tests/unit/plugins/tool/test_computer_use_tool.py b/tests/unit/plugins/tool/test_computer_use_tool.py
index 6097996363..d483cd1172 100644
--- a/tests/unit/plugins/tool/test_computer_use_tool.py
+++ b/tests/unit/plugins/tool/test_computer_use_tool.py
@@ -440,6 +440,27 @@ async def test_tool_threads_output_language_into_harness_env() -> None:
assert fake.task_envs[0].get(_OUTPUT_LANGUAGE_ENV_KEY) == "de"
+async def test_completion_carries_cu_tool_source_layer_for_history_mirror() -> None:
+ """The tool has NO access to BrainManager._history, so it tags its completion
+ with CU_TOOL_OUTCOME_LAYER; the manager subscriber mirrors that outcome into
+ the live history (otherwise a router/text-chat desktop action vanishes from
+ the model's next-turn context — the subsystem-confusion bug)."""
+ from jarvis.plugins.tool.computer_use_tool import ComputerUseTool
+ from jarvis.voice.action_phrases import CU_TOOL_OUTCOME_LAYER
+
+ bus = _FakeBus()
+ tool = ComputerUseTool(bus=bus, manager=_FakeHarnessManager())
+ result = await tool.execute({"goal": "open chrome"}, _ctx_en())
+ assert result.success
+
+ completions = await _collect_completion(bus)
+ assert len(completions) == 1
+ assert completions[0].source_layer == CU_TOOL_OUTCOME_LAYER, (
+ f"completion must be tagged for the history mirror; got "
+ f"{completions[0].source_layer!r}"
+ )
+
+
async def test_success_readback_falls_back_to_done_without_proof() -> None:
from jarvis.plugins.tool.computer_use_tool import ComputerUseTool
from jarvis.voice.action_phrases import action_phrase