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): a section that is loading says so instead of going black
rubenluetke10-beep4327738400c5
diff --git a/jarvis/ui/web/frontend/index.html b/jarvis/ui/web/frontend/index.htmlindex c9f699ac86..94c26c438e 100644--- a/jarvis/ui/web/frontend/index.html+++ b/jarvis/ui/web/frontend/index.html@@ -208,7 +208,7 @@title: "Die Oberfläche wurde nicht geladen.", // i18n-allowwhy: "Grund: ", // i18n-allowunknown: "Kein Grund gemeldet.", // i18n-allow- hint: "Das passiert, wenn die Oberfläche neu gebaut wird, während das Fenster offen ist.", // i18n-allow+ hint: "Das passiert, wenn ein Bereich beim Öffnen abstürzt oder die Oberfläche neu gebaut wird, während das Fenster offen ist.", // i18n-allowbutton: "Neu laden", // i18n-allow};}@@ -217,7 +217,7 @@title: "La interfaz no se cargó.", // i18n-allowwhy: "Motivo: ", // i18n-allowunknown: "No se informó ningún motivo.", // i18n-allow- hint: "Ocurre cuando la interfaz se reconstruye con la ventana abierta.", // i18n-allow+ hint: "Ocurre cuando una sección falla al abrirse o la interfaz se reconstruye con la ventana abierta.", // i18n-allowbutton: "Recargar", // i18n-allow};}@@ -225,7 +225,7 @@title: "The interface did not load.",why: "Reason: ",unknown: "No reason was reported.",- hint: "This happens when the interface is rebuilt while the window is open.",+ hint: "This happens when a section fails to open, or the interface is rebuilt while the window is open.",button: "Reload",};}@@ -273,10 +273,29 @@root.appendChild(box);}+ // The clock the grace period is measured against. It starts at page+ // load and is re-based every time the app goes from up to not-up, so a+ // section switch that empties #root twenty minutes in gets the same+ // 2.5 s of benefit of the doubt the first paint got — not an instant+ // verdict from a stopwatch that has been running since boot.+ var emptySince = started;+ var wasUp = false;+var timer = setInterval(function () {var now = state();if (now === "up") {- clearInterval(timer);+ // Healthy — but do NOT stop watching. This watchdog used to+ // clearInterval() here, which retired it permanently the moment the+ // app painted once. Everything it exists to catch can still happen+ // afterwards: a lazy section chunk whose import throws above every+ // error boundary empties #root minutes later, and with the timer+ // gone nothing noticed. The window simply stayed on the stage's+ // near-black ground with no card, no reason and no button — the+ // "it goes black when I switch sections" report. Watching costs one+ // childElementCount read every 500 ms; not watching costs the user+ // the whole window.+ wasUp = true;+ emptySince = null;// The page is healthy: give the next incident its own reload.try {sessionStorage.removeItem(KEY);@@ -285,8 +304,12 @@}return;}- var waited = Date.now() - started;- if (waited < (now === "empty" ? CRASH_GRACE_MS : LOAD_GRACE_MS)) return;+ if (emptySince === null) emptySince = Date.now();+ var waited = Date.now() - emptySince;+ // Once the app HAS painted, an empty #root is a crash rather than a+ // slow bundle, so the short clock applies to both states.+ var grace = now === "empty" || wasUp ? CRASH_GRACE_MS : LOAD_GRACE_MS;+ if (waited < grace) return;clearInterval(timer);var spent = null;try {diff --git a/jarvis/ui/web/frontend/src/components/layout/MainView.loading.test.tsx b/jarvis/ui/web/frontend/src/components/layout/MainView.loading.test.tsxnew file mode 100644index 0000000000..0010508b74--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/layout/MainView.loading.test.tsx@@ -0,0 +1,80 @@+/**+ * The loading state a section switch shows before its chunk arrives.+ *+ * Why this test exists (2026-08-22): the placeholder rendered nothing at all —+ * `<div className="h-full w-full" aria-busy="true" />` — on the reasoning that+ * the idle prefetch makes the wait invisible. When the backend's single asyncio+ * loop blocks (measured that week at 15.0 s to 17.9 s), the chunk stops+ * mid-flight and that empty div is all there is: the section stage's own+ * `rgb(10, 10, 10)` ground and no other mark on the screen. Users reported it+ * as the app going black when they switch sections.+ *+ * So the contract is a staircase, and each step is pinned here: silent while+ * the wait is too short to notice, visibly loading once it is not, and honest+ * about it once the wait stops being normal.+ */++import { act, render, screen } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";++import {+ LOADING_HINT_MS,+ LOADING_SLOW_MS,+ ViewLoadingFallback,+} from "@/components/layout/MainView";++describe("the section loading placeholder", () => {+ beforeEach(() => {+ vi.useFakeTimers();+ });+ afterEach(() => {+ vi.useRealTimers();+ });++ test("stays silent for a wait too short to notice", () => {+ render(<ViewLoadingFallback />);+ act(() => {+ vi.advanceTimersByTime(LOADING_HINT_MS - 50);+ });+ expect(+ screen.getByTestId("view-loading-fallback").getAttribute("data-phase"),+ ).toBe("quiet");+ });++ test("never leaves the stage unpainted, not even while silent", () => {+ // The whole defect was a transparent placeholder over a near-black stage.+ // Whatever else changes, this element paints the theme's own ground.+ render(<ViewLoadingFallback />);+ expect(screen.getByTestId("view-loading-fallback").className).toContain(+ "bg-background",+ );+ });++ test("says it is loading once the wait is long enough to see", () => {+ render(<ViewLoadingFallback />);+ act(() => {+ vi.advanceTimersByTime(LOADING_HINT_MS + 50);+ });+ const el = screen.getByTestId("view-loading-fallback");+ expect(el.getAttribute("data-phase")).toBe("loading");+ expect(el.textContent?.trim()).not.toBe("");+ });++ test("admits it is taking longer than usual instead of just sitting there", () => {+ render(<ViewLoadingFallback />);+ act(() => {+ vi.advanceTimersByTime(LOADING_SLOW_MS + 50);+ });+ const el = screen.getByTestId("view-loading-fallback");+ expect(el.getAttribute("data-phase")).toBe("slow");+ // Two lines by then: what is happening, and that it is running late.+ expect(el.querySelectorAll("p")).toHaveLength(2);+ });++ test("is announced to assistive technology as a busy region", () => {+ render(<ViewLoadingFallback />);+ const el = screen.getByTestId("view-loading-fallback");+ expect(el.getAttribute("aria-busy")).toBe("true");+ expect(el.getAttribute("role")).toBe("status");+ });+});diff --git a/jarvis/ui/web/frontend/src/components/layout/MainView.tsx b/jarvis/ui/web/frontend/src/components/layout/MainView.tsxindex e31e74e9fe..2fb876c821 100644--- a/jarvis/ui/web/frontend/src/components/layout/MainView.tsx+++ b/jarvis/ui/web/frontend/src/components/layout/MainView.tsx@@ -6,7 +6,9 @@ import {type ComponentType,type LazyExoticComponent,} from "react";+import { Loader2 } from "lucide-react";import { useEventStore } from "@/store/events";+import { useT } from "@/i18n";import { cn } from "@/lib/utils";import { ViewErrorBoundary } from "@/components/ViewErrorBoundary";import { DetachedViewPlaceholder } from "@/components/layout/DetachedViewPlaceholder";@@ -226,16 +228,67 @@ function useIdleViewPrefetch(): void {}, []);}+/** Quiet time before a loading section admits it is loading. */+export const LOADING_HINT_MS = 400;++/** After this, the wait stops being normal and the placeholder says so. */+export const LOADING_SLOW_MS = 8_000;+/*** Placeholder shown while a section chunk is in flight.*- * Deliberately empty: the idle prefetch means this is almost never seen, and a- * spinner that appears for 30 ms reads as a flicker — worse than nothing. It- * only holds the layout so the surrounding chrome does not jump. Being- * text-free, it also needs no translation.+ * It used to render nothing at all, on the reasoning that the idle prefetch+ * makes this almost invisible and a spinner shown for 30 ms reads as a+ * flicker. The first half of that holds; the second half assumed the wait is+ * always ~30 ms, and it is not. Every asset is served from the one asyncio+ * loop the whole backend shares, so any synchronous call on that loop stops+ * the chunk mid-flight — measured on the maintainer's box at 15.0 s, 15.1 s,+ * 15.2 s, 16.2 s and 17.9 s. For all of that time the only thing painted here+ * is the section stage's own ground, `rgb(10, 10, 10)`: an unannounced black+ * rectangle where the app used to be. That is what gets reported as "the app+ * goes black when I switch sections", and it is a missing loading state rather+ * than a crash.+ *+ * So the quiet is kept where it was earned and dropped where it was not:+ * nothing for {@link LOADING_HINT_MS}, so a warm chunk still swaps in without+ * a flash; a calm spinner once the wait is long enough to notice; and past+ * {@link LOADING_SLOW_MS} a line saying it is taking longer than usual, so a+ * stalled backend looks like a slow app instead of a dead one.*/-function ViewLoadingFallback() {- return <div className="h-full w-full" aria-busy="true" />;+export function ViewLoadingFallback() {+ const t = useT();+ const [phase, setPhase] = useState<"quiet" | "loading" | "slow">("quiet");++ useEffect(() => {+ const hint = window.setTimeout(() => setPhase("loading"), LOADING_HINT_MS);+ const slow = window.setTimeout(() => setPhase("slow"), LOADING_SLOW_MS);+ return () => {+ window.clearTimeout(hint);+ window.clearTimeout(slow);+ };+ }, []);++ return (+ <div+ className="flex h-full w-full flex-col items-center justify-center gap-3 bg-background"+ aria-busy="true"+ role="status"+ data-testid="view-loading-fallback"+ data-phase={phase}+ >+ {phase !== "quiet" && (+ <>+ <Loader2 className="h-5 w-5 animate-spin text-primary" />+ <p className="text-sm text-muted-foreground">{t("view_loading.loading")}</p>+ {phase === "slow" && (+ <p className="max-w-[46ch] text-center text-xs text-muted-foreground/80">+ {t("view_loading.slow")}+ </p>+ )}+ </>+ )}+ </div>+ );}/**diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 17d0054cd9..752546229f 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -2415,6 +2415,10 @@"group_hint": "Alle anderen Einstellungen auf dieser Seite funktionieren weiterhin.","group_retry": "Erneut versuchen"},+ "view_loading": {+ "loading": "Bereich wird geladen…",+ "slow": "Das dauert länger als sonst — die App arbeitet noch daran."+ },"plan_step_list": {"no_plan": "Kein strukturierter Plan — Single-Shot-Run.","show_output": "Output anzeigen"diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 9fca0d82f0..e0ad679f46 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -2415,6 +2415,10 @@"group_hint": "Every other setting on this page still works.","group_retry": "Try again"},+ "view_loading": {+ "loading": "Loading the section…",+ "slow": "This is taking longer than usual — the app is still working on it."+ },"plan_step_list": {"no_plan": "No structured plan — single-shot run.","show_output": "Show output"diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex d9c595b201..59d0d75e83 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -2415,6 +2415,10 @@"group_hint": "El resto de los ajustes de esta página siguen funcionando.","group_retry": "Intentar de nuevo"},+ "view_loading": {+ "loading": "Cargando la sección…",+ "slow": "Está tardando más de lo normal: la aplicación sigue trabajando."+ },"plan_step_list": {"no_plan": "Sin plan estructurado: ejecución de un solo paso.","show_output": "Mostrar salida"diff --git a/jarvis/ui/web/frontend/src/lib/bootWatchdog.test.ts b/jarvis/ui/web/frontend/src/lib/bootWatchdog.test.tsindex d46221a450..4eaaf7501f 100644--- a/jarvis/ui/web/frontend/src/lib/bootWatchdog.test.ts+++ b/jarvis/ui/web/frontend/src/lib/bootWatchdog.test.ts@@ -130,6 +130,53 @@ describe("the blank-window watchdog in index.html", () => {);});+ test("it keeps watching after the app is up, and catches a LATER crash", () => {+ // The section-switch failure, in order: the app paints, the user works for+ // a while, then a lazy chunk throws above every error boundary and empties+ // #root. The watchdog used to clearInterval() on the first healthy poll,+ // so from that moment nothing was watching and the window just went dark.+ setRoot(SPLASH);+ const run = runWatchdog();+ setRoot("<main>the deck</main>");+ vi.advanceTimersByTime(60_000);+ expect(run.reloads()).toBe(0);++ setRoot("");+ vi.advanceTimersByTime(3_000);+ expect(run.reloads()).toBe(1);+ });++ test("a healthy app that empties later still gets its full grace period", () => {+ // The grace must be measured from when the window went blank, not from+ // page load — otherwise a stopwatch running since boot condemns the very+ // first poll after a crash and reloads on a momentary gap.+ setRoot(SPLASH);+ const run = runWatchdog();+ setRoot("<main>the deck</main>");+ vi.advanceTimersByTime(60_000);++ setRoot("");+ vi.advanceTimersByTime(1_000);+ expect(run.reloads()).toBe(0);+ vi.advanceTimersByTime(2_000);+ expect(run.reloads()).toBe(1);+ });++ test("a later crash that has already spent its reload explains itself", () => {+ setRoot(SPLASH);+ const run = runWatchdog();+ setRoot("<main>the deck</main>");+ vi.advanceTimersByTime(1_000);+ run.store.set("jarvis:blank-reloaded", "1");++ setRoot("");+ vi.advanceTimersByTime(3_000);+ expect(run.reloads()).toBe(0);+ expect(document.getElementById("root")!.textContent).toContain(+ "The interface did not load.",+ );+ });+test("the reload button clears the guard, so the fresh page may heal itself", () => {setRoot("");const run = runWatchdog();