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.

feat(agentic-ide): let the Command Deck hand out work nobody named

rubenluetke10-beepd666c8a03be5
diff --git a/jarvis/agentic_ide/fleet_actions.py b/jarvis/agentic_ide/fleet_actions.py
index 72e62b9004..43f7fbad9c 100644
--- a/jarvis/agentic_ide/fleet_actions.py
+++ b/jarvis/agentic_ide/fleet_actions.py
@@ -134,10 +134,53 @@ def terminals_closed_event(
)
+def free_agents(session: Any, *, now: float | None = None) -> list[Any]:
+ """Panes that could take a job right now, in the order they should get one.
+
+ "Somebody get the wake-path tests green" has to land somewhere, and the
+ Command Deck is where the user stops naming a pane for every order. This is
+ what turns that into a specific terminal.
+
+ Four things disqualify a pane, and each one is a promise that would
+ otherwise be broken:
+
+ * **It is not an agent.** A plain shell would run the sentence as a command.
+ * **It is working.** Typing a second job into a busy agent does not queue
+ it — the CLI takes it as an interruption of the first.
+ * **The user took it over** (``deck_hold``). That is the whole point of the
+ hold: Jarvis stops using this one.
+ * **It is not alive.** A pane whose agent exited cannot be briefed, and
+ telling the user it was is the lie this surface cannot afford.
+
+ Ordered oldest-idle first so a fleet is used evenly rather than the same
+ pane taking every order while the rest sit there — with the pane's own
+ position as the tiebreak, so an answer is stable when nothing has run yet.
+ """
+ from .activity import observed
+ from .session import accepts_prompts
+
+ moment = time.time() if now is None else now
+ free: list[tuple[float, int, Any]] = []
+ for term in getattr(session, "terminals", []):
+ if not accepts_prompts(str(getattr(term, "agent", "") or "")):
+ continue
+ if bool(getattr(term, "deck_hold", False)):
+ continue
+ if str(getattr(term, "status", "")) != "live":
+ continue
+ reading = observed(term, now=moment)
+ if reading.activity != "waiting":
+ continue
+ free.append((float(reading.since or 0.0), int(getattr(term, "index", 0)), term))
+ free.sort(key=lambda item: (item[0], item[1]))
+ return [term for _since, _index, term in free]
+
+
__all__ = [
"READY_POLL_S",
"READY_TIMEOUT_S",
"close_agent_terminals",
+ "free_agents",
"ready_for_prompt",
"terminals_closed_event",
"wait_for_prompt_ready",
diff --git a/jarvis/agentic_ide/intent.py b/jarvis/agentic_ide/intent.py
index e121c943b0..af04fbdd07 100644
--- a/jarvis/agentic_ide/intent.py
+++ b/jarvis/agentic_ide/intent.py
@@ -2628,6 +2628,85 @@ def owns_turn(user_text: str, *, names: list[str] | None = None) -> bool:
return names is None and detect_visible(text) is not None
+# --------------------------------------------------------------------------- #
+# Work with nobody's name on it #
+# --------------------------------------------------------------------------- #
+# Everything above answers "which pane is this turn about". The Command Deck
+# asks a different question: the user there is a team lead who has stopped
+# naming a pane per order, and "somebody get the wake-path tests green" has to
+# land on an agent rather than on the floor.
+#
+# This is deliberately NOT wired into ``detect``: outside the deck an
+# unaddressed sentence must keep meaning what it has always meant, or every
+# open workspace would start swallowing ordinary conversation. The deck's fast
+# path asks for it by name, and only after ``detect_all`` has come back empty.
+#
+# The bar is set high on purpose, because the failure is expensive in one
+# direction only. A false negative costs one clearer sentence. A false positive
+# types "what time is it" into a coding agent as a task, and the user finds out
+# minutes later.
+
+#: Turns that ASK rather than instruct. A question about the workspace is
+#: answered by the normal path with the focus-context block; handing it to an
+#: agent as a job is the single worst thing this detector could do.
+_ASKS_RE = re.compile(
+ r"^\s*(?:"
+ r"what|which|who|when|where|why|how|is|are|do|does|did|can|could|would|"
+ r"should|will|has|have|"
+ r"was|welche\w*|wer|wann|wo|warum|wieso|wie|" # i18n-allow: input vocab
+ r"ist|sind|kann|k[oö]nn\w*|" # i18n-allow: input vocab
+ r"h[aä]st|hat|haben|soll\w*|w[uü]rde\w*|" # i18n-allow: input vocab
+ r"qu[eé]|cu[aá]l\w*|qui[eé]n|cu[aá]ndo|d[oó]nde|" # i18n-allow: input vocab
+ r"por\s+qu[eé]|c[oó]mo|es|son|puede\w*|deber[ií]a\w*" # i18n-allow: input vocab
+ r")\b",
+ re.IGNORECASE,
+)
+
+
+def unaddressed_work(user_text: str, *, names: list[str] | None = None) -> str | None:
+ """The job in a turn that names no pane, or ``None`` if it is not one.
+
+ Answers only for the Command Deck (see the note above). The caller is
+ expected to have established three things already, because each is somebody
+ else's rule and a second copy here would drift from it:
+
+ 1. no pane is addressed (``detect_all`` came back empty);
+ 2. the turn does not name a spawn vehicle
+ (``spawn_vehicle_outranks_workspace``);
+ 3. the workspace is actually being read as a deck.
+
+ What is left to decide is whether this sentence is WORK. Four ways it is
+ not, in the order they are cheapest to rule out.
+ """
+ text = (user_text or "").strip()
+ if not text:
+ return None
+ # A question is answered, never delegated. Checked before anything else
+ # because "how do I fix the wake path" contains a perfectly good
+ # instruction verb and is not an instruction at all.
+ if _ASKS_RE.match(text) or text.rstrip().endswith("?"):
+ return None
+ # Talk about the world rather than the workspace — the same guard the
+ # collective address uses, so the two cannot disagree about what "everyone"
+ # means in a sentence about people.
+ if _is_outside_world_talk(text):
+ return None
+ # Asking what the agents are DOING is a status question even without a
+ # question mark ("status on the tests"), and the deck answers those from
+ # the panes rather than by starting more work.
+ if _VISIBLE_REPORT_RE.match(text):
+ return None
+ if not _looks_like_instruction(text):
+ return None
+ # A pane WAS named, just not in an addressing shape ("Mika die Tests"). The
+ # caller's detector stood down for a reason, and quietly re-routing the
+ # order to whichever agent happens to be free would send it to the wrong
+ # one — with the right one's name still in the sentence.
+ if names and _mentions(text, list(names)):
+ return None
+ return text
+
+
__all__ = [
"KIND_PROMPT",
"KIND_REPORT",
@@ -2647,5 +2726,6 @@ __all__ = [
"spawn_includes_task",
"spawn_instruction",
"spawn_vehicle_outranks_workspace",
+ "unaddressed_work",
"wants_split",
]
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.py
index 21622a7dd2..1076235826 100644
--- a/jarvis/agentic_ide/session.py
+++ b/jarvis/agentic_ide/session.py
@@ -1106,6 +1106,21 @@ class Terminal:
# every cold start behind the slowest one.
attach_lock: asyncio.Lock = field(default_factory=asyncio.Lock, repr=False, compare=False)
+ # "I'll take this one" — the Command Deck's per-pane hold.
+ #
+ # The deck's whole promise is that Jarvis runs the floor, and the honest
+ # limit on that promise is a pane the user has decided to drive themselves:
+ # a permission prompt to answer, a password, a question only they can settle.
+ # While this is on, the deck neither assigns work to the pane nor reports it
+ # — both would be talking over somebody who is already there.
+ #
+ # Ephemeral and per pane rather than a workspace mode: the interesting case
+ # is one agent out of eight, and the other seven should carry on. It is not
+ # persisted for the same reason `surface_view` is not — a restart lands the
+ # user back in the ordinary state rather than in a hold they set an hour ago
+ # and have long forgotten.
+ deck_hold: bool = False
+
def to_dict(self) -> dict[str, Any]:
# Read the replayed screen ONCE. `lines()` walks the whole scrollback,
# and both the line count below and the recap want it — asking twice per
@@ -1131,6 +1146,9 @@ class Terminal:
# the voice path both have to know, or they would offer a target
# that refuses every instruction sent to it.
"accepts_prompts": accepts_prompts(self.agent),
+ # Has the user taken this pane over in the Command Deck? Reported
+ # so the card can show it and the deck can leave the pane alone.
+ "deck_hold": self.deck_hold,
"index": self.index,
"column": self.column,
"slot": self.slot,
@@ -2362,6 +2380,30 @@ class Registry:
logger.info("Agentic IDE focus mode {}", "on" if enabled else "off")
return session.focus_mode
+ def set_deck_hold(self, name: str, held: bool, *, workspace_id: str | None = None) -> bool:
+ """"I'll take this one" — stop the Command Deck using this pane.
+
+ While held, the deck neither assigns work to the pane nor reports it,
+ and the pane's own editor is unlocked in the UI. Everything else about
+ the pane is unchanged: it keeps running, keeps its recap, keeps its
+ place, and the bell still counts it like every other pane.
+
+ Raises for a pane that is not there rather than answering False — the
+ two outcomes are "it is now held" and "it is now not", and a silent
+ no-op for a mistyped call-sign looks exactly like the first.
+ """
+ located = self._locate(name, workspace_id)
+ if located is None:
+ raise SessionError(f"No terminal called '{name}'.")
+ _session, term = located
+ term.deck_hold = bool(held)
+ logger.info(
+ "Agentic IDE: {} {} by the user in the Command Deck",
+ term.name,
+ "taken over" if term.deck_hold else "handed back",
+ )
+ return term.deck_hold
+
def set_surface_context(
self,
*,
diff --git a/jarvis/agentic_ide/standup.py b/jarvis/agentic_ide/standup.py
index 08543948c5..f7254a8ba0 100644
--- a/jarvis/agentic_ide/standup.py
+++ b/jarvis/agentic_ide/standup.py
@@ -657,6 +657,24 @@ def deck_workspaces(registry: Any) -> set[str]:
return found
+def held_panes(registry: Any) -> set[tuple[str, str]]:
+ """Panes the user has taken over — the deck reports none of them.
+
+ The other half of ``deck_hold`` (see ``session.Terminal``). Somebody who is
+ sitting in front of a pane answering its question does not need to be told
+ it stopped: they are watching it stop.
+ """
+ held: set[tuple[str, str]] = set()
+ try:
+ for session in registry.sessions:
+ for term in getattr(session, "terminals", []):
+ if bool(getattr(term, "deck_hold", False)):
+ held.add((str(session.id), str(getattr(term, "key", "") or "")))
+ except Exception: # noqa: BLE001 - a registry read must not end the sweep
+ return set()
+ return held
+
+
async def pump(registry: Any, entries: Sequence[Notification]) -> str:
"""The sweep's one call into this module: take the news, say what is due.
@@ -676,9 +694,21 @@ async def pump(registry: Any, entries: Sequence[Notification]) -> str:
# Nothing is being read as a deck. The queue keeps whatever it
# holds — the user may come back to it — but takes nothing new.
return ""
- fresh = [entry for entry in entries if entry.workspace_id in decks]
+ held = held_panes(registry)
+ fresh = [
+ entry
+ for entry in entries
+ if entry.workspace_id in decks
+ and (entry.workspace_id, entry.pane_key) not in held
+ ]
if fresh:
_QUEUE.offer(fresh)
+ # A pane taken over AFTER its report was filed drops out too. The user
+ # is in front of it now, which is the same reason reading one silences
+ # it (rule 6) — and without this the deck would announce a pane the
+ # user is currently typing into.
+ for workspace_id, pane_key in held:
+ _QUEUE.drop_pane(workspace_id, pane_key)
return await announce_due()
except Exception as exc: # noqa: BLE001 - a mute deck beats a dead sweep
logger.warning("Agentic IDE: standup pump failed: %s", exc)
@@ -780,6 +810,7 @@ __all__ = [
"canned_line",
"deck_workspaces",
"enabled",
+ "held_panes",
"pump",
"queue",
"reset",
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index c4c33fb964..7f9a6012b0 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -6133,6 +6133,25 @@ class BrainManager:
)
if retry is not None:
return retry
+ # In the Command Deck the user is a team lead, and a team lead does
+ # not address people by name for every order. "Somebody get the
+ # wake-path tests green" is a real instruction; asking WHICH agent
+ # would be the deck handing its own job back.
+ #
+ # Only in the deck: everywhere else an unaddressed sentence keeps
+ # meaning what it always did, or an open workspace would start
+ # swallowing ordinary conversation.
+ delegated = await self._delegate_in_command_deck(
+ user_text,
+ session=session,
+ candidates=candidates,
+ language=out_lang,
+ consume_pending_voice_attachments=(
+ consume_pending_voice_attachments
+ ),
+ )
+ if delegated is not None:
+ return delegated
return self._ask_which_agentic_ide_terminal(
user_text, candidates=candidates, language=out_lang
)
@@ -6312,6 +6331,114 @@ class BrainManager:
)
return _fanout_reply_line(result, language)
+ async def _delegate_in_command_deck(
+ self,
+ user_text: str,
+ *,
+ session: Any,
+ candidates: list[str],
+ language: str,
+ consume_pending_voice_attachments: bool = False,
+ ) -> str | None:
+ """Hand work that names no pane to whoever is free. Deck only.
+
+ Everywhere else, an instruction with no call-sign in it is a question
+ for Jarvis. In the Command Deck the user is running a team and has
+ stopped naming people for every order, so "somebody get the wake-path
+ tests green" has to reach an agent — asking which one would be the deck
+ handing its own job back to the person who opened it.
+
+ Three answers, and the middle one is the reason this is not a loop over
+ ``deliver``:
+
+ * one free agent, or an order that does not decompose → one brief;
+ * several free agents AND an explicit request to split → ``work_split``
+ plans distinct assignments and the fan-out delivers them together,
+ because the same sentence sent five times is five agents racing on
+ one file rather than a team;
+ * nobody free → SAY so. A silently held order is how a user ends up
+ waiting an hour on work that was never started.
+
+ Returns ``None`` for anything that is not deck delegation, so the
+ caller's clarifying question still runs.
+ """
+ try:
+ from jarvis.agentic_ide import fleet_actions as ide_fleet
+ from jarvis.agentic_ide import intent as ide_intent
+ from jarvis.agentic_ide.workspace_view import VIEW_DECK
+
+ if getattr(session, "surface_view", "") != VIEW_DECK:
+ return None
+ work = ide_intent.unaddressed_work(user_text, names=candidates)
+ if work is None:
+ return None
+ free = ide_fleet.free_agents(session)
+ except Exception: # noqa: BLE001 - never crash a turn over an optional surface
+ log.warning("Command Deck delegation check failed", exc_info=True)
+ return None
+
+ if not free:
+ # Two different situations, two different answers: a workspace whose
+ # agents are all busy, and one that has no agent at all. Offering to
+ # "open one" is right in both, but telling somebody their agents are
+ # busy when they have none is the kind of small lie that makes a
+ # surface untrustworthy.
+ try:
+ from jarvis.agentic_ide.session import accepts_prompts
+
+ has_agents = any(
+ accepts_prompts(str(getattr(term, "agent", "") or ""))
+ for term in getattr(session, "terminals", [])
+ )
+ except Exception: # noqa: BLE001 - the phrasing is not worth a crash
+ has_agents = True
+ key = "ide_deck_nobody_free" if has_agents else "ide_deck_no_agents"
+ log.info("Command Deck: nothing free for an unaddressed order")
+ return action_phrase(key, language)
+
+ # An explicit split across a free fleet, or one agent takes it. The
+ # default is deliberately ONE: "fix the wake path" is a job, not a
+ # committee, and spending five subscriptions on it because five panes
+ # happened to be idle is the fan-out mistake in reverse.
+ names = [term.name for term in free]
+ assignments: dict[str, str] | None = None
+ if len(names) > 1 and ide_intent.wants_split(user_text):
+ try:
+ from jarvis.agentic_ide import work_split as ide_split
+
+ plan = await ide_split.split(
+ work,
+ session=session,
+ count=len(names),
+ conversation=self._agentic_ide_conversation(user_text),
+ )
+ assignments = {
+ name: item.task
+ for name, item in zip(names, plan.assignments, strict=False)
+ }
+ log.info(
+ "Command Deck: split %s across %d free panes (%s)",
+ plan.split_by,
+ len(assignments),
+ ", ".join(a.area for a in plan.assignments),
+ )
+ except Exception: # noqa: BLE001 - an unplanned fleet still works
+ log.warning("Command Deck work split failed", exc_info=True)
+ names = names[:1]
+ else:
+ names = names[:1]
+
+ log.info("Command Deck: delegating an unaddressed order to %s", ", ".join(names))
+ return await self._deliver_agentic_ide_prompt(
+ session=session,
+ names=names,
+ utterance=work,
+ instruction="",
+ language=language,
+ assignments=assignments,
+ consume_pending_voice_attachments=consume_pending_voice_attachments,
+ )
+
#: How long a "you never prompted it" complaint may reach back. Bounded to
#: the running conversation: past this, "do it again" is a fresh request and
#: replaying a stale sentence into a coding agent would be its own bug.
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index 490ac6c683..e49bb49cb5 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -354,6 +354,17 @@ if set(get_args(DeckAction)) != set(get_args(standup.Action)): # pragma: no cov
)
+class DeckHoldRequest(BaseModel):
+ """Whether the user is driving this pane themselves for now."""
+
+ held: bool = Field(
+ description=(
+ "True takes the pane over: the Command Deck stops assigning work to "
+ "it and stops reporting it. False hands it back."
+ )
+ )
+
+
class DeckAckRequest(BaseModel):
"""What the user said about one Command Deck report."""
@@ -1894,6 +1905,23 @@ async def get_deck_queue() -> dict:
return standup.queue().state()
[email protected]("/deck/hold/{name}", summary="Take a pane over from the Command Deck")
+async def set_deck_hold(name: str, req: DeckHoldRequest) -> dict:
+ """"I'll take this one" — and handing it back.
+
+ The honest limit on the deck's promise. A pane can hold a question only the
+ user can settle, and while they are dealing with it the deck must stop
+ assigning work to it and stop reporting it. Per pane rather than a mode:
+ the interesting case is one agent out of eight, and the other seven carry
+ on being run by Jarvis.
+ """
+ try:
+ held = get_registry().set_deck_hold(name, req.held)
+ except SessionError as exc:
+ raise HTTPException(status_code=404, detail=str(exc)) from exc
+ return {"terminal": name, "deck_hold": held}
+
+
@router.post("/deck/ack", summary="Answer a Command Deck report")
async def ack_deck_report(req: DeckAckRequest) -> dict:
""""Tell me that one" / "later" / "drop it", from voice or from the lane.
diff --git a/jarvis/voice/action_phrases.py b/jarvis/voice/action_phrases.py
index dad71e1ab3..ff111aaa86 100644
--- a/jarvis/voice/action_phrases.py
+++ b/jarvis/voice/action_phrases.py
@@ -361,6 +361,22 @@ _PHRASES: dict[str, dict[str, str]] = {
"en": "I could not reach {failed}, so nothing is running.",
"es": "No pude llegar a {failed}, así que no hay nada en marcha.",
},
+ # The Command Deck was handed work with nobody's name on it and has no
+ # agent free to take it. Said rather than queued: a silently held order is
+ # how a user ends up waiting on work that was never started.
+ "ide_deck_nobody_free": {
+ "de": "Alle arbeiten noch. Soll ich einen dazuholen?", # i18n-allow
+ "en": "Nobody is free right now — they are all still working. Shall I open one?",
+ "es": "Ahora mismo no hay nadie libre, todos siguen trabajando. ¿Abro uno?",
+ },
+ # No agent pane at all: an empty workspace, or one holding only plain
+ # shells. A different sentence from the one above, because the answer the
+ # user needs is different.
+ "ide_deck_no_agents": {
+ "de": "In diesem Workspace läuft noch kein Agent. Soll ich einen öffnen?", # i18n-allow
+ "en": "There is no agent running in this workspace yet. Shall I open one?",
+ "es": "Todavía no hay ningún agente en este espacio. ¿Abro uno?",
+ },
# Typed into the input box but never submitted — looks identical to a
# running agent until you ask it something (the 2026-07-25 popup trap).
"ide_prompt_typed_not_started": {
diff --git a/tests/unit/agentic_ide/test_deck_delegation.py b/tests/unit/agentic_ide/test_deck_delegation.py
new file mode 100644
index 0000000000..4bc6d2d8a9
--- /dev/null
+++ b/tests/unit/agentic_ide/test_deck_delegation.py
@@ -0,0 +1,185 @@
+"""Work with nobody's name on it still reaches an agent — in the deck only.
+
+Two halves, and the second one is the dangerous half. Getting "somebody fix the
+wake path" to a free agent is the feature; NOT getting "what time is it" typed
+into a coding agent as a task is what makes the feature safe to ship.
+"""
+
+from __future__ import annotations
+
+import time
+from typing import Any
+
+import pytest
+
+from jarvis.agentic_ide import intent, standup
+from jarvis.agentic_ide.fleet_actions import free_agents
+
+from .test_standup import entry
+
+
+class FakeTerminal:
+ """Enough of a pane for the free-agent scan and the hold."""
+
+ def __init__(
+ self,
+ name: str,
+ *,
+ agent: str = "claude",
+ activity: str = "waiting",
+ status: str = "live",
+ index: int = 0,
+ since: float = 0.0,
+ deck_hold: bool = False,
+ ) -> None:
+ self.key = name.lower()
+ self.name = name
+ self.agent = agent
+ self.status = status
+ self.index = index
+ self.deck_hold = deck_hold
+ # Stamped as the sweep would, so `observed` reads it rather than
+ # falling back to a single look at a screen this fake does not have.
+ self.activity = activity
+ self.activity_at = time.time()
+ self.activity_since = since
+
+
+class FakeSession:
+ def __init__(self, *terminals: FakeTerminal, view: str = "deck") -> None:
+ self.id = "ide_test"
+ self.terminals = list(terminals)
+ self.surface_view = view
+
+
+class TestWhoTakesIt:
+ def test_an_idle_agent_is_offered(self) -> None:
+ session = FakeSession(FakeTerminal("Mika"))
+
+ assert [t.name for t in free_agents(session)] == ["Mika"]
+
+ def test_a_working_agent_is_not(self) -> None:
+ # Typing a second job into a busy CLI does not queue it — it lands as
+ # an interruption of the first.
+ session = FakeSession(FakeTerminal("Mika", activity="working"))
+
+ assert free_agents(session) == []
+
+ def test_a_plain_shell_is_never_offered(self) -> None:
+ # It would RUN the sentence as a command.
+ session = FakeSession(FakeTerminal("Sh", agent="shell"))
+
+ assert free_agents(session) == []
+
+ def test_a_dead_pane_is_not_offered(self) -> None:
+ session = FakeSession(FakeTerminal("Mika", status="exited"))
+
+ assert free_agents(session) == []
+
+ def test_a_pane_the_user_took_over_is_not_offered(self) -> None:
+ session = FakeSession(FakeTerminal("Mika", deck_hold=True), FakeTerminal("Nova"))
+
+ assert [t.name for t in free_agents(session)] == ["Nova"]
+
+ def test_the_longest_idle_agent_goes_first(self) -> None:
+ # Otherwise the same pane takes every order while the rest sit there.
+ session = FakeSession(
+ FakeTerminal("Mika", since=500.0, index=0),
+ FakeTerminal("Nova", since=100.0, index=1),
+ )
+
+ assert [t.name for t in free_agents(session)] == ["Nova", "Mika"]
+
+ def test_an_untouched_fleet_answers_in_pane_order(self) -> None:
+ # Nothing has run, so every `since` is 0 — the answer still has to be
+ # stable, or two consecutive orders would scatter at random.
+ session = FakeSession(
+ FakeTerminal("Kai", index=2),
+ FakeTerminal("Mika", index=0),
+ FakeTerminal("Nova", index=1),
+ )
+
+ assert [t.name for t in free_agents(session)] == ["Mika", "Nova", "Kai"]
+
+
+class TestWhatCountsAsWork:
+ @pytest.mark.parametrize(
+ "utterance",
+ [
+ "get the wake-path tests green",
+ "fix the failing build",
+ "refactor the audio provider",
+ "mach mal einen Deep Dive über den Wake-Pfad", # i18n-allow: spoken input
+ "schreib Tests für die Recap-Engine", # i18n-allow: spoken input
+ "revisa el módulo de audio", # i18n-allow: spoken input
+ ],
+ )
+ def test_an_order_with_no_name_on_it_is_work(self, utterance: str) -> None:
+ assert intent.unaddressed_work(utterance) == utterance
+
+ @pytest.mark.parametrize(
+ "utterance",
+ [
+ # Questions are ANSWERED, never delegated. Each of these carries a
+ # perfectly good instruction verb and is not an instruction.
+ "what time is it?",
+ "how do I fix the wake path",
+ "can you explain what a PTY is",
+ "was machen die gerade", # i18n-allow: spoken input
+ "wie läuft der Build", # i18n-allow: spoken input
+ "¿qué está haciendo?", # i18n-allow: spoken input
+ # A status question without a question mark.
+ "status on the tests",
+ # No instruction shape at all.
+ "okay",
+ "danke, super", # i18n-allow: spoken input
+ "",
+ ],
+ )
+ def test_everything_else_is_not(self, utterance: str) -> None:
+ assert intent.unaddressed_work(utterance) is None
+
+ def test_a_named_pane_is_left_to_the_addressing_detector(self) -> None:
+ # The detector above stood down for a reason. Re-routing the order to
+ # whichever agent happens to be free would send it to the wrong one —
+ # with the right one's name still in the sentence.
+ assert intent.unaddressed_work("Mika die Tests", names=["Mika", "Nova"]) is None
+
+
+class TestHoldSilencesReports:
+ @pytest.fixture(autouse=True)
+ def _fresh(self) -> Any:
+ standup.reset()
+ standup.unwire()
+ yield
+ standup.reset()
+ standup.unwire()
+
+ class Registry:
+ def __init__(self, session: FakeSession) -> None:
+ self.sessions = [session]
+
+ async def test_a_held_pane_is_not_reported(self) -> None:
+ said: list[str] = []
+ standup.wire(speak=lambda text, _lang: said.append(text), language=lambda: "en")
+ standup.queue().conversation_started()
+ session = FakeSession(FakeTerminal("Mika", deck_hold=True))
+
+ await standup.pump(self.Registry(session), [entry("Mika")])
+
+ assert said == []
+ assert standup.queue().pending() == []
+
+ async def test_taking_a_pane_over_drops_a_report_already_waiting(self) -> None:
+ # The user is typing into it right now. Announcing it would be the deck
+ # talking over somebody who is already there.
+ standup.queue().conversation_started()
+ session = FakeSession(FakeTerminal("Mika"), FakeTerminal("Nova"))
+ registry = self.Registry(session)
+ await standup.pump(registry, [entry("Mika"), entry("Nova")])
+ assert len(standup.queue().pending()) >= 1
+
+ session.terminals[0].deck_hold = True
+ await standup.pump(registry, [])
+
+ assert "Mika" not in [r.pane for r in standup.queue().pending()]
diff --git a/tests/unit/brain/test_command_deck_delegation.py b/tests/unit/brain/test_command_deck_delegation.py
new file mode 100644
index 0000000000..41ece54ec7
--- /dev/null
+++ b/tests/unit/brain/test_command_deck_delegation.py
@@ -0,0 +1,217 @@
+"""In the Command Deck, an order with nobody's name on it still reaches an agent.
+
+Everywhere else that sentence keeps meaning what it always did. That boundary is
+the whole safety story of this feature: a workspace open in the grid must not
+start swallowing ordinary conversation, and the deck must not need a call-sign
+per order from a user who is running the room by voice.
+"""
+
+from __future__ import annotations
+
+import time
+from pathlib import Path
+
+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.manager import BrainManager
+from jarvis.core.bus import EventBus
+from jarvis.core.config import JarvisConfig
+from tests.fakes.fake_pty_manager import FakePtyManager
+
+
[email protected](autouse=True)
+def _isolated_recents(
+ tmp_path_factory: pytest.TempPathFactory, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ from jarvis.agentic_ide import recents
+
+ store = tmp_path_factory.mktemp("recents") / "recents.json"
+ monkeypatch.setattr(recents, "_store_path", lambda: store)
+
+
+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 manager() -> BrainManager:
+ cfg = JarvisConfig()
+ cfg.brain.primary = "fake"
+ mgr = BrainManager(config=cfg, bus=EventBus(), tools={})
+ # Pinned so the 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
+
+
[email protected](autouse=True)
+def _fake_composer(monkeypatch: pytest.MonkeyPatch) -> None:
+ 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=[], composed_by="llm"
+ )
+
+ monkeypatch.setattr(prompt_composer, "compose", fake_compose)
+
+
+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, *, view: str) -> None:
+ """Open ``count`` live panes and report the workspace as read in ``view``."""
+ 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)
+ registry.set_surface_context(
+ workspace_id=registry.session.id,
+ view=view,
+ on_screen=True,
+ terminal=None,
+ )
+
+
+def _typed(registry: Registry) -> dict[str, str]:
+ """What actually reached each pane, by call-sign."""
+ assert registry.session is not None
+ return {
+ term.name: str(getattr(term, "last_prompt", "") or "")
+ for term in registry.session.terminals
+ }
+
+
+async def test_the_deck_gives_an_unaddressed_order_to_a_free_agent(
+ manager: BrainManager, registry: Registry, tmp_path: Path
+) -> None:
+ await _open(registry, tmp_path, 2, view="deck")
+
+ reply = await manager._run_agentic_ide_fast_path("get the wake-path tests green")
+
+ assert reply is not None
+ delivered = [name for name, prompt in _typed(registry).items() if prompt]
+ assert len(delivered) == 1
+
+
+async def test_the_grid_does_not(
+ manager: BrainManager, registry: Registry, tmp_path: Path
+) -> None:
+ # The boundary. An unaddressed instruction in the grid is a sentence for
+ # Jarvis, and a workspace that quietly typed it into an agent would make
+ # every open workspace a hazard to ordinary conversation.
+ await _open(registry, tmp_path, 2, view="grid")
+
+ await manager._run_agentic_ide_fast_path("get the wake-path tests green")
+
+ assert not any(_typed(registry).values())
+
+
+async def test_a_question_is_never_delegated(
+ manager: BrainManager, registry: Registry, tmp_path: Path
+) -> None:
+ # It contains an instruction verb and is not an instruction. Typing it into
+ # a coding agent as a task is the worst thing this path could do.
+ await _open(registry, tmp_path, 2, view="deck")
+
+ await manager._run_agentic_ide_fast_path("how do I fix the wake path?")
+
+ assert not any(_typed(registry).values())
+
+
+async def test_a_busy_fleet_is_told_rather_than_queued(
+ manager: BrainManager, registry: Registry, tmp_path: Path
+) -> None:
+ # A silently held order is how somebody ends up waiting an hour on work
+ # that was never started.
+ await _open(registry, tmp_path, 1, view="deck")
+ assert registry.session is not None
+ for term in registry.session.terminals:
+ # Stamped as the sweep would, NOW. A timestamp in the future is not
+ # "very fresh" to `activity.observed` — it is outside the window in the
+ # other direction, and the reading falls back to a single look.
+ term.activity = "working"
+ term.activity_at = time.time()
+ term.activity_since = time.time()
+
+ reply = await manager._run_agentic_ide_fast_path("get the wake-path tests green")
+
+ assert reply is not None
+ assert "free" in reply.lower() or "working" in reply.lower()
+ assert not any(_typed(registry).values())
+
+
+async def test_a_workspace_with_no_agent_says_that_instead(
+ manager: BrainManager, registry: Registry, tmp_path: Path
+) -> None:
+ # Telling somebody their agents are busy when they have none is the kind of
+ # small lie that makes a surface untrustworthy.
+ await registry.start(str(tmp_path), [{"agent": "shell"}])
+ assert registry.session is not None
+ registry.set_surface_context(
+ workspace_id=registry.session.id, view="deck", on_screen=True, terminal=None
+ )
+
+ reply = await manager._run_agentic_ide_fast_path("get the wake-path tests green")
+
+ assert reply is not None
+ assert "no agent" in reply.lower()
+
+
+async def test_a_pane_the_user_took_over_is_skipped(
+ manager: BrainManager, registry: Registry, tmp_path: Path
+) -> None:
+ await _open(registry, tmp_path, 2, view="deck")
+ assert registry.session is not None
+ first, second = registry.session.terminals
+ registry.set_deck_hold(first.name, True)
+
+ await manager._run_agentic_ide_fast_path("get the wake-path tests green")
+
+ typed = _typed(registry)
+ assert not typed[first.name]
+ assert typed[second.name]
+
+
+async def test_naming_a_pane_still_wins(
+ manager: BrainManager, registry: Registry, tmp_path: Path
+) -> None:
+ # Delegation is the fallback for an order with no name on it, never a
+ # replacement for the addressing path.
+ await _open(registry, tmp_path, 3, view="deck")
+ assert registry.session is not None
+ wanted = registry.session.terminals[2].name
+
+ await manager._run_agentic_ide_fast_path(f"tell {wanted} to fix the wake path")
+
+ typed = _typed(registry)
+ assert typed[wanted]
+ assert [name for name, prompt in typed.items() if prompt] == [wanted]
+
+
+async def test_asking_for_a_background_agent_still_spawns_one(
+ manager: BrainManager, registry: Registry, tmp_path: Path
+) -> None:
+ # Precedence rule 1 of `intent`: naming the spawn vehicle outranks the
+ # workspace. The deck must not swallow it just because a pane is free.
+ await _open(registry, tmp_path, 2, view="deck")
+
+ reply = await manager._run_agentic_ide_fast_path(
+ "spawn a background agent to review the wake path"
+ )
+
+ assert reply is None
+ assert not any(_typed(registry).values())