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(agentic-ide): a prompt ending in an @file reference was never submitted
Ruben Lütkeb4d7c4ea92a5
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.pyindex 8484bcc8df..1ef189715c 100644--- a/jarvis/agentic_ide/session.py+++ b/jarvis/agentic_ide/session.py@@ -69,6 +69,67 @@ ENTER_DELAY_S = 0.12Status = str # "pending" | "live" | "exited" | "error"+# Verification budget. Measured against a real Claude Code: a plain prompt clears+# the input line within ~0.3 s, but one carrying an @file reference takes over a+# second (the agent reads the file before redrawing). A 1.4 s window reported a+# prompt as failed that had in fact gone through — a false alarm is as bad as a+# silent drop — so the window is generous, polled finely, and returns the moment+# the line is clear (the normal case still costs ~0.3 s).+_SUBMIT_POLL_S = 0.25+_SUBMIT_WINDOW_S = 2.5+# One extra Enter, and only while the text is DEMONSTRABLY still in the box.+# Pressing blindly into an agent that already started is how you accidentally+# confirm one of ITS prompts.+_SUBMIT_RETRY_AFTER_S = 1.0++# Glyphs an agent TUI draws in front of its input line.+_INPUT_MARKERS = ("❯", ">", "›")+++def _opens_completion(payload: str) -> bool:+ """True when the prompt's last token would leave a completion popup open.++ ``@path`` opens the file picker and ``/name`` the command picker; with either+ still open, Enter selects from the list instead of submitting.+ """+ last = payload.rsplit(" ", 1)[-1]+ return last.startswith(("@", "/")) and len(last) > 1+++def _submit_needle(payload: str) -> str:+ """The fragment used to recognise the prompt inside the input line.++ The beginning, not the end: the input box wraps long prompts, so only the+ first line is reliably intact — and it is the part that never changes when a+ completion popup rewrites the tail.+ """+ return " ".join(payload.split())[:28].strip().lower()+++def _input_line_holds(tail: list[str], needle: str) -> bool:+ """True when the terminal's input line still shows ``needle`` being typed.++ Only the LAST prompt-marked line counts. An agent echoes a submitted prompt+ back into its history behind the same ``>`` glyph, so "any line starting with+ > contains the text" reports every successful submit as a failure — measured,+ it did exactly that. The live input line is always the bottom-most one, and+ after a submit it is empty.+ """+ if not needle:+ return False+ current: str | None = None+ for line in tail:+ stripped = line.strip()+ if not stripped:+ continue+ for marker in _INPUT_MARKERS:+ if stripped.startswith(marker):+ current = stripped[len(marker) :].strip()+ break+ if not current:+ return False+ return current.lower().startswith(needle[: max(8, len(needle) // 2)])+def sanitize_prompt(text: str) -> str:"""Injectable form of ``text``: printable characters only, length-capped.@@ -139,6 +200,8 @@ class Terminal:last_output_at: float | None = Noneprompts_sent: int = 0last_prompt: str = ""+ # Did the last prompt actually leave the input line? None = none sent yet.+ submitted: bool | None = Nonetranscript: Transcript = field(default_factory=Transcript)def to_dict(self) -> dict[str, Any]:@@ -159,6 +222,7 @@ class Terminal:),"prompts_sent": self.prompts_sent,"last_prompt": self.last_prompt,+ "submitted": self.submitted,"lines_captured": len(self.transcript.lines()),}@@ -635,10 +699,29 @@ class Registry:# --------------------------------------------------------------- promptasync def send_prompt(self, wanted: str, text: str) -> Terminal:- """Type ``text`` into a terminal and press Enter.-- Raises ``SessionError`` when the terminal is unknown, not running, or- the prompt sanitizes down to nothing.+ """Type ``text`` into a terminal, press Enter, and CONFIRM it was sent.++ Typing and hoping is not enough, which a live failure proved on+ 2026-07-25: three prompts were typed into three agents and only one ran.+ The two that stalled both ended with an ``@file`` reference, and that is+ the whole mechanism — an ``@path`` (or a ``/command``) at the end of the+ line leaves the agent's completion popup OPEN, so the Enter that follows+ picks a suggestion instead of submitting. Measured on a real Claude Code:+ ending with ``@README.md`` never submits; the same prompt with one+ trailing space always does.++ So two defences, because a silent no-op is the worst outcome here:++ 1. **Close any open completion** before Enter — a single space when the+ prompt ends in an ``@``/``/`` token. Harmless to the prompt text.+ 2. **Verify and retry.** After Enter, the sent text must be GONE from the+ input line. While it is still sitting there, press Enter again (twice+ at most). Whether it finally went is reported back, so a caller can+ say "sent to Mika" or "Mika did not accept it" — never guess.++ Raises ``SessionError`` when the terminal is unknown, not running, or the+ prompt sanitizes down to nothing. A prompt that was typed but refused to+ submit is NOT an error — the text is in the box and the caller is told."""session = self._sessionif session is None:@@ -657,16 +740,53 @@ class Registry:raise SessionError("The prompt was empty after cleanup.")manager = self._manager()- if not manager.write(term.pty_id, payload):+ typed = payload + (" " if _opens_completion(payload) else "")+ if not manager.write(term.pty_id, typed):raise SessionError(f"Could not write to {term.name}.")await asyncio.sleep(ENTER_DELAY_S)manager.write(term.pty_id, "\r")term.prompts_sent += 1term.last_prompt = payload- logger.info("Agentic IDE prompt -> {}: {}", term.name, payload[:120])+ term.submitted = await self._confirm_submitted(term, payload, manager)+ logger.info(+ "Agentic IDE prompt -> {} ({}): {}",+ term.name,+ "submitted" if term.submitted else "STILL IN THE INPUT BOX",+ payload[:120],+ )return term+ async def _confirm_submitted(+ self, term: Terminal, payload: str, manager: PtyManager+ ) -> bool:+ """True once ``payload`` has left the terminal's input line.++ The input line lives at the bottom of the screen, just above the status+ bar; a submitted prompt scrolls up out of it. So the check is: does the+ BOTTOM of the replayed screen still show the beginning of what we typed?+ Content-based rather than timing-based, because "the agent produced some+ output" is not the same as "the prompt was accepted" (a completion popup+ redraws too).+ """+ needle = _submit_needle(payload)+ checks = max(1, int(_SUBMIT_WINDOW_S / _SUBMIT_POLL_S)) if _SUBMIT_POLL_S else 1+ retried = False+ for step in range(checks):+ await asyncio.sleep(_SUBMIT_POLL_S)+ if not _input_line_holds(term.transcript.tail(10), needle):+ return True+ elapsed = (step + 1) * _SUBMIT_POLL_S+ if not retried and elapsed >= _SUBMIT_RETRY_AFTER_S:+ retried = True+ logger.warning(+ "Agentic IDE: {} still holds the prompt in its input box — "+ "pressing Enter once more",+ term.name,+ )+ manager.write(term.pty_id or "", "\r")+ return not _input_line_holds(term.transcript.tail(10), needle)+def report(self, wanted: str, lines: int = 40) -> dict[str, Any]:"""What one terminal has been up to — the answer to "what is X doing?"."""session = self._sessiondiff --git a/jarvis/commands/registry.py b/jarvis/commands/registry.pyindex 00ea3579a6..75559220af 100644--- a/jarvis/commands/registry.py+++ b/jarvis/commands/registry.py@@ -667,7 +667,11 @@ def _build_registry() -> tuple[AppCommand, ...]:"— that work belongs to that agent, never to a background ""worker. Pass the user's instruction as the prompt; with ""compose=true it is rewritten into a briefed task with the "- "relevant files of this workspace attached."+ "relevant files of this workspace attached. "+ "CHECK THE REPLY: it carries a 'submitted' flag. True means the "+ "agent accepted the prompt and started. False means the text is "+ "only sitting in that terminal's input box — say so plainly and "+ "name the terminal, never report it as done."),method="POST",path="/api/agentic-ide/terminals/{name}/prompt",diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.pyindex 5ecc17665a..8acf80170c 100644--- a/jarvis/ui/web/agentic_ide_routes.py+++ b/jarvis/ui/web/agentic_ide_routes.py@@ -495,6 +495,9 @@ async def terminal_prompt(name: str, req: PromptRequest) -> dict:term = await registry.send_prompt(name, text)except SessionError as exc:raise HTTPException(status_code=409, detail=str(exc)) from exc+ # `submitted` is the honest part of this answer: the text was typed either+ # way, but only a True here means the agent actually accepted it and started.+ # A caller that reports "sent to Mika" on a False is lying to the user.return {"ok": True,"terminal": term.name,@@ -503,6 +506,15 @@ async def terminal_prompt(name: str, req: PromptRequest) -> dict:"composed_by": composed_by,"files": files,"prompts_sent": term.prompts_sent,+ "submitted": bool(term.submitted),+ "detail": (+ ""+ if term.submitted+ else (+ f"{term.name} did not accept the prompt — the text is sitting in "+ "its input box. Tell the user, and let them press Enter there."+ )+ ),}diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsxindex c4fbbf0132..49c69828f4 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx@@ -29,12 +29,12 @@ import {type PaneStatus,} from "./AgenticTerminal";import type { TerminalAppearance } from "./terminalThemes";+import { paneColumns, paneLines, paneRows } from "./layout";import {addTerminal,closeTerminal,promptTerminal,type SessionState,- type TerminalState,} from "@/lib/agenticIdeApi";interface AgenticGridProps {@@ -75,14 +75,7 @@ export function AgenticGrid({// Group panes into their rows. The backend keeps `row` packed and the list in// render order, so this is a straight fold rather than a sort.- const rows = useMemo(() => {- const grouped: TerminalState[][] = [];- for (const term of session.terminals) {- while (grouped.length <= term.row) grouped.push([]);- grouped[term.row].push(term);- }- return grouped.filter((row) => row.length > 0);- }, [session.terminals]);+ const rows = useMemo(() => paneRows(session.terminals), [session.terminals]);const atLimit = session.terminals.length >= maxTerminals;@@ -126,8 +119,17 @@ export function AgenticGrid({if (!text || !target) return;setSending(true);try {- await promptTerminal(target, text);+ const result = await promptTerminal(target, text);setPrompt("");+ // The text is typed either way — but if the agent did not accept it, say+ // so instead of leaving the user to wonder why nothing happened.+ if (result && result.submitted === false) {+ pushToast(+ "warning",+ result.detail ||+ `${target} did not accept the prompt — the text is waiting in its input box.`,+ );+ }} catch (e) {pushToast("error", (e as Error).message);} finally {@@ -246,21 +248,40 @@ export function AgenticGrid({stays MOUNTED at all times — including while another one is maximized —because unmounting it would tear down its WebSocket and kill the agentbehind it. Maximizing therefore hides the others with CSS instead.++ Each row is a CSS grid whose width comes from `paneColumns`, so a row+ wider than that wraps onto a second line (12 panes → 6 above, 6 below)+ instead of squeezing every pane down to an unreadable sliver. Wrapping+ inside ONE grid rather than into extra row elements is what keeps the+ panes mounted through the wrap — moving a pane to a different parent+ would remount it, and remounting kills its agent.*/}<div className="flex flex-1 flex-col gap-3 overflow-hidden p-3">{rows.map((rowTerminals, rowIndex) => {const rowHidden =maximized !== null && !rowTerminals.some((t) => t.name === maximized);+ // While a pane is maximized the row collapses to a single column, so+ // the one visible pane gets the full width instead of keeping the+ // narrow slot it had in the grid.+ const columns = maximized !== null ? 1 : paneColumns(rowTerminals.length);return (<divkey={rowIndex}- className={cn("flex min-h-0 flex-1 gap-3", rowHidden && "hidden")}+ className={cn("grid min-h-0 gap-3", rowHidden && "hidden")}+ style={{+ gridTemplateColumns: `repeat(${Math.max(1, columns)}, minmax(0, 1fr))`,+ gridAutoRows: "minmax(0, 1fr)",+ // A row that wraps onto two lines needs twice the height of a+ // single-line row, or its panes end up half as tall.+ flexGrow: maximized !== null ? 1 : paneLines(rowTerminals.length),+ flexBasis: 0,+ }}>{rowTerminals.map((term) => (<divkey={term.key}className={cn(- "min-w-0 flex-1",+ "min-w-0",maximized !== null && maximized !== term.name && "hidden",)}>diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.tsindex 5fdf230b94..b29411fb7c 100644--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts@@ -255,6 +255,14 @@ export interface PromptResult {composed_by: "llm" | "fallback" | "raw";/** Repo-relative files referenced with `@` in the sent prompt. */files: string[];+ /**+ * Did the agent actually ACCEPT the prompt? The text is typed either way; a+ * false means it is still sitting in that terminal's input box (see the+ * backend's submit verification). Never report a send as done without it.+ */+ submitted: boolean;+ /** Plain-language explanation when `submitted` is false. */+ detail?: string;}/**diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsxindex 697f82b2a2..a07394ee97 100644--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx@@ -240,6 +240,7 @@ describe("Agentic IDE running workspace", () => {sent: "run the tests",composed_by: "raw",files: [],+ submitted: true,});render(<AgenticIdeView />);diff --git a/tests/unit/agentic_ide/test_prompt_submit.py b/tests/unit/agentic_ide/test_prompt_submit.pynew file mode 100644index 0000000000..7c7aa68ebd--- /dev/null+++ b/tests/unit/agentic_ide/test_prompt_submit.py@@ -0,0 +1,184 @@+"""Making sure a prompt is actually SUBMITTED, not just typed.++Live failure, 2026-07-25: Jarvis typed three review prompts into three agents and+only one ran. The two that stalled both ended with an ``@file`` reference — an+``@path`` at the end of the line leaves the agent's file-completion popup open, so+the Enter that follows picks a suggestion instead of submitting. Measured against a+real Claude Code: ending in ``@README.md`` never submits, the same prompt with one+trailing space always does.++Two defences are tested here: closing the completion before Enter, and verifying+afterwards that the text left the input line (retrying Enter while it has not).+"""+from __future__ import annotations++from pathlib import Path++import pytest++from jarvis.agentic_ide import session as session_mod+from jarvis.agentic_ide.session import (+ Registry,+ SessionError,+ _input_line_holds,+ _opens_completion,+ _submit_needle,+)+from tests.fakes.fake_pty_manager import FakePtyManager+++# ------------------------------------------------------------------ helpers+ "payload",+ [+ "review this. @jarvis/ultrawiki/pipeline.py",+ "check @tests/unit/test_x.py",+ "run /effort",+ ],+)+def test_a_trailing_reference_is_recognised(payload: str) -> None:+ assert _opens_completion(payload) is True+++ "payload",+ [+ "review the pipeline please",+ "look at @jarvis/x.py and report back", # reference is not last+ "email me @", # a bare @ opens nothing+ "10 / 2 is five",+ ],+)+def test_plain_endings_need_no_space(payload: str) -> None:+ assert _opens_completion(payload) is False+++def test_the_needle_comes_from_the_start_of_the_prompt() -> None:+ """The input box wraps, so only the first line is reliably intact."""+ needle = _submit_needle("Führe ein gründliches Code-Review durch. @a/b.py")+ assert needle.startswith("führe ein")+ assert "@a/b.py" not in needle+++def test_an_input_line_still_holding_the_prompt_is_detected() -> None:+ needle = _submit_needle("Review the pipeline")+ assert _input_line_holds(["❯ Review the pipeline", " 📁 project 🌿 main"], needle)+ assert _input_line_holds(["> Review the pipeline and tests"], needle)+++def test_an_empty_input_line_means_submitted() -> None:+ needle = _submit_needle("Review the pipeline")+ assert not _input_line_holds(["❯", " 📁 project", "✽ Mulling…"], needle)+++def test_an_echo_above_the_input_line_does_not_count_as_pending() -> None:+ """A submitted prompt is echoed into the history — that is success, not a+ prompt still waiting to be sent."""+ needle = _submit_needle("Review the pipeline")+ assert not _input_line_holds(["Review the pipeline", "✻ Cooked for 2s", "❯"], needle)+++# ------------------------------------------------------------------ the path+def fake_pty() -> FakePtyManager:+ return FakePtyManager()+++def registry(fake_pty: FakePtyManager, monkeypatch: pytest.MonkeyPatch) -> Registry:+ monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))+ # Keep the verification loop fast in tests.+ monkeypatch.setattr(session_mod, "_SUBMIT_POLL_S", 0.0)+ monkeypatch.setattr(session_mod, "_SUBMIT_WINDOW_S", 0.0)+ monkeypatch.setattr(session_mod, "_SUBMIT_RETRY_AFTER_S", 0.0)+ return Registry(pty_manager=fake_pty)+++async def _open(registry: Registry, folder: Path):+ return await registry.start(str(folder), [{"agent": "claude", "name": "Mika"}])+++async def _noop(_text: str) -> None:+ return None+++async def _noop_exit(_code: int) -> None:+ return None+++async def _live(registry: Registry, tmp_path: Path):+ await _open(registry, tmp_path)+ return await registry.attach("Mika", 100, 30, _noop, _noop_exit)+++async def test_a_trailing_reference_gets_a_closing_space(+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path+) -> None:+ term = await _live(registry, tmp_path)+ # Empty screen: the verification sees no pending input line -> submitted.+ await registry.send_prompt("Mika", "review this. @jarvis/x.py")+ assert fake_pty.typed[0] == "review this. @jarvis/x.py ", fake_pty.typed+ assert fake_pty.typed[1] == "\r"+ assert term.submitted is True+++async def test_a_plain_prompt_is_typed_verbatim(+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path+) -> None:+ await _live(registry, tmp_path)+ await registry.send_prompt("Mika", "review the pipeline")+ assert fake_pty.typed[0] == "review the pipeline", fake_pty.typed+++async def test_enter_is_pressed_again_while_the_prompt_sits_in_the_box(+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path+) -> None:+ """The safety net for cases the space alone does not fix."""+ term = await _live(registry, tmp_path)+ # Make the screen look like the prompt never left the input line.+ on_output = fake_pty.spawns[-1]["on_output"]+ await on_output("pty", "\x1b[2J\x1b[H❯ review the pipeline\r\n")++ await registry.send_prompt("Mika", "review the pipeline")++ enters = [d for d in fake_pty.typed if d == "\r"]+ assert len(enters) == 2, f"one Enter plus a single retry, got {fake_pty.typed}"+ assert term.submitted is False+++async def test_a_prompt_that_lands_reports_submitted(+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path+) -> None:+ term = await _live(registry, tmp_path)+ on_output = fake_pty.spawns[-1]["on_output"]+ # Screen after a successful submit: the prompt is echoed in the history and+ # the input line is empty again.+ await on_output("pty", "\x1b[2J\x1b[Hreview the pipeline\r\n✽ Mulling…\r\n❯\r\n")++ await registry.send_prompt("Mika", "review the pipeline")+ assert term.submitted is True+ assert [d for d in fake_pty.typed if d == "\r"] == ["\r"], "no needless retries"+++async def test_the_submitted_flag_is_reported(+ registry: Registry, tmp_path: Path+) -> None:+ term = await _live(registry, tmp_path)+ await registry.send_prompt("Mika", "review the pipeline")+ assert term.to_dict()["submitted"] is True+++async def test_a_fresh_terminal_has_no_submitted_verdict(+ registry: Registry, tmp_path: Path+) -> None:+ await _open(registry, tmp_path)+ assert registry.session.terminals[0].to_dict()["submitted"] is None+++async def test_a_dead_terminal_still_refuses_outright(+ registry: Registry, tmp_path: Path+) -> None:+ """Verification never softens the hard refusal: no live agent, nothing typed."""+ await _open(registry, tmp_path)+ with pytest.raises(SessionError, match="not running"):+ await registry.send_prompt("Mika", "review the pipeline")