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
feat(agentic-ide): show whether a pane is working or done, not that it is "live"
Ruben Lütkeed6ea0555a4a
diff --git a/jarvis/agentic_ide/activity.py b/jarvis/agentic_ide/activity.pyindex 5bc05b28d0..f14f0d1334 100644--- a/jarvis/agentic_ide/activity.py+++ b/jarvis/agentic_ide/activity.py@@ -76,13 +76,30 @@ optimistic, which is the one case where this is wrong in the user's favourrather than silent. A CLI that genuinely draws nothing at all while it works —none of the four measured — would be reported early. A plain shell pane is notan agent and is left out entirely by the caller.++## Who reads this, and why it is stamped on the pane++Two callers, one reading. The notification sweep (:mod:`.notifications`) is the+one that can actually SEE movement — it compares this sweep's fingerprint with+the last one — and it runs every couple of seconds for as long as a workspace is+open. Everything else that wants to know what a pane is doing (the workspace+state, the recap poll behind the pane list) is a request handler with a single+look and no history, and a single look cannot tell a still screen from a moving+one.++So the sweep :func:`stamp`\\ s what it observed onto the pane and the request+handlers read it back (:func:`observed`). A stamp older than+:data:`STAMP_FRESH_S` is not trusted: that is not a stale reading, it is+evidence that nothing is watching this pane at all — the sweep never started, or+its task died — and the caller gets a fresh single-look answer instead of a word+that stopped being true minutes ago."""from __future__ import annotationsimport hashlibimport time-from typing import TYPE_CHECKING, Any, Literal+from typing import TYPE_CHECKING, Any, Literal, NamedTupleif TYPE_CHECKING: # pragma: no cover - typing onlyfrom collections.abc import Sequence@@ -260,15 +277,107 @@ def is_settled(activity: str) -> bool:return activity in SETTLED+#: How long a stamped reading is trusted by a caller that did not take it.+#:+#: The sweep behind it runs every two seconds+#: (``notifications.SWEEP_INTERVAL_S``), so three sweeps of slack absorbs a busy+#: event loop while keeping the "nothing is watching" case honest — see the+#: module docstring.+STAMP_FRESH_S = 6.0+++class Reading(NamedTuple):+ """What a pane is doing, and when it started doing it.++ ``since`` is 0 for an answer derived from one look, which has no way of+ knowing how long the pane has been in this state — never a claim that it+ started at the epoch.++ The empty activity is a real answer and means "this vocabulary does not+ describe this pane" — see :data:`NO_READING`.+ """++ activity: Activity | Literal[""]+ since: float+++#: The answer for a pane that has no job to be in the middle of: a plain shell,+#: which runs no agent at all.+#:+#: Its own value rather than ``waiting``, because every word here is a claim+#: about a JOB — and "waiting" on a shell prompt would read as an agent that has+#: finished one. A caller that gets this shows whatever it showed before this+#: feature existed.+NO_READING = Reading("", 0.0)+++def stamp(term: Any, activity: Activity, *, now: float) -> None:+ """Publish what this sweep observed, for readers that cannot observe.++ Only the transition is timed: re-stamping the same word every two seconds+ must not keep resetting "since", or a pane that has been waiting for twenty+ minutes would always look like it just stopped.+ """+ if getattr(term, "activity", "") != activity:+ term.activity_since = now+ term.activity = activity+ term.activity_at = now+++def observed(term: Any, *, now: float | None = None) -> Reading:+ """What ``term`` is doing, for a caller with no history of its own.++ The sweep's reading while there is a fresh one, and a single-look answer+ otherwise. Duck-typed like the rest of this module: a pane that has never+ been stamped answers from the look, not with an ``AttributeError``.+ """+ moment = time.time() if now is None else now+ word = str(getattr(term, "activity", "") or "")+ at = float(getattr(term, "activity_at", 0.0) or 0.0)+ if word and 0 <= moment - at <= STAMP_FRESH_S:+ since = float(getattr(term, "activity_since", 0.0) or 0.0)+ return Reading(word, since) # type: ignore[arg-type]+ return Reading(read_activity(term, now=moment), 0.0)+++def has_been_tasked(term: Any) -> bool:+ """Has anybody ever given this pane an instruction?++ Two proofs, because a pane can be driven two ways and both count. A+ timestamp from the moment something was submitted into it — by Jarvis or by+ a person pressing Enter — and the counter of prompts Jarvis has sent, which+ is the half that survives into a restored workspace where the timestamp does+ not. A pane typed into by hand before a restart therefore starts its next+ life unproven, and is described as merely idle rather than as finished: a+ missing claim, rather than an invented one.++ It is what separates "this agent finished the job" from "this terminal has+ never been asked for anything", which are the same STILL SCREEN and must not+ be the same word.+ """+ if getattr(term, "last_submit_at", None):+ return True+ try:+ return int(getattr(term, "prompts_sent", 0) or 0) > 0+ except (TypeError, ValueError): # a test double may carry anything+ return False++__all__ = ["ASK_FRAGMENTS",+ "NO_READING","SETTLED",+ "STAMP_FRESH_S","STILL_S","TAIL_ROWS","Activity",+ "Reading",+ "has_been_tasked","is_settled",+ "observed","read_activity","screen_digest","shows_question",+ "stamp","visible_rows",]diff --git a/jarvis/agentic_ide/notifications.py b/jarvis/agentic_ide/notifications.pyindex 594822143b..ade739487b 100644--- a/jarvis/agentic_ide/notifications.py+++ b/jarvis/agentic_ide/notifications.py@@ -94,7 +94,15 @@ from typing import TYPE_CHECKING, Any, Literal, NamedTuplefrom loguru import logger-from .activity import STILL_S, Activity, is_settled, read_activity, screen_digest+from .activity import (+ STILL_S,+ Activity,+ has_been_tasked,+ is_settled,+ read_activity,+ screen_digest,+ stamp,+)if TYPE_CHECKING: # pragma: no cover - typing onlyfrom collections.abc import Iterable, Mapping@@ -472,6 +480,7 @@ class ActivityWatcher:process_generation=process_generation,)self._panes[ident] = watch+ stamp(term, activity, now=now)self._checkpoint_resume_state(term, activity, watch, now)return None@@ -497,6 +506,11 @@ class ActivityWatcher:watch.since = nowwatch.announced = False+ # Publish the reading before deciding whether it is worth a bell entry.+ # The pane list shows this on every pane, all the time, while an entry+ # is filed once per episode and only for the few states that are news —+ # so an early return below must never cost the UI its status.+ stamp(term, activity, now=now)self._checkpoint_resume_state(term, activity, watch, now)if watch.announced:@@ -607,20 +621,13 @@ class ActivityWatcher:def _tasked(term: Any) -> bool:"""Has anybody ever given this pane an instruction?- Two proofs, because a pane can be driven two ways and both count. A- timestamp from the moment something was submitted into it — by Jarvis or by- a person pressing Enter — and the counter of prompts Jarvis has sent, which- is the half that survives into a restored workspace where the timestamp does- not. A pane typed into by hand before a restart therefore starts its next- life unproven, and stays quiet until the next thing is typed into it: a- missing notice, rather than an invented one.+ The rule itself lives in :func:`~.activity.has_been_tasked`, because the+ pane list asks the same question for the same reason: a still screen means+ "finished" only for a pane that was given something to finish, and+ "untouched" for one that never was. Two copies of that rule would drift into+ a bell that reports a completion the pane list calls idle."""- if getattr(term, "last_submit_at", None):- return True- try:- return int(getattr(term, "prompts_sent", 0) or 0) > 0- except (TypeError, ValueError): # a test double may carry anything- return False+ return has_been_tasked(term)def _is_agent(term: Any) -> bool:diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.pyindex 14110dafb4..575c83ae09 100644--- a/jarvis/agentic_ide/session.py+++ b/jarvis/agentic_ide/session.py@@ -79,6 +79,7 @@ from loguru import loggerfrom jarvis.workspace import agents as workspace_agentsfrom . import prompt_history, recap_engine, resume_store+from .activity import NO_READING, Reading, has_been_tasked, observedfrom .agent_sessions import (ResumeHandle,can_resume,@@ -935,6 +936,21 @@ class Terminal:# looks, never a single one), cleared on every spawn. Never persisted — it# describes the process now running in the pane.idle_seen: bool = False+ # What this pane is DOING, as the activity sweep last observed it: working,+ # waiting, asking, starting, exited, failed (see `.activity`). Empty until+ # the first sweep has looked at this pane, and for a plain terminal, which+ # runs no agent and therefore has no job to be in the middle of.+ #+ # Stamped here rather than kept inside the sweep because whether a screen is+ # MOVING can only be seen across two looks, and everything else that wants+ # the answer — the workspace state, the pane list's poll — is a request+ # handler with exactly one look. `activity_at` is when the observation was+ # taken (so a reader can tell a live reading from one left behind by a sweep+ # that has since died), `activity_since` when the pane entered this state+ # (so "waiting" can be shown with how long it has been waiting).+ activity: str = ""+ activity_at: float = 0.0+ activity_since: float = 0.0# Monotonic identity for the process currently occupying this pane. The# notification watcher outlives PTYs, so it uses this to discard the old# process's screen fingerprint before interpreting a replacement process.@@ -1029,6 +1045,7 @@ class Terminal:# by the /recaps poll, which is the caller that knows a human is# actually looking at this workspace.summary = recap_engine.recap_for(self, lines=lines)+ reading = self.reading()return {"key": self.key,"name": self.name,@@ -1076,6 +1093,15 @@ class Terminal:# see .recap for why it is computed on read."recap": summary.headline,"recap_detail": summary.detail,+ # Is this pane's agent still on the job, or has it stopped? See+ # `.reading` — the one question the pane list could not answer, and+ # the reason it used to say "live" at a terminal that had been+ # finished for twenty minutes. Empty for a plain shell.+ "activity": reading.activity,+ "activity_since": reading.since,+ # Whether a still screen means "finished" or "never asked for+ # anything" — the same picture, and not the same news.+ "tasked": has_been_tasked(self),"resumed": self.resumed,# Continued its old conversation and has had no instruction since —# the pane a restart left standing still. Carried in the ordinary@@ -1090,6 +1116,22 @@ class Terminal:"account_label": account_label(self.account),}+ def reading(self) -> Reading:+ """Is this pane's agent working, or has it stopped — and since when?++ One place, because two clients ask: the workspace state (what a pane+ opens with) and the pane-list poll (what it says from then on), and a+ pane described as working by one and finished by the other is worse than+ either answer alone.++ A plain terminal reads as nothing at all. It is a shell prompt, not an+ agent: it stands still for its whole life, so every word this vocabulary+ has would be a claim about a job it was never given.+ """+ if not accepts_prompts(self.agent):+ return NO_READING+ return observed(self)+def to_snapshot(self) -> resume_store.SnapshotTerminal:"""This pane as the resume store remembers it."""return resume_store.SnapshotTerminal(diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.pyindex c08c87ebeb..c7aac61401 100644--- a/jarvis/ui/web/agentic_ide_routes.py+++ b/jarvis/ui/web/agentic_ide_routes.py@@ -72,6 +72,7 @@ from jarvis.agentic_ide import (recents,resume_store,)+from jarvis.agentic_ide.activity import has_been_taskedfrom jarvis.agentic_ide.agent_sessions import has_conversationfrom jarvis.agentic_ide.device import device_namefrom jarvis.agentic_ide.fleet_actions import (@@ -884,6 +885,33 @@ class TerminalRecap(BaseModel):"transcript-derived recap, which is recomputed on every read."),)+ activity: str = Field(+ default="",+ description=(+ "Whether this pane's agent is still on the job: 'working' (its "+ "screen is moving), 'waiting' (alive and standing still), 'asking' "+ "(standing still with a question on screen), 'starting', 'exited' "+ "or 'failed'. Read from the terminal itself rather than from "+ "anything a particular CLI prints, so it holds for every coding CLI "+ "a pane can run, including ones added later. Empty for a plain "+ "terminal, which runs no agent."+ ),+ )+ activity_since: float = Field(+ default=0.0,+ description=(+ "When the pane entered that state (epoch seconds), so 'waiting' can "+ "be shown with how long it has been waiting. 0 when unknown."+ ),+ )+ tasked: bool = Field(+ default=False,+ description=(+ "Has this pane ever been given an instruction? It is what separates "+ "an agent that FINISHED from a terminal nobody has asked for "+ "anything — the same still screen, and not the same news."+ ),+ )class RecapsResponse(BaseModel):@@ -1957,6 +1985,7 @@ def _recap_row(term: Terminal, summary: recap_engine.SmartRecap) -> TerminalRecainto describing the same pane differently — the drift class §5 calls out,on a payload that is read four times a minute."""+ reading = term.reading()return TerminalRecap(key=term.key,name=term.name,@@ -1968,6 +1997,12 @@ def _recap_row(term: Terminal, summary: recap_engine.SmartRecap) -> TerminalRecawriter=summary.writer,note=summary.note,generated_at=summary.generated_at,+ # This poll is what keeps the pane list current, so it carries what the+ # pane is DOING as well as what it is doing it about. Both come from the+ # pane itself; neither is recomputed here, or the two would drift.+ activity=reading.activity,+ activity_since=reading.since,+ tasked=has_been_tasked(term),)diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsxindex e17fac1364..89b9a9eec0 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx@@ -185,7 +185,6 @@ vi.mock("./AgenticTerminal", () => ({</div>);},- PaneStatusPill: () => <span>live</span>,}));import { AgenticGrid } from "./AgenticGrid";@@ -823,7 +822,7 @@ describe("selecting several terminals", () => {session: sessionWith([["Nova", 0]]),});renderGrid();- fireEvent.click(screen.getByRole("button", { name: /Nova live/i }));+ fireEvent.click(screen.getByTestId("prompt-target-Nova"));fireEvent.click(screen.getByTestId("terminal-selection-toggle"));fireEvent.click(screen.getByRole("button", { name: "Select all" }));fireEvent.click(screen.getByTestId("close-selected-terminals"));diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsxindex f53384909f..2ecaadd697 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx@@ -50,10 +50,10 @@ import { PaneResizer } from "@/components/layout/PaneResizer";import { useEventStore } from "@/store/events";import {AgenticTerminal,- PaneStatusPill,type PaneStatus,type SplitDirection,} from "./AgenticTerminal";+import { PaneActivityPill } from "./PaneActivityPill";import {AgentPickerMenu,offersAgentChoice,@@ -671,6 +671,24 @@ export function AgenticGrid({};}, [session.id, pollRecaps]);+ /*+ * Is this pane's agent still working, or has it stopped?+ *+ * The same two sources as the recap beside it, for the same reason: the+ * workspace state carries an opening value so a pane never renders a blank+ * badge, and the five-second poll keeps it true from then on. Both come+ * straight from the pane — nothing is derived here, or two views of one+ * terminal would disagree about whether it is busy.+ */+ const activityOf = (term: TerminalState) => {+ const row = recaps[term.name];+ return {+ activity: row?.activity ?? term.activity ?? "",+ since: row?.activity_since ?? term.activity_since ?? 0,+ tasked: row?.tasked ?? term.tasked ?? false,+ };+ };+/** The three things a user may do about a pane's recap.*@@ -1885,9 +1903,13 @@ export function AgenticGrid({<span className="min-w-0 flex-1 truncate text-xs font-semibold">{term.display_name || term.name}</span>- <PaneStatusPill+ {/* Not "live". Every pane in this list is live, all day —+ what the user is scanning for is which of them still+ owes them something. See ./PaneActivityPill. */}+ <PaneActivityPillstatus={state?.status ?? "connecting"}detail={state?.detail}+ {...activityOf(term)}/></span>{headline && (@@ -1932,10 +1954,12 @@ export function AgenticGrid({ref={canvasRef}data-testid="agentic-grid-canvas"className={cn(- "relative",- // The chat stage is a centred column — one conversation-sized card- // rather than a surface stretched across a widescreen window.- chatView ? "mx-auto h-full w-full max-w-[1100px]" : "w-full",+ "relative w-full",+ // The chat stage fills everything between the rail and the voice+ // column. It started as a centred, capped column; the maintainer+ // wants the terminal at full size (2026-07-31), and the calm framing+ // comes from the rail and the card border, not from margins.+ chatView && "h-full",)}style={{ height: chatView ? undefined : canvasHeight || undefined }}>@@ -2305,6 +2329,7 @@ export function AgenticGrid({<buttonkey={term.key}type="button"+ data-testid={`prompt-target-${term.name}`}onClick={() => setTarget(term.name)}aria-pressed={target === term.name}className={cn(@@ -2315,7 +2340,11 @@ export function AgenticGrid({)}><span className="font-medium">{term.name}</span>- <PaneStatusPill status={state?.status ?? "connecting"} detail={state?.detail} />+ <PaneActivityPill+ status={state?.status ?? "connecting"}+ detail={state?.detail}+ {...activityOf(term)}+ /></button>);})}diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsxindex 225aeedcf5..5ced1053f4 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx@@ -49,9 +49,7 @@ import { CanvasAddon } from "@xterm/addon-canvas";import { Unicode11Addon } from "@xterm/addon-unicode11";import "@xterm/xterm/css/xterm.css";import {- AlertCircle,Check,- Circle,Columns2,Loader2,Maximize2,@@ -1723,50 +1721,10 @@ function PaneAction({);}-/** Small status pill reused by the grid toolbar. */-export function PaneStatusPill({- status,- detail,-}: {- status: PaneStatus;- detail?: string;-}) {- if (status === "live") {- return (- <span- className="flex items-center gap-1 text-[11px] text-emerald-400"- title={detail}- >- <Circle className="h-2 w-2 fill-current" />- live- </span>- );- }- if (status === "error") {- return (- <span- className="flex items-center gap-1 text-[11px] text-destructive"- title={detail}- >- <AlertCircle className="h-3 w-3" />- error- </span>- );- }- if (status === "exited") {- return (- <span className="text-[11px] text-muted-foreground" title={detail}>- exited- </span>- );- }- return (- <span- className="flex items-center gap-1 text-[11px] text-muted-foreground"- title={detail}- >- <Loader2 className="h-3 w-3 animate-spin" />- starting- </span>- );-}+/*+ * The pane badge used to live here and reported the SOCKET: "live" for any pane+ * with a working pipe, which is nearly all of them nearly all of the time. It+ * moved to ./PaneActivityPill, which answers the question people were actually+ * reading it for — is this agent still working — and still reports the pipe in+ * the three cases where the pipe is the news.+ */diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneActivityPill.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneActivityPill.test.tsxnew file mode 100644index 0000000000..cf52f2240b--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneActivityPill.test.tsx@@ -0,0 +1,121 @@+/**+ * The badge that stopped saying "live".+ *+ * Every case here is about a pane the OLD badge described identically: socket+ * up, process alive, `live` — while one was mid-refactor, one had been finished+ * for twenty minutes, and one was sitting on an unanswered question. Telling+ * those apart is the entire feature, so the tests are about the distinctions+ * rather than about the markup.+ */+import { describe, expect, it } from "vitest";+import { render, screen } from "@testing-library/react";+import { PaneActivityPill, durationLabel } from "./PaneActivityPill";++/** The clock the tests read, so nothing here races the wall. */+const NOW_MS = 1_700_000_000_000;+const NOW_S = NOW_MS / 1000;++function pill(props: Parameters<typeof PaneActivityPill>[0]) {+ render(<PaneActivityPill {...props} now={NOW_MS} />);+ return screen.getByTestId("pane-activity");+}++describe("what the badge says", () => {+ it("says the agent is working while its screen moves", () => {+ expect(pill({ status: "live", activity: "working" }).textContent).toBe(+ "working",+ );+ });++ it("says done for a pane that was given a job and has stopped", () => {+ expect(+ pill({ status: "live", activity: "waiting", tasked: true }).textContent,+ ).toBe("done");+ });++ it("says idle — never done — for a pane nobody has instructed", () => {+ // The SAME still screen as the case above. Calling it "done" would invent a+ // job for a terminal that was never given one, and read as "your work is+ // ready" on a pane that has done none.+ expect(+ pill({ status: "live", activity: "waiting", tasked: false }).textContent,+ ).toBe("idle");+ });++ it("calls out a pane that is waiting for an answer", () => {+ expect(pill({ status: "live", activity: "asking" }).textContent).toBe(+ "needs you",+ );+ });++ it("reports an agent that could not be started", () => {+ expect(pill({ status: "live", activity: "failed" }).textContent).toBe(+ "failed",+ );+ });++ it("reports an agent whose process is gone", () => {+ expect(pill({ status: "live", activity: "exited" }).textContent).toBe(+ "exited",+ );+ });+});++describe("when the pipe is the news", () => {+ it("reports a socket that is still connecting", () => {+ // Whatever the last known activity was, it describes a pane this viewer is+ // not connected to yet — the connection is what the user can act on.+ expect(+ pill({ status: "connecting", activity: "working" }).textContent,+ ).toBe("starting");+ });++ it("reports a broken pane, and says what broke in the tooltip", () => {+ const badge = pill({ status: "error", detail: "Socket closed." });+ expect(badge.textContent).toBe("error");+ expect(badge.getAttribute("title")).toContain("Socket closed.");+ });++ it("falls back to the old badge for a pane with no reading", () => {+ // A plain terminal runs no agent, so it has no job to be in the middle of,+ // and the backend answers with no activity at all. The honest thing left to+ // say is that the pipe is up.+ expect(pill({ status: "live", activity: "" }).textContent).toBe("live");+ });+});++describe("how long it has been that way", () => {+ it("puts the duration in the tooltip, never in the badge", () => {+ // The badge sits in a narrow column beside a call-sign; a number that+ // changes every second there is movement without information.+ const badge = pill({+ status: "live",+ activity: "waiting",+ tasked: true,+ since: NOW_S - 180,+ });+ expect(badge.textContent).toBe("done");+ expect(badge.getAttribute("title")).toContain("For 3 min.");+ });++ it("says nothing about timing when the backend does not know", () => {+ const badge = pill({ status: "live", activity: "working", since: 0 });+ expect(badge.getAttribute("title")).not.toContain("For");+ });++ it("reads as a duration rather than a moment", () => {+ expect(durationLabel(NOW_S - 12, NOW_MS)).toBe("12s");+ expect(durationLabel(NOW_S - 200, NOW_MS)).toBe("3 min");+ expect(durationLabel(NOW_S - 3600, NOW_MS)).toBe("1 hour");+ // A stamp from the future is a clock disagreement, not negative time.+ expect(durationLabel(NOW_S + 500, NOW_MS)).toBe("0s");+ });+});++describe("what a screen reader hears", () => {+ it("carries the word and the sentence behind it", () => {+ const badge = pill({ status: "live", activity: "working" });+ expect(badge.getAttribute("aria-label")).toContain("working");+ expect(badge.getAttribute("aria-label")).toContain("screen is still");+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneActivityPill.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneActivityPill.tsxnew file mode 100644index 0000000000..de4489d699--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneActivityPill.tsx@@ -0,0 +1,230 @@+import { AlertCircle, Check, CircleDot, HelpCircle, Loader2 } from "lucide-react";+import { cn } from "@/lib/utils";+import type { PaneActivity } from "@/lib/agenticIdeApi";++/**+ * The one badge on a pane: is anybody still owed something by this terminal?+ *+ * ## The question it replaced+ *+ * Every pane used to be labelled `live`, which answers a question nobody was+ * asking. `live` is a property of the PIPE — the socket is up and a process is+ * on the other end — and it stays true for a terminal that finished its work+ * twenty minutes ago, for one sitting on an unanswered permission prompt, and+ * for one grinding through a refactor. In a chat-mode list of a dozen agents,+ * that is a column of identical green dots next to twelve panes in completely+ * different states, and the user has to open each one to find out which.+ *+ * What a person actually wants to know is whether the agent is still WORKING or+ * has STOPPED, and this pill answers that instead. The pipe is still reported,+ * but only when it has something to say (connecting, exited, broken) — a+ * healthy connection is the boring case and is now spent on the useful claim.+ *+ * ## Why it holds for every coding CLI, including ones added later+ *+ * The distinction is not made here and not made from anything a product prints.+ * The backend derives it from the terminal SCREEN — a pane whose picture keeps+ * changing is working, a pane that stands still has stopped — which is a+ * property of the terminal rather than of whatever is running inside it. Two+ * earlier attempts read Claude Code's interrupt hint and Codex's bracketed+ * clock, and each broke on the next product and on the next release of its own.+ * See `jarvis/agentic_ide/activity.py`, which measured all four installed CLIs+ * before committing to the rule.+ *+ * So a CLI connected next year gets a working status pill with no code here,+ * and none there either.+ *+ * ## Why "done" and "idle" are not the same word+ *+ * A finished agent and a terminal nobody has ever spoken to show the SAME still+ * screen. Calling both "done" would invent a job for the second one, and be+ * read as "your work is ready" for a pane that has done none. `tasked` — has+ * anything ever been sent here — is what separates them, and it is the same+ * evidence the notification bell uses before claiming a pane completed+ * anything.+ *+ * Nothing here claims the work is CORRECT. "done" means the pane went quiet,+ * which is all a terminal can prove.+ */++/** What each activity is called on screen, and how it is drawn. */+type Look = {+ label: string;+ className: string;+ icon: "spinner" | "check" | "dot" | "ask" | "alert" | "none";+ /** The sentence behind the badge, minus the timing clause. */+ hint: string;+};++/**+ * Every state a pane can be in, in the user's words.+ *+ * A `Record` over the whole vocabulary rather than a chain of `if`s: a value+ * added to the Python `Activity` literal fails to compile here until it is+ * given a label, which is the drift this repo has been bitten by five times+ * (§5). `waiting` carries two looks because it is two different pieces of news+ * — see the module docstring.+ */+const LOOK: Record<Exclude<PaneActivity, "" | "waiting">, Look> = {+ working: {+ label: "working",+ className: "text-amber-400",+ icon: "spinner",+ hint: "Working — its screen is still changing.",+ },+ starting: {+ label: "starting",+ className: "text-muted-foreground",+ icon: "spinner",+ hint: "Starting up. Its agent has not taken the pane yet.",+ },+ asking: {+ label: "needs you",+ className: "text-amber-400",+ icon: "ask",+ hint: "Stopped with a question on screen. It is waiting for your answer.",+ },+ exited: {+ label: "exited",+ className: "text-muted-foreground",+ icon: "none",+ hint: "Its process is gone.",+ },+ failed: {+ label: "failed",+ className: "text-destructive",+ icon: "alert",+ hint: "Its agent could not be started.",+ },+};++const DONE: Look = {+ label: "done",+ className: "text-emerald-400",+ icon: "check",+ hint: "Finished and waiting at its prompt. That it stopped, not that the work is right.",+};++const IDLE: Look = {+ label: "idle",+ className: "text-muted-foreground",+ icon: "dot",+ hint: "Waiting at its prompt. Nothing has been sent to it yet.",+};++/** The pipe, for the three cases where the pipe is the news. */+const CONNECTING: Look = {+ label: "starting",+ className: "text-muted-foreground",+ icon: "spinner",+ hint: "Connecting to the pane.",+};++const EXITED: Look = {+ label: "exited",+ className: "text-muted-foreground",+ icon: "none",+ hint: "Its process is gone.",+};++const BROKEN: Look = {+ label: "error",+ className: "text-destructive",+ icon: "alert",+ hint: "This pane could not be reached.",+};++/**+ * A live pipe with nothing else known yet.+ *+ * The old badge, kept for exactly two panes: a plain terminal, which is a shell+ * prompt and has no job to be in the middle of, and an agent pane in the second+ * before its first status poll answers.+ */+const CONNECTED: Look = {+ label: "live",+ className: "text-emerald-400",+ icon: "dot",+ hint: "Connected.",+};++function lookFor(+ status: string,+ activity: PaneActivity,+ tasked: boolean,+): Look {+ if (status === "error") return BROKEN;+ if (status === "exited") return EXITED;+ if (status !== "live") return CONNECTING;+ if (activity === "waiting") return tasked ? DONE : IDLE;+ if (activity === "") return CONNECTED;+ return LOOK[activity];+}++/**+ * How long it has been in this state — "45s", "3 min", "2 hours".+ *+ * A DURATION, not a moment: "waiting since 14:02" makes the reader do the+ * subtraction, and the number they actually want is how long they have been+ * waiting. Rounded on purpose; a pill is a glance, not a stopwatch.+ */+export function durationLabel(since: number, now: number): string {+ const seconds = Math.max(0, Math.round(now / 1000 - since));+ if (seconds < 60) return `${seconds}s`;+ const minutes = Math.round(seconds / 60);+ if (minutes < 60) return `${minutes} min`;+ const hours = Math.round(minutes / 60);+ return hours === 1 ? "1 hour" : `${hours} hours`;+}++function Icon({ look }: { look: Look }) {+ if (look.icon === "spinner")+ return <Loader2 className="h-3 w-3 animate-spin" />;+ if (look.icon === "check") return <Check className="h-3 w-3" />;+ if (look.icon === "dot") return <CircleDot className="h-2.5 w-2.5" />;+ if (look.icon === "ask") return <HelpCircle className="h-3 w-3" />;+ if (look.icon === "alert") return <AlertCircle className="h-3 w-3" />;+ return null;+}++export function PaneActivityPill({+ status,+ detail,+ activity = "",+ since = 0,+ tasked = false,+ now,+}: {+ /** The socket's own view: `connecting`, `live`, `exited`, `error`. */+ status: string;+ /** Whatever the socket said about that, shown in the tooltip. */+ detail?: string;+ activity?: PaneActivity;+ /** When the pane entered this state (epoch seconds); 0 when unknown. */+ since?: number;+ /** Has this pane ever been given an instruction? */+ tasked?: boolean;+ /** Injectable clock, in milliseconds — the tests do not race the wall. */+ now?: number;+}) {+ const look = lookFor(status, activity, tasked);+ // How long it has been in this state, when the backend knows. Only in the+ // tooltip: the badge itself sits in a 64-pixel column beside a call-sign, and+ // a number that changes every second there is movement without information.+ const elapsed = since > 0 ? durationLabel(since, now ?? Date.now()) : "";+ const title = [look.hint, elapsed && `For ${elapsed}.`, detail]+ .filter(Boolean)+ .join(" ");+ return (+ <span+ data-testid="pane-activity"+ data-activity={activity || status}+ className={cn("flex items-center gap-1 text-[11px]", look.className)}+ title={title}+ aria-label={`${look.label}. ${title}`}+ >+ <Icon look={look} />+ {look.label}+ </span>+ );+}diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.tsindex 3eaa30bf51..84d49391e5 100644--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts@@ -139,8 +139,38 @@ export interface TerminalState {recap?: string;/** The one-or-two-sentence version, shown when the header line is hovered. */recap_detail?: string;+ /** Is its agent still on the job? The OPENING value, like `recap` above. */+ activity?: PaneActivity;+ /** When it entered that state (epoch seconds); 0 when unknown. */+ activity_since?: number;+ /** Has this pane ever been given an instruction? */+ tasked?: boolean;}+/**+ * Whether a pane's agent is still on the job.+ *+ * Deliberately NOT the same question as `TerminalState.status`, which is about+ * the pipe: a pane can be perfectly "live" and have been finished for twenty+ * minutes, and that gap is the whole reason this exists.+ *+ * The backend derives it from the terminal SCREEN — a pane whose picture keeps+ * changing is working, one that stands still has stopped — so it holds for every+ * coding CLI a pane can run, including ones connected later. It knows nothing+ * about what any product prints. See `jarvis/agentic_ide/activity.py`.+ *+ * `""` means "no answer for this pane": a plain terminal is a shell prompt, not+ * an agent, so it has no job to be in the middle of.+ */+export type PaneActivity =+ | "starting"+ | "working"+ | "waiting"+ | "asking"+ | "failed"+ | "exited"+ | "";+/*** Who wrote the recap on screen.*@@ -182,6 +212,21 @@ export interface TerminalRecap {note?: string;/** When the model wrote it, or when the user did. 0 for the derived one. */generated_at?: number;+ /**+ * Is its agent still on the job, or has it stopped? This poll is what keeps+ * the pane list current, so it carries what the pane is DOING as well as what+ * it is doing it about.+ */+ activity?: PaneActivity;+ /** When it entered that state (epoch seconds); 0 when unknown. */+ activity_since?: number;+ /**+ * Has this pane ever been given an instruction?+ *+ * What separates "this agent finished" from "nobody has asked this terminal+ * for anything" — the same still screen, and not the same news.+ */+ tasked?: boolean;}export interface RecapsResponse {diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsxindex 20dd4ffa44..b156808f53 100644--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx@@ -61,7 +61,6 @@ vi.mock("@/components/agentic/AgenticTerminal", () => ({AgenticTerminal: ({ name }: { name: string }) => (<div data-testid={`pane-${name}`}>{name}</div>),- PaneStatusPill: () => <span>live</span>,}));vi.mock("@/lib/agenticIdeApi", () => ({diff --git a/tests/unit/agentic_ide/test_pane_activity_parity.py b/tests/unit/agentic_ide/test_pane_activity_parity.pynew file mode 100644index 0000000000..796f5d7a0c--- /dev/null+++ b/tests/unit/agentic_ide/test_pane_activity_parity.py@@ -0,0 +1,74 @@+"""Cross-layer parity guard for the pane activity vocabulary.++The words a pane can be in ("working", "waiting", …) cross four layers: the+Python literal that produces them, the Pydantic field that ships them, the+TypeScript union that types them and the label map that turns each one into+something a person reads. CLAUDE.md §5 exists because a value added to one layer+and forgotten in another is this repo's most-repeated bug — and the failure mode+here is quiet: an unknown word reaches a `Record` lookup, the badge renders+nothing, and a pane silently loses its status.++The panes have no database, so the SQL layer collapses; the four that exist are+all pinned here.+"""++from __future__ import annotations++import re+from pathlib import Path+from typing import get_args++from jarvis.agentic_ide.activity import Activity+from jarvis.ui.web.agentic_ide_routes import TerminalRecap++_REPO = Path(__file__).resolve().parents[3]+_FRONTEND = _REPO / "jarvis" / "ui" / "web" / "frontend" / "src"+_API = _FRONTEND / "lib" / "agenticIdeApi.ts"+_PILL = _FRONTEND / "components" / "agentic" / "PaneActivityPill.tsx"+++def _ts_activities() -> set[str]:+ text = _API.read_text(encoding="utf-8")+ match = re.search(r"export type PaneActivity\s*=([^;]+);", text)+ assert match is not None, "TypeScript PaneActivity union is missing"+ return set(re.findall(r'"([^"]*)"', match.group(1)))+++def _ui_labelled() -> set[str]:+ """Every word the badge can draw, however it is drawn.++ The `LOOK` record covers all but ``waiting``, which is deliberately two+ looks — "done" for a pane that was given a job, "idle" for one that was not+ — and is therefore matched separately rather than being allowed to vanish.+ """+ text = _PILL.read_text(encoding="utf-8")+ match = re.search(r"> = \{(.*?)\n\};", text, flags=re.DOTALL)+ assert match is not None, "PaneActivityPill LOOK map is missing"+ labelled = set(re.findall(r"^\s{2}([a-z]+):", match.group(1), flags=re.MULTILINE))+ assert 'if (activity === "waiting")' in text, "the waiting split is gone"+ return labelled | {"waiting"}+++def test_activity_python_typescript_and_ui_parity() -> None:+ python_words = set(get_args(Activity))+ # The empty word is a TypeScript-side addition: "this vocabulary does not+ # describe this pane" (a plain shell). It is not an activity.+ assert _ts_activities() - {""} == python_words+ assert _ui_labelled() == python_words+++def test_the_route_ships_the_reading() -> None:+ """A word nothing carries is a word the UI never sees."""+ assert {"activity", "activity_since", "tasked"} <= set(TerminalRecap.model_fields)+++def test_activity_expected_vocabulary() -> None:+ """Pinned, so widening the vocabulary is a deliberate act with a diff."""+ assert set(get_args(Activity)) == {+ "starting",+ "working",+ "waiting",+ "asking",+ "failed",+ "exited",+ }diff --git a/tests/unit/agentic_ide/test_pane_activity_status.py b/tests/unit/agentic_ide/test_pane_activity_status.pynew file mode 100644index 0000000000..0588030312--- /dev/null+++ b/tests/unit/agentic_ide/test_pane_activity_status.py@@ -0,0 +1,223 @@+"""What the pane list shows instead of "live".++The badge beside every pane used to report the SOCKET, which is up for a pane+that finished twenty minutes ago, for one sitting on an unanswered question, and+for one grinding through a refactor. These tests are about the claim that+replaced it: is this pane's agent still working, and how does that reach a+client.++Three properties, and each one has an obvious wrong implementation:++* the reading is taken from the terminal SCREEN, so it holds for every coding+ CLI a pane can run — including one connected next year, which is why the cases+ are parametrized over the installed products rather than written against one;+* a request handler gets the SWEEP's reading rather than its own single look,+ because whether a screen is moving cannot be seen from one look at it;+* and a still screen is only called "finished" for a pane that was given+ something to finish.+"""++from __future__ import annotations++import time+from pathlib import Path+from typing import Any++import pytest++from jarvis.agentic_ide import notifications+from jarvis.agentic_ide import session as session_mod+from jarvis.agentic_ide.activity import STAMP_FRESH_S, observed+from jarvis.agentic_ide.session import PLAIN_TERMINAL, Registry+from tests.fakes.fake_pty_manager import FakePtyManager++# Screens copied off the real products, exactly as the notification tests use+# them: four CLIs that look nothing like each other, read by one rule.+REST_SCREENS = {+ "claude": "\r\n✻ Worked for 13m 27s\r\n>\r\n 📁 probe-repo 🌿 main Opus 5\r\n",+ "codex": "\r\n• ping\r\n› Improve documentation in @filename\r\n gpt-5.6-sol xhigh fast\r\n",+ "opencode": "\r\n ┃ Build · Nano Banana Pro Google\r\n tab agents ctrl+p commands\r\n",+ "kimi": '\r\n ✦ Use Kimi K3\r\n Error: LLM not set, send "/login" to login\r\n │ > \r\n',+}++[email protected](autouse=True)+def _clean_store() -> Any:+ notifications.reset()+ yield+ notifications.reset()+++def registry(monkeypatch: pytest.MonkeyPatch) -> Registry:+ monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))+ return Registry(pty_manager=FakePtyManager())+++async def _noop(_text: str) -> None:+ return None+++async def _noop_exit(_code: int) -> None:+ return None+++async def _pane(registry: Registry, folder: Path, *, name: str = "Alex", agent: str = "claude"):+ session = await registry.start(str(folder), [{"agent": agent, "name": name}])+ term = await registry.attach(name, 100, 30, _noop, _noop_exit)+ term.last_output_at = 0.0+ term.last_input_at = None+ return session, term+++def _sweep(registry: Registry, at: float) -> None:+ """One pass of the watcher that publishes what every pane is doing."""+ notifications.watcher().poll(registry, now=at, emit=False)+++def _watched(registry: Registry, term: Any, *, moves: bool) -> None:+ """Two sweeps on the REAL clock — one look cannot see movement.++ Wall clock rather than a synthetic timeline, because these cases end at+ ``to_dict``, which is a request handler and reads the clock a request+ actually happens on. A stamp from an invented year is one this module is+ right to distrust (`test_a_reading_nobody_refreshed_is_not_trusted`).+ """+ now = time.time()+ _sweep(registry, now - notifications.SWEEP_INTERVAL_S)+ if moves:+ term.transcript.feed("\r\n· one more line\r\n")+ _sweep(registry, now)+++# ------------------------------------------------------ every CLI, one rule++[email protected]("agent,screen", list(REST_SCREENS.items()))+async def test_a_finished_pane_is_reported_as_waiting_whatever_it_runs(+ registry: Registry, tmp_path: Path, agent: str, screen: str+) -> None:+ """A pane whose picture stands still has stopped — for all four products."""+ _session, term = await _pane(registry, tmp_path, agent=agent, name="Px")+ term.transcript.feed(screen)++ _watched(registry, term, moves=False)++ assert term.to_dict()["activity"] == "waiting"++[email protected]("agent,screen", list(REST_SCREENS.items()))+async def test_a_moving_pane_is_reported_as_working_whatever_it_runs(+ registry: Registry, tmp_path: Path, agent: str, screen: str+) -> None:+ """And one whose picture keeps changing is still on the job."""+ _session, term = await _pane(registry, tmp_path, agent=agent, name="Px")+ term.transcript.feed(screen)++ _watched(registry, term, moves=True)++ assert term.to_dict()["activity"] == "working"+++# --------------------------------------------- the reading reaches a client+++async def test_the_state_carries_what_the_sweep_saw(registry: Registry, tmp_path: Path) -> None:+ """A request handler cannot see movement, so it reports what the sweep saw.++ The whole reason the reading is stamped on the pane: one look at a terminal+ cannot tell a still screen from a moving one, and every client of this is a+ single look.+ """+ _session, term = await _pane(registry, tmp_path)+ term.transcript.feed("\r\n· Scurrying… (2m 4s)\r\n")+ _sweep(registry, 500.0)+ term.transcript.clear()+ term.transcript.feed("\r\n· Scurrying… (2m 6s)\r\n")+ _sweep(registry, 502.0)++ reading = observed(term, now=503.0)++ assert reading.activity == "working"+ assert reading.since == 502.0+++async def test_a_reading_nobody_refreshed_is_not_trusted(+ registry: Registry, tmp_path: Path+) -> None:+ """A stamp that stopped being refreshed means nothing is watching.++ Not a stale word to keep showing: the sweep runs every two seconds for as+ long as a workspace is open, so a stamp minutes old says the sweep died or+ never started. The caller gets a fresh single look instead — which, for a+ pane that has printed nothing in a while, is "waiting".+ """+ _session, term = await _pane(registry, tmp_path)+ term.transcript.feed("\r\n· Scurrying…\r\n")+ _sweep(registry, 500.0)+ _sweep(registry, 502.0)+ assert term.activity == "waiting"+ term.activity = "working" # a word the sweep left behind and never renewed++ assert observed(term, now=502.0 + STAMP_FRESH_S + 1).activity == "waiting"+++async def test_a_plain_terminal_is_not_described_as_finished(+ registry: Registry, tmp_path: Path+) -> None:+ """A shell prompt runs no agent, so every word here would be a lie.++ It stands perfectly still for its whole life, which is what "finished" looks+ like — and it has never been given a job to finish. The pane list falls back+ to reporting the connection for it.+ """+ _session, term = await _pane(registry, tmp_path, agent=PLAIN_TERMINAL, name="Shell")+ term.transcript.feed("\r\nC:\\probe-repo> \r\n")+ _watched(registry, term, moves=False)++ assert term.to_dict()["activity"] == ""+++# ------------------------------------------- finished, versus never asked+++async def test_a_pane_nobody_instructed_is_not_called_finished(+ registry: Registry, tmp_path: Path+) -> None:+ """Same still screen, different news — so the client is told which."""+ _session, term = await _pane(registry, tmp_path)+ term.transcript.feed(REST_SCREENS["claude"])+ _watched(registry, term, moves=False)++ state = term.to_dict()++ assert state["activity"] == "waiting"+ assert state["tasked"] is False+++async def test_a_pane_that_was_given_a_job_is(registry: Registry, tmp_path: Path) -> None:+ """And a pane somebody typed into carries the evidence for "finished"."""+ _session, term = await _pane(registry, tmp_path)+ term.last_submit_at = time.time() - 60+ term.transcript.feed(REST_SCREENS["claude"])+ _watched(registry, term, moves=False)++ assert term.to_dict()["tasked"] is True+++async def test_the_two_readings_of_one_pane_agree(registry: Registry, tmp_path: Path) -> None:+ """The workspace state and the pane-list poll describe the same pane alike.++ They are two different reads on two different clocks, and a pane the grid+ calls working while the list calls it finished is worse than either answer+ on its own — the drift class §5 exists for exactly this.+ """+ _session, term = await _pane(registry, tmp_path)+ term.transcript.feed("\r\n· Scurrying…\r\n")+ _watched(registry, term, moves=True)++ state = term.to_dict()+ reading = term.reading()++ assert state["activity"] == reading.activity+ assert state["activity_since"] == reading.since