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(ui): hold every automatic reload during a call or a streaming reply
rubenluetke10-beepafb8221fb062
diff --git a/jarvis/ui/web/frontend/src/lib/reloadHold.ts b/jarvis/ui/web/frontend/src/lib/reloadHold.tsindex f16c8d275e..5bfd2c158b 100644--- a/jarvis/ui/web/frontend/src/lib/reloadHold.ts+++ b/jarvis/ui/web/frontend/src/lib/reloadHold.ts@@ -9,8 +9,15 @@* 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.+ * A typed reply that is still streaming holds them too (main.tsx): a reload+ * mid-answer drops what was being written.+ *+ * Every automatic reload — the bundle watch and the preload recovery — asks+ * {@link reloadHeld}, both before it decides and again right before the+ * navigation (./safeReload), and waits while anything is held. The preload+ * recovery used to skip it, so opening a not-yet-loaded view during a call+ * after a rebuild still hung the call up. A reload the user asked for (a crash+ * card's button) does not wait.*/const holds = new Set<string>();diff --git a/jarvis/ui/web/frontend/src/lib/safeReload.test.ts b/jarvis/ui/web/frontend/src/lib/safeReload.test.tsindex 9e83710289..77a10c105f 100644--- a/jarvis/ui/web/frontend/src/lib/safeReload.test.ts+++ b/jarvis/ui/web/frontend/src/lib/safeReload.test.ts@@ -163,6 +163,31 @@ describe("reloadWhenServable", () => {expect(h.reloads()).toBe(1);});+ test("a held window waits with a whole build ready, then reloads", async () => {+ // A live call or a streaming reply owns the document; the reload must wait+ // until it is over instead of hanging it up.+ let held = true;+ const h = harness([INDEX], () => true);+ h.deps.held = () => {+ const now = held;+ held = false;+ return now;+ };+ reloadWhenServable(h.deps);+ await settle();+ expect(h.waits()).toBe(1);+ expect(h.reloads()).toBe(1);+ });++ test("a hold that never lifts never reloads", async () => {+ const h = harness([INDEX], () => true);+ h.deps.held = () => true;+ reloadWhenServable(h.deps);+ await settle();+ expect(h.reloads()).toBe(0);+ expect(h.waits()).toBeGreaterThan(1);+ });+test("a fetch that throws is a retry, never a reload", async () => {let reloads = 0;let waits = 0;diff --git a/jarvis/ui/web/frontend/src/lib/safeReload.ts b/jarvis/ui/web/frontend/src/lib/safeReload.tsindex a22abc57e1..53ebf7f0a9 100644--- a/jarvis/ui/web/frontend/src/lib/safeReload.ts+++ b/jarvis/ui/web/frontend/src/lib/safeReload.ts@@ -68,6 +68,13 @@ export interface SafeReloadDeps {reload: () => void;/** Schedule the next check. */defer: (fn: () => void, ms: number) => void;+ /**+ * Is something in this window holding automatic reloads off (a live call, a+ * reply still streaming)? Asked right before the navigation, because a+ * conversation can start while the build is being checked. Absent for a+ * reload the user asked for.+ */+ held?: () => boolean;}/**@@ -124,6 +131,12 @@ export function reloadWhenServable(deps: SafeReloadDeps): void {return;}}+ if (deps.held?.()) {+ // The build is ready but a conversation owns this document; reloading+ // now hangs it up. Ask again gently until it is over.+ deps.defer(check, SLOW_RETRY_MS);+ return;+ }deps.reload();}).catch(() => {@@ -136,9 +149,17 @@ export function reloadWhenServable(deps: SafeReloadDeps): void {check();}-/** The deps a real browser window uses. Kept here so every caller agrees. */-export function browserSafeReloadDeps(): SafeReloadDeps {+/**+ * The deps a real browser window uses. Kept here so every caller agrees.+ *+ * Automatic reloads pass `held` (see ./reloadHold); a reload the user pressed a+ * button for leaves it out and goes ahead.+ */+export function browserSafeReloadDeps(+ options: { held?: () => boolean } = {},+): SafeReloadDeps {return {+ held: options.held,fetchIndex: () =>fetch("/", { cache: "no-store", headers: { Accept: "text/html" } }).then((response) => (response.ok ? response.text() : ""))diff --git a/jarvis/ui/web/frontend/src/main.tsx b/jarvis/ui/web/frontend/src/main.tsxindex edeef79ef2..0e16b20754 100644--- a/jarvis/ui/web/frontend/src/main.tsx+++ b/jarvis/ui/web/frontend/src/main.tsx@@ -7,7 +7,8 @@ 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 { reloadHeld, setReloadHold } from "./lib/reloadHold";+import { useEventStore } from "./store/events";import { browserSafeReloadDeps, reloadWhenServable } from "./lib/safeReload";import { loadUiLocale, useI18nStore } from "./i18n";import "./index.css";@@ -24,8 +25,9 @@ installPreloadRecovery({// Never a bare location.reload(). The chunk went missing because a rebuild// is running, which is precisely when the entry document is also briefly// unservable — reloading into that leaves the window with no JavaScript and- // nothing left to recover with. See lib/safeReload.- reload: () => reloadWhenServable(browserSafeReloadDeps()),+ // nothing left to recover with. See lib/safeReload. It also waits out a live+ // call or a streaming reply, like every automatic reload (lib/reloadHold).+ reload: () => reloadWhenServable(browserSafeReloadDeps({ held: reloadHeld })),defer: (fn, ms) => {window.setTimeout(fn, ms);},@@ -37,6 +39,13 @@ installPreloadRecovery({// fresh window would load, and reload when the answer has changed — a rebuild// is then something the user watches happen instead of something they operate.// See lib/bundleWatch for the two guards that keep this quiet.+//+// A typed reply streams into this document the way a call does, so it holds+// reloads too. `chatThinking` always ends: the reply, an error, or the turn's+// timeout clears it (lib/chat).+useEventStore.subscribe((state) =>+ setReloadHold("typed-chat-reply", state.chatThinking),+);{let lastInput: number | null = null;const noteInput = () => {@@ -57,7 +66,7 @@ installPreloadRecovery({? AbortSignal.timeout(POLL_MS - 500): undefined,}).then((response) => (response.ok ? response.text() : "")),- reload: () => reloadWhenServable(browserSafeReloadDeps()),+ reload: () => reloadWhenServable(browserSafeReloadDeps({ held: reloadHeld })),idleFor: () => (lastInput === null ? null : Date.now() - lastInput),held: reloadHeld,visible: () => document.visibilityState !== "hidden",