Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(scene-studio): stop the editor hiding its own menu bar and tell a new scene what to do next

nirholasf464bfd64a91
diff --git a/docs/scene-studio.md b/docs/scene-studio.md
index a8ad7d6ce..39e2094b0 100644
--- a/docs/scene-studio.md
+++ b/docs/scene-studio.md
@@ -18,14 +18,23 @@ The editor is ported from the upstream `editor/index.html` with a small set of l
- **Scripting.** The editor bundles CodeMirror (with JavaScript and GLSL modes) and a Tern.js autocomplete engine seeded with three.js type definitions, so you can attach live scripts to objects and write shaders with completion.
- **Play and export.** The Player runs the scene (scripts included). The menubar exports the scene or selected objects to glTF/GLB, and the Draco encoder is bundled for compressed export.
+### The three.ws layer
+
+Four sibling modules sit on top of the vendored editor without touching `vendor/**`. They are the difference between a mirror of the upstream demo and a surface that belongs to this platform:
+
+- **A quick-action bar** (top right, clear of the sidebar): **Import from Forge** takes a GLB URL from a [Forge](./forge.md) or Forge Max result and adds it through the same undo-able path as a drag-and-drop import; **Export** writes a Web GLB or an AR bundle (`.usdz` for iOS Quick Look) in one click; **Share** uploads the scene and opens the platform's "Embed this model" panel with an iframe, web-component, and `<agent-3d>` snippet.
+- **An empty state.** A brand-new scene holds nothing but the default camera, which renders as a bare grid. The overlay on that grid says what a starting point looks like (drag a `.glb` in, pick a primitive from **Add**, or import a model you already generated) and retires itself the moment the scene has content, including a scene restored from autosave.
+- **Designed failures.** A dead link, a private URL, a blocked cross-origin fetch, or a failed upload each surface in the platform's toast with the likely cause named and a fallback to try, rather than in a native `alert()` box.
+- **Accessible transform buttons.** The vendored translate/rotate/scale controls are icon-only `<button>`s; the studio gives them names read from the editor's own string table and mirrors the active mode into `aria-pressed`, so the gizmo mode is both announced and reachable by keyboard.
+
### Handoff from Animation Studio
Scene Studio is the render target for animations built in [Animation Studio](./animation-studio.md). When you click "Open in Scene Studio" there, the studio bakes your keyframed animation into a GLB, stashes it in IndexedDB, and navigates to `/scene?handoff=1`. Scene Studio picks the model up on boot (`takeSceneHandoff`), drops it into the scene with its animation track ready, and you record it to video from the editor's render menu. The GLB is passed through browser storage, not the network, so nothing large is uploaded to move a model between the two tools.
## Walkthrough
-1. Open [/scene](https://three.ws/scene). The empty editor loads with an object hierarchy on one side and the property sidebar on the other.
-2. Drag a `.glb` into the viewport (or use Menubar ▸ import). It appears in the hierarchy.
+1. Open [/scene](https://three.ws/scene). The empty editor loads with an object hierarchy on one side and the property sidebar on the other, and a card over the empty grid offering the three ways to start.
+2. Drag a `.glb` into the viewport (or use Menubar ▸ import, or **Import from Forge** in the quick-action bar). It appears in the hierarchy, and the empty-state card retires.
3. Click it to select. Use the toolbar gizmos, or the keyboard, to move, rotate, and scale it. Fine-tune exact values in the sidebar.
4. Open the Material tab to change its color, metalness, roughness, or maps. Add a light from the Add menu and set its intensity and shadows.
5. Add more objects to compose the scene. Adjust the scene background, fog, and environment in the sidebar's Scene tab.
@@ -48,7 +57,8 @@ A typical round trip from another studio:
## States & limits
- **Dark theme only.** The vendored editor chrome ships a single dark skin; the studio locks the page to dark so the panels render correctly, regardless of your site theme preference.
-- **Desktop-class tool.** This is the full three.js editor with dense panels and gizmo interactions. It expects a pointer and a reasonably sized viewport; it is not tuned for small touch screens the way the other studios are.
+- **Desktop-class tool.** This is the full three.js editor with dense panels and gizmo interactions. It expects a pointer and a reasonably sized viewport; it is not tuned for small touch screens the way the other studios are. It does stay usable down to 320px: below 600px the sidebar docks along the bottom instead of the right, the menubar keeps its six items on one row, and the quick-action bar reclaims the right edge.
+- **Scenes live in this browser.** Autosave writes to IndexedDB on the machine you are using, so a scene does not follow you to another device or another browser. **Share** (which uploads a GLB) and **Export** are how a scene leaves the machine.
- **Vendored, MIT-licensed.** The editor is a vendored copy of three.js r184 under MIT. Attribution and the upstream license live in [src/scene-studio/vendor/](../src/scene-studio/vendor) (see the vendor `README`/`LICENSE`). Local changes are limited to the container mount, theme lock, and chrome overrides.
- **Handoff is browser-local.** The Animation Studio handoff moves the GLB through IndexedDB in the same browser. Opening `/scene?handoff=1` directly, with nothing stashed, just gives you an empty editor.
- **Export format.** Scenes export to glTF/GLB (Draco available). That is the same format Restyle Studio, Scene Composer, and the viewer all read, so a scene authored here flows back into the rest of the platform.
@@ -59,3 +69,4 @@ A typical round trip from another studio:
- [Animation Studio](./animation-studio.md): builds the animated GLBs Scene Studio records to video.
- [Restyle Studio](./restyle.md): re-skin the models before or after composing them.
- [3D asset pipeline](./3d-asset-pipeline.md): how GLB, glTF, and clip formats relate across the platform.
+- [src/scene-studio/README.md](../src/scene-studio/README.md): the module layout, the exported wrapper API, and how re-vendoring a three.js upgrade stays mechanical.
diff --git a/pages/scene.html b/pages/scene.html
index ed6e47844..1aac49299 100644
--- a/pages/scene.html
+++ b/pages/scene.html
@@ -78,6 +78,10 @@
</head>
<body class="scene-studio">
<div id="nav-container"></div>
+ <!-- The editor fills the window and has no visible heading of its own, so
+ the page's document title lives here for screen readers and for the
+ one-h1-per-page contract every other three.ws route keeps. -->
+ <h1 class="sr-only" data-i18n="scene.h1">Scene Studio</h1>
<div id="studio-app" role="application" aria-label="Scene Studio 3D editor"></div>
<script src="/nav.js" defer></script>
diff --git a/src/scene-studio/README.md b/src/scene-studio/README.md
index 100d30559..c4d239998 100644
--- a/src/scene-studio/README.md
+++ b/src/scene-studio/README.md
@@ -10,27 +10,33 @@ publishable app zip.
Building a scene editor from scratch is a solved problem: the three.js project
ships one. Instead of reinventing it, this directory vendors the upstream
`editor/` from three.js r184 (MIT, see [vendor/LICENSE](vendor/LICENSE)) and
-wraps it with three thin sibling modules that adapt it to three.ws. The wrappers
+wraps it with a handful of thin sibling modules that adapt it to three.ws. The wrappers
never modify `vendor/**`; every local change to upstream files is documented in
[vendor/README.md](vendor/README.md) so re-vendoring on a three upgrade stays
mechanical.
The wrappers are what make it a three.ws surface rather than a mirror of the
-upstream demo: models forged on `/forge` or `/parts` deep-link straight into the
-scene, animations baked on `/pose` hand off through IndexedDB, and any composed
-scene can be exported with one click or uploaded and embedded on another site.
+upstream demo: models forged on `/forge` or `/forge-max` deep-link straight into
+the scene, animations baked on `/pose` hand off through IndexedDB, and any
+composed scene can be exported with one click or uploaded and embedded on
+another site. They also close the gaps the upstream demo never had to care
+about: a first-run empty state, accessible names on the icon-only transform
+buttons, and failures that surface in the platform's own toast instead of a
+native `alert()`.
## Layout
```
src/scene-studio/
-├── main.js Boot: mounts the vendored editor into #studio-app, wires
-│ autosave, drag-and-drop import, and the deep-link importers
-├── loader.js Shared GLB loader: Draco/KTX2/Meshopt-wired GLTFLoader that
-│ adds a parsed GLB through the undo-able AddObjectCommand path
-├── actions.js Layered action bar: Import from Forge, Export presets, Share
-├── studio.css three.ws chrome overrides (vendor css/main.css is untouched)
-└── vendor/ three.js r184 editor source (see vendor/README.md)
+├── main.js Boot: mounts the vendored editor into #studio-app, wires
+│ autosave, drag-and-drop import, and the deep-link importers
+├── loader.js Shared GLB loader: Draco/KTX2/Meshopt-wired GLTFLoader that
+│ adds a parsed GLB through the undo-able AddObjectCommand path
+├── actions.js Layered action bar: Import from Forge, Export presets, Share
+├── empty-state.js First-run overlay over the empty grid, retires on first object
+├── toolbar-a11y.js Accessible names + pressed state for the transform gizmo buttons
+├── studio.css three.ws chrome overrides (vendor css/main.css is untouched)
+└── vendor/ three.js r184 editor source (see vendor/README.md)
```
Static runtime assets (Draco/Basis decoders, toolbar icons, CodeMirror and the
@@ -63,7 +69,7 @@ the browser console.
- `/scene?model=<glb_url>&name=<label>` adds the GLB at that URL to the scene
through the normal undo-able import path, then strips the query from the
address bar so a reload does not import a duplicate. This is the "Open in
- Scene Studio" hand-off used by Forge and Parts Studio results. Only `https://`
+ Scene Studio" hand-off used by Forge and Forge Max results. Only `https://`
and same-origin `/` URLs are accepted.
- `/scene?handoff=1` pulls a baked GLB (mesh plus embedded animation clip) that
the Animation Studio at `/pose` stashed in IndexedDB via
@@ -78,8 +84,11 @@ the browser console.
`actions.js` mounts a toolbar layered over the vendored chrome with three
affordances the stock File and Export menus do not offer on their own:
-- **Import from Forge**: paste a GLB URL from a Forge or Parts Studio result and
- drop it straight into the scene.
+- **Import from Forge**: paste a GLB URL from a Forge or Forge Max result into
+ the platform's own dialog (the shared `<dialog>` `Modal`, with inline
+ validation for a non-`https` link) and drop the model straight into the scene.
+ A fetch that fails is explained in a toast that names the likely cause and
+ points at drag-and-drop as the fallback.
- **Export presets**: one click for a Web GLB (binary, with cloned and optimized
animation clips, identical to File, Export, GLB) or an AR bundle (.usdz for
iOS Quick Look).
@@ -97,24 +106,33 @@ The wrappers export two functions; `main.js` is entry-only and exports nothing.
| --- | --- | --- |
| `loader.js` | `addGltfBufferToScene(editor, contents, label?)` | Parses a GLB `ArrayBuffer` with the Draco/KTX2/Meshopt-wired loader and adds it via `AddObjectCommand` (undo-able, autosave-triggering, outliner-visible). Resolves to the added `THREE.Object3D`. |
| `actions.js` | `mountStudioActions(editor, container)` | Mounts the Import from Forge / Export / Share bar into the studio container. Returns the bar element. |
+| `actions.js` | `openImportDialog(editor, triggerEl?)` | Opens the import dialog and, on a confirmed URL, fetches and adds the model. Shared with the empty state so both entry points behave identically. |
+| `actions.js` | `sceneTitle(editor)` | The scene's own name, or a stable fallback, for the Share embed panel's label. |
+| `actions.js` | `describeImportFailure(error)` | Turns an `HTTP 4xx` / `Failed to fetch` into copy that names the likely cause. |
+| `empty-state.js` | `mountEmptyState(editor, container)` | Mounts the first-run overlay and keeps it in sync with the scene graph. Returns the overlay element. |
+| `toolbar-a11y.js` | `enhanceToolbarA11y(editor, toolbarDom)` | Labels the vendored translate/rotate/scale buttons and mirrors their `selected` class into `aria-pressed`. Returns the labelled buttons. |
## Example
This is how `actions.js` imports a Forge result into the scene, using the shared
-loader (trimmed from `importFromForge` in [actions.js](actions.js)):
+loader (trimmed from `openImportDialog` in [actions.js](actions.js)):
```js
import { addGltfBufferToScene } from './loader.js';
+import { describeImportFailure } from './actions.js';
+import { toastError } from '../shared/toast.js';
// `editor` is the vendored Editor instance (window.editor on /scene).
-const url = window.prompt('Paste the GLB URL from a Forge result.');
-const trimmed = url.trim();
-const res = await fetch(trimmed);
-if (!res.ok) throw new Error('HTTP ' + res.status);
-const contents = await res.arrayBuffer();
-const base = decodeURIComponent(trimmed.split('?')[0].split('/').pop() || '');
+// `url` is an https GLB link the user confirmed in the import dialog.
+const base = decodeURIComponent(url.split('?')[0].split('/').pop() || '');
const label = (base.replace(/\.(glb|gltf)$/i, '') || 'Forge model').slice(0, 64);
-await addGltfBufferToScene(editor, contents, label);
+try {
+ const res = await fetch(url);
+ if (!res.ok) throw new Error('HTTP ' + res.status);
+ await addGltfBufferToScene(editor, await res.arrayBuffer(), label);
+} catch (error) {
+ toastError(`Could not import that model: ${describeImportFailure(error)}.`);
+}
```
Both callers of the loader (the `?model=` deep link in `main.js` and the action
@@ -124,7 +142,9 @@ behaves identically to a manual drag-and-drop import.
## Related surfaces
- [STRUCTURE.md](../../STRUCTURE.md) row: Scene Studio (3D scene editor).
-- `/forge` and `/parts` produce the GLBs that deep-link here; `/pose` hands off
- baked animations; the Share flow reuses the Forge embed panel.
+- `/forge` and `/forge-max` produce the GLBs that deep-link here; `/pose` hands
+ off baked animations; the Share flow reuses the Forge embed panel.
+- Unit tests for the exported pure logic live in
+ [tests/scene-studio-actions.test.js](../../tests/scene-studio-actions.test.js).
- The page entry in [data/pages.json](../../data/pages.json) (`path: "/scene"`)
feeds the sitemap, `llms.txt`, and the changelog.
diff --git a/src/scene-studio/actions.js b/src/scene-studio/actions.js
index 037c24916..4f250cd3c 100644
--- a/src/scene-studio/actions.js
+++ b/src/scene-studio/actions.js
@@ -4,7 +4,7 @@
// edits vendor files, only reads `editor` and mounts its own DOM/CSS. Adds
// three affordances the vendored File/Export menus don't offer on their own:
//
-// • Import from Forge — paste the GLB URL from a Forge (or Parts Studio)
+// • Import from Forge: paste the GLB URL from a Forge (or Forge Max)
// result and drop it straight into the scene, using the same undo-able
// AddObjectCommand path the ?model= deep-link importer uses.
// • Export presets — one click for "Web GLB" or "AR bundle (USDZ)",
@@ -12,9 +12,17 @@
// • Share / Embed — uploads the current scene as a GLB and opens the
// platform's existing "Embed this model" panel (iframe / web component /
// <agent-3d> snippet) — the same modal Forge results use.
+//
+// Failures surface through the shared toast (src/shared/toast.js) and the
+// import prompt through the shared <dialog> Modal (src/shared/modal.js), so a
+// bad URL or a dead upload reads like the rest of the platform instead of a
+// native alert()/prompt() box that ignores the studio's theme and traps focus
+// outside the editor.
import { addGltfBufferToScene } from './loader.js';
import { showEmbedPanel } from '../forge-embed-panel.js';
+import { Modal } from '../shared/modal.js';
+import { toast, toastError, toastSuccess } from '../shared/toast.js';
const STYLE_ID = 'tws-studio-actions-styles';
@@ -48,6 +56,21 @@ function downloadBlob(blob, filename) {
setTimeout(() => URL.revokeObjectURL(url), 1500);
}
+/** Human-readable cause for a failed fetch/parse, for the toast copy. */
+export function describeImportFailure(error) {
+ const raw = String(error?.message || error || '').trim();
+ // A thrown plain object stringifies to "[object Object]", which is worse
+ // than saying nothing; fetch/parse rejections are not always Errors.
+ const message = !raw || raw.startsWith('[object ') ? 'Unknown error' : raw;
+ if (/^HTTP 40[13]$/.test(message)) return 'that link is private or expired';
+ if (/^HTTP 404$/.test(message)) return 'nothing is hosted at that link';
+ if (/^HTTP 5\d\d$/.test(message)) return 'the host that stores it is down';
+ if (/failed to fetch|networkerror|load failed/i.test(message)) {
+ return 'the host blocked the request (no CORS header) or is unreachable';
+ }
+ return message;
+}
+
// Same GLB export shape as the vendored File ▸ Export ▸ GLB menu item —
// binary, with cloned+optimized animation clips.
async function exportSceneGlb(editor) {
@@ -69,25 +92,118 @@ async function exportSceneUsdz(editor) {
return exporter.parseAsync(editor.scene);
}
-async function importFromForge(editor) {
- const url = window.prompt(
- 'Paste the GLB URL from a Forge result (its "Copy share link" or Download link).',
- );
+/**
+ * The scene's own name when the user set one in the sidebar, else a stable
+ * fallback. Deliberately NOT derived from document.title: the page title is
+ * "Scene Studio · Assemble 3D worlds · three.ws" for every scene, so using it
+ * labelled every shared embed with the studio's marketing string.
+ */
+export function sceneTitle(editor) {
+ const name = String(editor.scene?.name || '').trim();
+ return name && name.toLowerCase() !== 'scene' ? name : 'Scene composed on three.ws';
+}
+
+/** Ask for a GLB URL in the platform's own dialog. Resolves null on cancel. */
+function askForModelUrl(triggerBtn) {
+ return new Promise((resolve) => {
+ let settled = false;
+ const done = (value) => {
+ if (settled) return;
+ settled = true;
+ resolve(value);
+ };
+
+ const modal = new Modal({
+ title: 'Import a model',
+ body: `
+ <label class="tws-sa-field" for="tws-sa-url">
+ <span>GLB or glTF URL</span>
+ <input id="tws-sa-url" class="tws-sa-input" type="url" inputmode="url"
+ placeholder="https://…/model.glb" autocomplete="off" spellcheck="false" />
+ </label>
+ <p class="tws-sa-hint">
+ Paste the link from a <a href="/forge">Forge</a> or
+ <a href="/forge-max">Forge Max</a> result (its Download or
+ &ldquo;Copy share link&rdquo; button). The model is added to the
+ current scene, and Edit&nbsp;▸&nbsp;Undo removes it again.
+ </p>
+ <p class="tws-sa-error" role="alert" hidden></p>
+ `,
+ actions: `
+ <button type="button" class="tws-sa-dlg-btn" data-dlg="cancel">Cancel</button>
+ <button type="button" class="tws-sa-dlg-btn tws-sa-dlg-primary" data-dlg="import">Import</button>
+ `,
+ onClose: () => done(null),
+ }).open(triggerBtn);
+
+ const input = modal.bodyEl.querySelector('#tws-sa-url');
+ const errorEl = modal.bodyEl.querySelector('.tws-sa-error');
+ input.focus();
+
+ const fail = (message) => {
+ errorEl.textContent = message;
+ errorEl.hidden = false;
+ input.setAttribute('aria-invalid', 'true');
+ input.focus();
+ };
+
+ const submit = () => {
+ const trimmed = input.value.trim();
+ if (!trimmed) return fail('Paste a link first.');
+ if (!/^https:\/\//i.test(trimmed)) {
+ return fail('That is not an https link. Copy the GLB link from the result bar and try again.');
+ }
+ done(trimmed);
+ modal.close();
+ };
+
+ input.addEventListener('input', () => {
+ errorEl.hidden = true;
+ input.removeAttribute('aria-invalid');
+ });
+ input.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ submit();
+ }
+ });
+ modal.actionsEl.addEventListener('click', (e) => {
+ const btn = e.target.closest('[data-dlg]');
+ if (!btn) return;
+ if (btn.dataset.dlg === 'import') submit();
+ else modal.close();
+ });
+ });
+}
+
+/**
+ * Open the import dialog and, on a confirmed URL, fetch + add the model.
+ * Exported so the empty-state overlay can offer the same flow without
+ * duplicating the fetch/label/error handling.
+ * @param {import('./vendor/js/Editor.js').Editor} editor
+ * @param {HTMLElement} [triggerBtn] focus returns here when the dialog closes.
+ */
+export async function openImportDialog(editor, triggerBtn) {
+ const url = await askForModelUrl(triggerBtn);
if (!url) return;
- const trimmed = url.trim();
- if (!/^https:\/\//i.test(trimmed)) {
- alert('That doesn\'t look like an https URL. Copy the GLB link from Forge\'s result bar and try again.');
- return;
- }
+
+ const base = decodeURIComponent(url.split('?')[0].split('/').pop() || '');
+ const label = (base.replace(/\.(glb|gltf)$/i, '') || 'Forge model').slice(0, 64);
+ const settle = toast(`Importing ${label}…`, { duration: 60000 });
try {
- const res = await fetch(trimmed);
+ const res = await fetch(url);
if (!res.ok) throw new Error('HTTP ' + res.status);
const contents = await res.arrayBuffer();
- const base = decodeURIComponent(trimmed.split('?')[0].split('/').pop() || '');
- const label = (base.replace(/\.(glb|gltf)$/i, '') || 'Forge model').slice(0, 64);
await addGltfBufferToScene(editor, contents, label);
+ settle();
+ toastSuccess(`${label} added to the scene.`);
} catch (error) {
- alert('Could not import that model (' + error.message + '). You can drag the GLB file into the editor instead.');
+ settle();
+ toastError(
+ `Could not import that model: ${describeImportFailure(error)}. ` +
+ 'Download the GLB and drag the file into the editor instead.',
+ { duration: 7000 },
+ );
}
}
@@ -107,34 +223,55 @@ function showExportMenu(editor, anchorBtn) {
document.body.appendChild(menu);
const rect = anchorBtn.getBoundingClientRect();
menu.style.left = `${Math.max(8, rect.right - menu.offsetWidth)}px`;
- menu.style.top = `${rect.top - menu.offsetHeight - 8}px`;
+ menu.style.top = `${rect.bottom + 8}px`;
+ anchorBtn.setAttribute('aria-expanded', 'true');
+
+ const dismiss = () => {
+ closeMenu(menu);
+ anchorBtn.setAttribute('aria-expanded', 'false');
+ document.removeEventListener('click', onDocClick, true);
+ document.removeEventListener('keydown', onKeydown, true);
+ };
const onDocClick = (e) => {
- if (!menu.contains(e.target) && e.target !== anchorBtn) {
- closeMenu(menu);
- document.removeEventListener('click', onDocClick, true);
+ if (!menu.contains(e.target) && e.target !== anchorBtn) dismiss();
+ };
+ const onKeydown = (e) => {
+ if (e.key === 'Escape') {
+ dismiss();
+ anchorBtn.focus();
}
};
- setTimeout(() => document.addEventListener('click', onDocClick, true), 0);
+ setTimeout(() => {
+ document.addEventListener('click', onDocClick, true);
+ document.addEventListener('keydown', onKeydown, true);
+ }, 0);
+ menu.querySelector('button')?.focus();
menu.addEventListener('click', async (e) => {
const btn = e.target.closest('[data-preset]');
if (!btn) return;
- closeMenu(menu);
- document.removeEventListener('click', onDocClick, true);
+ const isGlb = btn.dataset.preset === 'glb';
+ dismiss();
+ const settle = toast(`Exporting ${isGlb ? 'GLB' : 'USDZ'}…`, { duration: 60000 });
try {
- if (btn.dataset.preset === 'glb') {
- saveArrayBuffer(await exportSceneGlb(editor), 'scene.glb');
- } else {
- saveArrayBuffer(await exportSceneUsdz(editor), 'scene.usdz');
- }
+ if (isGlb) saveArrayBuffer(await exportSceneGlb(editor), 'scene.glb');
+ else saveArrayBuffer(await exportSceneUsdz(editor), 'scene.usdz');
+ settle();
+ toastSuccess(isGlb ? 'scene.glb downloaded.' : 'scene.usdz downloaded.');
} catch (error) {
- alert('Export failed: ' + (error?.message || error));
+ settle();
+ toastError(`Export failed: ${error?.message || error}`, { duration: 7000 });
}
});
}
async function shareScene(editor, triggerBtn) {
+ if (editor.scene.children.length === 0) {
+ toast('Add something to the scene first: use Add ▸, Import from Forge, or drag a GLB in.');
+ return;
+ }
+
const original = triggerBtn.textContent;
triggerBtn.disabled = true;
triggerBtn.textContent = 'Exporting…';
@@ -160,16 +297,50 @@ async function shareScene(editor, triggerBtn) {
});
if (!putRes.ok) throw new Error(`Upload failed (HTTP ${putRes.status})`);
- const title = document.title.replace(/\s*·\s*Scene Studio.*$/i, '').trim() || 'Scene composed on three.ws';
- showEmbedPanel({ glbUrl: presign.public_url, title }, triggerBtn);
+ showEmbedPanel({ glbUrl: presign.public_url, title: sceneTitle(editor) }, triggerBtn);
} catch (error) {
- alert('Could not share this scene: ' + (error?.message || error));
+ toastError(
+ `Could not share this scene: ${error?.message || error}. ` +
+ 'Export ▸ Web GLB still saves it to your machine.',
+ { duration: 7000 },
+ );
} finally {
triggerBtn.disabled = false;
triggerBtn.textContent = original;
}
}
+/**
+ * Keep the bar clear of the sidebar. The vendored sidebar is 350px wide above
+ * 600px AND user-resizable (Resizer.js writes `#sidebar.style.width` on drag),
+ * so a static `right: 12px` parked all three buttons on top of the
+ * SCENE / PROJECT / SETTINGS tab row at every desktop width. Mirroring the live
+ * width into a custom property keeps the bar docked beside the sidebar through
+ * a resize drag as well as a window resize.
+ *
+ * The property is written on the studio container, not on the bar, so the
+ * empty-state overlay (empty-state.js) inherits the same measurement and stays
+ * centred on the viewport rather than on the window.
+ */
+function trackSidebarWidth(container) {
+ const sidebar = document.getElementById('sidebar');
+ if (!sidebar) return () => {};
+ const apply = () => {
+ container.style.setProperty(
+ '--tws-sa-sidebar-w',
+ `${Math.round(sidebar.getBoundingClientRect().width)}px`,
+ );
+ };
+ apply();
+ if (typeof ResizeObserver === 'undefined') {
+ window.addEventListener('resize', apply);
+ return () => window.removeEventListener('resize', apply);
+ }
+ const observer = new ResizeObserver(apply);
+ observer.observe(sidebar);
+ return () => observer.disconnect();
+}
+
/**
* Mount the action bar into the Scene Studio container.
* @param {import('./vendor/js/Editor.js').Editor} editor
@@ -183,15 +354,16 @@ export function mountStudioActions(editor, container) {
bar.setAttribute('aria-label', 'Scene Studio quick actions');
bar.innerHTML = `
<button type="button" class="tws-sa-btn" data-action="import" aria-label="Import a model from Forge">⤵ Import from Forge</button>
- <button type="button" class="tws-sa-btn" data-action="export" aria-label="Export presets">⇩ Export</button>
+ <button type="button" class="tws-sa-btn" data-action="export" aria-label="Export presets" aria-haspopup="menu" aria-expanded="false">⇩ Export</button>
<button type="button" class="tws-sa-btn tws-sa-primary" data-action="share" aria-label="Share or embed this scene">🔗 Share</button>
`;
container.appendChild(bar);
+ trackSidebarWidth(container);
bar.addEventListener('click', (e) => {
const btn = e.target.closest('.tws-sa-btn');
if (!btn) return;
- if (btn.dataset.action === 'import') importFromForge(editor);
+ if (btn.dataset.action === 'import') openImportDialog(editor, btn);
else if (btn.dataset.action === 'export') showExportMenu(editor, btn);
else if (btn.dataset.action === 'share') shareScene(editor, btn);
});
@@ -204,8 +376,11 @@ const CSS = `
/* Clears the vendored #menubar row (fixed 36px tall — see
src/scene-studio/vendor/css/main.css, also the reference #player/#viewport
use for their own top offset) at every breakpoint we support (320/768/1440),
- so this bar never sits on top of File/Edit/Add/View/Render/Help. */
- position: absolute; top: 44px; right: 12px; z-index: 10;
+ so this bar never sits on top of File/Edit/Add/View/Render/Help.
+ Horizontally it clears the sidebar too: --tws-sa-sidebar-w is written by
+ trackSidebarWidth() above and follows the resizer drag. */
+ position: absolute; top: 44px; right: calc(var(--tws-sa-sidebar-w, 350px) + 12px);
+ z-index: 10;
display: flex; gap: 6px;
font: 600 12px/1 system-ui, -apple-system, sans-serif;
}
@@ -237,12 +412,52 @@ const CSS = `
}
.tws-sa-menu button:hover, .tws-sa-menu button:focus-visible { background: rgba(255,255,255,0.08); outline: none; }
.tws-sa-menu button span { display: block; margin-top: 2px; font-weight: 400; font-size: 11px; color: #9a9aa8; }
-@media (prefers-reduced-motion: reduce) { .tws-sa-btn { transition: none; } }
-/* Narrow viewports: stay pinned top-right (never bottom — that corner is
- reserved for the site-wide "Getting started" launcher pill on every page,
- see public/getting-started.js) and shrink to fit under the vendor menubar. */
-@media (max-width: 640px) {
- .tws-sa-bar { flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 16px); }
+
+/* Import dialog (mounted inside the shared <dialog> Modal). */
+.tws-sa-field { display: block; }
+.tws-sa-field > span {
+ display: block; margin-bottom: 6px;
+ font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
+ color: var(--ink, #f2f3f7);
+}
+.tws-sa-input {
+ width: 100%; box-sizing: border-box;
+ border: 1px solid rgba(255,255,255,0.18); border-radius: 8px;
+ padding: 9px 11px; background: rgba(10,10,14,0.8); color: var(--ink, #f2f3f7);
+ font: 400 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
+}
+.tws-sa-input:focus-visible { outline: 2px solid #6ee7b7; outline-offset: 1px; }
+.tws-sa-input[aria-invalid='true'] { border-color: rgba(255,122,138,0.7); }
+.tws-sa-hint { margin: 10px 0 0; font-size: 12.5px; line-height: 1.5; }
+.tws-sa-hint a { color: #6ee7b7; }
+.tws-sa-error {
+ margin: 10px 0 0; font-size: 12.5px; line-height: 1.5; color: #ff7a8a;
+}
+.tws-sa-error[hidden] { display: none; }
+.tws-sa-dlg-btn {
+ appearance: none; cursor: pointer;
+ border: 1px solid rgba(255,255,255,0.18); border-radius: 8px;
+ padding: 8px 14px; background: transparent; color: var(--ink, #f2f3f7);
+ font: 600 13px/1 system-ui, sans-serif;
+ transition: background 0.14s, border-color 0.14s;
+}
+.tws-sa-dlg-btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.32); }
+.tws-sa-dlg-btn:focus-visible { outline: 2px solid #6ee7b7; outline-offset: 2px; }
+.tws-sa-dlg-primary { background: #e8e8ec; color: #0a0a0f; border-color: transparent; }
+.tws-sa-dlg-primary:hover { background: #ffffff; }
+
+@media (prefers-reduced-motion: reduce) { .tws-sa-btn, .tws-sa-dlg-btn { transition: none; } }
+/* Narrow viewports: the vendored sidebar stops being a right-hand column and
+ docks full-width along the bottom (vendor/css/main.css, max-width 600px), so
+ the bar reclaims the right edge. It stays pinned top-right (never bottom:
+ that corner is reserved for the site-wide "Getting started" launcher pill on
+ every page, see public/getting-started.js) and shrinks to fit under the
+ vendor menubar. */
+@media (max-width: 600px) {
+ .tws-sa-bar {
+ right: 12px;
+ flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 16px);
+ }
.tws-sa-btn { font-size: 11px; padding: 6px 8px; }
}
`;
diff --git a/src/scene-studio/empty-state.js b/src/scene-studio/empty-state.js
new file mode 100644
index 000000000..34a904e88
--- /dev/null
+++ b/src/scene-studio/empty-state.js
@@ -0,0 +1,143 @@
+// Scene Studio: first-run empty state.
+//
+// The vendored editor opens on a scene holding nothing but the default camera,
+// which renders as a bare grid: technically correct, and completely silent
+// about what to do next. Someone arriving from /scene has no way to learn that
+// the Add menu, a dragged GLB, and a Forge link are all valid starting points.
+//
+// This overlay says so, and retires itself the moment the scene has content
+// (including a scene restored from the editor's IndexedDB autosave, which lands
+// after this module mounts). It is a sibling module: it reads `editor` and
+// mounts its own DOM, never touching vendor/**.
+
+import { openImportDialog } from './actions.js';
+
+const STYLE_ID = 'tws-studio-empty-styles';
+
+function ensureStyles() {
+ if (document.getElementById(STYLE_ID)) return;
+ const el = document.createElement('style');
+ el.id = STYLE_ID;
+ el.textContent = CSS;
+ document.head.appendChild(el);
+}
+
+/**
+ * Mount the empty-state overlay into the Scene Studio container.
+ * @param {import('./vendor/js/Editor.js').Editor} editor
+ * @param {HTMLElement} container
+ * @returns {HTMLElement} the overlay element.
+ */
+export function mountEmptyState(editor, container) {
+ ensureStyles();
+
+ const el = document.createElement('div');
+ el.className = 'tws-se';
+ el.hidden = true;
+ el.innerHTML = `
+ <div class="tws-se-card">
+ <p class="tws-se-eyebrow">Empty scene</p>
+ <h2 class="tws-se-title">Start with a model</h2>
+ <p class="tws-se-copy">
+ Drag a <strong>.glb</strong> or <strong>.gltf</strong> file anywhere onto this
+ page, pick a primitive from the <strong>Add</strong> menu above, or pull in a
+ model you already generated.
+ </p>
+ <div class="tws-se-actions">
+ <button type="button" class="tws-se-btn tws-se-primary" data-se="import">Import a model by URL</button>
+ <a class="tws-se-btn" href="/forge">Generate one in Forge</a>
+ </div>
+ <p class="tws-se-foot">
+ Everything you build here autosaves to this browser, and
+ <strong>Export</strong> writes a GLB or a USDZ you can take anywhere.
+ </p>
+ </div>
+ `;
+ container.appendChild(el);
+
+ el.querySelector('[data-se="import"]').addEventListener('click', (e) => {
+ openImportDialog(editor, e.currentTarget);
+ });
+
+ const sync = () => {
+ el.hidden = editor.scene.children.length > 0;
+ };
+
+ editor.signals.sceneGraphChanged.add(sync);
+ editor.signals.editorCleared.add(sync);
+ sync();
+
+ return el;
+}
+
+const CSS = `
+.tws-se {
+ /* Sits over the viewport only: the vendored #viewport is inset by the 36px
+ menubar and the sidebar column, and this mirrors that box so the card
+ centres on the 3D view rather than on the whole window. Pointer events
+ pass through everywhere except the card, so orbiting an empty grid still
+ works while the hint is up. */
+ position: absolute;
+ top: 36px; left: 0; bottom: 0;
+ right: var(--tws-sa-sidebar-w, 350px);
+ z-index: 5;
+ display: flex; align-items: center; justify-content: center;
+ padding: 16px;
+ pointer-events: none;
+}
+.tws-se[hidden] { display: none; }
+.tws-se-card {
+ pointer-events: auto;
+ max-width: 420px; width: 100%;
+ box-sizing: border-box;
+ padding: 22px 24px;
+ border: 1px solid rgba(255,255,255,0.12);
+ border-radius: 14px;
+ background: rgba(14,15,21,0.86);
+ backdrop-filter: blur(14px);
+ -webkit-backdrop-filter: blur(14px);
+ box-shadow: 0 18px 48px rgba(0,0,0,0.5);
+ color: #e8e8ec;
+ font-family: system-ui, -apple-system, sans-serif;
+ animation: tws-se-in 0.28s ease both;
+}
+@keyframes tws-se-in {
+ from { opacity: 0; transform: translateY(8px); }
+ to { opacity: 1; transform: none; }
+}
+.tws-se-eyebrow {
+ margin: 0 0 6px; font-size: 11px; font-weight: 700;
+ letter-spacing: 0.09em; text-transform: uppercase; color: #6ee7b7;
+}
+.tws-se-title { margin: 0 0 8px; font-size: 19px; font-weight: 650; color: #fff; }
+.tws-se-copy, .tws-se-foot {
+ margin: 0; font-size: 13px; line-height: 1.55; color: #a8a9b8;
+}
+.tws-se-copy strong, .tws-se-foot strong { color: #d5d6e0; font-weight: 600; }
+.tws-se-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 14px; }
+.tws-se-btn {
+ appearance: none; cursor: pointer; text-decoration: none;
+ display: inline-flex; align-items: center;
+ border: 1px solid rgba(255,255,255,0.18); border-radius: 9px;
+ padding: 9px 13px; background: transparent; color: #e8e8ec;
+ font: 600 12.5px/1 system-ui, sans-serif;
+ transition: background 0.14s, border-color 0.14s, transform 0.08s;
+}
+.tws-se-btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.34); }
+.tws-se-btn:active { transform: translateY(1px); }
+.tws-se-btn:focus-visible { outline: 2px solid #6ee7b7; outline-offset: 2px; }
+.tws-se-primary { background: #e8e8ec; color: #0a0a0f; border-color: transparent; }
+.tws-se-primary:hover { background: #fff; }
+.tws-se-foot { font-size: 12px; }
+@media (prefers-reduced-motion: reduce) {
+ .tws-se-card { animation: none; }
+ .tws-se-btn { transition: none; }
+}
+/* Below 600px the vendored sidebar docks along the bottom instead of the right
+ (vendor/css/main.css), so the overlay spans the full width and stops above it. */
+@media (max-width: 600px) {
+ .tws-se { right: 0; bottom: 320px; }
+ .tws-se-card { padding: 18px; }
+ .tws-se-title { font-size: 17px; }
+}
+`;
diff --git a/src/scene-studio/main.js b/src/scene-studio/main.js
index 00d9f99b4..28b873640 100644
--- a/src/scene-studio/main.js
+++ b/src/scene-studio/main.js
@@ -29,6 +29,9 @@ import { TextGeometry } from 'three/addons/geometries/TextGeometry.js';
import { addGltfBufferToScene as sharedAddGltfBufferToScene } from './loader.js';
import { mountStudioActions } from './actions.js';
+import { mountEmptyState } from './empty-state.js';
+import { enhanceToolbarA11y } from './toolbar-a11y.js';
+import { toastError } from '../shared/toast.js';
window.URL = window.URL || window.webkitURL;
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
@@ -73,6 +76,14 @@ container.appendChild(animationResizer.dom);
// sibling to the vendored chrome, never touching vendor/**. See actions.js.
mountStudioActions(editor, container);
+// The vendored transform buttons ship as icon-only <button>s with no
+// accessible name; label them and announce their pressed state.
+enhanceToolbarA11y(editor, toolbar.dom);
+
+// First-run guidance over the empty grid. Retires itself as soon as the scene
+// holds anything, including a scene restored from the autosave below.
+mountEmptyState(editor, container);
+
editor.signals.animationPanelChanged.add(function (height) {
const visible = height !== false;
@@ -180,7 +191,11 @@ async function importModelFromQuery() {
.replace(/\s+/g, ' ').trim().slice(0, 64) || 'Model';
await addGltfBufferToScene(contents, label);
} catch (error) {
- alert('Could not load the handed-off model (' + error.message + '). You can drag the GLB file into the editor instead.');
+ toastError(
+ `Could not load the handed-off model: ${error.message}. ` +
+ 'Download the GLB and drag the file into the editor instead.',
+ { duration: 7000 },
+ );
}
}
@@ -225,7 +240,11 @@ async function importHandoffAnimation() {
editor.execute(new AddScriptCommand(editor, object, { ...HANDOFF_PLAY_SCRIPT }));
}
} catch (error) {
- alert('Could not load the animation from the Animation Studio (' + error.message + '). Try Export GLB on /pose and drag the file in instead.');
+ toastError(
+ `Could not load the animation from the Animation Studio: ${error.message}. ` +
+ 'Try Export GLB on /pose and drag the file in instead.',
+ { duration: 7000 },
+ );
}
}
diff --git a/src/scene-studio/studio.css b/src/scene-studio/studio.css
index a8d38cd79..bc0cc0d87 100644
--- a/src/scene-studio/studio.css
+++ b/src/scene-studio/studio.css
@@ -12,10 +12,16 @@ body.scene-studio {
}
/* The editor panels position themselves absolutely against their nearest
- * positioned ancestor; this container pins the whole tool under the site nav. */
+ * positioned ancestor; this container pins the whole tool under the site nav.
+ *
+ * The offset is --nav-h (the rendered height of the nav.js header), NOT
+ * --header-h: those are different numbers (69px vs 56px), and using the
+ * smaller one parked the top 13px of the editor behind the sticky nav, which
+ * sliced the tops off the File/Edit/Add/View/Render/Help glyphs and hid the
+ * autosave checkbox at every width. See the --nav-h note in public/tokens.css. */
#studio-app {
position: fixed;
- top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
+ top: calc(var(--nav-h, 69px) + env(safe-area-inset-top, 0px));
left: 0;
right: 0;
bottom: 0;
@@ -36,6 +42,22 @@ body.scene-studio {
color: var(--ink);
}
+/* The vendored #menubar is a fixed 36px tall strip of floated menus, and every
+ * panel below it (#viewport, #sidebar, #toolbar, #script, #player) is pinned to
+ * `top: 36px`. At 320px the six titles no longer fit on one line, so `Help`
+ * floated onto a second row that the 36px strip cannot show: it spilled over
+ * the viewport and landed under the quick-action bar. Tightening the padding
+ * below 600px fits all six on the single row the layout assumes. */
+@media (max-width: 600px) {
+ #studio-app #menubar .menu {
+ padding-right: 2px;
+ }
+
+ #studio-app #menubar .menu .title {
+ padding: 10px 6px;
+ }
+}
+
#studio-app #menubar .menu:hover,
#studio-app #menubar .menu.open {
background: var(--surface-2);
diff --git a/src/scene-studio/toolbar-a11y.js b/src/scene-studio/toolbar-a11y.js
new file mode 100644
index 000000000..2a19ed0ad
--- /dev/null
+++ b/src/scene-studio/toolbar-a11y.js
@@ -0,0 +1,56 @@
+// Scene Studio: accessible names for the vendored transform toolbar.
+//
+// The vendored Toolbar (vendor/js/Toolbar.js) builds its translate / rotate /
+// scale controls as a <button> whose only child is an <img> carrying a `title`
+// and no `alt`. A title on an <img> is not an accessible name for the button
+// that wraps it, so all three shipped to screen readers as unlabelled buttons,
+// and the pressed state (a `selected` class) was never announced at all.
+//
+// This runs over the mounted toolbar once and fixes both, reading the labels
+// from the same `editor.strings` table the vendor uses for the tooltips, so a
+// translated UI stays translated. Sibling module: it edits the live DOM, never
+// vendor/**.
+
+const MODE_KEYS = ['translate', 'rotate', 'scale'];
+
+/**
+ * Label the transform-mode buttons and keep aria-pressed in sync.
+ * @param {import('./vendor/js/Editor.js').Editor} editor
+ * @param {HTMLElement} toolbarDom the Toolbar instance's `.dom`.
+ */
+export function enhanceToolbarA11y(editor, toolbarDom) {
+ toolbarDom.setAttribute('role', 'toolbar');
+ toolbarDom.setAttribute('aria-label', 'Transform mode');
+
+ const buttons = MODE_KEYS.map((mode) => {
+ // Matched on the icon the vendor assigns, not on child order, so adding
+ // a control to the vendored toolbar can never silently relabel these.
+ const icon = toolbarDom.querySelector(`img[src$="/${mode}.svg"]`);
+ const button = icon?.closest('button');
+ if (!button) return null;
+ // The vendor's own tooltip string, e.g. "translate" / "rotate" / "scale".
+ const label = (icon?.title || mode).trim() || mode;
+
+ // A decorative alt keeps the icon out of the accessibility tree so the
+ // button's own label is what gets announced, rather than both.
+ if (icon && !icon.hasAttribute('alt')) icon.setAttribute('alt', '');
+
+ button.setAttribute('aria-label', label);
+ button.setAttribute('type', 'button');
+ if (!button.title) button.title = label;
+ return { mode, button };
+ }).filter(Boolean);
+
+ const sync = () => {
+ for (const { button } of buttons) {
+ button.setAttribute('aria-pressed', String(button.classList.contains('selected')));
+ }
+ };
+
+ // The vendor swaps the `selected` class inside its own handler for this
+ // signal; listening after it was added means we always read the new state.
+ editor.signals.transformModeChanged.add(sync);
+ sync();
+
+ return buttons.map(({ button }) => button);
+}
diff --git a/tests/scene-studio-actions.test.js b/tests/scene-studio-actions.test.js
new file mode 100644
index 000000000..943ccc5a8
--- /dev/null
+++ b/tests/scene-studio-actions.test.js
@@ -0,0 +1,71 @@
+/**
+ * Scene Studio action bar: pure-logic unit tests.
+ *
+ * Two of these pin regressions that shipped silently, because both failure
+ * modes produce a plausible-looking string rather than an error:
+ *
+ * 1. `sceneTitle` used to be `document.title.replace(/\s*·\s*Scene Studio.*$/i, '')`.
+ * The live title is "Scene Studio · Assemble 3D worlds · three.ws", which
+ * that pattern never matches (it looks for "· Scene Studio", and the page
+ * leads with it), so every scene shared from the studio was labelled with
+ * the studio's own marketing string instead of the scene's name.
+ * 2. `describeImportFailure` turns a bare `HTTP 4xx` / `Failed to fetch` into
+ * copy that tells the user what to do next. Its 403 branch was written as
+ * `40[34]`, which swallowed 404 and left the "nothing is hosted there"
+ * branch unreachable.
+ */
+
+import { describe, it, expect } from 'vitest';
+import { describeImportFailure, sceneTitle } from '../src/scene-studio/actions.js';
+
+describe('sceneTitle', () => {
+ it('uses the name the user gave the scene', () => {
+ expect(sceneTitle({ scene: { name: 'Rooftop bar' } })).toBe('Rooftop bar');
+ });
+
+ it('falls back for the editor default name, which is not a title', () => {
+ expect(sceneTitle({ scene: { name: 'Scene' } })).toBe('Scene composed on three.ws');
+ expect(sceneTitle({ scene: { name: 'scene' } })).toBe('Scene composed on three.ws');
+ });
+
+ it('falls back for an unnamed or whitespace-only scene', () => {
+ expect(sceneTitle({ scene: { name: '' } })).toBe('Scene composed on three.ws');
+ expect(sceneTitle({ scene: { name: ' ' } })).toBe('Scene composed on three.ws');
+ expect(sceneTitle({ scene: {} })).toBe('Scene composed on three.ws');
+ });
+
+ it('never reaches for the page title', () => {
+ expect(sceneTitle({})).toBe('Scene composed on three.ws');
+ });
+});
+
+describe('describeImportFailure', () => {
+ it('separates "not yours" from "not there"', () => {
+ expect(describeImportFailure(new Error('HTTP 401'))).toBe('that link is private or expired');
+ expect(describeImportFailure(new Error('HTTP 403'))).toBe('that link is private or expired');
+ expect(describeImportFailure(new Error('HTTP 404'))).toBe('nothing is hosted at that link');
+ });
+
+ it('names the host when the host is at fault', () => {
+ expect(describeImportFailure(new Error('HTTP 500'))).toBe('the host that stores it is down');
+ expect(describeImportFailure(new Error('HTTP 503'))).toBe('the host that stores it is down');
+ });
+
+ it('explains the opaque cross-origin failure every browser words differently', () => {
+ const cors = 'the host blocked the request (no CORS header) or is unreachable';
+ expect(describeImportFailure(new TypeError('Failed to fetch'))).toBe(cors);
+ expect(describeImportFailure(new TypeError('NetworkError when attempting to fetch resource.'))).toBe(cors);
+ expect(describeImportFailure(new TypeError('Load failed'))).toBe(cors);
+ });
+
+ it('passes an unrecognised message through rather than inventing one', () => {
+ expect(describeImportFailure(new Error('Unsupported glTF version'))).toBe('Unsupported glTF version');
+ expect(describeImportFailure('plain string')).toBe('plain string');
+ });
+
+ it('never renders undefined for a thrown non-error', () => {
+ expect(describeImportFailure(undefined)).toBe('Unknown error');
+ expect(describeImportFailure(null)).toBe('Unknown error');
+ expect(describeImportFailure({})).toBe('Unknown error');
+ });
+});