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): only call a pane finished when it was given something to do
Ruben Lütke24c35c93a225
diff --git a/jarvis/agentic_ide/notifications.py b/jarvis/agentic_ide/notifications.pyindex b6a5910478..f8df08188b 100644--- a/jarvis/agentic_ide/notifications.py+++ b/jarvis/agentic_ide/notifications.py@@ -18,7 +18,7 @@ that raised each one.Four kinds, and each one is something the pane itself established:-* ``completed`` — it was working, and it is not any more.+* ``completed`` — it was given a job, it was working, and it is not any more.* ``needs_input`` — it is not working and there is a question on its screen.* ``exited`` — its process is gone (with the exit code, if there was one).* ``failed`` — its agent could not be started at all.@@ -28,6 +28,23 @@ Nothing here reads the agent's prose to decide whether the job went well: aThat distinction is in the wording the UI shows, because promising the secondone would be a lie the module is in no position to tell.+## Why "completed" needs a job as well as a stop++The detector underneath reads MOVEMENT (see :mod:`.activity`), and a coding CLI+moves plenty on its own account. Starting up it paints a banner, a model line+and whatever warnings it carries, then stands still — which is, frame for+frame, what an agent finishing a job looks like. So the first version of this+rang the bell once per pane the moment a workspace opened, twice for the panes+whose startup drawing arrived in two bursts, before anybody had typed a word.++A stop is therefore only reported once the pane has been GIVEN something to do:+a prompt from Jarvis, or a person pressing Enter in it+(``Terminal.last_submit_at``). The flag latches — a pane in service stays in+service — because the thing it rules out is the period BEFORE the first+instruction, not the second job. The other three kinds are unconditional: a+question, a dead process and a failed start are news whether or not the pane+ever worked.+## Why a debounce, and why it is the whole trickA coding TUI drops its interrupt hint for a moment between steps — while it@@ -45,6 +62,14 @@ restart of the app, so a notification that did would point at a terminal thatno longer exists — the one thing worse than no notification. The store is abounded deque and is deliberately lost with the process.+The same reasoning inside one run: every sweep tells the store which panes are+still there (:meth:`NotificationCenter.retain`), and entries whose pane has been+closed go with it. A pane closed by name is cleared on the spot instead+(:meth:`NotificationCenter.forget_pane`), because its call-sign — and with it+its KEY — is handed straight back out to whatever opens next. That sweep is+also where a live pane's call-sign is refreshed, so an entry cannot go on naming+a terminal the user has since renamed.+One boolean does survive: whether a pane was observed actively working. Theresume snapshot uses that evidence to distinguish genuinely interrupted workfrom a conversation that had already finished or was awaiting an answer.@@ -65,14 +90,14 @@ import timefrom collections import dequefrom dataclasses import dataclass, fieldfrom itertools import count-from typing import TYPE_CHECKING, Any, Literal+from typing import TYPE_CHECKING, Any, Literal, NamedTuplefrom loguru import loggerfrom .activity import STILL_S, Activity, is_settled, read_activity, screen_digestif TYPE_CHECKING: # pragma: no cover - typing only- from collections.abc import Iterable+ from collections.abc import Iterable, Mappingfrom .session import Registry@@ -106,6 +131,20 @@ DETAIL_CHARS = 160_ids = count(1)+class PaneLabel(NamedTuple):+ """What a live pane is called right now, and the tab it sits in.++ Both travel with an entry so the panel can be read without opening+ anything, and both can change under it while the entry is on screen: a pane+ can be given a new call-sign and a workspace a new tab name. Hence a label+ rather than a bare name — the entry is refreshed from this, not frozen at+ the moment it was filed.+ """++ pane: str+ workspace: str++@dataclass(frozen=True, slots=True)class Notification:"""One thing that happened in one pane."""@@ -205,10 +244,65 @@ class NotificationCenter:Their "jump to pane" cannot be honoured any more, and an entry thatsilently does nothing when pressed is worse than one that is gone."""+ return self.clear(entry.id for entry in self._entries if entry.workspace_id == workspace_id)++ def forget_pane(self, workspace_id: str, pane_key: str) -> int:+ """Drop the entries of a single pane that has just been closed.++ The sweep would get to this on its own (:meth:`retain`), but not soon+ enough: pane keys are REUSED — a new pane taking the closed one's name+ takes its key with it — so an entry left in the gap between the close+ and the next sweep would re-attach itself to a terminal it was never+ about, and "jump to pane" would go somewhere plausible and wrong.+ """return self.clear(- entry.id for entry in self._entries if entry.workspace_id == workspace_id+ entry.id+ for entry in self._entries+ if entry.workspace_id == workspace_id and entry.pane_key == pane_key)+ def retain(self, live: Mapping[tuple[str, str], PaneLabel]) -> int:+ """Keep only the entries whose pane still exists, and relabel those.++ ``live`` is every watched pane in every open workspace, keyed by+ ``(workspace_id, pane_key)`` — the sweep has just built exactly that, so+ this costs one pass over a list of at most a couple of hundred.++ Two jobs, and they are the same job: an entry has to name something that+ is still there. One whose pane has been closed is a "jump to pane"+ button that does nothing — the net under :meth:`forget_pane`, catching+ every other way a pane can disappear. One whose pane has since been+ RENAMED, or whose workspace has, is worse than useless: it names a+ terminal the user cannot find, in a tab that no longer goes by that.++ Returns how many entries were DROPPED. Relabelling is not counted: it+ keeps an entry honest rather than removing it.+ """+ kept: list[Notification] = []+ for entry in self._entries:+ label = live.get((entry.workspace_id, entry.pane_key))+ if label is None:+ continue+ if entry.pane == label.pane and entry.workspace == label.workspace:+ kept.append(entry)+ continue+ # Frozen on purpose, as in `mark_read` — replaced, never mutated.+ kept.append(+ Notification(+ **{**entry.to_dict(), "pane": label.pane, "workspace": label.workspace}+ )+ )+ dropped = len(self._entries) - len(kept)+ if dropped:+ self._entries.clear()+ self._entries.extend(kept)+ return dropped+ # Same length, possibly different objects: replace in place so a+ # relabel is visible without disturbing the deque's bound.+ for index, entry in enumerate(kept):+ self._entries[index] = entry+ return 0+@dataclass(slots=True)class _PaneWatch:@@ -219,6 +313,12 @@ class _PaneWatch:#: Has this pane been working since the last entry was filed for it? What#: makes "it finished" different from "it has been idle all along".worked: bool = False+ #: Has anybody ever given this pane an instruction? A latch, never cleared+ #: while the pane lives: it rules out the stretch BEFORE the first one,+ #: where the only movement on screen is the CLI drawing itself. Without it+ #: a workspace rings its own bell once per pane the moment it opens — see+ #: the module docstring.+ tasked: bool = False#: Already reported for the CURRENT episode. Cleared when the pane changes#: state, so the next stop is reported again.announced: bool = False@@ -297,7 +397,7 @@ class ActivityWatcher:"""Look at every pane once and file whatever has just happened."""moment = time.time() if now is None else nowfiled: list[Notification] = []- alive: set[tuple[str, str]] = set()+ alive: dict[tuple[str, str], PaneLabel] = {}for session in registry.sessions:for term in session.terminals:@@ -307,15 +407,24 @@ class ActivityWatcher:# the moment it is opened and never again.continueident = (session.id, str(getattr(term, "key", "") or ""))- alive.add(ident)+ alive[ident] = PaneLabel(+ pane=str(getattr(term, "name", "") or ""),+ workspace=str(getattr(session, "name", "") or ""),+ )entry = self._step(session, term, ident, moment, emit=emit)if entry is not None:filed.append(entry)# Panes that were closed take their memory with them, or a workspace# cycled often enough would grow this dict without bound.- for gone in self._panes.keys() - alive:+ for gone in self._panes.keys() - alive.keys():del self._panes[gone]+ # And their entries, whose "jump to pane" has nowhere to go. Done from+ # the sweep rather than hooked onto the close path, because a pane+ # disappears in more than one way — closed singly, closed in a batch,+ # taken down with its workspace — and a hook per way is a hook missing+ # from the next one. The sweep sees whatever is actually left.+ self.center.retain(alive)return fileddef _step(@@ -351,6 +460,7 @@ class ActivityWatcher:activity=activity,since=now,announced=True,+ tasked=_tasked(term),resume_needed=bool(getattr(term, "resume_continuation_needed", False)),digest=digest,changed_at=settled_at,@@ -362,6 +472,8 @@ class ActivityWatcher:if digest != watch.digest:watch.digest = digestwatch.changed_at = now+ if not watch.tasked and _tasked(term):+ watch.tasked = True# ``now`` travels into the read as well, so a test can place a pane on# its own timeline instead of racing the wall clock.activity = read_activity(term, now=now, still_since=watch.changed_at)@@ -460,11 +572,35 @@ class ActivityWatcher:# asking for the user by name, and a CLI that asks one at startup# (an unauthenticated MCP server, a trust prompt) has never worked.return "needs_input"- if activity == "waiting" and watch.worked:+ if activity == "waiting" and watch.worked and watch.tasked:+ # Both halves are load-bearing. `worked` says the screen moved and+ # then stopped; `tasked` says somebody asked for that. A starting+ # CLI painting its own banner satisfies the first and none of the+ # second, and it is the whole reason a fresh workspace used to+ # announce every pane in it as finished.return "completed"return None+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.+ """+ 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++def _is_agent(term: Any) -> bool:"""Does this pane run an agent, rather than being a bare shell?"""try:@@ -631,6 +767,7 @@ __all__ = ["Kind","Notification","NotificationCenter",+ "PaneLabel","center","enabled","reset",diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.pyindex b8619e74d8..a0a331d52a 100644--- a/jarvis/agentic_ide/session.py+++ b/jarvis/agentic_ide/session.py@@ -827,6 +827,19 @@ class Terminal:# cannot be missed: it is read at mount, at every reconnect and at every# poll, so the receipt is still there when somebody looks ten minutes later.last_prompt_at: float | None = None+ # When this pane was last GIVEN something to do — by Jarvis or by a person+ # pressing Enter in it. Distinct from `last_prompt_at`, which only knows+ # about the injection path, and from `last_input_at`, which counts every+ # arrow key.+ #+ # It exists because the activity detector reads MOVEMENT, and a coding CLI+ # moves plenty on its own: starting up, it paints a banner, a model line and+ # whatever warnings it has, then stands still. That is indistinguishable+ # from an agent finishing a job, so a freshly opened workspace rang its bell+ # once per pane — sometimes twice, when the startup drawing came in two+ # bursts — for work nobody had asked for. A pane nobody has given an+ # instruction cannot have finished one, and this is how that is known.+ last_submit_at: float | None = None# Did the last prompt actually leave the input line? None = none sent yet.submitted: bool | None = None# Did it arrive with its line structure intact? False means the pane@@ -2711,6 +2724,11 @@ class Registry:# stalled agent behind an accidental one.term.continuation_pending = Falseterm.resume_continuation_needed = False+ # And this pane now has an instruction of its own, which is what+ # makes its next stop worth reporting — a pane driven only by hand+ # never goes through `send_prompt`, so without this hook the bell+ # would stay silent for everybody who types their own prompts.+ term.last_submit_at = term.last_input_at# And the pane's conversation may have just begun, which for most# coding CLIs is the first moment its id exists on disk at all. A# pane driven only by hand never goes through `send_prompt`, so@@ -3169,6 +3187,19 @@ class Registry:# (a new "Mika" in the same workspace). Dropping it here is what# stops a fresh pane opening under the last one's sentence.recap_engine.forget(term.key)+ # Its bell entries go the same way and for the same reason.+ # Each one is a "jump to this pane" button, and the pane has+ # just stopped existing — while its key has not, so waiting for+ # the sweep to notice would hand them to whoever takes the name+ # next.+ try:+ from . import notifications++ notifications.center().forget_pane(session.id, term.key)+ except Exception as exc: # noqa: BLE001 - never fail a close on bookkeeping+ logger.warning(+ "Agentic IDE: could not clear notifications for a closed pane: {}", exc+ )self._renumber(session)if resolved:await self._persist()@@ -3279,6 +3310,11 @@ class Registry:# never disagree about when this happened — and so a viewer that arrives# a second later reads the same instant the notice carried.term.last_prompt_at = time.time()+ # The same stamp under the name the activity watcher reads, so a pane+ # driven by Jarvis and one driven by hand prove the same thing the same+ # way. Set even for a hard False: the text is in the pane's input box,+ # and whatever it does next was still asked of it.+ term.last_submit_at = term.last_prompt_atterm.submitted = submittedterm.sent_multiline = multiline and submitted is True# Somebody is driving this pane again, whatever the prompt said. Cleareddiff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneNotifications.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneNotifications.test.tsxindex 73927549ca..0d0fffc732 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneNotifications.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneNotifications.test.tsx@@ -210,4 +210,39 @@ describe("relative time", () => {expect(ago(at - 7200, now)).toBe("2h ago");expect(ago(at - 172_800, now)).toBe("2d ago");});++ it("ages an entry filed long after the workspace was opened", async () => {+ /*+ * The bug this pins read "0s ago" on every entry in the panel, however old,+ * and it survived the test above because that one calls `ago` directly.+ * The component used to freeze its idea of "now" when it MOUNTED — which is+ * when the workspace opens — and refresh it only every 30 s, and only while+ * the panel was open. So a notification filed at any point after the+ * workspace opened was measured against a moment before it existed, and the+ * clamp in `ago` turned that negative age into zero.+ *+ * Hence the shape here: mount first, let an hour pass, and only then does+ * anything arrive.+ */+ // Only the clock is faked — the polling and the queries keep their real+ // timers, so this stays an ordinary render-and-click test.+ vi.useFakeTimers({ toFake: ["Date"] });+ try {+ vi.setSystemTime(new Date("2026-07-30T12:00:00Z"));+ fetchMock.mockResolvedValue(state([]));+ render(<PaneNotifications onJump={vi.fn()} />);+ await screen.findByTestId("pane-notifications-bell");++ // An hour of the workspace sitting open, and then a pane finishes.+ vi.setSystemTime(new Date("2026-07-30T13:00:00Z"));+ fetchMock.mockResolvedValue(state([entry({ created_at: Date.now() / 1000 - 600 })]));++ const panel = await open();++ expect(panel.textContent).toContain("10m ago");+ expect(panel.textContent).not.toContain("0s ago");+ } finally {+ vi.useRealTimers();+ }+ });});diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneNotifications.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneNotifications.tsxindex 9d0af0c447..1df5eb0f54 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneNotifications.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneNotifications.tsx@@ -165,9 +165,19 @@ export function PaneNotifications({ onJump, onScreen = true }: PaneNotificationsconst [anchor, setAnchor] = useState<Anchor | null>(null);const bellRef = useRef<HTMLButtonElement | null>(null);const panelRef = useRef<HTMLDivElement | null>(null);- // Re-rendered on a slow beat so "3m ago" does not sit at "3m ago" for an- // hour while the panel stays open.- const [tick, setTick] = useState(() => Date.now());+ /*+ * A counter, not a clock. It only exists to force a re-render on a slow beat+ * so "3m ago" does not sit at "3m ago" for an hour while the panel stays+ * open; the time itself is read at render, from `Date.now()`.+ *+ * It used to hold the timestamp, and that was the bug behind every entry+ * reading "0s ago" however old it was: the value was taken once when the+ * workspace mounted and refreshed only every 30 s while the panel was open,+ * so anything filed after the workspace opened was compared against a moment+ * BEFORE it happened. That is a negative age, which the clamp in `ago` turns+ * into zero. A counter cannot go stale, because it is never used as a time.+ */+ const [, setTick] = useState(0);const refresh = useCallback(async (): Promise<PaneNotificationsState> => {try {@@ -199,7 +209,10 @@ export function PaneNotifications({ onJump, onScreen = true }: PaneNotificationsuseEffect(() => {if (!open) return;- const timer = window.setInterval(() => setTick(Date.now()), 30_000);+ // Every 15 s rather than 30: under a minute the panel counts in seconds,+ // and a seconds display that moves in half-minute jumps reads as frozen —+ // which is exactly what the bug above looked like.+ const timer = window.setInterval(() => setTick((n) => n + 1), 15_000);return () => window.clearInterval(timer);}, [open]);@@ -379,7 +392,10 @@ export function PaneNotifications({ onJump, onScreen = true }: PaneNotifications<Rowkey={entry.id}entry={entry}- now={tick}+ // Read here, at render, so it is the time the user is+ // looking at the list rather than the time something+ // last happened to schedule a render.+ now={Date.now()}onJump={() => jump(entry)}onDiscard={() => void discard(entry.id)}/>diff --git a/tests/unit/agentic_ide/test_pane_notifications.py b/tests/unit/agentic_ide/test_pane_notifications.pyindex 2145051874..8679b0fe10 100644--- a/tests/unit/agentic_ide/test_pane_notifications.py+++ b/tests/unit/agentic_ide/test_pane_notifications.py@@ -7,8 +7,10 @@ that edge right rather than about the store around it:* a pane that was busy and went quiet is reported ONCE,* a pane that has been idle since it appeared is never reported at all,+* a pane nobody has instructed yet is never reported either, however much its+ starting CLI paints itself across the screen,* the gap a TUI leaves between two steps does not produce a notification,-* and an entry never outlives the workspace whose pane it points at.+* and an entry never outlives the pane it points at — nor the workspace.Each of those has an obvious wrong implementation that looks correct in a demoand is unusable in a grid of twelve.@@ -94,7 +96,7 @@ REST_SCREENS = {),"kimi": ("\r\n ✦ Use Kimi K3 with High thinking effort\r\n"- " Error: LLM not set, send \"/login\" to login\r\n"+ ' Error: LLM not set, send "/login" to login\r\n'" │ > \r\n"" C:\\probe-repo \r\n"),@@ -123,9 +125,7 @@ async def _noop_exit(_code: int) -> None:return None-async def _pane(- registry: Registry, folder: Path, *, name: str = "Alex", agent: str = "claude"-):+async def _pane(registry: Registry, folder: Path, *, name: str = "Alex", agent: str = "claude"):"""One live pane in one workspace, through the real attach path."""session = await registry.start(str(folder), [{"agent": agent, "name": name}])term = await registry.attach(name, 100, 30, _noop, _noop_exit)@@ -157,7 +157,13 @@ def _busy(watcher: Any, registry: Registry, term: Any, *, start: float, sweeps:test means changing its picture — repeatedly, since a single change cannotbe told from a pane that was already still. Returns the moment of the lastsweep, which is when the screen stopped moving.++ The pane is also stamped as having been GIVEN the job, because that is what+ a working pane is: an agent does not start moving on its own account except+ while it is starting up, which is the case+ `test_a_starting_cli_painting_itself_is_not_a_finished_job` covers."""+ term.last_submit_at = start - 0.1at = startfor step in range(sweeps):at = start + step * notifications.SWEEP_INTERVAL_S@@ -206,9 +212,7 @@ async def test_a_moving_screen_is_a_working_pane(assert read_activity(term, now=1000.5, still_since=1000.0) == "working"-async def test_movement_is_the_only_thing_that_counts(- registry: Registry, tmp_path: Path-) -> None:+async def test_movement_is_the_only_thing_that_counts(registry: Registry, tmp_path: Path) -> None:"""The rows this build draws while WORKING are not treated as special.The point of the rewrite: these are the exact rows that fooled two earlier@@ -239,9 +243,7 @@ async def test_a_pane_whose_screen_keeps_changing_is_working(assert watcher._panes[(_session.id, term.key)].activity == "working"-async def test_the_startup_banner_is_not_a_question(- registry: Registry, tmp_path: Path-) -> None:+async def test_the_startup_banner_is_not_a_question(registry: Registry, tmp_path: Path) -> None:"""It sits there for the pane's whole life — a standing banner, not an ask."""_session, term = await _pane(registry, tmp_path)_draw(term, REAL_STARTUP_BANNER)@@ -285,14 +287,13 @@ async def test_movement_after_the_typing_stopped_is_work(assert read_activity(term, now=1010.2, still_since=1010.0) == "working"-async def test_a_real_pane_finishing_files_one_entry(- registry: Registry, tmp_path: Path-) -> None:+async def test_a_real_pane_finishing_files_one_entry(registry: Registry, tmp_path: Path) -> None:"""End to end on the real rows: working → finished → exactly one entry."""watcher = notifications.watcher()_session, term = await _pane(registry, tmp_path)_draw(term, REAL_WORKING)+ term.last_submit_at = 999.0term.last_output_at = 1000.0assert watcher.poll(registry, now=1000.5) == []@@ -321,9 +322,7 @@ async def test_the_interrupt_hint_is_what_marks_a_pane_busy(assert read_activity(term) == "working"-async def test_a_pane_at_its_prompt_reads_as_waiting(- registry: Registry, tmp_path: Path-) -> None:+async def test_a_pane_at_its_prompt_reads_as_waiting(registry: Registry, tmp_path: Path) -> None:_session, term = await _pane(registry, tmp_path)_draw(term, IDLE_SCREEN)@@ -434,6 +433,79 @@ async def test_a_pane_that_was_never_busy_is_never_reported(assert watcher.poll(registry, now=moment) == []+async def test_a_starting_cli_painting_itself_is_not_a_finished_job(+ registry: Registry, tmp_path: Path+) -> None:+ """The bug this rule exists for, in the form the user actually hit.++ Open a workspace and the CLIs in it draw themselves: a logo, a model line,+ an authentication banner. That is a screen moving and then stopping, which+ is frame for frame what an agent finishing a job looks like — so the bell+ filed "Finished and waiting at its prompt" for every pane in a workspace+ nobody had typed a word into, and twice for the panes whose startup drawing+ arrived in two bursts.++ Movement alone can never mean this again: the pane has to have been GIVEN+ something to do first.+ """+ watcher = notifications.watcher()+ _session, term = await _pane(registry, tmp_path)+ watcher.poll(registry, now=100.0)++ # The banner arrives in two bursts, exactly as a real cold start does.+ for step, chunk in enumerate(("\r\n Claude Code v2.1.220\r\n", REAL_STARTUP_BANNER)):+ term.transcript.clear()+ _draw(term, chunk)+ assert watcher.poll(registry, now=102.0 + step * 2) == []++ # And then it stands still at its prompt, for as long as anybody looks.+ for moment in (110.0, 120.0, 600.0):+ assert watcher.poll(registry, now=moment) == []+ assert notifications.center().list() == []+++async def test_a_prompt_typed_by_hand_arms_the_report(registry: Registry, tmp_path: Path) -> None:+ """The other side of that rule — and the half a `send_prompt` check misses.++ A pane driven by a person pressing Enter in it never goes through Jarvis'+ injection path, so a rule that only counted prompts Jarvis sent would leave+ the bell permanently silent for anybody who types their own.+ """+ watcher = notifications.watcher()+ session, term = await _pane(registry, tmp_path)+ watcher.poll(registry, now=100.0)+ assert term.prompts_sent == 0, "the point: nothing went through send_prompt"++ registry.write(term.key, "run the tests\r", workspace_id=session.id)++ stopped = _busy(watcher, registry, term, start=200.0)+ watcher.poll(registry, now=stopped + STILL_S + 1)+ filed = watcher.poll(registry, now=stopped + STILL_S + notifications.SETTLE_S + 2)++ assert [entry.kind for entry in filed] == ["completed"]+++async def test_arrow_keys_and_half_typed_lines_are_not_an_instruction(+ registry: Registry, tmp_path: Path+) -> None:+ """Typing is not submitting, or reading a prompt back would arm the bell."""+ watcher = notifications.watcher()+ session, term = await _pane(registry, tmp_path)+ watcher.poll(registry, now=100.0)++ registry.write(term.key, "run the te", workspace_id=session.id)++ assert term.last_submit_at is None+ stopped = _busy(watcher, registry, term, start=200.0)+ # `_busy` stamps the pane, so undo that here — this test is about the pane+ # NOT having been given anything, with a screen that moved regardless.+ term.last_submit_at = None+ watcher._panes[(session.id, term.key)].tasked = False+ watcher.poll(registry, now=stopped + STILL_S + 1)++ assert watcher.poll(registry, now=stopped + STILL_S + notifications.SETTLE_S + 2) == []++async def test_a_repaint_gap_does_not_file_a_notification(registry: Registry, tmp_path: Path) -> None:@@ -474,16 +546,12 @@ async def test_a_question_is_reported_even_though_it_never_worked(_draw(term, QUESTION_SCREEN)watcher.poll(registry, now=101.0)assert watcher.poll(registry, now=101.0 + STILL_S + 1) == []- filed = watcher.poll(- registry, now=101.0 + STILL_S + notifications.SETTLE_S + 2- )+ filed = watcher.poll(registry, now=101.0 + STILL_S + notifications.SETTLE_S + 2)assert [entry.kind for entry in filed] == ["needs_input"]-async def test_going_back_to_work_re_arms_the_report(- registry: Registry, tmp_path: Path-) -> None:+async def test_going_back_to_work_re_arms_the_report(registry: Registry, tmp_path: Path) -> None:"""A pane given a second job reports its second stop too."""watcher = notifications.watcher()_session, term = await _pane(registry, tmp_path)@@ -491,15 +559,11 @@ async def test_going_back_to_work_re_arms_the_report(for round_start in (100.0, 500.0):stopped = _busy(watcher, registry, term, start=round_start)watcher.poll(registry, now=stopped + STILL_S + 1)- filed = watcher.poll(- registry, now=stopped + STILL_S + notifications.SETTLE_S + 2- )+ filed = watcher.poll(registry, now=stopped + STILL_S + notifications.SETTLE_S + 2)assert [entry.kind for entry in filed] == ["completed"], round_start-async def test_a_dead_agent_is_reported_without_waiting(- registry: Registry, tmp_path: Path-) -> None:+async def test_a_dead_agent_is_reported_without_waiting(registry: Registry, tmp_path: Path) -> None:"""There is no repaint gap to sit out — the state cannot flip back by itself."""watcher = notifications.watcher()_session, term = await _pane(registry, tmp_path)@@ -555,6 +619,83 @@ def test_the_store_is_bounded() -> None:assert [entry.id for entry in center.list()] == ["n9", "n8", "n7"]+async def _file_one(watcher: Any, registry: Registry, term: Any, *, start: float) -> None:+ """Put exactly one ``completed`` entry in the bell for ``term``."""+ stopped = _busy(watcher, registry, term, start=start)+ watcher.poll(registry, now=stopped + STILL_S + 1)+ filed = watcher.poll(registry, now=stopped + STILL_S + notifications.SETTLE_S + 2)+ assert [entry.pane for entry in filed] == [term.name]+++async def test_closing_a_pane_takes_its_notifications_with_it(+ registry: Registry, tmp_path: Path+) -> None:+ """An entry is a "jump to this pane" button and the pane has just gone.++ The workspace stays open, so the entry used to stay with it — the bell kept+ counting terminals the user could no longer see, and pressing one of them+ did nothing at all.+ """+ watcher = notifications.watcher()+ session = await registry.start(+ str(tmp_path),+ [{"agent": "claude", "name": "T1"}, {"agent": "claude", "name": "T2"}],+ )+ first = await registry.attach("T1", 100, 30, _noop, _noop_exit)+ second = await registry.attach("T2", 100, 30, _noop, _noop_exit)+ await _file_one(watcher, registry, first, start=100.0)+ await _file_one(watcher, registry, second, start=500.0)+ assert {entry.pane for entry in notifications.center().list()} == {"T1", "T2"}++ await registry.close_terminal("T2")++ assert [entry.pane for entry in notifications.center().list()] == ["T1"]+ assert session.id+++async def test_a_new_pane_never_inherits_the_closed_ones_entries(+ registry: Registry, tmp_path: Path+) -> None:+ """Call-signs are handed back out, and with them the pane KEY.++ So an entry left behind by a closed T2 does not merely dangle — it+ re-attaches itself to whatever opens as T2 next, and "jump to pane" lands+ somewhere plausible and wrong. This is why the close path clears them+ itself instead of leaving it to the next sweep.+ """+ watcher = notifications.watcher()+ await registry.start(str(tmp_path), [{"agent": "claude", "name": "T1"}])+ first = await registry.attach("T1", 100, 30, _noop, _noop_exit)+ await _file_one(watcher, registry, first, start=100.0)++ await registry.close_terminal("T1")+ await registry.add_terminal(agent="claude", name="T1")+ reborn = await registry.attach("T1", 100, 30, _noop, _noop_exit)++ assert reborn.key == first.key, "the premise: the key came back with the name"+ assert notifications.center().list() == []+++async def test_an_entry_follows_the_pane_when_it_is_renamed(+ registry: Registry, tmp_path: Path+) -> None:+ """Otherwise it names a terminal that is not on screen under that name.++ The rename is applied to the pane directly rather than through whichever+ route offers it, because the claim under test belongs to the sweep: an+ entry carries a LABEL, and a label is refreshed from the pane rather than+ frozen at the moment it was filed.+ """+ watcher = notifications.watcher()+ _session, term = await _pane(registry, tmp_path, name="T1")+ await _file_one(watcher, registry, term, start=100.0)++ term.name = "Reviewer"+ watcher.poll(registry, now=900.0)++ assert [entry.pane for entry in notifications.center().list()] == ["Reviewer"]++async def test_closing_a_workspace_takes_its_notifications_with_it(registry: Registry, tmp_path: Path) -> None: