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(chat): actually run the agent on send, and delete the buttons that did nothing
rubenluetke10-beep440b0667dd2f
diff --git a/jarvis/ui/web/chat_library_routes.py b/jarvis/ui/web/chat_library_routes.pyindex d966d257aa..059eef52b4 100644--- a/jarvis/ui/web/chat_library_routes.py+++ b/jarvis/ui/web/chat_library_routes.py@@ -123,6 +123,11 @@ class PatchChatIn(BaseModel):archived: bool | None = Nonemodel: str | None = Noneaccount: str | None = None+ #: Which live pane this chat is attached to. Written by the surface once a+ #: prompt has actually started an agent, so reopening the chat finds the+ #: terminal that already holds the conversation instead of starting a+ #: second one beside it.+ terminal: str | None = Noneclass RemovedOut(BaseModel):diff --git a/jarvis/ui/web/frontend/src/components/chat/ChatActivity.tsx b/jarvis/ui/web/frontend/src/components/chat/ChatActivity.tsxnew file mode 100644index 0000000000..2b3be78c11--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/chat/ChatActivity.tsx@@ -0,0 +1,143 @@+/**+ * What the coding agent is actually doing, as a readable feed.+ *+ * A pane carries a *terminal protocol*, not a log: a coding CLI repaints rows+ * in place, so the raw stream is unreadable and merely stripping the escape+ * codes leaves the surviving text in an order nobody wrote. The backend already+ * solves that — it replays the terminal onto a screen and reads the transcript+ * off it (`jarvis/agentic_ide/transcript.py`) — so this polls THAT and renders+ * the result, rather than inventing a second parser that would be wrong in+ * different ways.+ *+ * The feed is the honest middle ground while the structured per-CLI reader is+ * built: it is what the agent printed, in the order it printed it, with the+ * decoration folded away. It is not a guess, and it is never empty while+ * something is happening.+ */+import { useEffect, useRef, useState } from "react";+import { Loader2, TriangleAlert } from "lucide-react";++import { cn } from "@/lib/utils";++/** How often the feed asks. Fast enough to feel live, cheap enough to leave on. */+const POLL_MS = 1200;++/** How much history the feed carries. Bounded — this is a view, not an archive. */+const LINES = 200;++interface Report {+ name: string;+ display_name?: string;+ status?: string;+ transcript?: string[];+}++export interface ChatActivityProps {+ /** Call-sign of the pane to follow. */+ terminal: string;+ /** Is this view on screen? Off-screen polling is stopped rather than throttled. */+ active?: boolean;+}++export function ChatActivity({ terminal, active = true }: ChatActivityProps) {+ const [report, setReport] = useState<Report | null>(null);+ const [error, setError] = useState<string | null>(null);+ const bottom = useRef<HTMLDivElement | null>(null);+ const scroller = useRef<HTMLDivElement | null>(null);+ /*+ * Follow the tail only while the reader IS at the tail.+ *+ * Scrolling up is a deliberate act — somebody is reading what already+ * happened — and yanking them back down every 1.2 seconds makes the history+ * unreadable. The moment they return to the bottom, following resumes.+ */+ const following = useRef(true);++ useEffect(() => {+ if (!active) return;+ let alive = true;+ const tick = async () => {+ try {+ const response = await fetch(+ `/api/agentic-ide/terminals/${encodeURIComponent(terminal)}/report?lines=${LINES}`,+ );+ if (!response.ok) throw new Error(await response.text());+ const body = (await response.json()) as Report;+ if (!alive) return;+ setReport(body);+ setError(null);+ } catch {+ if (!alive) return;+ // A pane that has gone away is a state, not a crash: the chat is still+ // readable and the header says the agent stopped.+ setError("This agent is no longer running.");+ }+ };+ void tick();+ const id = window.setInterval(() => void tick(), POLL_MS);+ return () => {+ alive = false;+ window.clearInterval(id);+ };+ }, [active, terminal]);++ useEffect(() => {+ if (following.current) bottom.current?.scrollIntoView({ block: "end" });+ }, [report]);++ const lines = report?.transcript ?? [];++ return (+ <div+ ref={scroller}+ data-testid="chat-activity"+ onScroll={(event) => {+ const node = event.currentTarget;+ following.current =+ node.scrollHeight - node.scrollTop - node.clientHeight < 48;+ }}+ className="min-h-0 flex-1 overflow-y-auto scrollbar-jarvis px-6 py-4"+ >+ <div className="mx-auto w-full max-w-3xl">+ {error && (+ <div className="mb-3 flex items-center gap-2 rounded-lg border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-xs text-amber-300">+ <TriangleAlert className="h-3.5 w-3.5 shrink-0" aria-hidden />+ {error}+ </div>+ )}+ {!report && !error && (+ <div className="flex items-center gap-2 text-xs text-muted-foreground">+ <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />+ Starting the agent…+ </div>+ )}+ {lines.length === 0 && report && !error && (+ <div className="text-xs text-muted-foreground">+ The agent is up and has not printed anything yet.+ </div>+ )}+ {lines.length > 0 && (+ <pre className="whitespace-pre-wrap break-words font-mono text-[12px] leading-relaxed text-foreground/85">+ {lines.join("\n")}+ </pre>+ )}+ <div ref={bottom} />+ </div>+ </div>+ );+}++/** A small live/idle mark for the chat header. */+export function ActivityDot({ status }: { status?: string }) {+ const working = status === "running" || status === "working";+ return (+ <span+ title={working ? "Working" : "Idle"}+ aria-label={working ? "Working" : "Idle"}+ className={cn(+ "h-1.5 w-1.5 shrink-0 rounded-full",+ working ? "animate-pulse bg-emerald-400" : "bg-muted-foreground/50",+ )}+ />+ );+}diff --git a/jarvis/ui/web/frontend/src/components/chat/ChatComposer.tsx b/jarvis/ui/web/frontend/src/components/chat/ChatComposer.tsxindex 8772188014..b35bd424cb 100644--- a/jarvis/ui/web/frontend/src/components/chat/ChatComposer.tsx+++ b/jarvis/ui/web/frontend/src/components/chat/ChatComposer.tsx@@ -27,7 +27,6 @@ import {Mic,Monitor,Paperclip,- ShieldCheck,ArrowUp,} from "lucide-react";@@ -50,10 +49,6 @@ export interface ChatComposerProps {modelId: string | null;onAgentChange: (agentId: string) => void;onModelChange: (modelId: string) => void;- /** How much the agent may do unasked. Wording comes from the caller. */- approval: string;- approvalOptions: readonly string[];- onApprovalChange: (value: string) => void;onSend: (text: string) => void | Promise<void>;/** Start dictation into this box. Absent = no speech-to-text on this device. */onDictate?: () => void;@@ -72,9 +67,6 @@ export function ChatComposer({modelId,onAgentChange,onModelChange,- approval,- approvalOptions,- onApprovalChange,onSend,onDictate,onTalk,@@ -83,7 +75,7 @@ export function ChatComposer({placeholder = "Just start typing…",}: ChatComposerProps) {const [text, setText] = useState("");- const [menu, setMenu] = useState<"agent" | "model" | "approval" | null>(null);+ const [menu, setMenu] = useState<"agent" | "model" | null>(null);const box = useRef<HTMLTextAreaElement | null>(null);const agent = agents.find((a) => a.id === agentId) ?? agents[0];@@ -159,18 +151,6 @@ export function ChatComposer({<div className="flex items-center gap-1 px-2 pb-2"><IconAction icon={Paperclip} label="Attach files" onClick={onAttach} />- <Chip- open={menu === "approval"}- onToggle={() => setMenu((m) => (m === "approval" ? null : "approval"))}- icon={<ShieldCheck className="h-3 w-3" aria-hidden />}- label={approval}- options={approvalOptions.map((value) => ({ id: value, label: value }))}- onPick={(value) => {- onApprovalChange(value);- setMenu(null);- }}- />-<div className="flex-1" /><Chipdiff --git a/jarvis/ui/web/frontend/src/lib/chatLibraryApi.ts b/jarvis/ui/web/frontend/src/lib/chatLibraryApi.tsindex 2011c071c6..87b93eb3ec 100644--- a/jarvis/ui/web/frontend/src/lib/chatLibraryApi.ts+++ b/jarvis/ui/web/frontend/src/lib/chatLibraryApi.ts@@ -144,7 +144,7 @@ export async function createChat(export async function patchChat(projectId: string,chatId: string,- changes: Partial<Pick<ChatRow, "title" | "archived" | "model" | "account">>,+ changes: Partial<Pick<ChatRow, "title" | "archived" | "model" | "account" | "terminal">>,): Promise<ChatRow> {return request<ChatRow>(`/projects/${encodeURIComponent(projectId)}/chats/${encodeURIComponent(chatId)}`,diff --git a/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx b/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsxindex faf93e9442..483eafb85b 100644--- a/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx+++ b/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx@@ -16,11 +16,9 @@import { useCallback, useEffect, useMemo, useState } from "react";import {Compass,- FileCode2,FolderOpen,LayoutGrid,ListChecks,- PanelRight,Sparkles,SquareTerminal,Wrench,@@ -34,7 +32,16 @@ import { FolderPicker } from "@/components/agentic/FolderPicker";import { PaneResizer } from "@/components/layout/PaneResizer";import { useResizablePane } from "@/hooks/useResizablePane";import { useEventStore } from "@/store/events";-import { fetchIdeAgents } from "@/lib/agenticIdeApi";+import {+ addTerminal,+ fetchIdeAgents,+ fetchIdeState,+ promptTerminal,+ startIdeSession,+} from "@/lib/agenticIdeApi";+import { ChatActivity } from "@/components/chat/ChatActivity";+import { VoiceBubble } from "@/components/agentic/VoiceBubble";+import { getWSClient } from "@/hooks/useWebSocket";import {type ChatProject,type ChatRow,@@ -84,15 +91,6 @@ const OPENERS = [},] as const;-/**- * How much an agent may do without asking, in the user's words.- *- * A display list on purpose: the enforcement lives in the risk tiers on the- * server, and a picker that invented its own names would be describing a- * policy nothing implements.- */-const APPROVAL_MODES = ["Ask before acting", "Auto for safe steps", "Full access"] as const;-export function ChatWorkspaceView() {const pushToast = useEventStore((s) => s.pushToast);const setActiveSection = useEventStore((s) => s.setActiveSection);@@ -103,12 +101,15 @@ export function ChatWorkspaceView() {const [pickedPath, setPickedPath] = useState<string | null>(null);const [refreshToken, setRefreshToken] = useState(0);const [busy, setBusy] = useState(false);- const [tools, setTools] = useState(true);+ // The spoken conversation, as a floating orb over this surface. Held here+ // rather than inside the composer: the conversation belongs to the app, and+ // a bubble mounted inside a component that re-renders per keystroke would+ // reset the orb mid-sentence.+ const [talking, setTalking] = useState(false);const [agents, setAgents] = useState<ComposerAgent[]>([]);const [agentId, setAgentId] = useState("");const [modelId, setModelId] = useState<string | null>(null);- const [approval, setApproval] = useState<string>(APPROVAL_MODES[0]);const list = useResizablePane({storageKey: "jarvis.chat.listWidth.v1",@@ -184,6 +185,59 @@ export function ChatWorkspaceView() {* type. The title comes from what they wrote, so the row in the sidebar is* recognisable the moment it appears.*/+ /**+ * Make sure this chat has a LIVE agent, and say which pane it is.+ *+ * Three cases, in the order they actually happen: the chat is already bound+ * to a running pane and we use it; the workspace is open on this project and+ * we add a pane to it; nothing is open and we start one. The chat records+ * the pane it got, so reopening it later finds the terminal that already+ * holds the conversation instead of starting a second agent beside it.+ */+ const ensureAgent = useCallback(+ async (project: ChatProject, chat: ChatRow): Promise<string> => {+ const state = await fetchIdeState();+ const session = state.session;+ const sameFolder =+ session && session.folder.toLowerCase() === project.path.toLowerCase();++ if (sameFolder && chat.terminal) {+ const live = session.terminals.find((t) => t.name === chat.terminal);+ if (live) return live.name;+ }++ const agent = agentId || agents[0]?.id;+ if (!agent) throw new Error("No coding CLI is installed on this machine.");++ const before = sameFolder ? session.terminals.map((t) => t.name) : [];+ const next = sameFolder+ ? await addTerminal({ agent })+ : (await startIdeSession(project.path, [{ agent }])).session;+ if (!next) throw new Error("The workspace closed while starting the agent.");++ // The pane that was NOT there a moment ago is ours. Asked this way rather+ // than by trusting a returned index, because the workspace is shared —+ // another surface can add a pane between these two calls.+ const fresh =+ next.terminals.find((t) => !before.includes(t.name)) ??+ next.terminals[next.terminals.length - 1];+ if (!fresh) throw new Error("The agent started but reported no terminal.");++ await patchChat(project.id, chat.id, { terminal: fresh.name });+ return fresh.name;+ },+ [agentId, agents],+ );++ /**+ * Send a prompt — for real.+ *+ * The chat is created here if the user typed straight into the starting+ * screen, which is the common path: nobody presses "New chat" first, they+ * type. Then an agent is started if this chat has none, and the prompt goes+ * into it. What the agent does next is on screen a second later, because the+ * feed below is already following that pane.+ */const send = useCallback(async (text: string) => {const project = activeProject;@@ -197,25 +251,21 @@ export function ChatWorkspaceView() {if (!target || target.project_id !== project.id) {target = await createChat(project.id, { agent: agentId, model: modelId });}+ const terminal = await ensureAgent(project, target);+ await promptTerminal(terminal, text);const updated = await patchChat(project.id, target.id, {title: target.title || text.slice(0, 48),+ terminal,});setOpen({ project, chat: updated });setRefreshToken((n) => n + 1);- // The prompt reaches the agent when the conversation layer lands. Said- // plainly rather than swallowed: a box that accepts text and does- // nothing visible is the single most confusing state a chat can be in.- pushToast(- "info",- "Saved to this chat. Delivering it to the agent lands with the conversation view.",- );} catch (error) {pushToast("error", error instanceof Error ? error.message : "Could not send that");} finally {setBusy(false);}},- [activeProject, agentId, modelId, open, pushToast],+ [activeProject, agentId, ensureAgent, modelId, open, pushToast],);const composer = useMemo(@@ -228,16 +278,26 @@ export function ChatWorkspaceView() {modelId={modelId}onAgentChange={setAgentId}onModelChange={setModelId}- approval={approval}- approvalOptions={APPROVAL_MODES}- onApprovalChange={setApproval}onSend={send}- onDictate={() => setActiveSection("dictation")}- onTalk={() => setActiveSection("chats")}+ onDictate={() => {+ // Speech lands in whichever field has the caret (the app-wide+ // dictation focus tracker decides that), so the box is focused+ // first — a dictation started from a BUTTON has already moved+ // focus onto the button by the time the transcript arrives.+ document+ .querySelector<HTMLTextAreaElement>('[data-dictation-target="true"]')+ ?.focus();+ getWSClient()?.send({+ type: "command",+ action: "stt_dictate",+ payload: { mode: "start" },+ });+ }}+ onTalk={() => setTalking(true)}busy={busy}/>) : null,- [activeProject, agentId, agents, approval, busy, modelId, send, setActiveSection],+ [activeProject, agentId, agents, busy, modelId, send],);return (@@ -307,19 +367,12 @@ export function ChatWorkspaceView() {<LayoutGrid className="h-3.5 w-3.5" aria-hidden />Terminal grid</button>- <button- type="button"- onClick={() => setTools((v) => !v)}- title={tools ? "Hide quick actions" : "Show quick actions"}- aria-label={tools ? "Hide quick actions" : "Show quick actions"}- aria-pressed={tools}- className="flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground"- >- <PanelRight className="h-3.5 w-3.5" aria-hidden />- </button></header><div className="flex min-h-0 flex-1 flex-col">+ {open?.chat.terminal ? (+ <ChatActivity terminal={open.chat.terminal} />+ ) : (<div className="flex min-h-0 flex-1 items-center justify-center overflow-y-auto scrollbar-jarvis px-6">{activeProject ? (<div className="w-full max-w-3xl py-8">@@ -367,22 +420,19 @@ export function ChatWorkspaceView() {</div>)}</div>+ )}{composer}</div>- {/* Quick actions, floating rather than docked: they belong to the chat- on screen, and a fourth permanent column would take width from the- one thing this surface exists to show. */}- {tools && activeProject && (- <div className="pointer-events-none absolute right-4 top-14 flex flex-col gap-1">- <QuickAction icon={ListChecks} label="Review" hint="Ctrl+Shift+G" />- <QuickAction icon={SquareTerminal} label="Terminal" />- <QuickAction icon={FileCode2} label="Files" hint="Ctrl+P" />- </div>- )}</div>+ <VoiceBubble+ open={talking}+ onClose={() => setTalking(false)}+ promptTarget={open?.chat.terminal ?? ""}+ />+{picking && (<div className="fixed inset-0 z-50 flex items-center justify-center bg-background/80 p-6"><div className="flex max-h-[80vh] w-full max-w-2xl flex-col overflow-hidden rounded-lg border border-border bg-card shadow-xl">@@ -429,24 +479,3 @@ export function ChatWorkspaceView() {</div>);}--function QuickAction({- icon: Icon,- label,- hint,-}: {- icon: typeof ListChecks;- label: string;- hint?: string;-}) {- return (- <button- type="button"- className="pointer-events-auto flex items-center gap-2 rounded-md px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground"- >- <Icon className="h-3.5 w-3.5" aria-hidden />- <span>{label}</span>- {hint && <span className="ml-2 text-[10px] text-muted-foreground/50">{hint}</span>}- </button>- );-}