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): never reload the window under a live voice call

rubenluetke10-beepbca01c462738
diff --git a/jarvis/ui/web/frontend/src/components/voice/BrowserRealtimeControl.tsx b/jarvis/ui/web/frontend/src/components/voice/BrowserRealtimeControl.tsx
index dbc1d4018b..7503d64005 100644
--- a/jarvis/ui/web/frontend/src/components/voice/BrowserRealtimeControl.tsx
+++ b/jarvis/ui/web/frontend/src/components/voice/BrowserRealtimeControl.tsx
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useRef, useState } from "react";
+import { useCallback, useEffect, useId, useRef, useState } from "react";
import { Loader2, Mic, MicOff, RotateCcw } from "lucide-react";
import { VoiceWaveform, type WaveformPhase } from "@/components/overlay/VoiceWaveform";
@@ -14,6 +14,7 @@ import {
type BrowserRealtimeSupportIssue,
} from "@/lib/realtimeAudio";
import { useEventStore, type VoiceState } from "@/store/events";
+import { setReloadHold } from "@/lib/reloadHold";
import { cn } from "@/lib/utils";
import {
clearVoiceInputLevel,
@@ -402,6 +403,14 @@ export function BrowserRealtimeControl({ controlOnly = false }: { controlOnly?:
if (!visible) void stop();
}, [stop, visible]);
+ // This document owns the call: an automatic reload (a rebuilt bundle) would
+ // unmount this control and hang up mid-sentence. Hold reloads while it lives.
+ const reloadOwner = useId();
+ useEffect(() => {
+ setReloadHold(reloadOwner, state === "connecting" || state === "connected");
+ }, [reloadOwner, state]);
+ useEffect(() => () => setReloadHold(reloadOwner, false), [reloadOwner]);
+
useEffect(
() => () => {
connectionGenerationRef.current += 1;
diff --git a/jarvis/ui/web/frontend/src/lib/bundleWatch.test.ts b/jarvis/ui/web/frontend/src/lib/bundleWatch.test.ts
index e56d571c96..816455061e 100644
--- a/jarvis/ui/web/frontend/src/lib/bundleWatch.test.ts
+++ b/jarvis/ui/web/frontend/src/lib/bundleWatch.test.ts
@@ -15,6 +15,7 @@ import {
shouldReload,
type BundleWatchDeps,
} from "./bundleWatch";
+import { reloadHeld, setReloadHold } from "./reloadHold";
function indexHtml(hash: string): string {
return [
@@ -130,6 +131,20 @@ describe("shouldReload", () => {
).toBe(true);
});
+ it("never hangs up a live call, however idle the user looks", () => {
+ // 2026-10-02: a rebuild reloaded the window 15 minutes into a voice call.
+ // The user was talking, so keyboard and mouse had been idle for minutes.
+ expect(
+ shouldReload({
+ baseline,
+ seen: "new",
+ confirmed: "new",
+ idleMs: 600_000,
+ held: true,
+ }),
+ ).toBe(false);
+ });
+
it("never reloads for an unchanged or unreadable answer", () => {
expect(
shouldReload({
@@ -192,6 +207,22 @@ describe("installBundleWatch", () => {
expect(app.reload).toHaveBeenCalledOnce();
});
+ it("waits for a held window and reloads once the hold is released", async () => {
+ let held = true;
+ const app = harness(indexHtml("AAA"));
+ installBundleWatch({ ...app.deps, held: () => held });
+ await app.tick();
+ app.serve(indexHtml("BBB"));
+ await app.tick();
+ await app.tick();
+ await app.tick();
+ expect(app.reload).not.toHaveBeenCalled();
+
+ held = false;
+ await app.tick();
+ expect(app.reload).toHaveBeenCalledOnce();
+ });
+
it("asks nothing of a hidden window and resumes when it comes back", async () => {
const app = harness(indexHtml("AAA"));
installBundleWatch(app.deps);
@@ -280,3 +311,15 @@ describe("installBundleWatch", () => {
expect(app.fetches()).toBe(before);
});
});
+
+describe("reloadHold", () => {
+ it("holds while any owner holds and releases per owner", () => {
+ expect(reloadHeld()).toBe(false);
+ setReloadHold("call-a", true);
+ setReloadHold("call-b", true);
+ setReloadHold("call-a", false);
+ expect(reloadHeld()).toBe(true);
+ setReloadHold("call-b", false);
+ expect(reloadHeld()).toBe(false);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/bundleWatch.ts b/jarvis/ui/web/frontend/src/lib/bundleWatch.ts
index b709f36cde..37cad77b4b 100644
--- a/jarvis/ui/web/frontend/src/lib/bundleWatch.ts
+++ b/jarvis/ui/web/frontend/src/lib/bundleWatch.ts
@@ -21,7 +21,9 @@
* publishes an `index.html` whose chunks are not all written yet, and
* reloading into that is the flicker loop preloadRecovery was written for;
* * the user must be idle for a moment, because a reload in the middle of a
- * sentence loses the sentence.
+ * sentence loses the sentence — and nothing may hold reloads off: a live
+ * voice call is owned by this document, and "no keystroke for two seconds"
+ * is exactly what a user who is talking looks like (see ./reloadHold).
*
* And two rules keep it from quietly dying, which is the failure that was
* actually reported (2026-08-23: the desktop window ran a morning-old build
@@ -73,6 +75,8 @@ export interface BundleWatchDeps {
reload: () => void;
/** Milliseconds since the last keystroke or pointer press, or null if none. */
idleFor: () => number | null;
+ /** Is something in this window (a live voice call) holding reloads off? */
+ held?: () => boolean;
/** Is this window on screen? A hidden window polls {@link HIDDEN_EVERY_N_TICKS}× slower. */
visible: () => boolean;
/** Schedule the repeating check. Returns a handle for {@link stop}. */
@@ -92,16 +96,21 @@ export function shouldReload({
seen,
confirmed,
idleMs,
+ held = false,
}: {
baseline: string;
seen: string;
confirmed: string | null;
idleMs: number | null;
+ held?: boolean;
}): boolean {
if (!baseline || !seen || seen === baseline) return false;
// A build in flight can serve a half-written index; the same fingerprint
// twice means the build finished and this is what it produced.
if (confirmed !== seen) return false;
+ // A reload would hang up a call this document owns; the next poll after the
+ // hold is released picks the build up.
+ if (held) return false;
// No input at all means nothing to interrupt.
return idleMs === null || idleMs >= IDLE_MS;
}
@@ -151,7 +160,13 @@ export function installBundleWatch(deps: BundleWatchDeps): () => void {
return;
}
if (
- shouldReload({ baseline, seen, confirmed, idleMs: deps.idleFor() })
+ shouldReload({
+ baseline,
+ seen,
+ confirmed,
+ idleMs: deps.idleFor(),
+ held: deps.held?.() ?? false,
+ })
) {
deps.reload();
return;
diff --git a/jarvis/ui/web/frontend/src/lib/reloadHold.ts b/jarvis/ui/web/frontend/src/lib/reloadHold.ts
new file mode 100644
index 0000000000..f16c8d275e
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/reloadHold.ts
@@ -0,0 +1,27 @@
+/**
+ * Things this window is doing that a reload would destroy.
+ *
+ * A live voice call is held by the page itself: the WebRTC media, the
+ * microphone and the control socket all belong to this document. Reloading it
+ * unmounts the call's owner, which sends `audio_stop` and hangs up mid-sentence.
+ * That is exactly what happened on 2026-10-02: a sibling session rebuilt the
+ * frontend during a 15-minute call, the bundle watch saw the user had not
+ * touched keyboard or mouse for two seconds — they were talking — and reloaded
+ * the window, which the backend recorded as a `client_stop` nobody pressed.
+ *
+ * Automatic reloads ask {@link reloadHeld} first and wait while anything is
+ * held. A reload the user asked for (a crash card's button) does not.
+ */
+
+const holds = new Set<string>();
+
+/** Hold (or release) automatic reloads on behalf of one owner. */
+export function setReloadHold(owner: string, held: boolean): void {
+ if (held) holds.add(owner);
+ else holds.delete(owner);
+}
+
+/** True while any owner holds automatic reloads off. */
+export function reloadHeld(): boolean {
+ return holds.size > 0;
+}
diff --git a/jarvis/ui/web/frontend/src/main.tsx b/jarvis/ui/web/frontend/src/main.tsx
index 02c72ad159..edeef79ef2 100644
--- a/jarvis/ui/web/frontend/src/main.tsx
+++ b/jarvis/ui/web/frontend/src/main.tsx
@@ -7,6 +7,7 @@ import { ViewErrorBoundary } from "./components/ViewErrorBoundary";
import { AuthGate } from "./components/AuthGate";
import { installPreloadRecovery } from "./lib/preloadRecovery";
import { POLL_MS, installBundleWatch } from "./lib/bundleWatch";
+import { reloadHeld } from "./lib/reloadHold";
import { browserSafeReloadDeps, reloadWhenServable } from "./lib/safeReload";
import { loadUiLocale, useI18nStore } from "./i18n";
import "./index.css";
@@ -58,6 +59,7 @@ installPreloadRecovery({
}).then((response) => (response.ok ? response.text() : "")),
reload: () => reloadWhenServable(browserSafeReloadDeps()),
idleFor: () => (lastInput === null ? null : Date.now() - lastInput),
+ held: reloadHeld,
visible: () => document.visibilityState !== "hidden",
every: (fn, ms) => window.setInterval(fn, ms),
stop: (handle) => window.clearInterval(handle),