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.

fix(society): integrate view clearing with current agent chats

rubenluetke10-beep96ea562ba798
diff --cc jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.switch.test.tsx
index c3041de236,a84adc03d1..2fe2c70047
--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.switch.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.switch.test.tsx
@@@ -1,4 -1,4 +1,5 @@@
- import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";
++import { useTranscriptViewStore } from "./useTranscriptView";
+ import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { EMPTY_TIMELINE, type Timeline, type UserItem } from "@/components/agentchat/reduce";
@@@ -86,7 -91,9 +92,10 @@@ const visual = agent({ agentId: "visual
const gmail = agent({ agentId: "gmail-agent", name: "Gmail Agent" });
beforeEach(() => {
+ useTranscriptViewStore.setState({ boundaries: {} });
+ useHomeStore.setState({ transcript: [], liveReply: "", jarvisCardMode: "voice", freshVoicePending: false });
+ useEventStore.setState({ activeKind: "text", activeThreadId: null, messages: [], voiceState: "idle" });
+ vi.stubGlobal("ResizeObserver", class { observe() {} unobserve() {} disconnect() {} });
Element.prototype.scrollIntoView = vi.fn();
vi.stubGlobal("WebSocket", FakeSocket);
vi.stubGlobal(
@@@ -190,3 -168,37 +170,66 @@@ it("keeps Jarvis on a fresh chat when h
render(<AgentChatPanel agent={jarvis} roster={[jarvis]} />);
expect(useAgentChatStore.getState().activeSessionId).toBeNull();
});
+
+ it("reads archived calls on the actual voice stage and returns there fresh after hangup while closed", async () => {
+ const jarvis = agent({ agentId: "jarvis", name: "Jarvis", tier: "lead" });
+ const voice = { kind: "voice", id: "voice-archive", title: "Archived call", preview: "", created_ms: 1, updated_ms: 2, message_count: 2 };
+ vi.mocked(fetch).mockImplementation(async (url) => {
+ const path = String(url);
+ if (path.includes("/api/chats?")) return new Response(JSON.stringify([voice]));
+ if (path.includes("/voice/voice-archive/resume")) return new Response(JSON.stringify({ ...voice, messages: [
+ { role: "user", text: "Archived question", ts_ms: 1 },
+ { role: "assistant", text: "Archived answer", ts_ms: 2 },
+ ] }));
- return new Response(JSON.stringify({ providers: [], sessions: [], mapping: [] }));
++ return new Response(JSON.stringify({ providers: [], sessions: [], mapping: [], events: [] }));
+ });
+ const view = render(<><AgentChatPanel agent={jarvis} roster={[jarvis]} /><JarvisHistoryRail /></>);
+ fireEvent.click(await screen.findByTestId("jarvis-history-voice-row"));
+ expect(await screen.findByText("Archived question")).toBeTruthy();
+ expect(screen.getByText("Archived answer")).toBeTruthy();
+ expect(screen.getByTestId("society-chat").getAttribute("data-mode")).toBe("voice");
+ expect(screen.getByTestId("jarvis-bar")).toBeTruthy();
+ expect(screen.queryByTestId("voice-thread-stage")).toBeNull();
+ fireEvent.click(screen.getByTestId("society-jarvis-mode-chat"));
+ fireEvent.click(screen.getByTestId("society-jarvis-mode-voice"));
+ expect(screen.getByText("Archived question")).toBeTruthy();
+ view.unmount();
+ act(() => {
+ setJarvisCardMode("chat");
+ useHomeStore.getState().ingest("VoiceSessionEnded", { hangup_reason: "hotkey" }, 3);
+ });
+ render(<AgentChatPanel agent={jarvis} roster={[jarvis]} />);
+ expect(screen.getByTestId("society-chat").getAttribute("data-mode")).toBe("voice");
+ expect(screen.getByTestId("voice-stage").getAttribute("data-empty")).toBe("true");
+ expect(screen.queryByText("Archived question")).toBeNull();
+ await waitFor(() => expect(fetch).toHaveBeenCalledWith("/api/chats/voice/new", { method: "POST" }));
+ });
++
++it.each(["specialist", "lead"] as const)("/clear empties only the %s view and keeps its session and context", (tier) => {
++ const current = tier === "lead" ? agent({ agentId: "jarvis", name: "Jarvis", tier }) : gmail;
++ const store = tier === "lead" ? useAgentChatStore : useSocietyChatStore;
++ const original = timelineWith("PREVIOUS_CONTEXT_TO_KEEP");
++ store.getState().openSession(current.chatSessionId!);
++ store.setState({ activeSessionId: current.chatSessionId, timeline: original, busy: false });
++ setJarvisCardMode("chat");
++ const view = render(<AgentChatPanel agent={current} roster={[current]} />);
++ expect(screen.getByText("PREVIOUS_CONTEXT_TO_KEEP")).toBeTruthy();
++ const input = screen.getByRole("textbox");
++ input.textContent = " /clear ";
++ fireEvent.input(input);
++ fireEvent.keyDown(input, { key: "Enter", code: "Enter" });
++ expect(screen.queryByText("PREVIOUS_CONTEXT_TO_KEEP")).toBeNull();
++ expect(input.textContent).toBe("");
++ expect(store.getState().activeSessionId).toBe(current.chatSessionId);
++ expect(store.getState().timeline).toBe(original);
++ expect(vi.mocked(fetch).mock.calls.some(([url, options]) =>
++ String(url).includes("/messages") || options?.method === "DELETE",
++ )).toBe(false);
++ act(() => store.setState({ timeline: { ...original, items: [...original.items, ...timelineWith("FIRST_VISIBLE_MESSAGE").items] } }));
++ expect(screen.getByText("FIRST_VISIBLE_MESSAGE")).toBeTruthy();
++ expect(screen.queryByText("PREVIOUS_CONTEXT_TO_KEEP")).toBeNull();
++ view.unmount();
++ render(<AgentChatPanel agent={current} roster={[current]} />);
++ expect(screen.getByText("FIRST_VISIBLE_MESSAGE")).toBeTruthy();
++ expect(screen.queryByText("PREVIOUS_CONTEXT_TO_KEEP")).toBeNull();
++});