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.

fix(agentic-ide): show a finished pane as finished after an Enter that started nothing

rubenluetke10-beepf39d4154f924
diff --git a/jarvis/agentic_ide/activity.py b/jarvis/agentic_ide/activity.py
index 5ad079f960..7ca70a89d2 100644
--- a/jarvis/agentic_ide/activity.py
+++ b/jarvis/agentic_ide/activity.py
@@ -268,6 +268,12 @@ def read_activity(
return states[proof.state]
if _has_current_instruction(term) and is_moving(term, moment, still_since):
return "working"
+ if proof.before in ("completed", "stopped") and not in_submit_wake(term, moment):
+ # A submission past its grace with no record and a still screen
+ # started no turn (an empty Enter, a slash command): the pane is
+ # where its last job left it. It still finishes nothing, so no
+ # completion is announced for it.
+ return states[proof.before]
return "unknown" if has_work_behind_it(term) else "waiting"
if _has_current_instruction(term) and is_moving(term, moment, still_since):
return "working"
diff --git a/jarvis/agentic_ide/task_state.py b/jarvis/agentic_ide/task_state.py
index ac8c83bf41..9ff61c0e0e 100644
--- a/jarvis/agentic_ide/task_state.py
+++ b/jarvis/agentic_ide/task_state.py
@@ -10,7 +10,7 @@ from __future__ import annotations
import asyncio
import json
import time
-from dataclasses import dataclass
+from dataclasses import dataclass, replace
from pathlib import Path
from typing import Any
@@ -27,6 +27,11 @@ class Evidence:
state: str = "unknown"
at: float = 0.0
checked_at: float = 0.0
+ # The last lifecycle state recorded BEFORE the current submission. Never
+ # the state of the current job; it only tells a submission that started
+ # no turn (an empty Enter, a slash command) after a finished one apart
+ # from a pane with no history at all.
+ before: str = ""
_readings: dict[tuple, Evidence] = {}
@@ -125,9 +130,9 @@ def _read(key: tuple, now: float) -> Evidence:
stat = path.stat()
signature = (str(path), stat.st_mtime_ns, stat.st_size)
if cached and cached[0] == signature:
- old = cached[1]
- return Evidence(old.state, old.at, now)
+ return replace(cached[1], checked_at=now)
result = Evidence(checked_at=now)
+ before = ""
# A bounded tail is enough: tool progress keeps a task working even
# when its start marker lies outside the window. No marker -> unknown.
with path.open("rb") as handle:
@@ -138,7 +143,7 @@ def _read(key: tuple, now: float) -> Evidence:
try:
row = json.loads(raw)
except (ValueError, UnicodeDecodeError):
- result = Evidence(checked_at=now)
+ result, before = Evidence(checked_at=now), ""
continue # The writer may not have completed its last JSON line.
if not isinstance(row, dict):
continue
@@ -151,11 +156,16 @@ def _read(key: tuple, now: float) -> Evidence:
# unanswered question into a successful turn boundary.
continue
change = transition(agent, row)
- if (
- change and 0 < change[1] <= time.time()
- and change[1] >= float(submitted_at or 0)
- ):
+ if not change or not 0 < change[1] <= time.time():
+ continue
+ if change[1] >= float(submitted_at or 0):
result = Evidence(*change, checked_at=now)
+ elif not (
+ agent == "claude" and row.get("subtype") == "turn_duration"
+ and before in {"stopped", "failed", "asking"}
+ ):
+ before = change[0]
+ result = replace(result, before=before)
_files[key] = (signature, result)
return result
except (OSError, ValueError, TypeError):
diff --git a/tests/unit/agentic_ide/test_send_gate.py b/tests/unit/agentic_ide/test_send_gate.py
index c4c1b6f3c6..2f7b0b49cc 100644
--- a/tests/unit/agentic_ide/test_send_gate.py
+++ b/tests/unit/agentic_ide/test_send_gate.py
@@ -130,7 +130,9 @@ async def test_enter_that_started_no_turn_does_not_make_the_pane_busy(pane):
# An empty Enter / slash command after the turn: a submit with no record.
submitted(term, now - 120)
await task_state.probe(term)
- assert activity.read_activity(term) == "unknown" # the badge stays honest
+ # The pane reads as finished again; its old completion is not re-announced.
+ assert activity.read_activity(term) == "waiting"
+ assert task_state.evidence(term).state == "unknown"
activity.stamp(term, "unknown", now=now)
await send(registry, workspace, term)
assert sent == ["Updated brief"]
diff --git a/tests/unit/agentic_ide/test_task_state.py b/tests/unit/agentic_ide/test_task_state.py
index 8dc0cc90a5..7df378e9f1 100644
--- a/tests/unit/agentic_ide/test_task_state.py
+++ b/tests/unit/agentic_ide/test_task_state.py
@@ -83,9 +83,21 @@ async def test_completion_abort_question_and_resume_are_distinct(pane):
@pytest.mark.asyncio
async def test_old_completion_missing_record_and_remote_record_are_unknown(pane):
term, registry, path = pane
- append(path, row("event_msg", {"type": "task_complete"}, term.last_submit_at - 1))
+ append(path, row("event_msg", {"type": "task_started"}, term.last_submit_at - 2))
await task_state.refresh(registry)
+ # An earlier job still running when the new submit came proves nothing.
assert activity.read_activity(term) == "unknown"
+ append(path, row("event_msg", {"type": "task_complete"}, term.last_submit_at - 1))
+ await task_state.refresh(registry)
+ # A finished job, then a submit that never started a turn (an empty Enter,
+ # a slash command): the still pane is back where that job left it, but the
+ # old completion never finishes the new submit.
+ assert task_state.evidence(term).state == "unknown"
+ assert activity.read_activity(term) == "waiting"
+ term.last_submit_at = time.time() - 1
+ await task_state.refresh(registry)
+ assert activity.read_activity(term) == "unknown" # inside the submit grace
+ term.last_submit_at = time.time() - 100
append(path, row("event_msg", {"type": "task_complete"}))
term.computer_id = "other-machine"
await task_state.refresh(registry)