From 57aa1794d37224122fffdc01af39285e83f5562d Mon Sep 17 00:00:00 2001 From: David McKay Date: Thu, 3 Dec 2026 19:45:49 -0800 Subject: [PATCH] A loading screen, and "OpenBot couldn't load" with Try again, never a blank page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Until the app's code and styles arrive, index.html drew nothing, so a slow or broken connection showed a plain white page with nothing to press. On 3 Dec that happened in a phone's Home Screen app on a conference's Wi-Fi for two minutes, while every request that reached OpenBot was answered. index.html now draws its own screen, as Gmail does: the theme's ground at once, "Loading…" after a second, and "OpenBot couldn't load. Check your connection." with Try again when the app's code or styles fail to download or the app hasn't started in ten seconds. It goes the moment the app draws. Plain CSS and a classic script, colours from the scheme's tokens, the layout of the app's error screen. app/tests/boot-screen.test.ts holds it in Chromium and WebKit, and holds the fallback colours to tokens/src/scheme.ts. --- .github/workflows/ci.yml | 1 + app/index.html | 223 +++++++++++++++ app/tests/boot-screen.fixture.tsx | 13 + app/tests/boot-screen.test.ts | 444 ++++++++++++++++++++++++++++++ 4 files changed, 681 insertions(+) create mode 100644 app/tests/boot-screen.fixture.tsx create mode 100644 app/tests/boot-screen.test.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 434e9d9fbb..6caa441dc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -705,6 +705,7 @@ jobs: app/tests/artifacts-kit.test.ts app/tests/artifacts-screens.test.tsx app/tests/board-row-layout.test.tsx + app/tests/boot-screen.test.ts app/tests/bot-file-links-browser.test.tsx app/tests/bot-long-instructions-layout.test.tsx app/tests/bot-owner-lists-layout.test.tsx diff --git a/app/index.html b/app/index.html index 6e707612c7..8dd7b5784b 100644 --- a/app/index.html +++ b/app/index.html @@ -55,9 +55,232 @@ } } catch {} + + +
+
+

Loading…

+
+

OpenBot couldn't load

+

Check your connection.

+ +
+
diff --git a/app/tests/boot-screen.fixture.tsx b/app/tests/boot-screen.fixture.tsx new file mode 100644 index 0000000000..c7c86aace6 --- /dev/null +++ b/app/tests/boot-screen.fixture.tsx @@ -0,0 +1,13 @@ +import { createRoot } from "react-dom/client"; + +/** + * The app as `boot-screen.test.ts` serves it: React drawing into `#root`, as `main.tsx` does, and + * nothing else. What the screen before the app reacts to is the first thing drawn there. + */ +const root = document.getElementById("root"); +if (root) + createRoot(root).render( +
+ OpenBot is up +
, + ); diff --git a/app/tests/boot-screen.test.ts b/app/tests/boot-screen.test.ts new file mode 100644 index 0000000000..05f2017dbc --- /dev/null +++ b/app/tests/boot-screen.test.ts @@ -0,0 +1,444 @@ +import { afterAll, beforeAll, describe, expect } from "bun:test"; +import { existsSync, mkdirSync, readFileSync } from "node:fs"; +import { dirname, join } from "node:path"; +import type { Browser, BrowserType, Page, Route } from "playwright-core"; +import { compile } from "tailwindcss"; +import { type Mode, scheme } from "../../tokens/src/scheme"; +import { test } from "./renderer-crash"; + +/** + * THE SCREEN BEFORE THE APP: NEVER A BLANK WHITE PAGE. + * + * FOUND ON OPENBOT CLOUD, 3 DEC 2026. On a conference's Wi-Fi, OpenBot in a phone's Home Screen app + * stayed plain white for two minutes, with nothing to press. Every request that reached OpenBot was + * answered: the app's code had not arrived, and until it does `index.html` drew nothing at all. Now + * the page draws its ground in the person's theme at once, "Loading…" after a second, and "OpenBot + * couldn't load" with Try again when the app's code or styles fail to download or the app hasn't + * started ten seconds in, as Gmail does. It goes the moment the app draws. + * + * The page is the app's real `index.html`, with its entry script and stylesheet where Vite's build + * puts them, a React app standing in for `main.tsx` (`boot-screen.fixture.tsx`) and the app's real + * stylesheet. The connection is the test's: a file that downloads, one that fails, one that never + * answers. In Chromium and in WebKit, the engine of Safari and of a phone's Home Screen app. + * + * OPENBOT_APP_BROWSER=1 bun test app/tests/boot-screen.test.ts + * + * Chromium by default; OPENBOT_APP_ENGINES=chromium,webkit adds WebKit, as CI runs it. With + * OPENBOT_APP_SHOTS= the screens are saved as boot----.png. + */ +const asked = process.env.OPENBOT_APP_BROWSER === "1"; +const shots = process.env.OPENBOT_APP_SHOTS; +const engines = (process.env.OPENBOT_APP_ENGINES ?? "chromium") + .split(",") + .map((engine) => engine.trim()) + .filter((engine) => engine === "chromium" || engine === "webkit") as ( + | "chromium" + | "webkit" +)[]; + +const APP = join(import.meta.dir, ".."); +const ORIGIN = "https://openbot.test"; +const HTML = readFileSync(join(APP, "index.html"), "utf8"); +const THEMES = ["light", "dark"] as const satisfies readonly Mode[]; +const WIDTHS = { + phone: { width: 390, height: 844 }, + desktop: { width: 1280, height: 800 }, +}; + +const FAILED = "OpenBot couldn't load"; + +/** The boot screen's stylesheet, as written in `index.html`. */ +function bootStyles(): string { + const style = /