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): make Continue reach every interrupted pane, exactly once

Ruben Lütke7591f4521656
diff --git a/docs/commands-reference.md b/docs/commands-reference.md
index 5b34994ed0..c34b5f762f 100644
--- a/docs/commands-reference.md
+++ b/docs/commands-reference.md
@@ -313,7 +313,7 @@ Which coding terminals came back holding their conversation and have been told n
## `agentic-ide-continue-interrupted` — Continue interrupted Agentic-IDE sessions
-Tell the coding terminals a restart left standing still to carry on: 'continue' is typed into each one and submitted. With no names, every interrupted pane in every open workspace — which is the shape of the problem, since a restart stops them all at once. CHECK THE REPLY: 'continued' really started, 'unconfirmed' had the text typed in without a confirmed submit (it may be sitting in the input box — tell the user to look at that pane), and 'failed' names what refused and why. Reporting an unconfirmed pane as running is the one wrong thing to do with this answer.
+Tell the coding terminals a restart left standing still to carry on: 'continue' is typed into each one and submitted. With no names, every interrupted pane in every open workspace — which is the shape of the problem, since a restart stops them all at once. CHECK THE REPLY: 'continued' really started, 'queued' had not finished starting yet and will carry on by itself within seconds (say 'shortly', not 'done'), 'unconfirmed' had the text typed in without a confirmed submit (it may be sitting in the input box — tell the user to look at that pane), and 'failed' names what refused and why. Reporting an unconfirmed or queued pane as running is the one wrong thing to do with this answer. Pressing twice is safe: each pane is claimed before anything is typed, so a repeat call cannot send a second 'continue' into the same agent.
- **Endpoint:** `POST /api/agentic-ide/interrupted/continue`
- **Arguments:** `names` (array; optional); `prompt` (string; optional)
diff --git a/jarvis/agentic_ide/interrupted.py b/jarvis/agentic_ide/interrupted.py
index 8226490a80..1837b7feda 100644
--- a/jarvis/agentic_ide/interrupted.py
+++ b/jarvis/agentic_ide/interrupted.py
@@ -50,7 +50,7 @@ exactly what it was told to stop doing. The offer is a button.
from __future__ import annotations
import asyncio
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from pathlib import Path
from typing import TYPE_CHECKING, Any
@@ -88,10 +88,17 @@ class InterruptedPane:
agent: str
display_name: str
status: str
- #: Can it be nudged right now? False for a pane whose agent is not running —
- #: an instruction cannot be typed into a dead terminal, and saying so before
- #: the click is the point.
+ #: Will a "continue" reach it? False only for a pane whose agent is DEAD —
+ #: an instruction cannot be typed into a terminal that exited, and saying so
+ #: before the click is the point. A pane that is merely still starting is
+ #: continuable: the instruction waits for it (see ``starting``).
continuable: bool
+ #: Its agent is still coming up. Continuing it is a promise kept a few
+ #: seconds later, not a refusal.
+ starting: bool
+ #: A "continue" is already waiting to be delivered to it. What stops a second
+ #: press from queueing a second one.
+ queued: bool
#: Why not, in one plain sentence. Empty when it can.
blocked_reason: str
#: What this pane was last asked to do, shortened. Empty when the last
@@ -114,6 +121,8 @@ class InterruptedPane:
"display_name": self.display_name,
"status": self.status,
"continuable": self.continuable,
+ "starting": self.starting,
+ "queued": self.queued,
"blocked_reason": self.blocked_reason,
"last_task": self.last_task,
"prompts_sent": self.prompts_sent,
@@ -125,17 +134,21 @@ class InterruptedPane:
class ContinueReport:
"""What sending the nudge actually did, pane by pane.
- Three lists rather than a count, because the three outcomes need different
- words from whoever reports this: a pane that took the instruction, one that
- refused it, and one that took the text but never submitted it (the prompt is
- sitting in its input box and a human has to press Enter). Collapsing the
- third into either of the others is the lie :meth:`Registry.send_prompt` goes
- to some length to avoid.
+ Four lists rather than a count, because the outcomes need different words
+ from whoever reports this: a pane that took the instruction, one whose agent
+ is still starting and will get it shortly, one that took the text but never
+ submitted it (the prompt is sitting in its input box and a human has to
+ press Enter), and one that refused. Collapsing any of them into "it is
+ running again" is the lie :meth:`Registry.send_prompt` goes to some length
+ to avoid.
"""
continued: list[str]
unconfirmed: list[str]
failed: list[tuple[str, str]]
+ #: Panes whose agent had not started yet. The instruction is held and
+ #: delivered when it comes up — a promise, not a refusal and not a send.
+ queued: list[str] = field(default_factory=list)
@property
def ok(self) -> bool:
@@ -145,6 +158,7 @@ class ContinueReport:
return {
"ok": self.ok,
"continued": list(self.continued),
+ "queued": list(self.queued),
"unconfirmed": list(self.unconfirmed),
"failed": [{"name": name, "detail": detail} for name, detail in self.failed],
}
@@ -156,11 +170,18 @@ def _workspace_label(session: Session) -> str:
def _blocked_reason(term: Terminal) -> str:
- """Why this pane cannot be nudged right now, or an empty string."""
+ """Why this pane cannot be nudged right now, or an empty string.
+
+ ``pending`` is deliberately NOT in here. A pane still waiting for a
+ cold-start slot is not blocked, it is early — and treating "early" as
+ "blocked" is what made the button skip terminals in a big workspace. Those
+ are reported by :func:`_starting`, continued the moment they come up, and
+ kept out of the refusal list entirely.
+ """
if term.status == "live" and term.pty_id:
return ""
if term.status == "pending":
- return "Its agent has not started yet — open the workspace so the pane connects."
+ return ""
if term.status == "error":
return term.error or "Its agent could not be started."
if term.status == "exited":
@@ -170,8 +191,19 @@ def _blocked_reason(term: Terminal) -> str:
return f"Its agent is not running (status: {term.status})."
+def _starting(term: Terminal) -> bool:
+ """Is this pane's agent still on its way up?
+
+ Cold starts are staggered on purpose (``COLD_START_LIMIT``), so a workspace
+ of a dozen panes has most of them in this state for the first few seconds
+ after it appears — the exact window somebody presses "Continue" in.
+ """
+ return term.status == "pending"
+
+
def _describe(session: Session, term: Terminal) -> InterruptedPane:
reason = _blocked_reason(term)
+ starting = _starting(term)
return InterruptedPane(
workspace_id=session.id,
workspace=_workspace_label(session),
@@ -181,7 +213,11 @@ def _describe(session: Session, term: Terminal) -> InterruptedPane:
agent=term.agent,
display_name=term.display_name,
status=term.status,
+ # A pane still starting counts as continuable: the instruction is not
+ # refused, it is held and delivered when its agent comes up.
continuable=not reason,
+ starting=starting,
+ queued=term.continue_when_ready,
blocked_reason=reason,
last_task=condense(term.last_prompt, TASK_CHARS),
prompts_sent=term.prompts_sent,
@@ -250,6 +286,39 @@ def _selected(
return chosen, rejected
+def _claim(registry: Registry, pane: InterruptedPane) -> Terminal | None:
+ """Take a pane off the waiting list BEFORE anything is sent to it.
+
+ **The bug this fixes.** Typing a prompt and verifying it takes seconds — the
+ submit is confirmed against the pane's own screen — and the flag used to be
+ cleared at the END of that. So a second press while the first was still in
+ flight found the pane still "waiting", and the agent received "continue"
+ twice; three presses, three times. Reported exactly that way.
+
+ Claiming is therefore the first thing that happens, in one synchronous step
+ with no ``await`` in it, so two overlapping requests cannot both win. The
+ caller puts the flag back when the send fails, and the pane returns to the
+ list rather than being silently dropped.
+ """
+ found = registry.find_terminal(pane.name)
+ if found is None:
+ return None
+ term = found[1]
+ if not term.continuation_pending:
+ # Somebody got here first — another press, or the user typing into the
+ # pane themselves between the scan and now.
+ return None
+ term.continuation_pending = False
+ return term
+
+
+def _release(registry: Registry, name: str) -> None:
+ """Put a pane back on the waiting list after its nudge failed to go."""
+ found = registry.find_terminal(name)
+ if found is not None:
+ found[1].continuation_pending = True
+
+
async def continue_panes(
registry: Registry,
*,
@@ -267,13 +336,37 @@ async def continue_panes(
seconds per pane and a grid of twelve would otherwise take the better part of
a minute. The panes are independent processes with independent PTYs, so there
is nothing to serialize; one pane refusing its prompt cannot affect another.
+
+ **A pane still starting is queued, not skipped.** Cold starts are staggered
+ (``COLD_START_LIMIT``), so most of a big workspace is still coming up in the
+ seconds after it appears — the very window this button is pressed in. Those
+ panes are marked and continued by :meth:`Registry.attach` the moment their
+ agent exists, and reported as ``queued`` rather than as done or refused.
+
+ **Pressing twice cannot send twice.** Every pane is claimed off the waiting
+ list synchronously before a single byte is typed (see :func:`_claim`), and
+ put back only if its nudge could not be delivered.
"""
text = (prompt or CONTINUE_PROMPT).strip() or CONTINUE_PROMPT
chosen, failed = _selected(scan(registry), names)
- blocked = [pane for pane in chosen if not pane.continuable]
- failed.extend((pane.name, pane.blocked_reason) for pane in blocked)
- runnable = [pane for pane in chosen if pane.continuable]
+ failed.extend((pane.name, pane.blocked_reason) for pane in chosen if not pane.continuable)
+
+ queued: list[str] = []
+ runnable: list[InterruptedPane] = []
+ for pane in chosen:
+ if not pane.continuable:
+ continue
+ term = _claim(registry, pane)
+ if term is None:
+ # Already claimed by a press that is still in flight. Not a failure
+ # and not a second send — the first one is doing the work.
+ continue
+ if pane.starting:
+ term.continue_when_ready = True
+ queued.append(pane.name)
+ else:
+ runnable.append(pane)
async def _send(pane: InterruptedPane) -> tuple[InterruptedPane, Any]:
try:
@@ -288,23 +381,31 @@ async def continue_panes(
unconfirmed: list[str] = []
for pane, outcome in await asyncio.gather(*(_send(pane) for pane in runnable)):
if isinstance(outcome, Exception):
+ # Nothing reached the agent, so this one is still waiting.
+ _release(registry, pane.name)
failed.append((pane.name, str(outcome) or outcome.__class__.__name__))
elif getattr(outcome, "submitted", None) is True:
continued.append(pane.name)
else:
# Typed in, not provably submitted. Its own bucket: telling the user
# this pane is running again would be a guess, and the fix is one
- # keypress in a pane they can see.
+ # keypress in a pane they can see. NOT released — the text is in that
+ # pane's input box, and offering to type it again would put a second
+ # copy behind the first.
unconfirmed.append(pane.name)
- if continued or unconfirmed or failed:
+ if continued or unconfirmed or queued or failed:
logger.info(
- "Agentic IDE: continued {} interrupted pane(s) ({} unconfirmed, {} refused)",
+ "Agentic IDE: continued {} interrupted pane(s) "
+ "({} queued until they start, {} unconfirmed, {} refused)",
len(continued),
+ len(queued),
len(unconfirmed),
len(failed),
)
- return ContinueReport(continued=continued, unconfirmed=unconfirmed, failed=failed)
+ return ContinueReport(
+ continued=continued, queued=queued, unconfirmed=unconfirmed, failed=failed
+ )
__all__ = [
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.py
index e8d0f65e2f..a3ae3c8281 100644
--- a/jarvis/agentic_ide/session.py
+++ b/jarvis/agentic_ide/session.py
@@ -196,6 +196,14 @@ COLD_START_LIMIT = max(2, (os.cpu_count() or 4) // 4)
# enough to stagger, short enough that nobody watches a spinner for it.
COLD_START_SETTLE_S = 1.2
+# How long a deferred "carry on" waits after its pane's process appears.
+#
+# The process existing is not the same as its prompt box being on screen: a
+# coding CLI spends a second or two loading, and text typed into that window is
+# swallowed whole rather than queued (measured on a real Codex — see
+# `_await_arrival`). Long enough to clear that boot burst, short enough that
+# nobody watches a pane sit there.
+CONTINUE_AFTER_START_S = 2.5
# How long the nudged window size is held before it is put back (see
# ``_nudge_repaint``). A PTY carries one size, not a queue of them: set twice
@@ -550,12 +558,22 @@ class Terminal:
# CLI sits at its prompt waiting rather than carrying on by itself — so the
# work simply stops, silently, and looks exactly like a pane that finished.
#
- # Set only where a process is SPAWNED onto an existing conversation (see
- # `attach`), and cleared by anything that counts as "somebody is driving
- # this pane again": a prompt from Jarvis, or a line the user typed into the
- # pane themselves. Never persisted — it is a fact about the process that is
- # running now, not about the workspace.
+ # Raised where a restore establishes that this pane's conversation really
+ # exists, and again where a process is SPAWNED onto one (see `attach`, which
+ # also clears it when a resume failed and the pane came back empty). Cleared
+ # by anything that counts as "somebody is driving this pane again": a prompt
+ # from Jarvis, or a line the user typed into the pane themselves. Never
+ # persisted — it describes the pane on screen, not the workspace on disk.
continuation_pending: bool = False
+ # "Continue this one as soon as it can be typed into."
+ #
+ # Cold starts are staggered (COLD_START_LIMIT), so in a workspace of a dozen
+ # panes most are still waiting for a slot when the user presses Continue.
+ # Sending only to the ones that happen to be up already is what made the
+ # button look like it skipped terminals; refusing them would be the same
+ # answer worn differently. So the wish is REMEMBERED here and spent by
+ # `attach` the moment that pane's agent exists.
+ continue_when_ready: bool = False
transcript: Transcript = field(default_factory=Transcript)
# The RAW output stream, kept so the next viewer can be handed the screen
# this pane is actually showing. Cleared on a fresh spawn, so what a viewer
@@ -1192,6 +1210,24 @@ class Registry:
)
for index, entry in enumerate(space.terminals)
]
+ # Which of them will come back mid-task, decided HERE rather than when
+ # each pane's agent happens to start.
+ #
+ # **The bug this fixes.** `continuation_pending` used to be raised in
+ # `attach`, which is the moment a pane's process is spawned — and cold
+ # starts are deliberately staggered (see COLD_START_LIMIT), so in a
+ # workspace of a dozen panes most of them are still `pending` seconds
+ # after the grid appears. Anybody pressing "Continue" in that window got
+ # the handful that had started and silently no others, which is exactly
+ # the "it skips terminals that should have carried on" report.
+ #
+ # A restored pane's answer does not depend on its process at all: it
+ # depends on whether the coding CLI's history really holds the
+ # conversation the handle points at. That is knowable now, so it is
+ # answered now — one thread hop for the whole workspace, since each
+ # check is a filename lookup. `attach` still corrects it either way when
+ # the process really starts (a resume that fails clears it).
+ await asyncio.to_thread(_mark_restored_continuations, terminals)
# A snapshot remembers the call-signs each workspace had. Another one may
# hold them now, and two panes answering to one name would make every
# spoken instruction ambiguous — so a collision is renamed here. Only the
@@ -1730,9 +1766,49 @@ class Registry:
# A CLI that cannot be told its session id (Codex): find out which
# one it just created, shortly from now.
self._schedule_lookup(session, term, session.folder, term.started_at)
+ if term.continue_when_ready:
+ # Somebody pressed "Continue" while this pane was still waiting for
+ # a cold-start slot. The wish outlives the wait — see
+ # `continue_when_ready` — and is spent HERE, once the agent exists
+ # and can be typed into. As a task, because the pane's socket is
+ # waiting on this call: the nudge itself watches the pane's screen
+ # for a few seconds, and holding the attach open for that would
+ # leave the terminal blank while it ran.
+ term.continue_when_ready = False
+ self._schedule_continue(session, term)
await self._persist()
return term
+ def _schedule_continue(self, session: Session, term: Terminal) -> None:
+ """Send the deferred "carry on" to a pane that has just come up.
+
+ Kept on the session's own task set, like the conversation-id lookups, so
+ closing that workspace cancels it rather than leaving a nudge in flight
+ for a pane that no longer exists.
+ """
+ from .interrupted import CONTINUE_PROMPT
+
+ async def _nudge() -> None:
+ try:
+ # The agent's CLI needs a moment after its process exists before
+ # its prompt box is on screen; typing into the boot sequence is
+ # how a paste gets swallowed whole (see `_await_arrival`, which
+ # then waits for text that never appears).
+ await asyncio.sleep(CONTINUE_AFTER_START_S)
+ await self.send_prompt(term.name, CONTINUE_PROMPT)
+ except SessionError as exc:
+ logger.warning(
+ "Agentic IDE: {} came up but could not be continued: {}", term.name, exc
+ )
+ except asyncio.CancelledError:
+ raise
+ except Exception as exc: # noqa: BLE001 - a nudge must not kill the pane
+ logger.warning("Agentic IDE: deferred continue for {} failed: {}", term.name, exc)
+
+ task = asyncio.create_task(_nudge())
+ session.lookups.add(task)
+ task.add_done_callback(session.lookups.discard)
+
def _prepare_spawn(self, term: Terminal, folder: str) -> dict[str, str] | None:
"""Everything this pane's agent needs on disk, then its environment.
@@ -2405,6 +2481,32 @@ class Registry:
return SessionError(f"No terminal called {wanted!r}. Running: {known or 'none'}.")
+def _mark_restored_continuations(terminals: list[Terminal]) -> None:
+ """Flag the restored panes that will come back in the middle of a job.
+
+ Runs off the event loop (each check stats the coding CLI's history) and
+ never raises: a pane whose history cannot be read is left unflagged, which
+ costs an offer to continue it and nothing else.
+
+ Holding a handle is not the same as having a conversation — a pane that was
+ opened and never used holds an id that points at nothing — so this asks the
+ CLI's own history, exactly as the resume offer does.
+ """
+ for term in terminals:
+ if term.resume is None or not accepts_prompts(term.agent):
+ continue
+ try:
+ term.continuation_pending = has_conversation(
+ term.agent, term.resume, account_home(term.agent, term.account)
+ )
+ except Exception as exc: # noqa: BLE001 - a restore must never fail on this
+ logger.debug(
+ "Agentic IDE: could not tell whether {} has work to continue: {}",
+ term.name,
+ exc,
+ )
+
+
def terminals_added_event(session: Session, created: list[Terminal], *, source_layer: str) -> Any:
"""The bus event announcing new panes to every connected client.
diff --git a/jarvis/commands/registry.py b/jarvis/commands/registry.py
index ff9c289904..d5c718d61c 100644
--- a/jarvis/commands/registry.py
+++ b/jarvis/commands/registry.py
@@ -834,11 +834,15 @@ def _build_registry() -> tuple[AppCommand, ...]:
"With no names, every interrupted pane in every open workspace "
"— which is the shape of the problem, since a restart stops "
"them all at once. CHECK THE REPLY: 'continued' really started, "
+ "'queued' had not finished starting yet and will carry on by "
+ "itself within seconds (say 'shortly', not 'done'), "
"'unconfirmed' had the text typed in without a confirmed "
"submit (it may be sitting in the input box — tell the user to "
"look at that pane), and 'failed' names what refused and why. "
- "Reporting an unconfirmed pane as running is the one wrong "
- "thing to do with this answer."
+ "Reporting an unconfirmed or queued pane as running is the one "
+ "wrong thing to do with this answer. Pressing twice is safe: "
+ "each pane is claimed before anything is typed, so a repeat "
+ "call cannot send a second 'continue' into the same agent."
),
method="POST",
path="/api/agentic-ide/interrupted/continue",
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index c4b872122c..6b10554087 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -516,10 +516,22 @@ class InterruptedPane(BaseModel):
status: str
continuable: bool = Field(
description=(
- "Can it be told to continue right now? False when its agent is not "
- "running — an instruction cannot be typed into a dead terminal."
+ "Will a 'continue' reach it? False only when its agent is DEAD — an "
+ "instruction cannot be typed into a terminal that exited. A pane "
+ "that is merely still starting IS continuable; see 'starting'."
)
)
+ starting: bool = Field(
+ default=False,
+ description=(
+ "Its agent is still coming up (cold starts are staggered). Continuing "
+ "it is a promise kept a few seconds later, not a refusal."
+ ),
+ )
+ queued: bool = Field(
+ default=False,
+ description="A 'continue' is already waiting to be delivered to this pane.",
+ )
blocked_reason: str = Field(
default="", description="Why not, in one sentence. Empty when it can."
)
@@ -572,6 +584,13 @@ class ContinueInterruptedResponse(BaseModel):
continued: list[str] = Field(
default_factory=list, description="Panes that accepted the instruction and started."
)
+ queued: list[str] = Field(
+ default_factory=list,
+ description=(
+ "Panes whose agent had not started yet. The instruction is held and "
+ "delivered the moment each one comes up — say 'shortly', not 'done'."
+ ),
+ )
unconfirmed: list[str] = Field(
default_factory=list,
description=(
diff --git a/jarvis/ui/web/frontend/src/components/agentic/ContinueInterrupted.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/ContinueInterrupted.test.tsx
index 8ced128396..a80452190d 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/ContinueInterrupted.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/ContinueInterrupted.test.tsx
@@ -67,6 +67,7 @@ function result(over: Partial<ContinueResult> = {}): ContinueResult {
return {
ok: true,
continued: [],
+ queued: [],
unconfirmed: [],
failed: [],
remaining: 0,
@@ -204,6 +205,53 @@ describe("ContinueInterrupted", () => {
await waitFor(() => expect(screen.queryByTestId("continue-interrupted")).toBeNull());
});
+ it("cannot be pressed twice while the first instruction is in flight", async () => {
+ // A delivery takes seconds — the submit is verified against the pane's own
+ // screen — and a live button in that window is a button somebody presses
+ // again. Two presses used to mean the agent got "continue" twice.
+ asked().mockResolvedValue(offer([pane()]));
+ let release: (value: ContinueResult) => void = () => {};
+ told().mockReturnValue(
+ new Promise<ContinueResult>((resolve) => {
+ release = resolve;
+ }),
+ );
+
+ await openDialog();
+ fireEvent.click(screen.getByTestId("continue-interrupted-all"));
+
+ await waitFor(() => expect(disabled("continue-interrupted-all")).toBe(true));
+ expect(disabled("continue-pane-Alex")).toBe(true);
+ fireEvent.click(screen.getByTestId("continue-interrupted-all"));
+ fireEvent.click(screen.getByTestId("continue-pane-Alex"));
+
+ expect(told()).toHaveBeenCalledTimes(1);
+ release(result({ continued: ["Alex"] }));
+ });
+
+ it("says a still-starting pane will carry on, rather than claiming it did", async () => {
+ asked().mockResolvedValue(offer([pane({ starting: true, status: "pending" })]));
+ told().mockResolvedValue(result({ queued: ["Alex"], remaining: 1 }));
+
+ await openDialog();
+ expect(screen.getByTestId("interrupted-starting-Alex")).toBeTruthy();
+ fireEvent.click(screen.getByTestId("continue-interrupted-all"));
+
+ await waitFor(() => expect(pushToast).toHaveBeenCalled());
+ const [, message] = pushToast.mock.calls.at(-1) as [string, string];
+ expect(message).toContain("Alex");
+ expect(message).not.toContain("carrying on");
+ });
+
+ it("leaves a pane alone once its continue is already queued", async () => {
+ // The backend is holding one for it. A second press would queue a second.
+ asked().mockResolvedValue(offer([pane({ starting: true, queued: true })]));
+
+ await openDialog();
+
+ expect(disabled("continue-pane-Alex")).toBe(true);
+ });
+
it("keeps its last count when the check fails", async () => {
// A backend hiccup must not put an error in front of somebody who is
// working — the control is a convenience, never the workspace.
diff --git a/jarvis/ui/web/frontend/src/components/agentic/ContinueInterrupted.tsx b/jarvis/ui/web/frontend/src/components/agentic/ContinueInterrupted.tsx
index 4e594c5f1b..5d0297dcd4 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/ContinueInterrupted.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/ContinueInterrupted.tsx
@@ -32,7 +32,7 @@
*/
import { useCallback, useEffect, useState } from "react";
import * as Dialog from "@radix-ui/react-dialog";
-import { AlertCircle, FolderGit2, PlayCircle, Terminal, X } from "lucide-react";
+import { AlertCircle, FolderGit2, Loader2, PlayCircle, Terminal, X } from "lucide-react";
import { useT } from "@/i18n";
import { cn } from "@/lib/utils";
@@ -92,6 +92,16 @@ export function continueOutcome(
.replace("{1}", result.continued.join(", ")),
);
}
+ // Held, not sent: their agents are still starting. Said separately because
+ // "carrying on" would be a claim about panes that have not been typed into
+ // yet — they are a promise the backend keeps a few seconds later.
+ if (result.queued.length > 0) {
+ parts.push(
+ t("agentic_grid.continue.result_queued")
+ .replace("{0}", String(result.queued.length))
+ .replace("{1}", result.queued.join(", ")),
+ );
+ }
// Its own sentence, never folded into the success count: those panes were
// typed into without a confirmed submit, so the text may be sitting in the
// input box waiting for a keypress the user has to make.
@@ -120,13 +130,20 @@ export function continueOutcome(
function PaneRow({
pane,
busy,
+ sending,
onContinue,
}: {
pane: InterruptedPane;
busy: boolean;
+ /** This pane's own instruction is in flight — its button is spent. */
+ sending: boolean;
onContinue: () => void;
}) {
const t = useT();
+ // Already spoken for: in flight from this window, or held by the backend
+ // until its agent comes up. Either way a second press would be a second
+ // "continue" into the same conversation.
+ const spent = sending || Boolean(pane.queued);
return (
<li
data-testid={`interrupted-pane-${pane.name}`}
@@ -161,16 +178,28 @@ function PaneRow({
{pane.blocked_reason}
</p>
)}
+ {pane.continuable && pane.starting && (
+ <p
+ data-testid={`interrupted-starting-${pane.name}`}
+ className="mt-1.5 text-xs text-muted-foreground"
+ >
+ {t("agentic_grid.continue.starting")}
+ </p>
+ )}
</div>
<button
type="button"
data-testid={`continue-pane-${pane.name}`}
className="btn-ghost shrink-0 disabled:cursor-not-allowed disabled:opacity-40"
- disabled={busy || !pane.continuable}
+ disabled={busy || spent || !pane.continuable}
onClick={onContinue}
>
- <PlayCircle className="h-4 w-4" />
- {t("agentic_grid.continue.one")}
+ {sending ? (
+ <Loader2 className="h-4 w-4 animate-spin" />
+ ) : (
+ <PlayCircle className="h-4 w-4" />
+ )}
+ {spent ? t("agentic_grid.continue.sending") : t("agentic_grid.continue.one")}
</button>
</div>
</li>
@@ -183,6 +212,10 @@ export function ContinueInterrupted({ busy = false }: ContinueInterruptedProps)
const [offer, setOffer] = useState<InterruptedOffer>(EMPTY);
const [open, setOpen] = useState(false);
const [working, setWorking] = useState(false);
+ // Call-signs whose instruction is in flight from THIS window. Per pane rather
+ // than one global flag, so continuing one pane does not freeze the buttons of
+ // the others while it waits for its screen to change.
+ const [sending, setSending] = useState<Set<string>>(() => new Set());
const refresh = useCallback(async (): Promise<InterruptedOffer> => {
try {
@@ -219,6 +252,16 @@ export function ContinueInterrupted({ busy = false }: ContinueInterruptedProps)
}, [refresh]);
const run = async (names?: string[]) => {
+ // Which panes this press owns, marked BEFORE the request goes out.
+ //
+ // Delivering a "continue" takes seconds — the submit is verified against
+ // the pane's own screen — and a button that stays live for that whole time
+ // is a button somebody presses again. The backend refuses the duplicate
+ // too (it claims each pane synchronously), but a control that looks
+ // clickable and silently does nothing is its own bug: this makes the wait
+ // visible where the click happened.
+ const claimed = names ?? offer.panes.filter((p) => p.continuable).map((p) => p.name);
+ setSending((current) => new Set([...current, ...claimed]));
setWorking(true);
try {
const result = await continueInterrupted(names);
@@ -231,6 +274,11 @@ export function ContinueInterrupted({ busy = false }: ContinueInterruptedProps)
} catch (e) {
pushToast("error", (e as Error).message);
} finally {
+ setSending((current) => {
+ const rest = new Set(current);
+ for (const name of claimed) rest.delete(name);
+ return rest;
+ });
setWorking(false);
}
};
@@ -318,7 +366,8 @@ export function ContinueInterrupted({ busy = false }: ContinueInterruptedProps)
<PaneRow
key={`${pane.workspace_id}:${pane.key}`}
pane={pane}
- busy={busy || working}
+ busy={busy}
+ sending={sending.has(pane.name)}
onContinue={() => void run([pane.name])}
/>
))}
@@ -341,11 +390,17 @@ export function ContinueInterrupted({ busy = false }: ContinueInterruptedProps)
disabled={busy || working || offer.continuable_count === 0}
onClick={() => void run()}
>
- <PlayCircle className="h-4 w-4" />
- {t("agentic_grid.continue.all").replace(
- "{0}",
- String(offer.continuable_count),
+ {working ? (
+ <Loader2 className="h-4 w-4 animate-spin" />
+ ) : (
+ <PlayCircle className="h-4 w-4" />
)}
+ {working
+ ? t("agentic_grid.continue.sending")
+ : t("agentic_grid.continue.all").replace(
+ "{0}",
+ String(offer.continuable_count),
+ )}
</button>
</div>
</div>
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 7f00c6c416..8f453307a2 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -3270,10 +3270,10 @@
"headline_stalled": "Bereit für Fragen, aber die Warteschlange steht.",
"headline_notready": "Noch nicht bereit für Fragen.",
"headline_empty": "Noch nichts gespeichert.",
- "headline_starting": "Der Wissensspeicher ist noch nicht geöffnet.",
- "detail_starting": "Solange er nicht offen ist, kann er nicht sagen, was er enthält — deshalb stehen hier keine Zahlen. Das erledigt sich meist Sekunden nach dem Start; wenn nicht, sagen die Prüfungen unten warum.",
+ "headline_starting": "Der Wissensspeicher ist noch nicht geöffnet.",
+ "detail_starting": "Solange er nicht offen ist, kann er nicht sagen, was er enthält — deshalb stehen hier keine Zahlen. Das erledigt sich meist Sekunden nach dem Start; wenn nicht, sagen die Prüfungen unten warum.",
"detail_done": "Alle {0} Einträge sind durchsuchbar und zusammengefasst.",
- "detail_working": "{0} von {1} werden noch {2}. Alles andere ist schon durchsuchbar — du musst nicht warten.",
+ "detail_working": "{0} von {1} sind noch {2}. Alles andere ist schon durchsuchbar; wie lange der Rest dauert, wird gerade gemessen.",
"detail_stalled": "{0} von {1} werden noch {2} — aber im Moment arbeitet nichts daran.",
"detail_notready": "Unten muss erst etwas geklärt werden, bevor Fragen beantwortet werden können. Die Liste darunter sagt, was.",
"detail_empty": "Füge eine Quelle hinzu, dann landen ihre Inhalte hier. Gelesen wird nichts, bevor du es erlaubst.",
@@ -3366,7 +3366,18 @@
"summary_blocked": "{0} können erst fortgesetzt werden, wenn ihre Agenten wieder laufen.",
"result_continued": "{0} Pane(s) machen weiter: {1}.",
"result_unconfirmed": "Diese Panes bitte selbst prüfen — die Anweisung wurde eingetippt, aber nicht sichtbar abgeschickt: {0}.",
- "result_failed": "Konnten nicht fortgesetzt werden: {0}."
+ "result_failed": "Konnten nicht fortgesetzt werden: {0}.",
+ "sending": "Wird gesendet …",
+ "starting": "Der Agent startet noch — er wird fortgesetzt, sobald er läuft.",
+ "result_queued": "{0} starten noch; sie machen weiter, sobald sie laufen: {1}."
+ },
+ "arrange": {
+ "carrying": "auf ein Terminal ziehen",
+ "swap": "Mit {0} tauschen",
+ "left": "Links von {0}",
+ "right": "Rechts von {0}",
+ "above": "Über {0}",
+ "below": "Unter {0}"
},
"selection": {
"start": "Terminals auswählen",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 7a48c621ba..ea53c390bd 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -3256,10 +3256,10 @@
"headline_stalled": "Ready to answer, but the queue is standing still.",
"headline_notready": "Not ready to answer yet.",
"headline_empty": "Nothing stored yet.",
- "headline_starting": "The knowledge store is not open yet.",
- "detail_starting": "Until it opens it cannot say what it holds, so no numbers are shown. This usually clears within seconds of starting the app; if it does not, the checks below say why.",
+ "headline_starting": "The knowledge store is not open yet.",
+ "detail_starting": "Until it opens it cannot say what it holds, so no numbers are shown. This usually clears within seconds of starting the app; if it does not, the checks below say why.",
"detail_done": "All {0} items are searchable and summarised.",
- "detail_working": "{0} of {1} are still {2}. Everything else can be searched right now — you do not have to wait.",
+ "detail_working": "{0} of {1} are still {2}. Everything else can be searched right now; how long the rest takes is still being measured.",
"detail_stalled": "{0} of {1} are still {2} — but nothing is processing them right now.",
"detail_notready": "Something below has to be sorted out before questions can be answered. The list underneath says what.",
"detail_empty": "Add a source and its contents land here. Nothing is read before you approve it.",
@@ -3352,7 +3352,18 @@
"summary_blocked": "{0} cannot be continued until their agents are running again.",
"result_continued": "{0} pane(s) carrying on: {1}.",
"result_unconfirmed": "Check these panes yourself — the instruction was typed in but never seen to submit: {0}.",
- "result_failed": "Could not be continued: {0}."
+ "result_failed": "Could not be continued: {0}.",
+ "sending": "Sending …",
+ "starting": "Its agent is still starting — it will be continued as soon as it is up.",
+ "result_queued": "{0} still starting; they carry on the moment they are up: {1}."
+ },
+ "arrange": {
+ "carrying": "drop it on a terminal",
+ "swap": "Swap with {0}",
+ "left": "Left of {0}",
+ "right": "Right of {0}",
+ "above": "Above {0}",
+ "below": "Below {0}"
},
"selection": {
"start": "Select terminals",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 4473fe4034..4626505d85 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -3255,10 +3255,10 @@
"headline_stalled": "Listo para responder, pero la cola está parada.",
"headline_notready": "Todavía no puede responder.",
"headline_empty": "Aún no hay nada guardado.",
- "headline_starting": "El almacén de conocimiento aún no está abierto.",
- "detail_starting": "Mientras no se abra no puede decir qué contiene, por eso no se muestran cifras. Suele resolverse a los pocos segundos de arrancar; si no, las comprobaciones de abajo dicen por qué.",
+ "headline_starting": "El almacén de conocimiento aún no está abierto.",
+ "detail_starting": "Mientras no se abra no puede decir qué contiene, por eso no se muestran cifras. Suele resolverse a los pocos segundos de arrancar; si no, las comprobaciones de abajo dicen por qué.",
"detail_done": "Los {0} elementos son buscables y están resumidos.",
- "detail_working": "{0} de {1} siguen {2}. Todo lo demás ya se puede buscar: no hace falta esperar.",
+ "detail_working": "{0} de {1} siguen {2}. Todo lo demás ya se puede buscar; cuánto tarda el resto se está midiendo.",
"detail_stalled": "{0} de {1} siguen {2}, pero ahora mismo nada los está procesando.",
"detail_notready": "Hay algo que resolver antes de poder responder preguntas. La lista de abajo dice qué.",
"detail_empty": "Añade una fuente y su contenido aparecerá aquí. Nada se lee antes de que lo apruebes.",
@@ -3351,7 +3351,18 @@
"summary_blocked": "{0} no se pueden continuar hasta que sus agentes vuelvan a ejecutarse.",
"result_continued": "{0} panel(es) continúan: {1}.",
"result_unconfirmed": "Revisa estos paneles tú mismo: la instrucción se escribió pero no se vio enviarse: {0}.",
- "result_failed": "No se pudieron continuar: {0}."
+ "result_failed": "No se pudieron continuar: {0}.",
+ "sending": "Enviando …",
+ "starting": "Su agente todavía está arrancando: continuará en cuanto esté listo.",
+ "result_queued": "{0} aún arrancan; seguirán en cuanto estén listos: {1}."
+ },
+ "arrange": {
+ "carrying": "suéltalo sobre un terminal",
+ "swap": "Intercambiar con {0}",
+ "left": "A la izquierda de {0}",
+ "right": "A la derecha de {0}",
+ "above": "Encima de {0}",
+ "below": "Debajo de {0}"
},
"selection": {
"start": "Seleccionar terminales",
diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
index 348a1dad59..87ba8077a8 100644
--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
@@ -288,8 +288,21 @@ export interface InterruptedPane {
agent: string;
display_name: string;
status: string;
- /** False when its agent is not running: an instruction cannot be typed into it. */
+ /**
+ * Will a "continue" reach it? False only when its agent is DEAD — a pane that
+ * is merely still starting IS continuable, the instruction just waits for it.
+ */
continuable: boolean;
+ /**
+ * Its agent is still coming up.
+ *
+ * Cold starts are staggered on purpose, so most of a big workspace is in this
+ * state for the first seconds after it appears — which is exactly when this
+ * button gets pressed. Those panes are queued, never skipped.
+ */
+ starting?: boolean;
+ /** A "continue" is already on its way to this pane. */
+ queued?: boolean;
/** Why not, in one sentence. Empty when it can be continued. */
blocked_reason: string;
/** What it was last asked to do. Empty when that instruction was typed in by hand. */
@@ -310,6 +323,11 @@ export interface ContinueResult {
ok: boolean;
/** Panes that accepted the instruction and started. */
continued: string[];
+ /**
+ * Panes whose agent had not started yet. The instruction is held and delivered
+ * when each comes up — "shortly", never "done".
+ */
+ queued: string[];
/**
* Panes the text was typed into without a confirmed submit — the prompt may be
* sitting in the input box. Reporting these as running is the one wrong thing
@@ -744,6 +762,7 @@ export async function continueInterrupted(
return {
ok: body.ok ?? false,
continued: body.continued ?? [],
+ queued: body.queued ?? [],
unconfirmed: body.unconfirmed ?? [],
failed: body.failed ?? [],
remaining: body.remaining ?? 0,
diff --git a/tests/unit/agentic_ide/test_interrupted.py b/tests/unit/agentic_ide/test_interrupted.py
index 01190f43d4..e8f9e93e68 100644
--- a/tests/unit/agentic_ide/test_interrupted.py
+++ b/tests/unit/agentic_ide/test_interrupted.py
@@ -13,12 +13,13 @@ a false one offers to type "continue" behind a prompt the user is still writing.
from __future__ import annotations
+import asyncio
from pathlib import Path
from typing import Any
import pytest
-from jarvis.agentic_ide import interrupted
+from jarvis.agentic_ide import interrupted, resume_store
from jarvis.agentic_ide import session as session_mod
from jarvis.agentic_ide.agent_sessions import ResumeHandle
from jarvis.agentic_ide.session import Registry
@@ -41,6 +42,9 @@ def registry(fake_pty: FakePtyManager, monkeypatch: pytest.MonkeyPatch) -> Regis
monkeypatch.setattr(session_mod, "_SUBMIT_RETRY_AFTER_S", 0.02)
monkeypatch.setattr(session_mod, "_ARRIVAL_POLL_S", 0.01)
monkeypatch.setattr(session_mod, "_ARRIVAL_WINDOW_S", 0.04)
+ # A deferred continue waits for the CLI's boot burst to clear before typing.
+ # Real length, no value to a test that owns a fake terminal.
+ monkeypatch.setattr(session_mod, "CONTINUE_AFTER_START_S", 0.01)
return Registry(pty_manager=fake_pty)
@@ -265,6 +269,124 @@ async def test_a_dead_pane_fails_with_its_reason(
assert report.failed == [(term.name, "claude is not on PATH.")]
+# ------------------------------------------------------ pressing twice, big grids
+# Three live complaints, one test group. All of them are about a workspace with
+# more than a couple of panes, which is the only size where any of them shows up.
+
+
+async def test_pressing_continue_twice_sends_it_once(
+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path, existing_conversation: Any
+) -> None:
+ """A second press while the first is in flight must not repeat the word.
+
+ Delivering a prompt takes seconds — the submit is verified against the pane's
+ own screen — and the pane used to stay on the waiting list for all of it. So
+ two presses put "continue" into the agent twice and three put it in three
+ times, which is what the user saw.
+ """
+ fake_pty.tui_echo = True
+ _session, term = await _restarted_pane(registry, tmp_path, existing_conversation)
+
+ first, second = await asyncio.gather(
+ interrupted.continue_panes(registry),
+ interrupted.continue_panes(registry),
+ )
+
+ assert fake_pty.typed.count(interrupted.CONTINUE_PROMPT) == 1, fake_pty.typed
+ assert sorted([*first.continued, *second.continued]) == [term.name]
+ # The press that lost the race says nothing happened rather than claiming it
+ # continued a pane it never touched.
+ assert not (first.failed or second.failed)
+
+
+async def test_a_pane_still_starting_is_continued_when_it_comes_up(
+ registry: Registry, fake_pty: FakePtyManager, tmp_path: Path, existing_conversation: Any
+) -> None:
+ """The big-workspace bug: cold starts are staggered, so most panes are `pending`.
+
+ Pressing Continue in that window used to reach only the handful that had
+ already started — reported as "some terminals are skipped". The instruction
+ is now held and delivered when the pane's agent appears.
+ """
+ fake_pty.tui_echo = True
+ session = await registry.start(
+ str(tmp_path), [{"agent": "claude", "name": "Alex"}, {"agent": "claude", "name": "Blake"}]
+ )
+ existing_conversation("conv-late")
+ late = session.terminals[1]
+ late.resume = ResumeHandle(kind="claude_session", id="conv-late", captured_at=1.0)
+ late.continuation_pending = True # what a restore establishes before any spawn
+
+ report = await interrupted.continue_panes(registry)
+
+ assert report.queued == ["Blake"], "a pane that has not started yet is queued, not skipped"
+ assert report.continued == []
+ assert late.continue_when_ready is True
+
+ # Now the grid gets round to it — the pane connects and its agent starts.
+ await registry.attach("Blake", 100, 30, _noop, _noop_exit)
+ await _settle()
+
+ assert fake_pty.typed.count(interrupted.CONTINUE_PROMPT) == 1, fake_pty.typed
+ assert late.continue_when_ready is False
+ assert interrupted.scan(registry) == []
+
+
+async def test_a_restored_pane_is_listed_before_its_agent_starts(
+ registry: Registry, tmp_path: Path, existing_conversation: Any
+) -> None:
+ """A restore knows what has work to continue — it does not need the spawn.
+
+ This is the other half of the same bug: the list itself used to fill up only
+ as the panes started, so a user who pressed the button early was shown three
+ of twelve and told that was all of them.
+ """
+ existing_conversation("conv-restored")
+ resume_store.save(
+ resume_store.Snapshot(
+ saved_at=100.0,
+ workspaces=[
+ resume_store.SnapshotWorkspace(
+ session_id="ide_old",
+ folder=str(tmp_path),
+ terminals=[
+ resume_store.SnapshotTerminal(
+ key="alex",
+ name="Alex",
+ agent="claude",
+ resume=ResumeHandle(
+ kind="claude_session", id="conv-restored", captured_at=1.0
+ ),
+ prompts_sent=2,
+ ),
+ # No handle at all: nothing to continue, so it must NOT
+ # be offered — that would be a promise with nothing
+ # behind it.
+ resume_store.SnapshotTerminal(key="blake", name="Blake", agent="claude"),
+ ],
+ )
+ ],
+ )
+ )
+
+ await registry.restore(resume_store.load())
+
+ waiting = interrupted.scan(registry)
+ assert [pane.name for pane in waiting] == ["Alex"]
+ assert waiting[0].status == "pending", "listed before anything spawned"
+ assert waiting[0].continuable is True
+ assert waiting[0].starting is True
+
+
+async def _settle() -> None:
+ """Wait for the deferred continue task, rather than sleeping a guessed span."""
+ for _ in range(200):
+ pending = [t for t in asyncio.all_tasks() if t is not asyncio.current_task()]
+ if not pending:
+ return
+ await asyncio.wait(pending, timeout=1.0)
+
+
# ----------------------------------------------------------------- the routes
# The CLI-first contract: everything the button does is an endpoint, so the same
# action is reachable from `jarvis api agentic-ide ...` and from a coding agent.