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(voice): retain the running call's history identity

rubenluetke10-beep7ad87d5fa037
diff --git a/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx b/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx
index be6eff5eaf..212f51977c 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, voiceSelectionPending: false, voiceSwitchStopping: false });
+ continuedVoiceId: null, liveConversationId: null, voiceSelectionPending: false, voiceSwitchStopping: false });
useAgentChatStore.setState({
sessions: [
{
@@ -130,8 +130,10 @@ describe("RecentChats", () => {
);
it("recognizes a running call recorded into a continued voice chat", async () => {
- useEventStore.setState({ voiceState: "speaking" });
- useHomeStore.setState({ liveSessionId: "current-call", continuedVoiceId: "v1", liveReply: "Still speaking" });
+ useEventStore.setState({ voiceState: "speaking", activeKind: "voice", activeThreadId: "v1" });
+ useHomeStore.setState({ continuedVoiceId: "v1", liveReply: "Still speaking" });
+ useHomeStore.getState().ingest("VoiceSessionStarted", { session_id: "current-call" }, 3);
+ useEventStore.setState({ activeKind: "text", activeThreadId: null });
render(<RecentChats />);
fireEvent.click(screen.getByTitle("Spoken thread"));
await flush();
@@ -150,9 +152,10 @@ describe("RecentChats", () => {
expect(useHomeStore.getState().transcript.map((line) => line.text)).toEqual(["hello", "Hi there."]);
});
- it("does not mistake another archive for the running call when selecting its row", async () => {
+ it.each(["other-archive", "v1"])("does not mistake archive selection %s for a fresh running call", async (continuedVoiceId) => {
useEventStore.setState({ voiceState: "listening" });
- useHomeStore.setState({ liveSessionId: "other-call", continuedVoiceId: "other-archive" });
+ useHomeStore.setState({ continuedVoiceId });
+ useHomeStore.getState().ingest("VoiceSessionStarted", { session_id: "other-call" }, 2);
render(<RecentChats />);
fireEvent.click(screen.getByTitle("Spoken thread"));
await waitFor(() => expect(fetch).toHaveBeenCalledWith("/api/voice/hangup", { method: "POST", cache: "no-store" }));
diff --git a/jarvis/ui/web/frontend/src/hooks/useConversations.ts b/jarvis/ui/web/frontend/src/hooks/useConversations.ts
index e67083679c..c266f8db8d 100644
--- a/jarvis/ui/web/frontend/src/hooks/useConversations.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useConversations.ts
@@ -84,10 +84,10 @@ export function useConversations({ poll = false }: { poll?: boolean } = {}) {
const voiceState = useEventStore.getState().voiceState;
if (
!home.liveSessionId
+ || home.voiceSwitchStopping
|| !["listening", "thinking", "speaking", "paused", "connecting"].includes(voiceState)
- || (id !== home.liveSessionId && id !== home.continuedVoiceId)
+ || (id !== home.liveSessionId && id !== home.liveConversationId)
) return false;
- // Check before callers replace continuedVoiceId with the selected row.
// A previous archive read must not overwrite the call after this click.
++selectionGeneration;
setActiveConversation("voice", id);
diff --git a/jarvis/ui/web/frontend/src/store/home.test.ts b/jarvis/ui/web/frontend/src/store/home.test.ts
index 23ae35a75d..46278e13dd 100644
--- a/jarvis/ui/web/frontend/src/store/home.test.ts
+++ b/jarvis/ui/web/frontend/src/store/home.test.ts
@@ -4,7 +4,25 @@ import { reduceLiveReply, useHomeStore } from "@/store/home";
import { useEventStore } from "@/store/events";
describe("voice conversation boundaries", () => {
- beforeEach(() => useHomeStore.getState().resetTranscript());
+ beforeEach(() => {
+ useHomeStore.getState().resetTranscript();
+ useHomeStore.setState({ continuedVoiceId: null });
+ });
+
+ it("keeps the running call's history row independent of later selections", () => {
+ useHomeStore.setState({ continuedVoiceId: "archive" });
+ useEventStore.setState({ activeKind: "voice", activeThreadId: "archive" });
+ useHomeStore.getState().ingest("VoiceSessionStarted", { session_id: "call" }, 1);
+ useHomeStore.getState().setContinuedVoiceId("another-archive");
+ expect(useHomeStore.getState().liveConversationId).toBe("archive");
+ });
+
+ it("does not attach a fresh call to a stale archive selection", () => {
+ useHomeStore.setState({ continuedVoiceId: "old-archive" });
+ useEventStore.setState({ activeKind: "voice", activeThreadId: null });
+ useHomeStore.getState().ingest("VoiceSessionStarted", { session_id: "fresh-call" }, 1);
+ expect(useHomeStore.getState().liveConversationId).toBe("fresh-call");
+ });
it.each(["hotkey", "voice_pattern", "client_stop", "idle_timeout"])("starts a fresh lane after %s", (hangup_reason) => {
const home = useHomeStore.getState();
diff --git a/jarvis/ui/web/frontend/src/store/home.ts b/jarvis/ui/web/frontend/src/store/home.ts
index 6cc34a511a..0ed0d5f70d 100644
--- a/jarvis/ui/web/frontend/src/store/home.ts
+++ b/jarvis/ui/web/frontend/src/store/home.ts
@@ -47,6 +47,8 @@ interface HomeStore {
*/
liveReply: string;
liveSessionId: string | null;
+ /** History row captured when this call starts; navigation cannot reassign it. */
+ liveConversationId: string | null;
ingest: (name: string, payload: unknown, tsMs: number) => void;
/**
* Replace the lane with a stored conversation (a reopened voice session);
@@ -127,6 +129,7 @@ export const useHomeStore = create<HomeStore>((set, get) => ({
transcript: [],
liveReply: "",
liveSessionId: null,
+ liveConversationId: null,
ingest: (name, payload, tsMs) => {
if (name === "VoiceTranscriptUpdated") {
const sessionId = (payload as { session_id?: string } | null)?.session_id;
@@ -174,7 +177,15 @@ export const useHomeStore = create<HomeStore>((set, get) => ({
}
if (name === "VoiceSessionStarted") {
// A call already started elsewhere must not be ended on card re-entry.
- set({ freshVoicePending: false, liveSessionId: (payload as { session_id?: string })?.session_id || null });
+ const sessionId = (payload as { session_id?: string })?.session_id || null;
+ const events = useEventStore.getState();
+ const continued = get().continuedVoiceId;
+ set({
+ freshVoicePending: false,
+ liveSessionId: sessionId,
+ liveConversationId: continued && events.activeKind === "voice" && events.activeThreadId === continued
+ ? continued : sessionId,
+ });
// Wake words and external call controls start the same voice session as
// the composer button. Follow that session in the open Jarvis chat
// without starting another call or navigating away from other work.
@@ -190,5 +201,5 @@ export const useHomeStore = create<HomeStore>((set, get) => ({
}
},
seedTranscript: (lines) => set({ transcript: lines, liveReply: "", freshVoicePending: false }),
- resetTranscript: () => set({ transcript: [], liveReply: "", liveSessionId: null }),
+ resetTranscript: () => set({ transcript: [], liveReply: "", liveSessionId: null, liveConversationId: null }),
}));