Skip to content

Self-improving AI Employees for everyone

fix(home): say why the orb did not start, and stop retrying a dead load

trohitga53735e8baac
diff --git a/client/src/features/home/orb/__tests__/orb.test.ts b/client/src/features/home/orb/__tests__/orb.test.ts
index af9f1f7e..ea6d9480 100644
--- a/client/src/features/home/orb/__tests__/orb.test.ts
+++ b/client/src/features/home/orb/__tests__/orb.test.ts
@@ -1,9 +1,9 @@
/**
* The orb's lifecycle (orb.ts): stages and slots are stacks, so a screen
* mounted over another borrows the orb and hands it back; the engine loads
- * once; a failed engine load shows the mark until the next stage tries
- * again; a lost WebGL context shows it until the browser hands the context
- * back; no WebGL and reduced motion hold for good.
+ * once; a lost WebGL context shows the mark until the browser hands the
+ * context back; an engine that did not start, no WebGL and reduced motion
+ * hold it for good.
*/
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@@ -116,7 +116,10 @@ describe('stages', () => {
});
describe('the static mark', () => {
- it('shows while the engine failed to load, and the next stage tries again', async () => {
+ it('holds when the engine did not start, and says why in the console', async () => {
+ // A browser keeps a failed module load for the page, so a later stage
+ // could never load it either.
+ const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {});
const { result } = renderHook(() => useOrbFallback());
createOrbEngine.mockImplementationOnce(() => {
throw new Error('the chunk did not load');
@@ -125,12 +128,14 @@ describe('the static mark', () => {
mountOrb(first);
await loaded();
expect(result.current).toBe(true);
+ expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('[Orb]'), expect.any(Error));
unmountOrb(first);
mountOrb(element());
await loaded();
- expect(createOrbEngine).toHaveBeenCalledTimes(2);
- expect(result.current).toBe(false);
+ expect(createOrbEngine).toHaveBeenCalledTimes(1);
+ expect(result.current).toBe(true);
+ consoleError.mockRestore();
});
it('holds without WebGL, and nothing tries again', async () => {
diff --git a/client/src/features/home/orb/orb.ts b/client/src/features/home/orb/orb.ts
index 5b84a67f..5e09c73a 100644
--- a/client/src/features/home/orb/orb.ts
+++ b/client/src/features/home/orb/orb.ts
@@ -13,9 +13,11 @@
* Slots show the static mark instead when the orb cannot run. No WebGL and
* reduced motion hold for the session. While the browser has taken the
* WebGL context away (after sleep, or a GPU switch), the mark shows until it
- * hands the context back, and the same engine carries on. An engine chunk
- * that failed to load shows the mark until the next stage mounts, which
- * tries again.
+ * hands the context back, and the same engine carries on. An engine that
+ * did not start (its chunk failed to load, or the renderer could not be
+ * created) holds the mark until the page reloads, and the console says why:
+ * a browser keeps a failed module load for the page's lifetime, so loading
+ * it again cannot succeed.
*/
import { useSyncExternalStore } from 'react';
@@ -77,10 +79,9 @@ interface OrbEngine {
dispose(): void;
}
-/** Why slots show the mark: the engine's chunk did not load (`missing`),
- * the orb cannot run here (`latched`), or the browser has the WebGL
- * context for now (`lost`). */
-type Fallback = 'none' | 'missing' | 'latched' | 'lost';
+/** Why slots show the mark: the orb cannot run on this page (`latched`), or
+ * the browser has the WebGL context for now (`lost`). */
+type Fallback = 'none' | 'latched' | 'lost';
let engine: OrbEngine | null = null;
let loading = false;
@@ -135,9 +136,10 @@ function show(): void {
setFallback('none');
show();
})
- .catch(() => {
+ .catch((error: unknown) => {
loading = false;
- setFallback('missing');
+ console.error('[Orb] The 3D orb did not start; showing the static mark until the page reloads:', error);
+ setFallback('latched');
});
}
diff --git a/docs-internal/normal_mode.md b/docs-internal/normal_mode.md
index eb7a6817..c800a0f8 100644
--- a/docs-internal/normal_mode.md
+++ b/docs-internal/normal_mode.md
@@ -204,8 +204,14 @@ browser takes the WebGL context away (after sleep, or when a laptop switches
GPU), the engine asks for it back (`preventDefault` on `webglcontextlost`) and
the slot shows the mark until `webglcontextrestored`; then the same engine
carries on, three.js having rebuilt the scene's GPU resources. When the
-engine's chunk fails to load the slot shows the mark until the next stage
-mounts and tries again (`orb/__tests__/orb.test.ts`).
+engine does not start (its chunk fails to load, or the renderer cannot be
+created) the slot shows the mark until the page reloads, since a browser
+keeps a failed module load for the page, and the console logs why (`[Orb]`;
+`orb/__tests__/orb.test.ts`). One such failure: a server answering the
+engine's URL with the app's HTML page ("Expected a JavaScript module script
+but the server responded with a MIME type of text/html"); the backend's SPA
+fallback now answers missing file paths with a 404 and sends its shell with
+`Cache-Control: no-cache` (`core/approot.is_spa_route`).
## The Workspace