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): open an agent's chat on the front page from the sidebar

rubenluetke10-beepceb08e91ac39
diff --git a/jarvis/ui/web/frontend/src/components/home/AssistantChat.tsx b/jarvis/ui/web/frontend/src/components/home/AssistantChat.tsx
index 3e76d16e00..0ce5e61bbb 100644
--- a/jarvis/ui/web/frontend/src/components/home/AssistantChat.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/AssistantChat.tsx
@@ -8,6 +8,8 @@ import { useHomeStore } from "@/store/home";
const ChatStage = lazy(() =>
import("@/components/home/ChatStage").then((module) => ({ default: module.ChatStage })),
);
+// An agent's own chat, opened from the sidebar — society code, its own chunk.
+const HomeAgentChat = lazy(() => import("@/components/home/HomeAgentChat"));
/**
* The front page: ONE chat with the assistant (2026-10-01).
@@ -23,7 +25,23 @@ const ChatStage = lazy(() =>
export function AssistantChat() {
const t = useT();
const surface = useHomeStore((s) => s.surface);
+ const agentChatId = useHomeStore((s) => s.agentChatId);
const voice = useVoiceModeSwitch();
+ const loading = (
+ <div role="status" className="flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground">
+ {t("common.loading")}
+ </div>
+ );
+
+ if (agentChatId) {
+ return (
+ <div className="relative flex min-h-0 flex-1 flex-col" data-testid="assistant-chat" data-agent={agentChatId}>
+ <Suspense fallback={loading}>
+ <HomeAgentChat agentId={agentChatId} />
+ </Suspense>
+ </div>
+ );
+ }
return (
<div className="relative flex min-h-0 flex-1 flex-col" data-testid="assistant-chat">
diff --git a/jarvis/ui/web/frontend/src/components/home/HomeAgentChat.tsx b/jarvis/ui/web/frontend/src/components/home/HomeAgentChat.tsx
new file mode 100644
index 0000000000..ec3becec29
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/home/HomeAgentChat.tsx
@@ -0,0 +1,64 @@
+import { useEffect } from "react";
+import { ArrowLeft } from "lucide-react";
+
+import { AgentSwatch } from "@/components/society/AgentSwatch";
+import { useSocietyRoster } from "@/components/society/data";
+import { AgentChatPanel } from "@/components/society/chat/AgentChatPanel";
+import { fill, useLocaleChunk, useT } from "@/i18n";
+import { startNewTextChat } from "@/lib/newChat";
+import { useEventStore } from "@/store/events";
+import { useHomeStore } from "@/store/home";
+
+/**
+ * One of the person's agents, talked to on the front page.
+ *
+ * Picked from the sidebar's agent list, the agent's own chat takes the
+ * column Jarvis' chat normally holds — the very panel the Agents page shows
+ * (society/chat/AgentChatPanel), so the conversation, its history and its
+ * approvals are the same wherever it is opened. A slim row above names who
+ * is talking and leads back to Jarvis. An agent that vanished from the
+ * roster (retired elsewhere) hands the page back to Jarvis.
+ */
+export default function HomeAgentChat({ agentId }: { agentId: string }) {
+ const t = useT();
+ // The agent chat's own words live in the society locale chunk.
+ useLocaleChunk("society");
+ const assistantName = useEventStore((s) => s.assistantName);
+ const openAgentChat = useHomeStore((s) => s.openAgentChat);
+ const roster = useSocietyRoster();
+ const agents = roster.data && !roster.data.sample ? roster.data.agents : [];
+ const agent = agents.find((a) => a.agentId === agentId) ?? null;
+
+ useEffect(() => {
+ if (roster.isSuccess && !agent) openAgentChat(null);
+ }, [agent, openAgentChat, roster.isSuccess]);
+
+ if (!agent) {
+ return (
+ <div role="status" className="flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground">
+ {t("common.loading")}
+ </div>
+ );
+ }
+
+ return (
+ <div className="flex min-h-0 flex-1 flex-col" data-testid="home-agent-chat">
+ <header className="flex h-12 shrink-0 items-center gap-2.5 px-4">
+ <AgentSwatch agent={agent} size={22} />
+ <span className="min-w-0 truncate text-sm font-medium text-foreground-strong">{agent.name}</span>
+ <button
+ type="button"
+ onClick={() => startNewTextChat()}
+ data-testid="home-agent-chat-back"
+ className="ml-auto flex h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ <ArrowLeft aria-hidden className="h-3.5 w-3.5" />
+ {fill(t("home.back_to_assistant"), { name: assistantName })}
+ </button>
+ </header>
+ <div className="mx-auto flex min-h-0 w-full max-w-[820px] flex-1 flex-col">
+ <AgentChatPanel key={agent.agentId} agent={agent} roster={agents} />
+ </div>
+ </div>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/home/chatRows.ts b/jarvis/ui/web/frontend/src/components/home/chatRows.ts
index cac7e38739..c03a5596a9 100644
--- a/jarvis/ui/web/frontend/src/components/home/chatRows.ts
+++ b/jarvis/ui/web/frontend/src/components/home/chatRows.ts
@@ -94,6 +94,9 @@ export function useChatRows({ poll = false }: { poll?: boolean } = {}): ChatRows
const open = useCallback(
(row: ChatRow) => {
+ // A history row is Jarvis' conversation: it takes the stage back from
+ // an agent's chat opened from the sidebar.
+ useHomeStore.getState().openAgentChat(null);
if (row.kind === "voice") {
// End the agent session on stage first: the chat stage renders the
// voice archive only while no agent chat is open, and its socket has
diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
index 5b8b74cb4b..226d1710d9 100644
--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
@@ -178,6 +178,7 @@ export function Sidebar({
const t = useT();
const active = useEventStore((s) => s.activeSection);
const openVoiceThread = useEventStore((s) => s.activeKind === "voice" && Boolean(s.activeThreadId));
+ const agentChatOpen = useHomeStore((s) => s.agentChatId !== null);
const setActive = useEventStore((s) => s.setActiveSection);
const activeIdeWorkspaceId = useIdeProjectsStore((s) => s.activeWorkspaceId);
const openIdeWorkspaceOptions = useIdeProjectsStore((s) => s.openWorkspaceOptions);
@@ -233,7 +234,7 @@ export function Sidebar({
// An empty chat on the front page: nothing open, nothing being read.
const onEmptyChat = useAgentChatStore(
(st) => active === "chats" && !st.activeSessionId && st.timeline.items.length === 0,
- ) && !openVoiceThread;
+ ) && !openVoiceThread && !agentChatOpen;
const identity = usePublishIdentity();
const userName = useUserName();
// The person by first name once the Profile knows it, else their
diff --git a/jarvis/ui/web/frontend/src/components/layout/SidebarAgents.tsx b/jarvis/ui/web/frontend/src/components/layout/SidebarAgents.tsx
index 9f2d0579ea..1686dcb597 100644
--- a/jarvis/ui/web/frontend/src/components/layout/SidebarAgents.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/SidebarAgents.tsx
@@ -1,17 +1,24 @@
-import { useMemo } from "react";
+import { useMemo, useState } from "react";
+import { ChevronDown } from "lucide-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 { cn } from "@/lib/utils";
import { useEventStore } from "@/store/events";
+import { useHomeStore } from "@/store/home";
-/** How many agents the sidebar names before the Agents page takes over. */
+/** How many agents the sidebar names before "Show all" folds the rest out. */
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.
+ * The person's agents, most used first, between the sections and the chat
+ * history — each with its own face (`AgentSwatch`).
+ *
+ * Three show at rest; "Show all" folds out the rest. A click opens that
+ * agent's own chat on the front page, in the column Jarvis' chat normally
+ * holds (components/home/HomeAgentChat), rather than leaving for the Agents
+ * page; the open one is lit like the open chat in the history below.
*
* "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
@@ -22,47 +29,76 @@ export const SIDEBAR_AGENTS_MAX = 3;
export default function SidebarAgents() {
const t = useT();
const setActive = useEventStore((s) => s.setActiveSection);
+ const onFrontPage = useEventStore((s) => s.activeSection === "chats");
+ const openId = useHomeStore((s) => s.agentChatId);
+ const openAgentChat = useHomeStore((s) => s.openAgentChat);
+ const [expanded, setExpanded] = useState(false);
const roster = useSocietyRoster();
- const agents = useMemo(
- () => (roster.data && !roster.data.sample ? mostUsedAgents(roster.data.agents) : []),
+ const all = useMemo(
+ () => (roster.data && !roster.data.sample ? rankAgents(roster.data.agents) : []),
[roster.data],
);
- if (agents.length === 0) return null;
+ if (all.length === 0) return null;
+ const shown = expanded ? all : all.slice(0, SIDEBAR_AGENTS_MAX);
+ const hidden = all.length - SIDEBAR_AGENTS_MAX;
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>
- ))}
+ {shown.map((agent) => {
+ const active = onFrontPage && openId === agent.agentId;
+ return (
+ <li key={agent.agentId}>
+ <button
+ type="button"
+ onClick={() => {
+ openAgentChat(agent.agentId);
+ setActive("chats");
+ }}
+ title={agent.name}
+ aria-current={active ? "page" : undefined}
+ data-testid="sidebar-agent-row"
+ className={cn(
+ "flex h-8 w-full items-center gap-3 rounded-lg px-3 text-left text-base transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ active ? "jarvis-nav-active bg-secondary text-foreground-strong" : "text-foreground hover:bg-secondary",
+ )}
+ >
+ <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>
+ {hidden > 0 && (
+ <button
+ type="button"
+ onClick={() => setExpanded((v) => !v)}
+ aria-expanded={expanded}
+ data-testid="sidebar-agents-more"
+ className="flex h-8 w-full items-center gap-3 rounded-lg px-3 text-left text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ <ChevronDown
+ aria-hidden
+ strokeWidth={1.75}
+ className={cn("h-[18px] w-[18px] shrink-0 transition-transform", expanded && "rotate-180")}
+ />
+ <span className="min-w-0 flex-1 truncate text-sm">{t(expanded ? "sidebar.show_less" : "sidebar.show_all")}</span>
+ {!expanded && <span className="shrink-0 text-sm tabular-nums text-foreground-faint">+{hidden}</span>}
+ </button>
+ )}
</section>
);
}
-/** The roster's own agents, most used first, capped for the sidebar. */
-export function mostUsedAgents(agents: readonly SocietyAgent[]): SocietyAgent[] {
+/** The roster's own agents, most used first. */
+export function rankAgents(agents: readonly SocietyAgent[]): SocietyAgent[] {
return agents
.filter((a) => a.tier !== "lead" && a.lifecycle !== "archived")
.sort(
@@ -70,6 +106,10 @@ export function mostUsedAgents(agents: readonly SocietyAgent[]): SocietyAgent[]
(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);
+ );
+}
+
+/** The ones the sidebar shows at rest. */
+export function mostUsedAgents(agents: readonly SocietyAgent[]): SocietyAgent[] {
+ return rankAgents(agents).slice(0, SIDEBAR_AGENTS_MAX);
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 480dd3d987..d6a9faecd7 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -669,7 +669,8 @@
"prompt_mode_off": "Prompt-Modus ist aus — Diktate kommen so an, wie gesprochen. Klicken, damit jedes Diktat zu einem fertigen Prompt für einen Coding-Agenten wird.",
"prompt_mode_failed": "Der Prompt-Modus konnte nicht umgeschaltet werden.",
"theme_to_light": "Zum hellen Modus wechseln",
- "theme_to_dark": "Zum dunklen Modus wechseln"
+ "theme_to_dark": "Zum dunklen Modus wechseln",
+ "back_to_assistant": "Zurück zu {name}"
},
"assistant_chat": {
"voice_enter": "Sprachmodus",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index fa4f636959..4d7b6d545b 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -669,7 +669,8 @@
"prompt_mode_off": "Prompt Mode is off — dictations arrive as spoken. Click to turn every dictation into a finished prompt for a coding agent.",
"prompt_mode_failed": "Prompt Mode could not be switched.",
"theme_to_light": "Switch to light mode",
- "theme_to_dark": "Switch to dark mode"
+ "theme_to_dark": "Switch to dark mode",
+ "back_to_assistant": "Back to {name}"
},
"assistant_chat": {
"voice_enter": "Voice mode",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 66e8c13361..a56f625ebf 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -669,7 +669,8 @@
"prompt_mode_off": "El modo Prompt está desactivado: los dictados llegan tal como se dijeron. Haz clic para convertir cada dictado en un prompt terminado para un agente de código.",
"prompt_mode_failed": "No se pudo cambiar el modo Prompt.",
"theme_to_light": "Cambiar al modo claro",
- "theme_to_dark": "Cambiar al modo oscuro"
+ "theme_to_dark": "Cambiar al modo oscuro",
+ "back_to_assistant": "Volver a {name}"
},
"assistant_chat": {
"voice_enter": "Modo voz",
diff --git a/jarvis/ui/web/frontend/src/lib/newChat.ts b/jarvis/ui/web/frontend/src/lib/newChat.ts
index bedec516ba..bde1c8e5a4 100644
--- a/jarvis/ui/web/frontend/src/lib/newChat.ts
+++ b/jarvis/ui/web/frontend/src/lib/newChat.ts
@@ -22,6 +22,7 @@ export function resetTextConversation(): void {
export function startNewTextChat(): void {
resetTextConversation();
useAgentChatStore.getState().newChat();
+ useHomeStore.getState().openAgentChat(null);
useHomeStore.getState().setSurface("chat");
useEventStore.getState().setActiveSection("chats");
}
diff --git a/jarvis/ui/web/frontend/src/store/home.ts b/jarvis/ui/web/frontend/src/store/home.ts
index 91f1634cfa..c7f982d9d2 100644
--- a/jarvis/ui/web/frontend/src/store/home.ts
+++ b/jarvis/ui/web/frontend/src/store/home.ts
@@ -18,6 +18,13 @@ import { useEventStore } from "@/store/events";
interface HomeStore {
jarvisCardMode: "voice" | "chat";
setJarvisCardMode: (mode: "voice" | "chat") => void;
+ /**
+ * The society agent whose chat holds the front page instead of Jarvis'
+ * (picked from the sidebar's agent list), or null for Jarvis' own chat.
+ * Starting a new chat or opening one from the history clears it.
+ */
+ agentChatId: string | null;
+ openAgentChat: (agentId: string | null) => void;
freshVoicePending: boolean;
voiceSelectionPending: boolean;
voiceSwitchStopping: boolean;
@@ -81,6 +88,8 @@ export function reduceLiveReply(current: string, name: string, payload: unknown)
export const useHomeStore = create<HomeStore>((set, get) => ({
jarvisCardMode: "voice",
setJarvisCardMode: (jarvisCardMode) => set({ jarvisCardMode }),
+ agentChatId: null,
+ openAgentChat: (agentChatId) => set({ agentChatId }),
freshVoicePending: false,
voiceSelectionPending: false,
voiceSwitchStopping: false,
diff --git a/jarvis/ui/web/frontend/src/views/ChatsSurface.test.tsx b/jarvis/ui/web/frontend/src/views/ChatsSurface.test.tsx
index b9b293c99e..646a35d14c 100644
--- a/jarvis/ui/web/frontend/src/views/ChatsSurface.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/ChatsSurface.test.tsx
@@ -1,5 +1,5 @@
import { describe, it, expect, afterEach, beforeEach, vi } from "vitest";
-import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";
import { ChatsSurface } from "@/views/ChatsSurface";
import { useHomeStore } from "@/store/home";
import { readHomeSurface } from "@/lib/homeSurface";
@@ -22,17 +22,31 @@ vi.mock("@/components/home/VoiceStage", () => ({
vi.mock("@/components/home/ChatStage", () => ({
ChatStage: () => <div data-testid="chat">chat</div>,
}));
+vi.mock("@/components/home/HomeAgentChat", () => ({
+ default: ({ agentId }: { agentId: string }) => <div data-testid="agent-chat">{agentId}</div>,
+}));
const STORAGE_KEY = "jarvis.home.surface.v2";
describe("ChatsSurface (the front page)", () => {
beforeEach(() => {
window.localStorage.clear();
- useHomeStore.setState({ surface: readHomeSurface() });
+ useHomeStore.setState({ surface: readHomeSurface(), agentChatId: null });
});
afterEach(cleanup);
+ it("gives the page to an agent's chat picked in the sidebar, and back on a new chat", async () => {
+ useHomeStore.getState().openAgentChat("agent-7");
+ render(<ChatsSurface />);
+ expect((await screen.findByTestId("agent-chat")).textContent).toBe("agent-7");
+ expect(screen.queryByTestId("chat")).toBeNull();
+ const { startNewTextChat } = await import("@/lib/newChat");
+ act(() => startNewTextChat());
+ expect(await screen.findByTestId("chat")).toBeTruthy();
+ expect(useHomeStore.getState().agentChatId).toBeNull();
+ });
+
it("opens on the chat by default, with nothing above it", async () => {
render(<ChatsSurface />);
expect(await screen.findByTestId("chat")).toBeTruthy();