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(ui): show the three most-used agents in the sidebar instead of routines

rubenluetke10-beep8bd8ee10a8dc
diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
index 2d53044556..5b8b74cb4b 100644
--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
@@ -23,7 +23,6 @@ import { cn } from "@/lib/utils";
import { lazy, Suspense, useMemo, useState, type ReactNode } from "react";
import { useT } from "@/i18n";
import { RecentChats } from "@/components/home/RecentChats";
-import { SidebarScheduled } from "@/components/layout/SidebarScheduled";
import { useHomeStore } from "@/store/home";
import { IdeProjectTree } from "@/components/agentic/IdeProjectTree";
import { useIdeProjectsStore } from "@/store/ideProjects";
@@ -37,6 +36,10 @@ import { startNewTextChat } from "@/lib/newChat";
import { useUserName } from "@/hooks/useUserName";
import { useAgentChatStore } from "@/store/agentChat";
+// The person's most-used agents. The roster query and the agent faces live in
+// the society code, so they load on their own chunk, not in the sidebar's.
+const SidebarAgents = lazy(() => import("@/components/layout/SidebarAgents"));
+
// The update button renders nothing on most launches; loaded on its own so
// the title-strip module it lives in stays out of the sidebar's chunk.
const UpdateButton = lazy(() =>
@@ -553,7 +556,7 @@ export function Sidebar({
</nav>}
{!railed && (onIdeSection
? <IdeProjectTree />
- : <><SidebarScheduled /><section className="mt-5 px-2 pb-3" aria-label={t("sidebar.recent_chats")}><RecentChats /></section></>)}
+ : <><Suspense fallback={null}><SidebarAgents /></Suspense><section className="mt-5 px-2 pb-3" aria-label={t("sidebar.recent_chats")}><RecentChats /></section></>)}
</div>
{/* The footer is one button now, not a popup: it opens the Settings hub
diff --git a/jarvis/ui/web/frontend/src/components/layout/SidebarAgents.test.ts b/jarvis/ui/web/frontend/src/components/layout/SidebarAgents.test.ts
new file mode 100644
index 0000000000..a5be80a928
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/layout/SidebarAgents.test.ts
@@ -0,0 +1,40 @@
+import { describe, expect, it } from "vitest";
+
+import { mostUsedAgents, SIDEBAR_AGENTS_MAX } from "./SidebarAgents";
+import type { SocietyAgent } from "@/components/society/data";
+
+function agent(id: string, runs: number, extra: Partial<SocietyAgent> = {}): SocietyAgent {
+ return {
+ agentId: id,
+ name: id,
+ tier: "member",
+ lifecycle: "active",
+ createdMs: 0,
+ stats: { runs, totalCostUsd: 0, spentTodayUsd: 0, lastActiveMs: null },
+ ...extra,
+ } as SocietyAgent;
+}
+
+describe("mostUsedAgents", () => {
+ it("lists the most-run agents first and stops at the cap", () => {
+ const rows = mostUsedAgents([agent("a", 2), agent("b", 9), agent("c", 5), agent("d", 1)]);
+ expect(rows.map((r) => r.agentId)).toEqual(["b", "c", "a"].slice(0, SIDEBAR_AGENTS_MAX));
+ });
+
+ it("leaves out Jarvis itself and archived agents", () => {
+ const rows = mostUsedAgents([
+ agent("lead", 99, { tier: "lead" }),
+ agent("gone", 50, { lifecycle: "archived" }),
+ agent("kept", 1),
+ ]);
+ expect(rows.map((r) => r.agentId)).toEqual(["kept"]);
+ });
+
+ it("breaks a tie by the most recent activity", () => {
+ const rows = mostUsedAgents([
+ agent("old", 3, { stats: { runs: 3, totalCostUsd: 0, spentTodayUsd: 0, lastActiveMs: 10 } }),
+ agent("new", 3, { stats: { runs: 3, totalCostUsd: 0, spentTodayUsd: 0, lastActiveMs: 20 } }),
+ ]);
+ expect(rows.map((r) => r.agentId)).toEqual(["new", "old"]);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/layout/SidebarAgents.tsx b/jarvis/ui/web/frontend/src/components/layout/SidebarAgents.tsx
new file mode 100644
index 0000000000..9f2d0579ea
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/layout/SidebarAgents.tsx
@@ -0,0 +1,75 @@
+import { useMemo } from "react";
+
+import { AgentSwatch } from "@/components/society/AgentSwatch";
+import { useSocietyRoster, type SocietyAgent } from "@/components/society/data";
+import { rememberLastAgentId } from "@/views/society/lastAgent";
+import { useT } from "@/i18n";
+import { useEventStore } from "@/store/events";
+
+/** How many agents the sidebar names before the Agents page takes over. */
+export const SIDEBAR_AGENTS_MAX = 3;
+
+/**
+ * The person's three most-used agents, between the sections and the chat
+ * history — each with its own face (`AgentSwatch`), one click from its chat.
+ *
+ * "Most used" is the roster's own numbers: runs first, then the most recent
+ * activity, then the newest. Jarvis itself (the lead) is the front page, so
+ * it is not listed again; archived agents and the sample roster a fresh
+ * install shows never appear. With no agents of their own the section is
+ * absent rather than an empty heading.
+ */
+export default function SidebarAgents() {
+ const t = useT();
+ const setActive = useEventStore((s) => s.setActiveSection);
+ const roster = useSocietyRoster();
+ const agents = useMemo(
+ () => (roster.data && !roster.data.sample ? mostUsedAgents(roster.data.agents) : []),
+ [roster.data],
+ );
+ if (agents.length === 0) return null;
+
+ return (
+ <section className="mt-5 px-2" aria-label={t("nav.agents")} data-testid="sidebar-agents">
+ <h2 className="px-3 pb-1.5 text-sm text-muted-foreground">{t("nav.agents")}</h2>
+ <ul className="space-y-px">
+ {agents.map((agent) => (
+ <li key={agent.agentId}>
+ <button
+ type="button"
+ onClick={() => {
+ // The Agents page opens on the agent it last showed.
+ rememberLastAgentId(agent.agentId);
+ setActive("agents");
+ }}
+ title={agent.name}
+ data-testid="sidebar-agent-row"
+ className="flex h-8 w-full items-center gap-3 rounded-lg px-3 text-left text-base text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ <span className="-ml-0.5 flex h-5 w-5 shrink-0 items-center justify-center">
+ <AgentSwatch agent={agent} size={20} />
+ </span>
+ <span className="min-w-0 flex-1 truncate">{agent.name}</span>
+ {agent.state === "working" && (
+ <span aria-hidden className="h-1.5 w-1.5 shrink-0 rounded-full bg-accent animate-jarvis-pulse" />
+ )}
+ </button>
+ </li>
+ ))}
+ </ul>
+ </section>
+ );
+}
+
+/** The roster's own agents, most used first, capped for the sidebar. */
+export function mostUsedAgents(agents: readonly SocietyAgent[]): SocietyAgent[] {
+ return agents
+ .filter((a) => a.tier !== "lead" && a.lifecycle !== "archived")
+ .sort(
+ (a, b) =>
+ (b.stats?.runs ?? 0) - (a.stats?.runs ?? 0) ||
+ (b.stats?.lastActiveMs ?? 0) - (a.stats?.lastActiveMs ?? 0) ||
+ (b.createdMs ?? 0) - (a.createdMs ?? 0),
+ )
+ .slice(0, SIDEBAR_AGENTS_MAX);
+}
diff --git a/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.test.ts b/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.test.ts
deleted file mode 100644
index 8848c12e78..0000000000
--- a/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.test.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { describe, expect, it } from "vitest";
-
-import { routineTitle, upcomingRoutines, SIDEBAR_SCHEDULED_MAX } from "./SidebarScheduled";
-import type { TaskSummary } from "@/views/automations/automationsModel";
-
-function task(id: string, next: number, extra: Partial<TaskSummary> = {}): TaskSummary {
- return {
- id,
- title: id,
- state: "scheduled",
- trigger_type: "calendar",
- due_at_ns: next,
- next_due_at_ns: next,
- created_at_ns: 1,
- started_at_ns: null,
- finished_at_ns: null,
- attempts: 0,
- last_error: null,
- ...extra,
- } as TaskSummary;
-}
-
-describe("SidebarScheduled", () => {
- it("names the job, not the agent that owns it", () => {
- expect(routineTitle("[agent:GitHub Issue sortieren.] Daily GitHub issue triage")).toBe(
- "Daily GitHub issue triage",
- );
- expect(routineTitle("Morning brief")).toBe("Morning brief");
- });
-
- it("lists the soonest runs first, skips finished and paused ones, and stops at the cap", () => {
- const rows = upcomingRoutines([
- task("late", 400),
- task("done", 100, { state: "completed" }),
- task("paused", 50, { state: "paused" }),
- task("soon", 200),
- task("mid", 300),
- task("later", 500),
- ]);
- expect(rows.map((r) => r.id)).toEqual(["soon", "mid", "late"].slice(0, SIDEBAR_SCHEDULED_MAX));
- });
-});
diff --git a/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.tsx b/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.tsx
deleted file mode 100644
index 20137242dc..0000000000
--- a/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-import { useMemo } from "react";
-import { useQuery } from "@tanstack/react-query";
-import { Clock } from "lucide-react";
-
-import { fetchTasks, TASKS_QUERY_KEY } from "@/hooks/useAutomations";
-import { useT } from "@/i18n";
-import { useEventStore } from "@/store/events";
-import {
- localTimeHHMM,
- selectAutomations,
- selectSchedules,
- type TaskSummary,
-} from "@/views/automations/automationsModel";
-
-/** How many routines the sidebar names before the Automations page takes over. */
-export const SIDEBAR_SCHEDULED_MAX = 3;
-
-/**
- * "Scheduled" in the sidebar — the routines that run next, between the
- * sections and the chat history, the way the Claude app lists its scheduled
- * tasks there.
- *
- * Real rows only: the user's recurring automations and waiting one-off
- * schedules from `/api/tasks`, soonest first. With nothing scheduled (or no
- * answer yet) the section is absent — an empty heading would be filler.
- * The list shares the Automations page's query key, read at a slow cadence
- * here because the sidebar is on screen all day.
- */
-export function SidebarScheduled() {
- const t = useT();
- const setActive = useEventStore((s) => s.setActiveSection);
- const { data } = useQuery({
- queryKey: TASKS_QUERY_KEY,
- queryFn: fetchTasks,
- refetchInterval: 60_000,
- staleTime: 30_000,
- retry: false,
- });
- const upcoming = useMemo(() => upcomingRoutines(data?.tasks ?? []), [data]);
- if (upcoming.length === 0) return null;
-
- return (
- <section className="mt-5 px-2" aria-label={t("sidebar.scheduled")} data-testid="sidebar-scheduled">
- <h2 className="px-3 pb-1.5 text-sm text-muted-foreground">{t("sidebar.scheduled")}</h2>
- <ul className="space-y-px">
- {upcoming.map((task) => {
- const title = routineTitle(task.title);
- const next = nextRunNs(task);
- return (
- <li key={task.id}>
- <button
- type="button"
- onClick={() => setActive("tasks")}
- title={title}
- data-testid="sidebar-scheduled-row"
- className="flex h-8 w-full items-center gap-3 rounded-lg px-3 text-left text-base text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
- >
- <Clock aria-hidden strokeWidth={1.75} className="h-[18px] w-[18px] shrink-0" />
- <span className="min-w-0 flex-1 truncate">{title}</span>
- {next !== null && (
- <span className="shrink-0 text-xs tabular-nums text-muted-foreground">{whenLabel(next)}</span>
- )}
- </button>
- </li>
- );
- })}
- </ul>
- </section>
- );
-}
-
-function nextRunNs(task: TaskSummary): number | null {
- const ns = task.next_due_at_ns ?? task.due_at_ns;
- return typeof ns === "number" && Number.isFinite(ns) ? ns : null;
-}
-
-/** Recurring automations and waiting one-offs, soonest run first. */
-export function upcomingRoutines(tasks: TaskSummary[]): TaskSummary[] {
- return [...selectAutomations(tasks), ...selectSchedules(tasks)]
- .filter((task) => task.state !== "paused")
- .sort((a, b) => (nextRunNs(a) ?? Number.MAX_SAFE_INTEGER) - (nextRunNs(b) ?? Number.MAX_SAFE_INTEGER))
- .slice(0, SIDEBAR_SCHEDULED_MAX);
-}
-
-/** An agent's routine carries its owner as a "[agent:Name] " prefix; the row shows the job. */
-export function routineTitle(title: string): string {
- return title.replace(/^\s*\[agent:[^\]]*\]\s*/i, "").trim() || title.trim();
-}
-
-/** The clock for today, a short weekday for anything later. */
-function whenLabel(ns: number, now: Date = new Date()): string {
- const at = new Date(ns / 1e6);
- if (at.toDateString() === now.toDateString()) return localTimeHHMM(ns);
- return at.toLocaleDateString(undefined, { weekday: "short" });
-}