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): start subscription transport after desktop handoff
Ruben Lütke6eb451675567
diff --git a/jarvis/ui/web/frontend/src/components/voice/SubscriptionRealtimeTransportBroker.test.tsx b/jarvis/ui/web/frontend/src/components/voice/SubscriptionRealtimeTransportBroker.test.tsxindex dd8cc1764c..4a2dfa353e 100644--- a/jarvis/ui/web/frontend/src/components/voice/SubscriptionRealtimeTransportBroker.test.tsx+++ b/jarvis/ui/web/frontend/src/components/voice/SubscriptionRealtimeTransportBroker.test.tsx@@ -1,5 +1,5 @@import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";-import { cleanup, render } from "@testing-library/react";+import { act, cleanup, render } from "@testing-library/react";const fakes = vi.hoisted(() => ({mode: "pipeline",@@ -108,4 +108,22 @@ describe("SubscriptionRealtimeTransportBroker", () => {expect(fakes.constructed).toBe(0);});++ it("starts when the native host injects its capability after first render", () => {+ fakes.mode = "realtime";+ fakes.realtimeAvailable = true;+ fakes.requiresWebRtcOffer = true;+ delete window.__JARVIS_REALTIME_BROKER_TOKEN;++ render(<SubscriptionRealtimeTransportBroker />);+ expect(fakes.constructed).toBe(0);++ act(() => {+ window.__JARVIS_REALTIME_BROKER_TOKEN = "late-desktop-capability";+ window.dispatchEvent(new Event("jarvis-token-ready"));+ });++ expect(fakes.constructed).toBe(1);+ expect(fakes.start).toHaveBeenCalledOnce();+ });});diff --git a/jarvis/ui/web/frontend/src/components/voice/SubscriptionRealtimeTransportBroker.tsx b/jarvis/ui/web/frontend/src/components/voice/SubscriptionRealtimeTransportBroker.tsxindex 3eddde2703..0a2ad6b25d 100644--- a/jarvis/ui/web/frontend/src/components/voice/SubscriptionRealtimeTransportBroker.tsx+++ b/jarvis/ui/web/frontend/src/components/voice/SubscriptionRealtimeTransportBroker.tsx@@ -1,4 +1,4 @@-import { useEffect } from "react";+import { useEffect, useState } from "react";import { useVoiceMode } from "@/hooks/useVoiceMode";import { RealtimeTransportBroker } from "@/lib/realtimeTransportBroker";@@ -7,6 +7,20 @@ import { hasEmbeddedDesktopBridge } from "./BrowserRealtimeControl";/** Authenticated, invisible WebRTC offer broker for native voice sessions. */export function SubscriptionRealtimeTransportBroker() {const { mode, realtimeAvailable, requiresWebRtcOffer } = useVoiceMode();+ const [desktopCapabilityReady, setDesktopCapabilityReady] = useState(+ () => Boolean(window.__JARVIS_REALTIME_BROKER_TOKEN?.trim()),+ );++ useEffect(() => {+ const refreshCapability = () => {+ setDesktopCapabilityReady(Boolean(window.__JARVIS_REALTIME_BROKER_TOKEN?.trim()));+ };+ // The native host normally injects the capability after React's first+ // render. Re-read it both now and at the host's explicit handoff event.+ refreshCapability();+ window.addEventListener("jarvis-token-ready", refreshCapability);+ return () => window.removeEventListener("jarvis-token-ready", refreshCapability);+ }, []);useEffect(() => {if (@@ -14,13 +28,13 @@ export function SubscriptionRealtimeTransportBroker() {!realtimeAvailable ||!requiresWebRtcOffer ||!hasEmbeddedDesktopBridge() ||- !window.__JARVIS_REALTIME_BROKER_TOKEN?.trim()+ !desktopCapabilityReady) {return;}const broker = new RealtimeTransportBroker();broker.start();return () => broker.stop();- }, [mode, realtimeAvailable, requiresWebRtcOffer]);+ }, [desktopCapabilityReady, mode, realtimeAvailable, requiresWebRtcOffer]);return null;}