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.

feat(society): roster shows thinking spinner and unread results dot

rubenluetke10-beep9754f51609d0
diff --git a/jarvis/ui/web/frontend/src/components/society/roster/RosterRail.test.tsx b/jarvis/ui/web/frontend/src/components/society/roster/RosterRail.test.tsx
new file mode 100644
index 0000000000..9bbcb19a4c
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/roster/RosterRail.test.tsx
@@ -0,0 +1,101 @@
+import { cleanup, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import type { SocietyAgent } from "@/components/society/data";
+import { RosterRail } from "./RosterRail";
+
+vi.mock("@/i18n", () => ({ useT: () => (key: string) => key }));
+
+afterEach(() => {
+ cleanup();
+ localStorage.clear();
+});
+
+function agent(over: Partial<SocietyAgent> & Pick<SocietyAgent, "agentId" | "name">): SocietyAgent {
+ return {
+ title: "Title",
+ description: "",
+ tier: "specialist",
+ provider: "",
+ providerLabel: "",
+ model: "",
+ effort: "",
+ figure: null,
+ palette: { primary: "#000", secondary: "#111", accent: "#222" },
+ grantMode: "all",
+ toolGrants: [],
+ focus: [],
+ denies: [],
+ approvalRules: { requireApproval: [], alwaysAllow: [] },
+ permissionCeiling: "ask",
+ dailyBudgetUsd: 0,
+ checkpoint: "idle",
+ state: "idle",
+ lifecycle: "active",
+ createdMs: 0,
+ maxConcurrentRuns: 1,
+ workspaceDir: "",
+ wikiNamespace: "",
+ chatSessionId: null,
+ routines: [],
+ stats: { runs: 0, totalCostUsd: 0, spentTodayUsd: 0, lastActiveMs: null },
+ ...over,
+ };
+}
+
+const baseProps = {
+ loading: false,
+ sample: false,
+ onOpen: () => undefined,
+ onCreate: () => undefined,
+};
+
+describe("RosterRail status", () => {
+ it("shows a loading spinner while an agent is thinking", () => {
+ render(
+ <RosterRail
+ {...baseProps}
+ agents={[agent({ agentId: "a", name: "A", state: "working" })]}
+ activeAgentId={null}
+ />,
+ );
+ expect(screen.getByRole("status", { name: "society.roster.thinking" })).toBeTruthy();
+ expect(screen.queryByLabelText("society.roster.unread")).toBeNull();
+ });
+
+ it("shows a grey idle dot with no unseen results", () => {
+ render(
+ <RosterRail
+ {...baseProps}
+ agents={[agent({ agentId: "a", name: "A", state: "idle" })]}
+ activeAgentId={null}
+ />,
+ );
+ expect(screen.getByLabelText("society.state.idle")).toBeTruthy();
+ expect(screen.queryByRole("status")).toBeNull();
+ });
+
+ it("marks a finished agent green until it is opened", () => {
+ const working = [agent({ agentId: "a", name: "A", state: "working" })];
+ const done = [agent({ agentId: "a", name: "A", state: "idle" })];
+ const { rerender } = render(
+ <RosterRail {...baseProps} agents={working} activeAgentId={null} />,
+ );
+ rerender(<RosterRail {...baseProps} agents={done} activeAgentId={null} />);
+ expect(screen.getByLabelText("society.roster.unread")).toBeTruthy();
+
+ rerender(<RosterRail {...baseProps} agents={done} activeAgentId="a" />);
+ expect(screen.queryByLabelText("society.roster.unread")).toBeNull();
+ expect(screen.getByLabelText("society.state.idle")).toBeTruthy();
+ });
+
+ it("does not mark the open agent unread when it finishes in front of you", () => {
+ const working = [agent({ agentId: "a", name: "A", state: "working" })];
+ const done = [agent({ agentId: "a", name: "A", state: "idle" })];
+ const { rerender } = render(
+ <RosterRail {...baseProps} agents={working} activeAgentId="a" />,
+ );
+ rerender(<RosterRail {...baseProps} agents={done} activeAgentId="a" />);
+ expect(screen.queryByLabelText("society.roster.unread")).toBeNull();
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/society/roster/RosterRail.tsx b/jarvis/ui/web/frontend/src/components/society/roster/RosterRail.tsx
index 6db74d1587..f5589148fc 100644
--- a/jarvis/ui/web/frontend/src/components/society/roster/RosterRail.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/roster/RosterRail.tsx
@@ -16,7 +16,7 @@
* from the grid cell — same rows, same sizes, only the divider swaps sides.
*/
import { useMemo, useState } from "react";
-import { Plus, Search } from "lucide-react";
+import { Loader2, Plus, Search } from "lucide-react";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -26,6 +26,7 @@ import { cn } from "@/lib/utils";
import { AgentSwatch } from "../AgentSwatch";
import type { AgentRunState, SocietyAgent } from "../data";
+import { useRosterUnread } from "./useRosterUnread";
const STATE_DOT: Record<AgentRunState, string> = {
idle: "bg-muted-foreground/50",
@@ -60,6 +61,7 @@ export function RosterRail({
}: RosterRailProps) {
const t = useT();
const [query, setQuery] = useState("");
+ const unread = useRosterUnread(agents, activeAgentId);
const lead = useMemo(() => agents.find((a) => a.tier === "lead") ?? null, [agents]);
@@ -136,7 +138,25 @@ export function RosterRail({
lead.agentId === activeAgentId && "bg-secondary",
)}
>
- <AgentSwatch agent={lead} size={56} />
+ <span className="relative">
+ <AgentSwatch agent={lead} size={56} />
+ {lead.state === "working" ? (
+ <span
+ role="status"
+ aria-label={t("society.roster.thinking")}
+ title={t("society.roster.thinking")}
+ className="absolute -right-1 -top-1 grid h-5 w-5 place-items-center rounded-full bg-sidebar ring-2 ring-sidebar"
+ >
+ <Loader2 className="h-3.5 w-3.5 animate-spin text-muted-foreground" aria-hidden />
+ </span>
+ ) : unread.has(lead.agentId) ? (
+ <span
+ aria-label={t("society.roster.unread")}
+ title={t("society.roster.unread")}
+ className="absolute -right-0.5 -top-0.5 h-3 w-3 rounded-full bg-success ring-2 ring-sidebar"
+ />
+ ) : null}
+ </span>
<span className="flex max-w-full items-center justify-center gap-1.5">
<span className="truncate text-sm font-medium text-foreground">{lead.name}</span>
<Badge variant="secondary" className="shrink-0 px-1.5 py-0 text-xs">
@@ -179,11 +199,7 @@ export function RosterRail({
</span>
<span className="block truncate text-xs text-muted-foreground">{agent.title}</span>
</span>
- <span
- className={cn("h-2 w-2 shrink-0 rounded-full", STATE_DOT[agent.state])}
- title={t(`society.state.${agent.state}`)}
- aria-label={t(`society.state.${agent.state}`)}
- />
+ <RowStatus agent={agent} hasUnread={unread.has(agent.agentId)} />
</button>
</li>
))}
@@ -192,3 +208,42 @@ export function RosterRail({
</aside>
);
}
+
+/**
+ * The three states the roster dot can be in: thinking (a loading spinner
+ * while `state` is working), fresh results (green until the row is opened),
+ * or the plain backend state (grey idle, amber waiting, faint paused).
+ */
+function RowStatus({ agent, hasUnread }: { agent: SocietyAgent; hasUnread: boolean }) {
+ const t = useT();
+ if (agent.state === "working") {
+ const label = t("society.roster.thinking");
+ return (
+ <span
+ role="status"
+ aria-label={label}
+ title={label}
+ className="grid h-4 w-4 shrink-0 place-items-center"
+ >
+ <Loader2 className="h-3 w-3 animate-spin text-muted-foreground" aria-hidden />
+ </span>
+ );
+ }
+ if (hasUnread) {
+ const label = t("society.roster.unread");
+ return (
+ <span
+ className="h-2 w-2 shrink-0 rounded-full bg-success"
+ title={label}
+ aria-label={label}
+ />
+ );
+ }
+ return (
+ <span
+ className={cn("h-2 w-2 shrink-0 rounded-full", STATE_DOT[agent.state])}
+ title={t(`society.state.${agent.state}`)}
+ aria-label={t(`society.state.${agent.state}`)}
+ />
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/roster/useRosterUnread.ts b/jarvis/ui/web/frontend/src/components/society/roster/useRosterUnread.ts
new file mode 100644
index 0000000000..7e3fe94691
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/roster/useRosterUnread.ts
@@ -0,0 +1,100 @@
+import { useEffect, useRef, useState } from "react";
+
+import type { SocietyAgent } from "../data";
+
+const STORAGE_KEY = "society.rosterUnread.v1";
+
+function readStored(): Set<string> {
+ try {
+ const raw = localStorage.getItem(STORAGE_KEY);
+ if (!raw) return new Set();
+ const parsed: unknown = JSON.parse(raw);
+ if (!Array.isArray(parsed)) return new Set();
+ return new Set(parsed.filter((entry): entry is string => typeof entry === "string"));
+ } catch {
+ return new Set();
+ }
+}
+
+/**
+ * Unseen-results tracking for the roster rail.
+ *
+ * Backend `agent.state` only knows idle/working/waiting/paused. The rail
+ * needs one more fact: did this agent finish something the person has not
+ * opened yet. That fact lives here, in the window:
+ *
+ * - `working` is rendered by the caller as a loading spinner.
+ * - a `working -> idle|waiting` transition marks the agent unread (green dot),
+ * unless that agent is the one currently open.
+ * - opening an agent (`activeAgentId`) clears its unread mark (grey dot).
+ *
+ * Persisted to localStorage so a fresh result survives a reload until opened.
+ */
+export function useRosterUnread(
+ agents: SocietyAgent[],
+ activeAgentId: string | null,
+): Set<string> {
+ const [unread, setUnread] = useState<Set<string>>(() => readStored());
+ const prevStates = useRef(new Map<string, string>());
+ const initialized = useRef(false);
+
+ useEffect(() => {
+ const ids = new Set(agents.map((agent) => agent.agentId));
+ const current = new Map(agents.map((agent) => [agent.agentId, agent.state]));
+
+ if (!initialized.current) {
+ prevStates.current = current;
+ initialized.current = true;
+ setUnread((prev) => {
+ if ([...prev].every((id) => ids.has(id) && id !== activeAgentId)) return prev;
+ const copy = new Set(prev);
+ for (const id of [...copy]) {
+ if (!ids.has(id) || id === activeAgentId) copy.delete(id);
+ }
+ return copy;
+ });
+ return;
+ }
+
+ const finished: string[] = [];
+ for (const [id, state] of current) {
+ const prev = prevStates.current.get(id);
+ if (prev === "working" && state !== "working" && state !== "paused") {
+ if (id !== activeAgentId) finished.push(id);
+ }
+ }
+ prevStates.current = current;
+
+ setUnread((prev) => {
+ if (finished.length === 0) {
+ const needsPrune =
+ (activeAgentId !== null && prev.has(activeAgentId)) ||
+ [...prev].some((id) => !ids.has(id));
+ if (!needsPrune) return prev;
+ const copy = new Set(prev);
+ if (activeAgentId) copy.delete(activeAgentId);
+ for (const id of [...copy]) {
+ if (!ids.has(id)) copy.delete(id);
+ }
+ return copy;
+ }
+ const copy = new Set(prev);
+ for (const id of finished) copy.add(id);
+ if (activeAgentId) copy.delete(activeAgentId);
+ for (const id of [...copy]) {
+ if (!ids.has(id)) copy.delete(id);
+ }
+ return copy;
+ });
+ }, [agents, activeAgentId]);
+
+ useEffect(() => {
+ try {
+ localStorage.setItem(STORAGE_KEY, JSON.stringify([...unread]));
+ } catch {
+ /* storage full / private mode — the dots still work for this window */
+ }
+ }, [unread]);
+
+ return unread;
+}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index e182f60526..43bfe1a0ce 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -5279,7 +5279,9 @@
"create": "Neu",
"search": "Agenten suchen",
"loading": "Agenten werden geladen…",
- "empty": "Kein Agent passt."
+ "empty": "Kein Agent passt.",
+ "thinking": "Denkt nach…",
+ "unread": "Neues Ergebnis — öffnen zum Lesen"
},
"tier": {
"lead": "Leitung",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index aaa3b01345..56442650de 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -5312,7 +5312,9 @@
"create": "New",
"search": "Search agents",
"loading": "Loading agents…",
- "empty": "No agent matches."
+ "empty": "No agent matches.",
+ "thinking": "Thinking…",
+ "unread": "New results — open to read"
},
"tier": {
"lead": "Lead",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 63190b01f7..f8a999f22a 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -5279,7 +5279,9 @@
"create": "Nuevo",
"search": "Buscar agentes",
"loading": "Cargando agentes…",
- "empty": "Ningún agente coincide."
+ "empty": "Ningún agente coincide.",
+ "thinking": "Pensando…",
+ "unread": "Nuevos resultados — abre para leer"
},
"tier": {
"lead": "Líder",