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(routing): stop the navigation gate stealing an addressed-pane turn
Ruben Lütkee1afdb4d3462
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 18d18503bd..5f37abddf2 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -5817,6 +5817,27 @@ class BrainManager:"in the utterance wins (mission, not a sidebar switch).")return None+ # An addressed terminal outranks a sidebar switch, for the same reason+ # the desktop gate stands down for one a few lines below in ``generate``:+ # whichever gate holds the MORE SPECIFIC evidence wins. Naming a running+ # pane and telling it to do something is unambiguous; a section word that+ # happens to appear in the same breath is not.+ #+ # Live bug 2026-07-29 17:04 (BUG-121): "Kannst du mal bitte Terminal T7+ # prompten, … wieso das Resuming Feature nur bei claude Code Sessions+ # funktioniert … oder bei Open Codes oder bei anderen Sessions" opened+ # the Sessions section and returned. T7 was never briefed, and the live+ # model narrated the briefing anyway. ``match_navigation_intent`` now+ # binds its ingredients so that sentence no longer matches at all; this+ # is the second layer, because a matcher fix alone leaves the class open+ # for the next section word that lands next to a genuine cue.+ # <!-- i18n-allow: quoted spoken transcript of the failing utterance -->+ if self._agentic_ide_owns_turn(user_text):+ log.info(+ "navigation fast-path stands down — this turn addresses a "+ "running Agentic-IDE terminal (more specific evidence)."+ )+ return Nonetool = self._tools.get("navigate")if tool is None or self._tool_executor is None:return Nonediff --git a/jarvis/brain/navigation_intent.py b/jarvis/brain/navigation_intent.pyindex e4b3147b23..773d8e680f 100644--- a/jarvis/brain/navigation_intent.py+++ b/jarvis/brain/navigation_intent.py@@ -8,9 +8,24 @@ unreliable and wrong (the capability gate would refuse "zeig die Socials"because 'social' is an external-integration marker).Conservative by design: a navigation cue AND a known section are both required,-so unrelated utterances never hijack the UI. Pure regex, no LLM, no IO-(AP-9/AP-11). The section vocabulary is shared with the ``navigate`` tool-(``SECTION_PHRASES``), so the two never drift.+AND they must belong to the same clause — see ``_binds`` below. Pure regex, no+LLM, no IO (AP-9/AP-11). The section vocabulary is shared with the ``navigate``+tool (``SECTION_PHRASES``), so the two never drift.++Why the binding rule exists (live failure 2026-07-29 17:04, BUG-121). "Kannst+du mal bitte Terminal T7 prompten, … wieso das Resuming Feature … nur bei claude+Code Sessions funktioniert und nicht bei Codec Sessions oder bei Open Codes oder+bei anderen Sessions …" navigated the sidebar to *Sessions*: the cue ``open``+came from the CLI product name "Open Code" at offset 269, the section word+``sessions`` from a bug description at offset 300, and the two had nothing to do+with each other. Because this gate runs ahead of the Agentic-IDE fast path, the+turn returned "Opening Sessions." and the pane the user actually addressed was+never briefed — while the live model narrated a briefing that never happened.+<!-- i18n-allow: quoted spoken transcript of the failing utterance -->++This is the same defect class as BUG-120's reply-language gate: ingredients+matched independently across a long utterance with no proximity requirement.+The defense is the same too — bind every ingredient to the cue."""from __future__ import annotations@@ -39,14 +54,67 @@ _PHRASES: tuple[tuple[str, str], ...] = tuple(sorted(SECTION_PHRASES.items(), key=lambda kv: -len(kv[0])))+# A real navigation command puts the target right behind the verb: "zeige mir+# die Socials", "geh zu den Aufgaben", "show me the agents". What sits between+# them is an article and at most a filler word, never a clause. Measured against+# every phrasing this gate is meant to serve, three words is generous.+_MAX_GAP_WORDS = 3++# Words that end a clause. Their presence between the cue and the section word+# proves the two belong to different statements, whatever the distance —+# "open codes ODER bei anderen sessions" is a comparison, not an order.+# Matching *input vocabulary* across the supported locales, not prose.+_BREAK_WORDS = frozenset(+ {+ "und", "oder", "aber", "sondern", "weil", # i18n-allow: input vocab+ "dass", "ob", "wenn", "nicht", "kein", # i18n-allow: input vocab+ "keine", "keinen", "warum", "wieso", # i18n-allow: input vocab+ "funktioniert", # i18n-allow: input vocab+ "and", "or", "but", "because", "that", "if", "whether", "not", "why",+ "y", "o", "pero", "porque", "que", "si", "no", # i18n-allow: input vocab+ }+)++# Sentence enders. A cue in one sentence can never target a word in the next.+_SENTENCE_BREAK = re.compile(r"[.!?;]")+++def _binds(gap: str) -> bool:+ """True when the text between a cue and a section word keeps them one command.++ The gap is what the user said between the navigation verb and the section+ name. A command's gap is an article or two; anything longer, anything that+ crosses a sentence, and anything containing a clause-opening word means the+ two matches are unrelated and this gate must not claim the turn.+ """+ if _SENTENCE_BREAK.search(gap):+ return False+ words = gap.split()+ if len(words) > _MAX_GAP_WORDS:+ return False+ return not any(word.strip(",") in _BREAK_WORDS for word in words)+def match_navigation_intent(text: str) -> str | None:- """Return the canonical section id for a clear navigation command, else None."""+ """Return the canonical section id for a clear navigation command, else None.++ Both a navigation cue and a known section must appear, the section must come+ AFTER the cue (navigation is always verb-then-target), and the two must be+ bound to each other by ``_binds``. A section word that merely occurs+ somewhere in a long utterance never moves the UI.+ """t = " ".join((text or "").strip().lower().split())- if not t or not _NAV_CUE.search(t):+ if not t:+ return None+ cues = [match.end() for match in _NAV_CUE.finditer(t)]+ if not cues:return Nonefor phrase, section_id in _PHRASES:# Word boundaries so 'board' does not match inside 'keyboard'.- if re.search(r"\b" + re.escape(phrase) + r"\b", t):- return section_id+ for hit in re.finditer(r"\b" + re.escape(phrase) + r"\b", t):+ if any(+ cue_end <= hit.start() and _binds(t[cue_end : hit.start()])+ for cue_end in cues+ ):+ return section_idreturn Nonediff --git a/tests/unit/brain/test_navigation_gate_vs_agentic_ide_routing.py b/tests/unit/brain/test_navigation_gate_vs_agentic_ide_routing.pynew file mode 100644index 0000000000..0d9ed05e6c--- /dev/null+++ b/tests/unit/brain/test_navigation_gate_vs_agentic_ide_routing.py@@ -0,0 +1,254 @@+"""Navigation-gate-vs-Agentic-IDE routing (a section word inside a pane order).++Live bug (voice session 2026-07-29 17:04, coding mode ON, BUG-121): the user+asked terminal T7 to investigate why the workspace resume feature only works for+Claude Code sessions. Jarvis opened the *Sessions* sidebar section and answered+the turn. T7 was never briefed — and the live model, which is never told any of+this, narrated a briefing that had not happened. The user had to repeat himself+twice; the third attempt only worked because the live model happened to call the+action tool by itself.++Root cause (measured off the flight recorder, not guessed): ``BrainManager+.generate`` runs ``_run_navigation_fast_path`` at line ~9243 and+``_run_agentic_ide_fast_path`` at ~9279, and ``match_navigation_intent``+searched the whole utterance for a cue and a section word independently. In this+dictated paragraph the cue was ``open`` — from the CLI product name "Open Code"+— and the section word was ``sessions`` from a bug description 30 characters+later, in a different clause behind an "oder". The navigation gate returned+"Opening Sessions." and the delivery path 36 lines below never ran.++This is the same shape as BUG-120 (``test_config_gate_vs_agentic_ide_routing``),+with a different thief. Two independent fixes, one test file:++1. ``match_navigation_intent`` binds the section word to the cue — same clause,+ after the cue, at most a command's worth of filler between them.+2. A turn that NAMES A RUNNING PANE outranks the navigation gate, the same+ precedence the desktop gate and the config gates already honour.++Deterministic throughout: real gate, real detector, faked prompt composer.+"""+from __future__ import annotations++from pathlib import Path+from typing import Any+from uuid import UUID++import pytest++from jarvis.agentic_ide import prompt_composer+from jarvis.agentic_ide import session as session_mod+from jarvis.agentic_ide.prompt_composer import ComposedPrompt+from jarvis.agentic_ide.session import Registry+from jarvis.brain import navigation_intent+from jarvis.brain.manager import BrainManager+from jarvis.brain.navigation_intent import match_navigation_intent+from jarvis.core.bus import EventBus+from jarvis.core.config import JarvisConfig+from tests.fakes.fake_pty_manager import FakePtyManager++# The live transcript, verbatim off the flight recorder. ``{a}`` stands where+# the user named the pane. Every word that made the navigation gate fire is kept+# at its original distance from the others.+LIVE_FAILURE = (+ "Kannst du mal bitte Terminal {a} prompten, dass es einen " # i18n-allow: transcript+ "Deep Dive machen, sondern analysieren soll, wieso das " # i18n-allow: transcript+ "Resuming Feature von ähm unseren Agentic ID, was wir " # i18n-allow: transcript+ "eingebaut haben, nur bei ähm claude Code Sessions " # i18n-allow: transcript+ "funktioniert und nicht z.B. bei Codec Sessions oder bei " # i18n-allow: transcript+ "Open Codes oder bei anderen Sessions. Also, ich möchte, " # i18n-allow: transcript+ "dass das Resuming Feature bei allen ähm Coding Terminals, " # i18n-allow: transcript+ "welche wir verbunden haben, funktioniert." # i18n-allow: transcript+)+++class _SpyExecutor:+ """Records navigate executions so a stand-down can be proven, not inferred."""++ def __init__(self) -> None:+ self.calls: list[dict[str, Any]] = []++ async def execute(+ self,+ tool: object,+ args: dict[str, Any],+ *,+ user_utterance: str = "",+ trace_id: UUID | None = None,+ ) -> dict[str, Any]:+ self.calls.append(dict(args))+ return {"success": True}++[email protected](autouse=True)+def _isolated_recents(+ tmp_path_factory: pytest.TempPathFactory, monkeypatch: pytest.MonkeyPatch+) -> None:+ """Never rewrite the developer's real recent-workspace list from a test."""+ from jarvis.agentic_ide import recents++ store = tmp_path_factory.mktemp("recents") / "recents.json"+ monkeypatch.setattr(recents, "_store_path", lambda: store)++[email protected](autouse=True)+def _fake_composer(monkeypatch: pytest.MonkeyPatch) -> None:+ """A deterministic stand-in for the quality-tier prompt writer."""++ async def fake_compose(utterance: str, **kwargs: object) -> ComposedPrompt:+ name = kwargs["terminal_name"]+ instruction = kwargs.get("instruction") or utterance+ return ComposedPrompt(+ text=f"## Task for {name}\n{instruction}",+ files=["jarvis/core/bus.py"],+ composed_by="llm",+ )++ monkeypatch.setattr(prompt_composer, "compose", fake_compose)+++def registry(monkeypatch: pytest.MonkeyPatch) -> Registry:+ monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))+ reg = Registry(pty_manager=FakePtyManager())+ monkeypatch.setattr(session_mod, "get_registry", lambda: reg)+ return reg+++def spy() -> _SpyExecutor:+ return _SpyExecutor()+++def manager(spy: _SpyExecutor) -> BrainManager:+ cfg = JarvisConfig()+ cfg.brain.primary = "fake"+ # A real navigate tool is not needed — the fast path only forwards it to the+ # executor — but SOMETHING must be registered, or the gate returns None for+ # a reason that has nothing to do with the precedence under test.+ mgr = BrainManager(config=cfg, bus=EventBus(), tools={"navigate": object()})+ mgr._tool_executor = spy # type: ignore[assignment]+ # Pinned so wording assertions do not depend on the host's locale+ # (AP-23: never test against the maintainer's own configuration).+ mgr._reply_language = "en"+ return mgr+++async def _noop(_text: str) -> None:+ return None+++async def _noop_exit(_code: int) -> None:+ return None+++async def _open(registry: Registry, folder: Path, count: int) -> None:+ """Open ``count`` panes AND bring their agents live."""+ await registry.start(str(folder), [{"agent": "claude"} for _ in range(count)])+ assert registry.session is not None+ for term in list(registry.session.terminals):+ await registry.attach(term.name, 100, 30, _noop, _noop_exit)+++def _names(registry: Registry) -> list[str]:+ assert registry.session is not None+ return [t.name for t in registry.session.terminals]+++def _prompted(registry: Registry) -> list[str]:+ """Every pane that actually received a prompt."""+ assert registry.session is not None+ return [t.name for t in registry.session.terminals if t.prompts_sent > 0]+++def _spoken(registry: Registry) -> str:+ """The live utterance with the addressed pane filled in."""+ return LIVE_FAILURE.format(a=_names(registry)[6])+++# --------------------------------------------------------------------------- #+# Fix 1 — the gate may not assemble a command out of unrelated clauses #+# --------------------------------------------------------------------------- #+++def test_the_navigation_gate_no_longer_claims_this_turn() -> None:+ """The ingredients are all present; only their binding disqualifies them."""+ spoken = LIVE_FAILURE.format(a="T7")+ assert "Open" in spoken+ assert "Sessions" in spoken++ assert match_navigation_intent(spoken) is None+++def test_a_real_navigation_command_is_untouched() -> None:+ """The recall side: the gate still exists to catch these."""+ spoken = "zeig mir die Sessions" # i18n-allow: speech input under test+ assert match_navigation_intent(spoken) == "sessions"+++# --------------------------------------------------------------------------- #+# Fix 2 — a named pane outranks the navigation gate #+# --------------------------------------------------------------------------- #+++async def test_the_workspace_owns_this_turn(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ """The guard the navigation fast path consults, against a REAL workspace."""+ await _open(registry, tmp_path, 7)++ assert manager._agentic_ide_owns_turn(_spoken(registry)) is True+++async def test_a_forced_section_match_still_cannot_take_a_pane_turn(+ manager: BrainManager,+ registry: Registry,+ spy: _SpyExecutor,+ tmp_path: Path,+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """The precedence itself, proven independently of the matcher's own fix.++ The matcher is forced to claim a section, so this fails unless the fast path+ really does consult the workspace before it navigates. Belt and braces on+ purpose: fix 1 stops this particular sentence, fix 2 stops the whole class —+ some future section word will land next to a genuine cue in a pane order.+ """+ await _open(registry, tmp_path, 7)+ monkeypatch.setattr(+ navigation_intent, "match_navigation_intent", lambda _text: "sessions"+ )++ reply = await manager._run_navigation_fast_path(_spoken(registry))++ assert reply is None+ assert spy.calls == []+++async def test_navigation_still_runs_while_a_workspace_is_open(+ manager: BrainManager, registry: Registry, spy: _SpyExecutor, tmp_path: Path+) -> None:+ """The stand-down is about ADDRESSED panes, not about coding mode.++ An open workspace must not deafen the sidebar: "show me the sessions" names+ no pane and asks for no work, so it navigates exactly as before.+ """+ await _open(registry, tmp_path, 7)++ reply = await manager._run_navigation_fast_path("show me the sessions")++ assert reply is not None+ assert spy.calls == [{"section": "sessions"}]+++async def test_the_addressed_pane_is_briefed_end_to_end(+ manager: BrainManager, registry: Registry, tmp_path: Path+) -> None:+ """What the user actually asked for: the named agent gets the work."""+ await _open(registry, tmp_path, 7)+ names = _names(registry)++ reply = await manager._run_agentic_ide_fast_path(_spoken(registry))++ assert reply is not None+ assert _prompted(registry) == [names[6]]diff --git a/tests/unit/brain/test_navigation_intent.py b/tests/unit/brain/test_navigation_intent.pyindex 36c64c0dcc..ea76c940fd 100644--- a/tests/unit/brain/test_navigation_intent.py+++ b/tests/unit/brain/test_navigation_intent.py@@ -52,3 +52,58 @@ def test_negative_navigation(text: str) -> None:def test_keyboard_does_not_match_board() -> None:"""Word boundaries: 'keyboard' must not match the 'board' section."""assert match_navigation_intent("öffne das keyboard") is None+++# The utterance from the live failure (voice session 2026-07-29 17:04, BUG-121),+# verbatim off the flight recorder. The cue "open" is the CLI product name "Open+# Code"; the section word "sessions" is part of a bug description 30 characters+# later. Under the pre-fix matcher this returned "sessions", the navigation fast+# path claimed the turn, and terminal T7 — which the sentence explicitly+# addresses — was never briefed.+_BUG_121_UTTERANCE = (+ "Kannst du mal bitte Terminal T7 prompten, dass es einen Deep Dive machen, "+ "sondern analysieren soll, wieso das Resuming Feature von ähm unseren "+ "Agentic ID, was wir eingebaut haben, nur bei ähm claude Code Sessions "+ "funktioniert und nicht z.B. bei Codec Sessions oder bei Open Codes oder "+ "bei anderen Sessions. Also, ich möchte, dass das Resuming Feature bei "+ "allen ähm Coding Terminals, welche wir verbunden haben, funktioniert."+)+++def test_bug_121_live_utterance_does_not_navigate() -> None:+ """A cue and a section word from unrelated clauses must not navigate."""+ assert match_navigation_intent(_BUG_121_UTTERANCE) is None+++ "text",+ [+ # Cue and section in different clauses, joined by a conjunction.+ "bei Open Codes oder bei anderen Sessions",+ "open the file and then the sessions broke",+ # Cue and section separated by more than a command's worth of words.+ "open a terminal, wait for the banner, then look at the sessions",+ # Section word BEFORE the cue is never a target.+ "die Sessions sind kaputt, kannst du das aufmachen",+ # Cue and section in different sentences.+ "mach das Terminal auf. Die Sessions laufen nicht.",+ # A bug report that mentions both, which is the shape that broke live.+ "warum funktioniert open code nicht mit den sessions",+ ],+)+def test_unbound_cue_and_section_do_not_navigate(text: str) -> None:+ assert match_navigation_intent(text) is None+++ "text,expected",+ [+ # An article and a filler between verb and target still binds.+ ("zeig mir doch bitte die Einstellungen", "settings"),+ ("geh zu den offenen Aufgaben", "tasks"),+ ("open the settings", "settings"),+ ],+)+def test_binding_tolerates_ordinary_filler(text: str, expected: str) -> None:+ """The proximity rule must not break how people actually phrase commands."""+ assert match_navigation_intent(text) == expected