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
fix(voice): open a fresh conversation after hangup
rubenluetke10-beepdc010fc84d78
diff --git a/jarvis/ui/web/frontend/src/components/home/AssistantChat.tsx b/jarvis/ui/web/frontend/src/components/home/AssistantChat.tsxindex 5904935ab8..0e1d6d757a 100644--- a/jarvis/ui/web/frontend/src/components/home/AssistantChat.tsx+++ b/jarvis/ui/web/frontend/src/components/home/AssistantChat.tsx@@ -17,8 +17,8 @@ const HomeAgentChat = lazy(() => import("@/components/home/HomeAgentChat"));* The front page: ONE chat with the assistant (2026-10-01).** Nothing but the conversation — no header row, no side card. An empty chat- * is a short greeting over the composer in the middle of the page, the way- * the Claude app opens; the composer itself carries every control,+ * is a short greeting over the composer in the middle of the page;+ * the composer itself carries every control,* including the round voice-mode button. Voice mode is a state of this* chat, not another page: it swaps the typed composer for the voice* composer under the spoken transcript (components/home/VoiceStage), whose@@ -32,15 +32,15 @@ export function AssistantChat() {const chatItems = useAgentChatStore((s) => s.timeline.items);const seedTranscript = useHomeStore((s) => s.seedTranscript);const inVoice = surface === "voice" && !agentChatId;- // An archived voice chat on stage owns the lane (store/home.ts reloads it).+ const freshVoicePending = useHomeStore((s) => s.freshVoicePending);+ // An explicitly selected archived voice chat owns the lane.const voiceThreadOpen = useEventStore((s) => s.activeKind === "voice" && Boolean(s.activeThreadId));- // Between calls the voice lane IS the chat on stage. A hangup clears the- // lane (store/home.ts); the turns just spoken arrive in the chat a moment- // later (the backend files them there), so the lane follows the chat.+ // Only a selected chat may seed the idle lane. After hangup, delayed chat+ // updates must not put the completed conversation back on the blank page.useEffect(() => {- if (!inVoice || voice.live || voiceThreadOpen) return;+ if (!inVoice || voice.live || voiceThreadOpen || freshVoicePending) return;seedTranscript(transcriptFromTimeline(chatItems));- }, [chatItems, inVoice, seedTranscript, voice.live, voiceThreadOpen]);+ }, [chatItems, freshVoicePending, inVoice, seedTranscript, voice.live, voiceThreadOpen]);const loading = (<div role="status" className="flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground">{t("common.loading")}diff --git a/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx b/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsxindex 212f51977c..875f8bf2fb 100644--- a/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx+++ b/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx@@ -52,7 +52,7 @@ describe("RecentChats", () => {voiceState: "idle",});useHomeStore.setState({ surface: "voice", transcript: [], liveReply: "", liveSessionId: null,- continuedVoiceId: null, liveConversationId: null, voiceSelectionPending: false, voiceSwitchStopping: false });+ continuedVoiceId: null, liveConversationId: null, freshVoicePending: false, voiceSelectionPending: false, voiceSwitchStopping: false });useAgentChatStore.setState({sessions: [{@@ -215,6 +215,44 @@ describe("RecentChats", () => {await flush();});+ it("deselects an ended archive and only continues it after another explicit click", async () => {+ render(<RecentChats />);+ fireEvent.click(screen.getByTitle("Spoken thread"));+ await flush();+ act(() => {+ useHomeStore.getState().ingest("VoiceSessionStarted", { session_id: "call" }, 1);+ useHomeStore.getState().ingest("VoiceSessionEnded", { session_id: "call", hangup_reason: "hotkey" }, 2);+ });+ await flush();+ expect(useEventStore.getState().activeThreadId).toBeNull();+ expect(useHomeStore.getState().continuedVoiceId).toBeNull();+ expect(useHomeStore.getState().transcript).toEqual([]);+ expect(screen.getByTitle("Spoken thread")).toBeTruthy();+ fireEvent.click(screen.getByTitle("Spoken thread"));+ await flush();+ expect(useEventStore.getState().activeThreadId).toBe("v1");+ expect(useHomeStore.getState().continuedVoiceId).toBe("v1");+ expect(useHomeStore.getState().transcript.map(line => line.text)).toEqual(["hello", "Hi there."]);+ expect(useAgentChatStore.getState().newChat).toHaveBeenLastCalledWith({ voiceSessionId: "v1" });+ });++ it("does not reseed the blank lane when an archive response arrives after hangup", async () => {+ render(<RecentChats />);+ let finish!: (response: Response) => void;+ vi.mocked(fetch).mockImplementation(async (url) => String(url).endsWith("/resume")+ ? new Promise<Response>(resolve => { finish = resolve; })+ : new Response(JSON.stringify(CONVERSATIONS)));+ fireEvent.click(screen.getByTitle("Spoken thread"));+ await flush();+ await act(async () => {+ useHomeStore.getState().ingest("VoiceSessionEnded", { hangup_reason: "hotkey" }, 2);+ finish(new Response(JSON.stringify(DETAIL)));+ });+ expect(useHomeStore.getState().freshVoicePending).toBe(true);+ expect(useHomeStore.getState().transcript).toEqual([]);+ expect(useEventStore.getState().activeThreadId).toBeNull();+ });+it("opens an agent chat on the chat surface even from the voice stage", async () => {render(<RecentChats />);// The classic brain's text threads are no longer listed — the chatdiff --git a/jarvis/ui/web/frontend/src/components/home/assistantStatus.ts b/jarvis/ui/web/frontend/src/components/home/assistantStatus.tsindex be1590e11f..84ea16b7fa 100644--- a/jarvis/ui/web/frontend/src/components/home/assistantStatus.ts+++ b/jarvis/ui/web/frontend/src/components/home/assistantStatus.ts@@ -79,12 +79,13 @@ export function useVoiceModeSwitch() {const exit = useCallback(() => {if (active && !busy) void toggleCall();setSurface("chat");+ if (useHomeStore.getState().freshVoicePending) return;if (useAgentChatStore.getState().activeSessionId) return;// A call from a blank page opened its chat on the backend: show it.void fetchVoiceChat().then(({ session_id: sessionId }) => {const chat = useAgentChatStore.getState();- if (!sessionId || chat.activeSessionId) return;+ if (!sessionId || chat.activeSessionId || useHomeStore.getState().freshVoicePending) return;chat.openSession(sessionId);void chat.loadSessions();})diff --git a/jarvis/ui/web/frontend/src/components/home/chatRows.ts b/jarvis/ui/web/frontend/src/components/home/chatRows.tsindex 9daa7557f1..7675086efc 100644--- a/jarvis/ui/web/frontend/src/components/home/chatRows.ts+++ b/jarvis/ui/web/frontend/src/components/home/chatRows.ts@@ -117,7 +117,9 @@ export function useChatRows({ poll = false }: { poll?: boolean } = {}): ChatRowsconst opened = openConversation("voice", row.id);if (stayOnVoice) {void opened.then((messages) => {- if (messages !== null) seedTranscript(transcriptFromMessages(messages));+ const active = useEventStore.getState();+ if (messages === null || active.activeKind !== "voice" || active.activeThreadId !== row.id) return;+ seedTranscript(transcriptFromMessages(messages));});} else {void opened;diff --git 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.tsxindex 6efa443ba3..52d75f12ef 100644--- 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@@ -234,7 +234,10 @@ it("reads archived calls on the actual voice stage and returns there fresh afterexpect(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" }));+ await waitFor(() => expect(fetch).toHaveBeenCalledWith("/api/agent-chat/voice-chat", expect.objectContaining({+ method: "PUT", body: JSON.stringify({ session_id: null, voice_session_id: null }),+ })));+ expect(vi.mocked(fetch).mock.calls.some(([url]) => String(url) === "/api/chats/voice/new")).toBe(false);});it.each(["specialist", "lead"] as const)("/clear empties only the %s view and keeps its session and context", (tier) => {diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsxindex de8729e2ff..40d070833d 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx@@ -44,7 +44,6 @@ import { DictationButton } from "@/components/agentchat/DictationButton";import { useComposerDictation } from "@/components/agentchat/useComposerDictation";import { useEventStore } from "@/store/events";import { useHomeStore } from "@/store/home";-import { startNewVoiceRun } from "@/lib/chatsApi";import {runningTurn,type NoticeItem,@@ -349,19 +348,6 @@ function JarvisChat({ agent, roster }: AgentChatPanelProps) {const setActiveConversation = useEventStore((s) => s.setActiveConversation);const setMessages = useEventStore((s) => s.setMessages);- const voiceState = useEventStore((s) => s.voiceState);- const freshVoicePending = useHomeStore((s) => s.freshVoicePending);-- useEffect(() => {- if (!freshVoicePending || voiceState !== "idle" || !useHomeStore.getState().freshVoicePending) return;- useHomeStore.setState({ freshVoicePending: false });- // Use the existing reset contract once after hangup, including re-entry- // after the card was closed. Never interrupt a call started elsewhere.- void startNewVoiceRun().catch(() => {- useEventStore.getState().pushToast("error", `${t("sidebar.new_voice_chat")}: ${t("voice_state.error")}`);- });- }, [freshVoicePending, voiceState, t]);-// A null session is an intentional fresh chat. Only an explicit history// selection may open an older session; polling must not undo New chat.diff --git a/jarvis/ui/web/frontend/src/store/home.test.ts b/jarvis/ui/web/frontend/src/store/home.test.tsindex 46278e13dd..258c847767 100644--- a/jarvis/ui/web/frontend/src/store/home.test.ts+++ b/jarvis/ui/web/frontend/src/store/home.test.ts@@ -1,13 +1,17 @@-import { beforeEach, describe, expect, it } from "vitest";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { reduceLiveReply, useHomeStore } from "@/store/home";import { useEventStore } from "@/store/events";+import { useAgentChatStore } from "@/store/agentChat";describe("voice conversation boundaries", () => {beforeEach(() => {useHomeStore.getState().resetTranscript();- useHomeStore.setState({ continuedVoiceId: null });+ useHomeStore.setState({ continuedVoiceId: null, freshVoicePending: false, voiceSwitchStopping: false, voiceSelectionPending: false });+ useEventStore.setState({ activeKind: "voice", activeThreadId: null });+ vi.stubGlobal("fetch", vi.fn(async () => new Response(JSON.stringify({ providers: [], sessions: [] }))));});+ afterEach(() => vi.unstubAllGlobals());it("keeps the running call's history row independent of later selections", () => {useHomeStore.setState({ continuedVoiceId: "archive" });@@ -52,6 +56,54 @@ describe("voice conversation boundaries", () => {home.ingest("VoiceSessionEnded", { hangup_reason: "realtime_fallback" }, 4);home.ingest("VoiceSessionEnded", { hangup_reason: "desktop_fallback" }, 5);expect(useHomeStore.getState().transcript.map((line) => line.text)).toEqual(["Keep this turn"]);+ expect(fetch).not.toHaveBeenCalled();+ });++ it.each(["hotkey", "voice_pattern", "client_stop", "idle_timeout"])("leaves a continued archive after %s and unbinds the next wake", (hangup_reason) => {+ const home = useHomeStore.getState();+ home.setContinuedVoiceId("archive");+ useEventStore.setState({ activeKind: "voice", activeThreadId: "archive" });+ home.seedTranscript([{ id: "old", who: "user", text: "Saved conversation", ts: 1 }]);+ home.ingest("VoiceSessionStarted", { session_id: "call" }, 2);+ home.ingest("VoiceSessionEnded", { session_id: "call", hangup_reason }, 3);+ expect(useHomeStore.getState().continuedVoiceId).toBeNull();+ expect(useHomeStore.getState().freshVoicePending).toBe(true);+ expect(useEventStore.getState().activeThreadId).toBeNull();+ expect(useHomeStore.getState().transcript).toEqual([]);+ expect(fetch).toHaveBeenCalledWith("/api/agent-chat/voice-chat", expect.objectContaining({+ method: "PUT", body: JSON.stringify({ session_id: null, voice_session_id: null }),+ }));+ expect(vi.mocked(fetch).mock.calls.some(([url]) => String(url).endsWith("/resume"))).toBe(false);+ home.ingest("VoiceTranscriptUpdated", { session_id: "call", segment_id: "late", role: "assistant", text: "Late final", revision: 2 }, 4);+ home.ingest("SpeechSpoken", { text: "Late spoken reply", spoken_kind: "reply" }, 4);+ home.ingest("AssistantTextDelta", { channel: "voice", text: "Late snapshot" }, 4);+ expect(useHomeStore.getState().transcript).toEqual([]);+ expect(useHomeStore.getState().liveReply).toBe("");+ home.ingest("VoiceSessionStarted", { session_id: "next-call" }, 5);+ home.ingest("TranscriptFinal", { transcript: { text: "Fresh question" } }, 6);+ expect(useHomeStore.getState().transcript.map(line => line.text)).toEqual(["Fresh question"]);+ });++ it("clears the selected typed timeline when its voice call ends without deleting history", () => {+ const session = { session_id: "typed" };+ useAgentChatStore.setState({ activeSessionId: session.session_id });+ useEventStore.setState({ activeKind: "text", activeThreadId: "typed" });+ useHomeStore.getState().ingest("VoiceSessionEnded", { hangup_reason: "hotkey" }, 1);+ expect(useAgentChatStore.getState().activeSessionId).toBeNull();+ expect(useAgentChatStore.getState().timeline.items).toEqual([]);+ expect(useEventStore.getState().activeThreadId).toBeNull();+ expect(vi.mocked(fetch).mock.calls.some(([, init]) => init?.method === "DELETE")).toBe(false);+ });++ it("preserves an explicit archive switch while the previous call is stopping", () => {+ useEventStore.setState({ activeKind: "voice", activeThreadId: "chosen" });+ useHomeStore.setState({ continuedVoiceId: "chosen", voiceSwitchStopping: true, voiceSelectionPending: true });+ useHomeStore.getState().ingest("VoiceSessionEnded", { hangup_reason: "hotkey" }, 1);+ expect(useEventStore.getState().activeThreadId).toBe("chosen");+ expect(useHomeStore.getState().continuedVoiceId).toBe("chosen");+ expect(useHomeStore.getState().freshVoicePending).toBe(false);+ expect(useHomeStore.getState().voiceSelectionPending).toBe(true);+ expect(fetch).not.toHaveBeenCalled();});});diff --git a/jarvis/ui/web/frontend/src/store/home.ts b/jarvis/ui/web/frontend/src/store/home.tsindex 0ed0d5f70d..e78ada883a 100644--- a/jarvis/ui/web/frontend/src/store/home.ts+++ b/jarvis/ui/web/frontend/src/store/home.ts@@ -1,8 +1,8 @@import { create } from "zustand";import { readHomeSurface, writeHomeSurface, type HomeSurface } from "@/lib/homeSurface";-import { detailToMessages, detailToTraces, resumeConversation } from "@/lib/chatsApi";-import { reduceTranscript, transcriptFromMessages, type TranscriptLine } from "@/lib/homeTranscript";+import { reduceTranscript, type TranscriptLine } from "@/lib/homeTranscript";+import { useAgentChatStore } from "@/store/agentChat";import { useEventStore } from "@/store/events";/**@@ -31,8 +31,8 @@ interface HomeStore {voiceSwitchStopping: boolean;/*** The archived voice chat the front page reopened from the history. Its- * calls are recorded into it (jarvis/sessions/continuation.py), so a hangup- * keeps it on stage and reloads it instead of opening an empty lane.+ * calls are recorded into it (jarvis/sessions/continuation.py). A hangup+ * clears the selection; continuing it again requires a new history click.*/continuedVoiceId: string | null;setContinuedVoiceId: (id: string | null) => void;@@ -95,22 +95,6 @@ export function reduceLiveReply(current: string, name: string, payload: unknown)}}-/** Re-read a continued voice chat after a call and put its lines back on stage. */-async function reloadContinuedVoiceChat(id: string): Promise<void> {- try {- const detail = await resumeConversation("voice", id);- const events = useEventStore.getState();- if (events.activeKind !== "voice" || events.activeThreadId !== id) return;- const messages = detailToMessages(detail);- events.seedThinkingTraces(detailToTraces(detail));- events.setMessages(messages);- useHomeStore.getState().seedTranscript(transcriptFromMessages(messages));- } catch (error) {- // The lane keeps what the call showed; the history row has the rest.- console.info("Continued voice chat could not be reloaded.", error);- }-}-export const useHomeStore = create<HomeStore>((set, get) => ({jarvisCardMode: "voice",setJarvisCardMode: (jarvisCardMode) => set({ jarvisCardMode }),@@ -131,6 +115,9 @@ export const useHomeStore = create<HomeStore>((set, get) => ({liveSessionId: null,liveConversationId: null,ingest: (name, payload, tsMs) => {+ // Late captions, spoken replies, and tool traces belong to the completed+ // call. Keep its blank successor empty until a call or selection starts.+ if (get().freshVoicePending && name !== "VoiceSessionStarted" && name !== "VoiceSessionEnded") return;if (name === "VoiceTranscriptUpdated") {const sessionId = (payload as { session_id?: string } | null)?.session_id;if (get().liveSessionId && sessionId !== get().liveSessionId) return;@@ -147,28 +134,21 @@ export const useHomeStore = create<HomeStore>((set, get) => ({// empty lane; the completed conversation remains in the history rail.if (reason !== "realtime_fallback" && reason !== "desktop_fallback") {const events = useEventStore.getState();- const continued = get().continuedVoiceId;- if (- continued && events.activeKind === "voice" && events.activeThreadId === continued- && !get().voiceSwitchStopping- ) {- // The call was recorded into the reopened voice chat: it stays on- // stage, and its stored lines (now with this call) replace the lane.- events.setTranscription("", true);- set({ liveReply: "", freshVoicePending: false });- void reloadContinuedVoiceChat(continued);- return;- }- if (events.activeKind === "voice" && !get().voiceSwitchStopping) {+ if (!get().voiceSwitchStopping) {events.setActiveConversation("voice", null);events.setMessages([]);events.seedThinkingTraces({});+ // Close the old timeline and unbind its backend voice context now,+ // even when the front page/card is closed. This does not start or+ // stop a call, so a later wake cannot be cancelled by a reset effect.+ useAgentChatStore.getState().newChat();}events.setTranscription("", true);// Remember this even while the card is closed. Returning to Jarvis// must not restore the last archive selection or the typed surface.set({transcript: [], liveReply: "", jarvisCardMode: "voice",+ continuedVoiceId: get().voiceSwitchStopping ? get().continuedVoiceId : null,freshVoicePending: !get().voiceSwitchStopping,voiceSelectionPending: get().voiceSwitchStopping && get().voiceSelectionPending,});diff --git a/jarvis/ui/web/frontend/src/views/ChatsSurface.test.tsx b/jarvis/ui/web/frontend/src/views/ChatsSurface.test.tsxindex 734afffee5..2ae6cde72e 100644--- a/jarvis/ui/web/frontend/src/views/ChatsSurface.test.tsx+++ b/jarvis/ui/web/frontend/src/views/ChatsSurface.test.tsx@@ -4,6 +4,7 @@ import { ChatsSurface } from "@/views/ChatsSurface";import { useHomeStore } from "@/store/home";import { readHomeSurface } from "@/lib/homeSurface";import { useEventStore } from "@/store/events";+import { useAgentChatStore } from "@/store/agentChat";/*** The front page is ONE chat with a voice mode inside it (2026-10-01). What@@ -32,8 +33,8 @@ const STORAGE_KEY = "jarvis.home.surface.v2";describe("ChatsSurface (the front page)", () => {beforeEach(() => {window.localStorage.clear();- useHomeStore.setState({ surface: readHomeSurface(), agentChatId: null });- useEventStore.setState({ activeSection: "chats", voiceState: "idle" });+ useHomeStore.setState({ surface: readHomeSurface(), agentChatId: null, freshVoicePending: false, continuedVoiceId: null, voiceSwitchStopping: false });+ useEventStore.setState({ activeSection: "chats", voiceState: "idle", activeKind: "voice", activeThreadId: null });});afterEach(cleanup);@@ -85,6 +86,36 @@ describe("ChatsSurface (the front page)", () => {expect(useHomeStore.getState().surface).toBe("chat");});+ it("stays blank after hangup, late timeline updates, and switching back to typing", async () => {+ const fetcher = vi.fn(async (_url: RequestInfo | URL, _init?: RequestInit) =>+ new Response(JSON.stringify({ providers: [], sessions: [], session_id: "old-chat" })));+ vi.stubGlobal("fetch", fetcher);+ try {+ useHomeStore.setState({ surface: "voice", continuedVoiceId: "archive" });+ useEventStore.setState({ activeKind: "voice", activeThreadId: "archive" });+ useHomeStore.getState().seedTranscript([{ id: "old", who: "user", text: "Old call", ts: 1 }]);+ render(<ChatsSurface />);+ await act(async () => {+ useHomeStore.getState().ingest("VoiceSessionStarted", { session_id: "call" }, 1);+ useHomeStore.getState().ingest("VoiceSessionEnded", { session_id: "call", hangup_reason: "hotkey" }, 2);+ });+ act(() => useAgentChatStore.setState({ timeline: {+ ...useAgentChatStore.getState().timeline,+ items: [{ type: "user", id: "late", text: "Late stored turn", tsMs: 3, attachments: [] }],+ } }));+ expect(useHomeStore.getState().transcript).toEqual([]);+ expect(useHomeStore.getState().freshVoicePending).toBe(true);+ expect(useEventStore.getState().activeThreadId).toBeNull();+ expect(screen.getByTestId("voice")).toBeTruthy();+ fireEvent.click(screen.getByTestId("voice-mode-exit"));+ expect(await screen.findByTestId("chat")).toBeTruthy();+ expect(useAgentChatStore.getState().activeSessionId).toBeNull();+ expect(fetcher.mock.calls.some(([url, init]) => String(url) === "/api/agent-chat/voice-chat" && !init?.method)).toBe(false);+ } finally {+ vi.unstubAllGlobals();+ }+ });+it("ignores the retired Voice | Chat switch's stored choice", async () => {window.localStorage.setItem("jarvis.home.surface.v1", "voice");useHomeStore.setState({ surface: readHomeSurface() });