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(society): every agent's card opens its own chat, not a "not bound yet" placeholder
rubenluetke10-beep6349d9a0622b
diff --git a/jarvis/society/runtime.py b/jarvis/society/runtime.pyindex a4e24b89f2..46239e2e3f 100644--- a/jarvis/society/runtime.py+++ b/jarvis/society/runtime.py@@ -163,6 +163,14 @@ class SocietyRuntime:def data_dir(self) -> Path:return self._data_dir+ def chat_service(self) -> Any | None:+ """The agent-chat service, when the app has one (None in the bare runtime)."""+ return self._get_chat()++ def config(self) -> Any:+ """The live app config the chat binding reads provider defaults from."""+ return self._get_cfg()+async def close(self) -> None:await self.browser.close()for task in list(self._watchers):diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsxindex 12b90565d2..3364aeebb1 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx@@ -23,7 +23,8 @@ import type { ReasoningBlock, TimelineItem, ToolBlock, TurnItem, UserItem } fromimport { ProviderLogo } from "@/components/providers/ProviderLogo";import { useT } from "@/i18n";import { cn } from "@/lib/utils";-import { useAgentChatStore } from "@/store/agentChat";+import { createAgentChatStore, useAgentChatStore } from "@/store/agentChat";+import type { AgentChatSurface } from "@/lib/agentChatApi";import { AgentSwatch } from "../AgentSwatch";import type { SocietyAgent } from "../data";@@ -39,21 +40,113 @@ export interface AgentChatPanelProps {roster: SocietyAgent[];}+/**+ * Every other agent speaks in its OWN canonical chat (`society:<agent_id>`,+ * surface `society`): the backend binds the session to the roster row on+ * request, and this store — one socket for the society surface — opens it.+ * The brain is the roster's choice, so the column shows it instead of the+ * front page's pickers.+ */+const useSocietyChatStore = createAgentChatStore("society");+export function AgentChatPanel({ agent, roster }: AgentChatPanelProps) {- if (agent.tier !== "lead") return <NotBoundYet />;+ if (agent.tier === "lead") {+ return (+ <AgentChatStoreProvider store={useAgentChatStore}>+ <JarvisChat agent={agent} roster={roster} />+ </AgentChatStoreProvider>+ );+ }+ if (!agent.chatSessionId) return <NotBoundYet />;return (- <AgentChatStoreProvider store={useAgentChatStore}>- <JarvisChat agent={agent} roster={roster} />+ <AgentChatStoreProvider store={useSocietyChatStore}>+ <SpecialistChat agent={agent} roster={roster} /></AgentChatStoreProvider>);}-function NotBoundYet() {+function NotBoundYet({ detail }: { detail?: string | null }) {const t = useT();return (<div className="flex h-full flex-col items-center justify-center gap-2 p-6 text-center"><p className="text-sm font-medium text-foreground">{t("society.card.chat_empty_title")}</p>- <p className="max-w-[30ch] text-xs text-muted-foreground">{t("society.card.chat_empty_hint")}</p>+ <p className="max-w-[30ch] text-xs text-muted-foreground">{detail ?? t("society.card.chat_empty_hint")}</p>+ </div>+ );+}++async function bindAgentChat(agentId: string): Promise<void> {+ const res = await fetch(`/api/society/agents/${encodeURIComponent(agentId)}/chat`, { method: "POST" });+ if (!res.ok) throw new Error(`HTTP ${res.status}`);+}++function SpecialistChat({ agent, roster }: AgentChatPanelProps) {+ const t = useT();+ const items = useAgentChat((s) => s.timeline.items);+ const activeSessionId = useAgentChat((s) => s.activeSessionId);+ const busy = useAgentChat((s) => s.busy);+ const lastError = useAgentChat((s) => s.lastError);+ const loadCatalog = useAgentChat((s) => s.loadCatalog);+ const loadSessions = useAgentChat((s) => s.loadSessions);+ const openSession = useAgentChat((s) => s.openSession);+ const send = useAgentChat((s) => s.send);+ const cancel = useAgentChat((s) => s.cancel);+ const decide = useAgentChat((s) => s.decide);+ const [bindError, setBindError] = useState<string | null>(null);+ const sessionId = agent.chatSessionId;++ // Bind first (idempotent, no spend), then open: the socket needs the row to exist.+ useEffect(() => {+ if (!sessionId) return;+ let alive = true;+ setBindError(null);+ void (async () => {+ try {+ await bindAgentChat(agent.agentId);+ await loadCatalog();+ await loadSessions();+ if (alive) openSession(sessionId);+ } catch (err) {+ if (alive) setBindError(err instanceof Error ? err.message : String(err));+ }+ })();+ return () => {+ alive = false;+ };+ }, [agent.agentId, sessionId, loadCatalog, loadSessions, openSession]);++ const mentionable = useMemo(+ () => roster.filter((a) => a.agentId !== agent.agentId && a.tier !== "lead"),+ [roster, agent.agentId],+ );++ if (bindError) return <NotBoundYet detail={`${t("society.card.chat_bind_failed")} (${bindError})`} />;++ return (+ <div className="flex h-full min-h-0 flex-col" data-testid="society-chat">+ <div className="flex shrink-0 items-center gap-2 border-b border-border px-3 py-2 text-xs text-muted-foreground">+ {agent.provider ? <ProviderLogo providerId={agent.provider} label={agent.providerLabel} size="sm" /> : null}+ <span className="truncate text-foreground">{agent.providerLabel || t("society.chat.model_default")}</span>+ {agent.model ? <span className="truncate font-mono">{agent.model}</span> : null}+ {agent.effort ? <span className="ml-auto rounded-full border border-border px-2 py-0.5">{agent.effort}</span> : null}+ </div>+ <Transcript items={items} agent={agent} busy={busy} onDecide={decide} />+ {lastError ? (+ <p role="alert" className="px-4 pb-1 text-xs text-destructive">+ {lastError}+ </p>+ ) : null}+ <Composer+ agent={agent}+ mentionable={mentionable}+ busy={busy || activeSessionId !== sessionId}+ sessionId={activeSessionId}+ cwd=""+ provider={agent.provider}+ surface="society"+ onSend={send}+ onCancel={cancel}+ /></div>);}@@ -501,11 +594,13 @@ interface ComposerProps {sessionId: string | null;cwd: string;provider: string;+ /** Which chat surface the attachments belong to (the front page by default). */+ surface?: AgentChatSurface;onSend: (text: string, attachments?: ReturnType<typeof useChatAttachments>["attachments"]) => Promise<void>;onCancel: () => Promise<void>;}-function Composer({ agent, mentionable, busy, sessionId, cwd, provider, onSend, onCancel }: ComposerProps) {+function Composer({ agent, mentionable, busy, sessionId, cwd, provider, surface = "jarvis", onSend, onCancel }: ComposerProps) {const t = useT();const [value, setValue] = useState("");const [plusOpen, setPlusOpen] = useState(false);@@ -513,7 +608,7 @@ function Composer({ agent, mentionable, busy, sessionId, cwd, provider, onSend,const [mention, setMention] = useState<{ query: string; start: number } | null>(null);const textarea = useRef<HTMLTextAreaElement>(null);const fileInput = useRef<HTMLInputElement>(null);- const attachments = useChatAttachments({ sessionId, cwd, provider, surface: "jarvis" }, (message) => setProblem(message));+ const attachments = useChatAttachments({ sessionId, cwd, provider, surface }, (message) => setProblem(message));const dictation = useComposerDictation(value, setValue);const resize = useCallback(() => {diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 1fdfd73f2d..f2377fc788 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -5282,7 +5282,8 @@"last_active": "Zuletzt aktiv","never": "nie","chat_empty_title": "Noch kein Gespräch",- "chat_empty_hint": "Der Chat des Agenten öffnet sich hier, sobald das Society-Backend seine Sitzung anbindet."+ "chat_empty_hint": "Der Chat des Agenten öffnet sich hier, sobald das Society-Backend seine Sitzung anbindet.",+ "chat_bind_failed": "Der Chat konnte nicht verbunden werden."},"figure": {"drag_hint": "Ziehen zum Drehen und Kippen · Rad zum Zoomen · Doppelklick setzt zurück",@@ -5330,6 +5331,7 @@"tools_loading": "Fähigkeitenkatalog wird geladen…","tools_unavailable": "Kein Fähigkeitenkatalog erreichbar — Werkzeuge werden später auf der Karte gesetzt.","style": "Stil",+ "style_import_hint": "Eigene Figur über „.glb importieren“ hereinholen","style_soon": "Noch keine Figuren in diesem Stil — die Pipeline nimmt jeden Stil, der die Prüfung besteht","none": "Keins","title": "Agent erstellen",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex bc51d30854..e4abd65159 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -5282,7 +5282,8 @@"last_active": "Last active","never": "never","chat_empty_title": "No conversation yet",- "chat_empty_hint": "The agent's chat opens here once the society backend binds its session."+ "chat_empty_hint": "The agent's chat opens here once the society backend binds its session.",+ "chat_bind_failed": "The chat could not be bound."},"figure": {"drag_hint": "Drag to turn and tilt · wheel to zoom · double-click to reset",@@ -5330,6 +5331,7 @@"tools_loading": "Loading the capability catalog…","tools_unavailable": "No capability catalog reachable — tools are set on the card later.","style": "Style",+ "style_import_hint": "Bring your own figure in with Import .glb","style_soon": "No figures in this style yet — the pipeline takes any style that passes the gate","none": "None","title": "Create an agent",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex e958841941..10848f923c 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -5282,7 +5282,8 @@"last_active": "Última actividad","never": "nunca","chat_empty_title": "Aún no hay conversación",- "chat_empty_hint": "El chat del agente se abre aquí cuando el backend de la sociedad vincule su sesión."+ "chat_empty_hint": "El chat del agente se abre aquí cuando el backend de la sociedad vincule su sesión.",+ "chat_bind_failed": "No se pudo vincular el chat."},"figure": {"drag_hint": "Arrastra para girar e inclinar · rueda para acercar · doble clic restablece",@@ -5330,6 +5331,7 @@"tools_loading": "Cargando el catálogo de capacidades…","tools_unavailable": "No hay catálogo de capacidades — las herramientas se fijan después en la ficha.","style": "Estilo",+ "style_import_hint": "Trae tu propia figura con Importar .glb","style_soon": "Aún no hay figuras de este estilo — la canalización acepta cualquier estilo que pase la revisión","none": "Ninguno","title": "Crear un agente",diff --git a/jarvis/ui/web/society_routes.py b/jarvis/ui/web/society_routes.pyindex 849b7e126f..c7aaa43ea3 100644--- a/jarvis/ui/web/society_routes.py+++ b/jarvis/ui/web/society_routes.py@@ -225,6 +225,24 @@ async def patch_agent(agent_id: str, body: PatchAgentBody, request: Request) ->return {"agent": updated.to_dict()}[email protected]("/agents/{agent_id}/chat")+async def bind_agent_chat(agent_id: str, request: Request) -> dict[str, Any]:+ """The agent's canonical chat (``society:<agent_id>``), created or re-seated+ to the roster row. Idempotent and free of spend: nothing runs until a+ message is sent. The model card calls it before it opens the chat column."""+ rt = await _runtime(request)+ agent = await rt.roster.resolve(agent_id)+ if agent is None:+ raise HTTPException(404, {"reason": str(FailureReason.TARGET_UNKNOWN)})+ svc = rt.chat_service()+ if svc is None:+ raise HTTPException(503, "agent chat service unavailable")+ from jarvis.society.chat_binding import ensure_session++ session = ensure_session(svc, rt.config(), agent)+ return {"session": session.to_dict(), "agent_id": agent.agent_id}++@router.delete("/agents/{agent_id}")async def archive_agent(agent_id: str, request: Request) -> dict[str, Any]:rt = await _runtime(request)diff --git a/tests/unit/ui/web/test_society_routes.py b/tests/unit/ui/web/test_society_routes.pyindex b48e36fed0..c2d412f5d7 100644--- a/tests/unit/ui/web/test_society_routes.py+++ b/tests/unit/ui/web/test_society_routes.py@@ -354,6 +354,50 @@ def test_memory_overview_recall_and_promotion_through_approvals(memory_client):assert c.post("/api/society/memory/999/dismiss").status_code == 404+def test_bind_agent_chat_creates_the_canonical_session(tmp_path: Path):+ from jarvis.agent_chat.store import AgentChatStore++ class FakeService:+ def __init__(self, store: AgentChatStore) -> None:+ self.store = store++ def is_running(self, session_id: str) -> bool:+ return False++ svc = FakeService(AgentChatStore(tmp_path / "chat.db"))+ cfg = SimpleNamespace(+ memory=SimpleNamespace(data_dir=str(tmp_path / "data")),+ wiki=SimpleNamespace(vault_root=str(tmp_path / "vault")),+ )+ runtime = SocietyRuntime(+ tmp_path, seed_starter_team=False, chat_service=lambda: svc, cfg=lambda: cfg+ )+ app = FastAPI()+ app.include_router(router)+ app.state.society = None+ app.state.society_factory = lambda: runtime+ with TestClient(app) as c:+ c.post(+ "/api/society/agents", json={"name": "Scout", "provider": "openai", "model": "gpt-5"}+ )+ res = c.post("/api/society/agents/scout/chat")+ assert res.status_code == 200, res.text+ session = res.json()["session"]+ assert session["session_id"] == "society:scout" and session["surface"] == "society"+ assert session["provider"] == "openai" and session["model"] == "gpt-5"+ # Idempotent: the same session comes back, nothing is duplicated.+ again = c.post("/api/society/agents/scout/chat").json()["session"]+ assert again["session_id"] == session["session_id"]+ assert c.post("/api/society/agents/nobody/chat").status_code == 404+ svc.store.close()+++def test_bind_agent_chat_without_a_chat_service_is_503(memory_client):+ c, _ = memory_client+ c.post("/api/society/agents", json={"name": "Scout"})+ assert c.post("/api/society/agents/scout/chat").status_code == 503++def test_pausing_moves_the_figure_home(memory_client):c, _ = memory_clientc.post("/api/society/agents", json={"name": "Scout"})