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(society): quests wait for a busy agent, show live progress, and sit in a small quiet panel
rubenluetke10-beep1652773c9bce
diff --git a/jarvis/society/quests.py b/jarvis/society/quests.pyindex 23cdf7d440..f00b0cfe23 100644--- a/jarvis/society/quests.py+++ b/jarvis/society/quests.py@@ -28,6 +28,7 @@ the quest ``failed`` with the typed reason; ``retry`` routes it again.from __future__ import annotations+import asyncioimport jsonimport loggingimport re@@ -62,6 +63,13 @@ MIN_MATCH_SCORE: Final[int] = 3TERMINAL: Final[frozenset[QuestState]] = frozenset({QuestState.DONE, QuestState.FAILED, QuestState.CANCELLED})+#: Refusals that mean "not now", not "never": the quest waits and is routed again.+WAIT_REASONS: Final[frozenset[str]] = frozenset({"target_busy", "concurrency_cap"})+#: How long a waiting quest keeps knocking: every RETRY_DELAY_S, at most MAX_WAIT_ATTEMPTS.+RETRY_DELAY_S: Final[float] = 15.0+MAX_WAIT_ATTEMPTS: Final[int] = 40+#: How many progress lines a running quest keeps (newest last).+PROGRESS_KEEP: Final[int] = 6#: The generalist the foundry forges once when no specialist fits a quest.GENERALIST: Final[dict[str, Any]] = {@@ -294,10 +302,20 @@ class QuestRecord:class Quests:"""The quest board over the runtime: create → route → listen."""- def __init__(self, runtime: Any, *, publish: Callable[[Any], Any] | None = None) -> None:+ def __init__(+ self,+ runtime: Any,+ *,+ publish: Callable[[Any], Any] | None = None,+ retry_delay_s: float = RETRY_DELAY_S,+ ) -> None:self._runtime = runtimeself._publish = publish+ self._retry_delay = retry_delay_sself._unsubscribe: Callable[[], None] | None = None+ self._timers: dict[str, asyncio.TimerHandle] = {}+ self._attempts: dict[str, int] = {}+ self._tasks: set[asyncio.Task[Any]] = set()# ------------------------------------------------------------ wiring@@ -309,6 +327,89 @@ class Quests:if self._unsubscribe is not None:self._unsubscribe()self._unsubscribe = None+ for handle in self._timers.values():+ handle.cancel()+ self._timers.clear()+ for task in list(self._tasks):+ task.cancel()+ self._tasks.clear()++ # ------------------------------------------------------------ waiting++ def blocker_of(self, agent_id: str) -> str:+ """Why the agent cannot take work right now: ``approval`` (its chat waits+ for the person), ``busy`` (a turn runs), or an empty string."""+ get_chat = getattr(self._runtime, "_get_chat", None)+ svc = get_chat() if callable(get_chat) else None+ if svc is None:+ return ""+ session_id = f"society:{agent_id}"+ try:+ pending = getattr(svc, "pending_approvals", None)+ if callable(pending) and pending(session_id):+ return "approval"+ if svc.is_running(session_id):+ return "busy"+ except Exception: # noqa: BLE001 - the blocker is a hint for the card, never a gate+ log.debug("society quests: blocker probe failed for %s", agent_id, exc_info=True)+ return ""++ def _arm(self, quest_id: str, delay_s: float) -> None:+ old = self._timers.pop(quest_id, None)+ if old is not None:+ old.cancel()+ try:+ loop = asyncio.get_running_loop()+ except RuntimeError:+ return+ self._timers[quest_id] = loop.call_later(delay_s, self._fire, quest_id)++ def _fire(self, quest_id: str) -> None:+ self._timers.pop(quest_id, None)+ task = asyncio.create_task(self._retry_waiting(quest_id))+ self._tasks.add(task)+ task.add_done_callback(self._tasks.discard)++ async def _retry_waiting(self, quest_id: str) -> None:+ try:+ quest = await self.get(quest_id)+ if quest is None or quest.state is not QuestState.OPEN:+ return+ await self.route(quest_id)+ except asyncio.CancelledError:+ raise+ except Exception: # noqa: BLE001 - a failed knock is logged; the next timer knocks again+ log.warning("society quests: retry of %s failed", quest_id, exc_info=True)++ async def _wake_waiting(self) -> None:+ """A slot was freed: the oldest waiting quests knock right away."""+ waiting = sorted(await self.list(state=QuestState.OPEN), key=lambda q: q.created_ms)+ for quest in waiting:+ if quest.result.get("status") == "waiting":+ await self.route(quest.quest_id)++ async def note_progress(self, trace_id: str, line: str, *, live: str | None = None) -> None:+ """A running quest's latest step (from the agent's turn) for the card."""+ row = await self._runtime.store.get_quest_row_by_trace(trace_id)+ if row is None:+ return+ quest = QuestRecord.from_row(row)+ if quest.state is not QuestState.RUNNING:+ return+ result = dict(quest.result)+ progress = list(result.get("progress") or [])+ line = line.strip()+ if line and (not progress or progress[-1] != line):+ progress.append(line[:160])+ result["progress"] = progress[-PROGRESS_KEEP:]+ if live is not None:+ result["live"] = live.strip()[:240]+ await self._runtime.store.update_quest(+ quest.quest_id, {"result_json": json.dumps(result), "updated_ms": now_ms()}+ )+ fresh = await self.get(quest.quest_id)+ if fresh is not None:+ await self._announce(fresh, previous=quest.state)# ------------------------------------------------------------- reads@@ -364,6 +465,8 @@ class Quests:raise KeyError(quest_id)if quest.state in TERMINAL and quest.state is not QuestState.FAILED:return quest+ if quest.state is not QuestState.OPEN:+ self._attempts.pop(quest_id, None)roster = self._runtime.rosteragents = await roster.list()busy = {a.agent_id: self._runtime.scheduler.active_runs(a.agent_id) for a in agents}@@ -439,6 +542,10 @@ class Quests:return questif quest.run_id:self._runtime.scheduler.note_run_ended(quest.run_id)+ handle = self._timers.pop(quest_id, None)+ if handle is not None:+ handle.cancel()+ self._attempts.pop(quest_id, None)await self._set(quest, state=QuestState.CANCELLED, done_ms=now_ms())fresh = await self.get(quest_id)assert fresh is not None@@ -448,6 +555,8 @@ class Quests:async def _on_envelope(self, env: SocietyEnvelope) -> None:if not env.trace_id.startswith(TRACE_PREFIX):+ if env.msg_type is MsgType.RESULT:+ await self._wake_waiting()returnrow = await self._runtime.store.get_quest_row_by_trace(env.trace_id)if row is None:@@ -468,11 +577,30 @@ class Quests:"text": env.text,}state = QuestState.FAILED if status == "blocked" else QuestState.DONE+ result["progress"] = list(quest.result.get("progress") or [])await self._set(quest, state=state, result_json=json.dumps(result), done_ms=env.ts_ms)+ self._attempts.pop(quest.quest_id, None)+ await self._wake_waiting()elif env.msg_type is MsgType.VETO:+ reason = str(env.payload.get("reason", ""))+ attempts = self._attempts.get(quest.quest_id, 0) + 1+ if reason in WAIT_REASONS and attempts <= MAX_WAIT_ATTEMPTS:+ # Not now, not never: the quest waits on the board and knocks again.+ self._attempts[quest.quest_id] = attempts+ result = {+ "status": "waiting",+ "reason": reason,+ "blocker": self.blocker_of(quest.agent_id) if quest.agent_id else "",+ "text": env.text,+ "attempts": attempts,+ }+ await self._set(quest, state=QuestState.OPEN, result_json=json.dumps(result))+ self._arm(quest.quest_id, self._retry_delay)+ return+ self._attempts.pop(quest.quest_id, None)result = {"status": "vetoed",- "reason": env.payload.get("reason", ""),+ "reason": reason,"retry": env.payload.get("retry", ""),"text": env.text,}diff --git a/jarvis/society/runtime.py b/jarvis/society/runtime.pyindex 46239e2e3f..5f00089001 100644--- a/jarvis/society/runtime.py+++ b/jarvis/society/runtime.py@@ -306,6 +306,7 @@ class SocietyRuntime:error = ""tool_steps: list[str] = []used_browser = False+ quest_trace = env.trace_id.startswith("quest:")try:while True:event = await queue.get()@@ -315,10 +316,15 @@ class SocietyRuntime:continueif kind == "assistant_text":final_text = str(payload.get("text") or final_text)+ if quest_trace:+ await self.quests.note_progress(env.trace_id, "", live=final_text)elif kind == "tool_call":name = str(payload.get("name") or payload.get("tool") or "tool")summary = str(payload.get("summary") or "")[:120]- tool_steps.append(f"{name}: {summary}" if summary else name)+ step = f"{name}: {summary}" if summary else name+ tool_steps.append(step)+ if quest_trace:+ await self.quests.note_progress(env.trace_id, step)if name == "society_browser":used_browser = Trueelif kind == "error":diff --git a/jarvis/ui/web/frontend/src/components/society/world/QuestBoardDrawer.tsx b/jarvis/ui/web/frontend/src/components/society/world/QuestBoardDrawer.tsxindex 3013091d52..b83ac7bea2 100644--- a/jarvis/ui/web/frontend/src/components/society/world/QuestBoardDrawer.tsx+++ b/jarvis/ui/web/frontend/src/components/society/world/QuestBoardDrawer.tsx@@ -1,25 +1,25 @@/**- * What a click on the Quest Board opens: a composer to post a quest and the- * board itself — what is being worked on, what waits, what is done — as a- * drawer over the island (one-viewer doctrine: the world keeps living behind- * it). The list is live: every change on the backend arrives as a push and- * re-reads it within a second. The drawer is app chrome, so it wears the- * theme tokens; only the state dots echo the monument's scroll colours.+ * The Quest Board panel — small and quiet, the way a game's quest list sits+ * at the edge of the screen: a one-line box to post a quest, then compact+ * cards with a thin progress bar. A running quest shows what its agent is+ * doing right now (the latest step and sentence from the turn); a waiting+ * one says whom it waits for and why; a finished one folds its handoff+ * behind a tap. Live: every backend change arrives as a push within a second.+ * App chrome, so theme tokens; only the state colours echo the monument.*/import { useEffect, useMemo, useState, type FormEvent } from "react";-import { ExternalLink, RotateCcw, X } from "lucide-react";+import { ChevronDown, ChevronRight, Plus, RotateCcw, X } from "lucide-react";import { fill, useT } from "@/i18n";import type { QuestState, SocietyQuestRow } from "@/lib/societyApi";import { cn } from "@/lib/utils";-import { useEventStore } from "@/store/events";import { useSocietyRoster } from "../data";-import { ageOf, groupQuests, takerKind, type QuestGroup } from "./questBoard";+import { ageOf, groupQuests, takerKind } from "./questBoard";import { useCancelQuest, usePostQuest, useRetryQuest, useSocietyQuests } from "./questsData";-const STATE_DOT: Record<QuestState, string> = {- open: "#c9c2b2",+const STATE_COLOR: Record<QuestState, string> = {+ open: "#ffb703",assigned: "#ffb703",running: "#4cc9f0",done: "#06d6a0",@@ -27,142 +27,156 @@ const STATE_DOT: Record<QuestState, string> = {cancelled: "#8b8f9c",};-const GROUPS: ReadonlyArray<{ key: QuestGroup; labelKey: string }> = [- { key: "active", labelKey: "quest_group_active" },- { key: "done", labelKey: "quest_group_done" },- { key: "failed", labelKey: "quest_group_failed" },- { key: "cancelled", labelKey: "quest_group_cancelled" },-];--function useNow(tickMs = 30_000): number {- const [now, setNow] = useState(() => Date.now());- useEffect(() => {- const id = window.setInterval(() => setNow(Date.now()), tickMs);- return () => window.clearInterval(id);- }, [tickMs]);- return now;+function ProgressBar({ state }: { state: QuestState }) {+ const color = STATE_COLOR[state];+ const width = state === "done" ? "100%" : state === "failed" || state === "cancelled" ? "100%" : state === "running" ? "60%" : "18%";+ return (+ <div className="mt-1.5 h-[3px] w-full overflow-hidden rounded-full bg-foreground/10" aria-hidden>+ <div+ className={cn("h-full rounded-full transition-[width] duration-500", state === "running" && "sw-quest-shimmer")}+ style={{ width, background: color, opacity: state === "cancelled" ? 0.5 : 1 }}+ />+ </div>+ );}-function QuestRow({+function QuestCard({row,agentName,- agentColor,now,+ onOpenAgent,}: {row: SocietyQuestRow;agentName: string | null;- agentColor: string | null;now: number;+ onOpenAgent?: (agentId: string) => void;}) {const t = useT();const [open, setOpen] = useState(false);const cancel = useCancelQuest();const retry = useRetryQuest();+ const agent = agentName ?? row.agent_id ?? "";+ const kind = takerKind(row);+ const waiting = row.state === "open" && row.result?.status === "waiting";+ const active = row.state === "open" || row.state === "assigned" || row.state === "running";const age = ageOf(row.done_ms ?? row.created_ms, now);const ageText =age.unit === "now" ? t("society.world.quest_age_now") : fill(t(`society.world.quest_age_${age.unit}`), { n: age.n });- const kind = takerKind(row);- const takerText =- kind === "none"- ? t("society.world.quest_no_taker")- : fill(t(kind === "forged" ? "society.world.quest_forged" : "society.world.quest_taken_by"), {- agent: agentName ?? row.agent_id ?? "",- });- const active = row.state === "open" || row.state === "assigned" || row.state === "running";- const retryable = row.state === "failed" || row.state === "open";- const handoff = row.result?.done || row.result?.text || "";- const refusal = row.result?.status === "vetoed" ? row.result.reason || row.result.text || "" : "";+ let line: string;+ if (row.state === "running") {+ const progress = row.result?.progress ?? [];+ line = row.result?.live || progress[progress.length - 1] || fill(t("society.world.quest_taken_by"), { agent });+ } else if (waiting) {+ line = fill(+ t(row.result?.blocker === "approval" ? "society.world.quest_wait_approval" : "society.world.quest_wait_busy"),+ { agent },+ );+ } else if (row.state === "failed") {+ line = row.result?.status === "vetoed" ? fill(t("society.world.quest_refused"), { reason: row.result.reason ?? "" }) : row.result?.done || t("society.world.quest_state.failed");+ } else if (row.state === "done") {+ line = row.result?.done || row.result?.text || t("society.world.quest_state.done");+ } else if (kind === "none") {+ line = t("society.world.quest_no_taker");+ } else {+ line = fill(t(kind === "forged" ? "society.world.quest_forged" : "society.world.quest_taken_by"), { agent });+ }++ const Chevron = open ? ChevronDown : ChevronRight;return (- <li className="rounded-md border border-border bg-background/60">- <button- type="button"- onClick={() => setOpen((v) => !v)}- className="flex w-full items-start gap-2.5 px-3 py-2 text-left"- aria-expanded={open}- >- <span- className={cn("mt-1.5 inline-block h-2.5 w-2.5 shrink-0 rounded-full", row.state === "running" && "animate-pulse")}- style={{ background: STATE_DOT[row.state] }}- aria-hidden- />+ <li className="rounded-md border border-border/70 bg-background/70 px-2.5 py-2">+ <button type="button" onClick={() => setOpen((v) => !v)} className="flex w-full items-start gap-2 text-left" aria-expanded={open}>+ <span className="mt-[3px] inline-block h-2 w-2 shrink-0 rounded-full" style={{ background: STATE_COLOR[row.state] }} aria-hidden /><span className="min-w-0 flex-1">- <span className="block truncate text-sm font-medium text-foreground">{row.title}</span>- <span className="mt-0.5 flex items-center gap-1.5 text-xs text-muted-foreground">- {agentColor && <span className="inline-block h-2 w-2 rounded-sm" style={{ background: agentColor }} aria-hidden />}- <span className="truncate">{takerText}</span>- <span aria-hidden>·</span>- <span className="shrink-0">{t(`society.world.quest_state.${row.state}`)}</span>- <span aria-hidden>·</span>- <span className="shrink-0 tabular-nums">{ageText}</span>+ <span className="flex items-baseline justify-between gap-2">+ <span className="truncate text-[12.5px] font-medium leading-4 text-foreground">{row.title}</span>+ <span className="shrink-0 text-[10.5px] tabular-nums text-muted-foreground">{ageText}</span></span>+ <span className="mt-0.5 block truncate text-[11px] leading-4 text-muted-foreground">{line}</span>+ <ProgressBar state={row.state} /></span>+ <Chevron size={12} className="mt-[3px] shrink-0 text-muted-foreground" aria-hidden /></button>{open && (- <div className="space-y-2 border-t border-border px-3 py-2 text-sm">+ <div className="mt-2 space-y-1.5 border-t border-border/70 pt-2 text-[11.5px] leading-4"><p className="whitespace-pre-wrap text-foreground">{row.text}</p>- {handoff && (- <div>- <div className="text-xs font-medium uppercase tracking-wide text-muted-foreground">- {t("society.world.quest_result_label")}- </div>- <p className="whitespace-pre-wrap text-foreground">{handoff}</p>- </div>+ {agent && (+ <p className="text-muted-foreground">+ {fill(t(kind === "forged" ? "society.world.quest_forged" : "society.world.quest_taken_by"), { agent })}+ </p>+ )}+ {(row.result?.progress?.length ?? 0) > 0 && (+ <ul className="space-y-0.5 text-muted-foreground">+ {row.result.progress?.map((step, i) => (+ <li key={`${i}-${step}`} className="truncate">+ · {step}+ </li>+ ))}+ </ul>+ )}+ {row.state === "done" && (row.result?.done || row.result?.text) && (+ <p className="whitespace-pre-wrap text-foreground">{row.result.done || row.result.text}</p>)}{row.result?.open && row.result.open.length > 0 && (- <div>- <div className="text-xs font-medium uppercase tracking-wide text-muted-foreground">- {t("society.world.quest_open_label")}- </div>- <ul className="list-disc pl-4 text-foreground">- {row.result.open.map((item) => (- <li key={item}>{item}</li>- ))}- </ul>- </div>+ <ul className="list-disc pl-4 text-foreground">+ {row.result.open.map((item) => (+ <li key={item}>{item}</li>+ ))}+ </ul>)}- {refusal && <p className="text-destructive">{fill(t("society.world.quest_refused"), { reason: refusal })}</p>}- <div className="flex gap-2 pt-1">+ <div className="flex flex-wrap gap-1.5 pt-0.5">+ {row.agent_id && onOpenAgent && (+ <button+ type="button"+ onClick={() => onOpenAgent(row.agent_id as string)}+ className="inline-flex h-6 items-center rounded-md bg-secondary px-2 text-[11px] font-medium text-foreground hover:bg-muted"+ >+ {fill(t("society.world.quest_open_agent"), { agent })}+ </button>+ )}{active && (<buttontype="button"disabled={cancel.isPending}onClick={() => cancel.mutate([row.quest_id])}- className="inline-flex h-7 items-center gap-1.5 rounded-md bg-secondary px-2.5 text-xs font-medium text-foreground hover:bg-muted disabled:opacity-50"+ className="inline-flex h-6 items-center gap-1 rounded-md bg-secondary px-2 text-[11px] font-medium text-foreground hover:bg-muted disabled:opacity-50">- <X size={12} />+ <X size={11} />{t("society.world.quest_cancel")}</button>)}- {retryable && (+ {row.state === "failed" && (<buttontype="button"disabled={retry.isPending}onClick={() => retry.mutate([row.quest_id])}- className="inline-flex h-7 items-center gap-1.5 rounded-md bg-secondary px-2.5 text-xs font-medium text-foreground hover:bg-muted disabled:opacity-50"+ className="inline-flex h-6 items-center gap-1 rounded-md bg-secondary px-2 text-[11px] font-medium text-foreground hover:bg-muted disabled:opacity-50">- <RotateCcw size={12} />+ <RotateCcw size={11} />{t("society.world.quest_retry")}</button>)}</div>- {(cancel.isError || retry.isError) && (- <p className="text-xs text-destructive">{String(cancel.error ?? retry.error)}</p>- )}+ {(cancel.isError || retry.isError) && <p className="text-destructive">{String(cancel.error ?? retry.error)}</p>}</div>)}</li>);}-export function QuestBoardDrawer({ onClose }: { onClose: () => void }) {+export function QuestBoardDrawer({ onClose, onOpenAgent }: { onClose: () => void; onOpenAgent?: (agentId: string) => void }) {const t = useT();- const setActiveSection = useEventStore((s) => s.setActiveSection);const quests = useSocietyQuests();const roster = useSocietyRoster();const post = usePostQuest();const [text, setText] = useState("");- const now = useNow();+ const [showHistory, setShowHistory] = useState(false);+ const [now, setNow] = useState(() => Date.now());++ useEffect(() => {+ const id = window.setInterval(() => setNow(Date.now()), 30_000);+ return () => window.clearInterval(id);+ }, []);useEffect(() => {const onKey = (e: KeyboardEvent) => {@@ -172,13 +186,16 @@ export function QuestBoardDrawer({ onClose }: { onClose: () => void }) {return () => window.removeEventListener("keydown", onKey);}, [onClose]);- const agents = useMemo(() => {- const byId = new Map<string, { name: string; color: string }>();- for (const a of roster.data?.agents ?? []) byId.set(a.agentId, { name: a.name, color: a.palette.accent });+ const names = useMemo(() => {+ const byId = new Map<string, string>();+ for (const a of roster.data?.agents ?? []) byId.set(a.agentId, a.name);return byId;}, [roster.data]);const groups = useMemo(() => groupQuests(quests.data ?? []), [quests.data]);+ const history = [...groups.done, ...groups.failed, ...groups.cancelled].sort(+ (a, b) => (b.done_ms ?? b.updated_ms) - (a.done_ms ?? a.updated_ms),+ );const total = quests.data?.length ?? 0;const submit = (e: FormEvent) => {@@ -188,90 +205,71 @@ export function QuestBoardDrawer({ onClose }: { onClose: () => void }) {post.mutate([clean, ""], { onSuccess: () => setText("") });};+ const card = (row: SocietyQuestRow) => (+ <QuestCard key={row.quest_id} row={row} agentName={row.agent_id ? (names.get(row.agent_id) ?? null) : null} now={now} onOpenAgent={onOpenAgent} />+ );+return (<aside- className="absolute inset-y-3 right-3 z-30 flex w-[360px] max-w-[85%] flex-col overflow-hidden rounded-lg border border-border bg-popover text-foreground shadow-float"+ className="absolute right-3 top-14 z-30 flex max-h-[min(70%,560px)] w-[272px] flex-col overflow-hidden rounded-lg border border-border bg-popover/95 text-foreground shadow-float backdrop-blur"role="dialog"aria-label={t("society.world.drawer_quests_title")}>- <header className="flex items-start justify-between gap-3 border-b border-border px-4 py-3">- <div className="min-w-0">- <h2 className="font-display text-base font-semibold tracking-tight">{t("society.world.drawer_quests_title")}</h2>- <p className="mt-0.5 text-xs text-muted-foreground">{t("society.world.drawer_quests_hint")}</p>- </div>- <button- type="button"- onClick={onClose}- aria-label={t("society.world.quest_close")}- className="rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground"- >- <X size={16} />+ <header className="flex items-center justify-between gap-2 px-3 pb-1.5 pt-2.5">+ <h2 className="font-display text-[13px] font-semibold tracking-tight">+ {t("society.world.drawer_quests_title")}+ {groups.active.length > 0 && <span className="ml-1.5 tabular-nums text-muted-foreground">{groups.active.length}</span>}+ </h2>+ <button type="button" onClick={onClose} aria-label={t("society.world.quest_close")} className="rounded-md p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground">+ <X size={14} /></button></header>- <form onSubmit={submit} className="border-b border-border px-4 py-3">+ <form onSubmit={submit} className="px-3 pb-2"><label htmlFor="sw-quest-text" className="sr-only">{t("society.world.quest_post")}</label>- <textarea- id="sw-quest-text"- value={text}- onChange={(e) => setText(e.target.value)}- onKeyDown={(e) => {- if ((e.metaKey || e.ctrlKey) && e.key === "Enter") submit(e);- }}- rows={3}- placeholder={t("society.world.quest_compose_placeholder")}- className="w-full resize-none rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"- />- <div className="mt-2 flex items-center justify-between gap-2">- <span className="text-xs text-muted-foreground">{t("society.world.quest_compose_hint")}</span>+ <div className="flex items-center gap-1.5 rounded-md border border-border bg-background px-2 focus-within:ring-2 focus-within:ring-ring">+ <input+ id="sw-quest-text"+ value={text}+ onChange={(e) => setText(e.target.value)}+ placeholder={t("society.world.quest_add_placeholder")}+ className="h-7 min-w-0 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"+ autoComplete="off"+ /><buttontype="submit"disabled={!text.trim() || post.isPending}- className="inline-flex h-8 items-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50"+ aria-label={t("society.world.quest_post")}+ title={t("society.world.quest_post")}+ className="rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40">- {post.isPending ? t("society.world.quest_posting") : t("society.world.quest_post")}+ <Plus size={14} /></button></div>- {post.isError && <p className="mt-1.5 text-xs text-destructive">{String(post.error)}</p>}+ {post.isError && <p className="mt-1 text-[11px] text-destructive">{String(post.error)}</p>}</form>- <div className="min-h-0 flex-1 overflow-y-auto px-4 py-3">- {quests.isLoading && <p className="text-sm text-muted-foreground">{t("society.world.quest_loading")}</p>}- {quests.isError && <p className="text-sm text-destructive">{String(quests.error)}</p>}- {quests.data && total === 0 && <p className="text-sm text-muted-foreground">{t("society.world.quest_empty")}</p>}- {GROUPS.filter((g) => groups[g.key].length > 0).map((g) => (- <section key={g.key} className="mb-4">- <h3 className="mb-1.5 flex items-center gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground">- {t(`society.world.${g.labelKey}`)}- <span className="tabular-nums">{groups[g.key].length}</span>- </h3>- <ul className="space-y-1.5">- {groups[g.key].map((row) => {- const agent = row.agent_id ? agents.get(row.agent_id) : undefined;- return (- <QuestRow- key={row.quest_id}- row={row}- agentName={agent?.name ?? null}- agentColor={agent?.color ?? null}- now={now}- />- );- })}- </ul>- </section>- ))}+ <div className="min-h-0 flex-1 overflow-y-auto px-3 pb-3">+ {quests.isLoading && <p className="text-[11.5px] text-muted-foreground">{t("society.world.quest_loading")}</p>}+ {quests.isError && <p className="text-[11.5px] text-destructive">{String(quests.error)}</p>}+ {quests.data && total === 0 && <p className="text-[11.5px] text-muted-foreground">{t("society.world.quest_empty")}</p>}+ {groups.active.length > 0 && <ul className="space-y-1.5">{groups.active.map(card)}</ul>}+ {history.length > 0 && (+ <div className={cn(groups.active.length > 0 && "mt-2")}>+ <button+ type="button"+ onClick={() => setShowHistory((v) => !v)}+ className="flex w-full items-center gap-1 py-1 text-[10.5px] font-medium uppercase tracking-wide text-muted-foreground hover:text-foreground"+ aria-expanded={showHistory}+ >+ {showHistory ? <ChevronDown size={11} /> : <ChevronRight size={11} />}+ {t("society.world.quest_group_history")}+ <span className="tabular-nums">{history.length}</span>+ </button>+ {showHistory && <ul className="space-y-1.5">{history.map(card)}</ul>}+ </div>+ )}</div>- <footer className="border-t border-border px-4 py-3">- <button- type="button"- onClick={() => setActiveSection("agents")}- className="inline-flex h-8 items-center gap-2 rounded-md bg-secondary px-3 text-sm font-medium text-foreground hover:bg-muted"- >- <ExternalLink size={14} />- {t("society.world.quest_open_ledger")}- </button>- </footer></aside>);}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 705cf50213..c27bc020b7 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -5162,6 +5162,11 @@"quest_wait_busy": "{agent} ist beschäftigt – die Quest startet, sobald er frei ist","quest_open_agent": "{agent} öffnen","quest_group_history": "Verlauf",+ "quest_add_placeholder": "Neue Quest… z. B. die fünf wichtigsten Mails von heute",+ "quest_wait_approval": "{agent} wartet in seinem Chat auf deine Freigabe – danach startet die Quest sofort",+ "quest_wait_busy": "{agent} ist beschäftigt – die Quest startet, sobald er frei ist",+ "quest_open_agent": "{agent} öffnen",+ "quest_group_history": "Verlauf","drawer_quests_title": "Questtafel","drawer_quests_hint": "Gib einen Auftrag auf. Der passende Agent übernimmt ihn – passt niemand, schmiedet die Foundry einen.","quest_compose_placeholder": "Was soll erledigt werden? Zum Beispiel: die fünf wichtigsten Mails von heute",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex d74f7edeb5..2747edcd51 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -5162,6 +5162,11 @@"quest_wait_busy": "{agent} is busy — the quest starts as soon as it is free","quest_open_agent": "Open {agent}","quest_group_history": "History",+ "quest_add_placeholder": "New quest… e.g. the five most important mails of today",+ "quest_wait_approval": "{agent} is waiting for your approval in its chat — the quest starts right after",+ "quest_wait_busy": "{agent} is busy — the quest starts as soon as it is free",+ "quest_open_agent": "Open {agent}",+ "quest_group_history": "History","drawer_quests_title": "Quest Board","drawer_quests_hint": "Post a job. The agent who fits takes it — when nobody fits, the Foundry forges one.","quest_compose_placeholder": "What should be done? For example: the five most important mails of today",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 450e61313e..357c16102b 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -5162,6 +5162,11 @@"quest_wait_busy": "{agent} está ocupado; la misión empieza en cuanto quede libre","quest_open_agent": "Abrir {agent}","quest_group_history": "Historial",+ "quest_add_placeholder": "Nueva misión… p. ej. los cinco correos más importantes de hoy",+ "quest_wait_approval": "{agent} espera tu aprobación en su chat; la misión empieza justo después",+ "quest_wait_busy": "{agent} está ocupado; la misión empieza en cuanto quede libre",+ "quest_open_agent": "Abrir {agent}",+ "quest_group_history": "Historial","drawer_quests_title": "Tablón de misiones","drawer_quests_hint": "Publica un encargo. El agente adecuado lo toma; si nadie encaja, la Fundición forja uno.","quest_compose_placeholder": "¿Qué hay que hacer? Por ejemplo: los cinco correos más importantes de hoy",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json b/jarvis/ui/web/frontend/src/i18n/locales/society/de.jsonindex 5670888372..5e06a20b9b 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json@@ -42,6 +42,11 @@"quest_wait_busy": "{agent} ist beschäftigt – die Quest startet, sobald er frei ist","quest_open_agent": "{agent} öffnen","quest_group_history": "Verlauf",+ "quest_add_placeholder": "Neue Quest… z. B. die fünf wichtigsten Mails von heute",+ "quest_wait_approval": "{agent} wartet in seinem Chat auf deine Freigabe – danach startet die Quest sofort",+ "quest_wait_busy": "{agent} ist beschäftigt – die Quest startet, sobald er frei ist",+ "quest_open_agent": "{agent} öffnen",+ "quest_group_history": "Verlauf","drawer_quests_title": "Questtafel","drawer_quests_hint": "Gib einen Auftrag auf. Der passende Agent übernimmt ihn – passt niemand, schmiedet die Foundry einen.","quest_compose_placeholder": "Was soll erledigt werden? Zum Beispiel: die fünf wichtigsten Mails von heute",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json b/jarvis/ui/web/frontend/src/i18n/locales/society/en.jsonindex f8bcc2d120..d7bfa2b52d 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json@@ -42,6 +42,11 @@"quest_wait_busy": "{agent} is busy — the quest starts as soon as it is free","quest_open_agent": "Open {agent}","quest_group_history": "History",+ "quest_add_placeholder": "New quest… e.g. the five most important mails of today",+ "quest_wait_approval": "{agent} is waiting for your approval in its chat — the quest starts right after",+ "quest_wait_busy": "{agent} is busy — the quest starts as soon as it is free",+ "quest_open_agent": "Open {agent}",+ "quest_group_history": "History","drawer_quests_title": "Quest Board","drawer_quests_hint": "Post a job. The agent who fits takes it — when nobody fits, the Foundry forges one.","quest_compose_placeholder": "What should be done? For example: the five most important mails of today",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json b/jarvis/ui/web/frontend/src/i18n/locales/society/es.jsonindex e92afe3726..5a7a7ceded 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json@@ -42,6 +42,11 @@"quest_wait_busy": "{agent} está ocupado; la misión empieza en cuanto quede libre","quest_open_agent": "Abrir {agent}","quest_group_history": "Historial",+ "quest_add_placeholder": "Nueva misión… p. ej. los cinco correos más importantes de hoy",+ "quest_wait_approval": "{agent} espera tu aprobación en su chat; la misión empieza justo después",+ "quest_wait_busy": "{agent} está ocupado; la misión empieza en cuanto quede libre",+ "quest_open_agent": "Abrir {agent}",+ "quest_group_history": "Historial","drawer_quests_title": "Tablón de misiones","drawer_quests_hint": "Publica un encargo. El agente adecuado lo toma; si nadie encaja, la Fundición forja uno.","quest_compose_placeholder": "¿Qué hay que hacer? Por ejemplo: los cinco correos más importantes de hoy",diff --git a/jarvis/ui/web/frontend/src/lib/societyApi.ts b/jarvis/ui/web/frontend/src/lib/societyApi.tsindex 1e4ad61dc9..947293c8ac 100644--- a/jarvis/ui/web/frontend/src/lib/societyApi.ts+++ b/jarvis/ui/web/frontend/src/lib/societyApi.ts@@ -186,6 +186,12 @@ export interface SocietyQuestRow {text?: string;reason?: string;retry?: string;+ /** "waiting" while a busy taker is knocked again; why (blocker: approval | busy). */+ blocker?: string;+ attempts?: number;+ /** Live while running: the latest tool steps and the agent's latest sentence. */+ progress?: string[];+ live?: string;};created_ms: number;updated_ms: number;diff --git a/tests/unit/society/test_quests.py b/tests/unit/society/test_quests.pyindex 6b774d8f16..35c09a888a 100644--- a/tests/unit/society/test_quests.py+++ b/tests/unit/society/test_quests.py@@ -176,17 +176,18 @@ async def test_result_closes_the_quest(rt: SocietyRuntime):assert rt.scheduler.active_runs(mailbox.agent_id) == 0-async def test_blocked_result_and_veto_fail_the_quest_and_retry_routes_again(rt: SocietyRuntime):+async def test_a_busy_taker_makes_the_quest_wait_and_a_freed_slot_starts_it(rt: SocietyRuntime):mailbox, _ = await rt.roster.create(name="Mailbox", focus=["plugin:gmail"], max_concurrent_runs=1)first = await rt.quests.create("Sort my mails")- # The one slot is taken: the next quest is vetoed by the concurrency cap.+ # The one slot is taken: the next quest waits on the board instead of failing.second = await rt.quests.create("Archive old mails")- assert second.state is QuestState.FAILED- assert second.result["status"] == "vetoed"+ assert second.state is QuestState.OPEN+ assert second.result["status"] == "waiting"assert second.result["reason"] == "concurrency_cap"- # The first one ends blocked.+ assert second.quest_id in rt.quests._timers # noqa: SLF001 — it knocks again by timer+ # The first one ends blocked -> failed; the freed slot starts the waiting one at once.await rt.store.append_and_publish(SocietyEnvelope(msg_type=MsgType.RESULT,@@ -201,10 +202,61 @@ async def test_blocked_result_and_veto_fail_the_quest_and_retry_routes_again(rt:))assert (await rt.quests.get(first.quest_id)).state is QuestState.FAILED # type: ignore[union-attr]- # Retry: the slot is free again, the second quest runs.- retried = await rt.quests.retry(second.quest_id)- assert retried.state is QuestState.RUNNING- assert retried.result == {}+ woken = await rt.quests.get(second.quest_id)+ assert woken is not None and woken.state is QuestState.RUNNING+ assert woken.result == {}+ # A hard refusal still fails: the kill switch is "never", not "not now".+ await rt.store.set_kill_switch(True)+ third = await rt.quests.create("Reply to the newsletter")+ assert third.state is QuestState.FAILED+ assert third.result["reason"] == "kill_switch"+ await rt.store.set_kill_switch(False)+ retried = await rt.quests.retry(third.quest_id)+ # Mailbox is still busy, so the retry lands on the forged generalist.+ assert retried.state is QuestState.RUNNING and retried.agent_id == "runner"+++async def test_waiting_quests_knock_again_by_timer(tmp_path: Path):+ runtime = SocietyRuntime(tmp_path, seed_starter_team=False)+ runtime.catalog = lambda: CATALOG # type: ignore[method-assign]+ await runtime.ensure_started()+ runtime.scheduler._dispatch = FakeDispatcher() # noqa: SLF001+ runtime.quests._publish = lambda _e: None # noqa: SLF001+ runtime.quests._retry_delay = 0.05 # noqa: SLF001+ try:+ mailbox, _ = await runtime.roster.create(+ name="Mailbox", focus=["plugin:gmail"], max_concurrent_runs=1+ )+ first = await runtime.quests.create("Sort my mails")+ second = await runtime.quests.create("Archive old mails")+ assert second.state is QuestState.OPEN+ # Free the slot silently (no RESULT): only the timer can notice.+ runtime.scheduler.note_run_ended(first.run_id)+ import asyncio++ await asyncio.sleep(0.3)+ woken = await runtime.quests.get(second.quest_id)+ assert woken is not None and woken.state is QuestState.RUNNING+ assert mailbox.agent_id == woken.agent_id+ finally:+ await runtime.close()+++async def test_progress_lines_reach_the_card_while_running(rt: SocietyRuntime):+ await rt.roster.create(name="Mailbox", focus=["plugin:gmail"])+ quest = await rt.quests.create("Sort my mails")+ await rt.quests.note_progress(quest.trace_id, "gmail_list: 40 mails")+ await rt.quests.note_progress(quest.trace_id, "gmail_list: 40 mails") # duplicate step+ await rt.quests.note_progress(quest.trace_id, "", live="Reading the newest ones…")+ fresh = await rt.quests.get(quest.quest_id)+ assert fresh is not None+ assert fresh.result["progress"] == ["gmail_list: 40 mails"]+ assert fresh.result["live"] == "Reading the newest ones…"+ assert rt.pushed[-1].state == "running" # type: ignore[attr-defined]+ # A quest that is not running ignores late progress.+ await rt.quests.cancel(quest.quest_id)+ await rt.quests.note_progress(quest.trace_id, "late step")+ assert "late step" not in (await rt.quests.get(quest.quest_id)).result.get("progress", []) # type: ignore[union-attr]async def test_cancel_frees_the_slot_and_ignores_the_late_result(rt: SocietyRuntime):