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(objects): show all 511 CC0 props again and stop the library mounting 511 live 3D viewers at once

nirholasbeac3c33ad23
diff --git a/STRUCTURE.md b/STRUCTURE.md
index d1a8ef60e..dbd6c403c 100644
--- a/STRUCTURE.md
+++ b/STRUCTURE.md
@@ -154,7 +154,7 @@ bottom.
| Gesture vocabulary | [pages/gestures.html](pages/gestures.html) + [src/gestures-page.js](src/gestures-page.js), slots [src/runtime/animation-slots.js](src/runtime/animation-slots.js) | Live at `/gestures` | The 19 gesture slots an agent plays, each previewed on a live avatar, with the skill hints that trigger it and a builder that saves a per-slot clip override straight onto an agent (`meta.edits.animations`). Hint table is generated from the shipped skill definitions by [scripts/build-agent-hints.mjs](scripts/build-agent-hints.mjs), so attribution cannot go stale · see [docs/animations.md](docs/animations.md) |
| Choreographer | [pages/choreograph.html](pages/choreograph.html) + [src/choreograph-page.js](src/choreograph-page.js), engine [src/runtime/choreography.js](src/runtime/choreography.js) | Live at `/choreograph` | Timeline for composing gesture slots into named, timed routines, previewed on the shared live-preview engine with crossfades and a scrubbable playhead. One dependency-free module defines the routine format, the URL wire format and the timing engine; the studio, `PUT /api/agents/:id/animations` (stored at `meta.choreographies`), the public manifest and `AgentAvatar.playChoreography` all import it, and `<agent-3d>.playRoutine('welcome')` performs one from any embed. Also published as `@three-ws/avatar/runtime/choreography.js` · see [docs/choreography.md](docs/choreography.md) |
| Character Library | [pages/character-library.html](pages/character-library.html) + [src/character-library.js](src/character-library.js) (search/sort/link logic in [src/shared/character-library-view.js](src/shared/character-library-view.js), covered by [tests/character-library-view.test.js](tests/character-library-view.test.js)) → `/character-library`, API [api/avatars/library.js](api/avatars/library.js) | Live at `/character-library` | Professionally rigged Mixamo characters (skinned GLB + thumbnails on R2, `avatars/mixamo/`), each drives the full animation library. The live count comes from the R2 manifest and renders in the hero; no page copy hard-codes it. Pipeline: [scripts/fetch-mixamo-avatars.mjs](scripts/fetch-mixamo-avatars.mjs) → [scripts/convert-mixamo-avatars.mjs](scripts/convert-mixamo-avatars.mjs) → [scripts/fetch-mixamo-avatar-thumbnails.mjs](scripts/fetch-mixamo-avatar-thumbnails.mjs) → [scripts/build-mixamo-avatar-library.mjs](scripts/build-mixamo-avatar-library.mjs) publishes `avatars/library/manifest.json`. Cards deep-link into the 3D viewer (`/app#model=`), Widget Studio (`/studio?model=`), and Animation Studio (`/pose?src=`). Mirrors the animation-library R2-manifest pattern (no DB). See [public/avatars/mixamo/README.md](public/avatars/mixamo/README.md) |
-| Object Library | [pages/objects.html](pages/objects.html) + [src/objects-library.js](src/objects-library.js) → `/objects`, API [api/objects/library.js](api/objects/library.js) | Live at `/objects` | Hundreds of CC0 (public-domain) 3D props from Poly Haven (packed to GLB on R2, `objects/polyhaven/`). Pipeline: [scripts/fetch-polyhaven-objects.mjs](scripts/fetch-polyhaven-objects.mjs) (glTF→GLB via @gltf-transform) → [scripts/render-glb-thumbnails.mjs](scripts/render-glb-thumbnails.mjs) → [scripts/build-object-library.mjs](scripts/build-object-library.mjs) publishes `objects/library/manifest.json`. Same R2-manifest pattern as the Character/animation libraries (no DB). Cards preview in the 3D viewer (`/app#model=`), place into AR Studio (`/ar/studio?src=`), and download the GLB directly (CC0). AR Studio's tray also has an Objects tab over the same manifest. |
+| Object Library | [pages/objects.html](pages/objects.html) + [src/objects-library.js](src/objects-library.js) → `/objects`, API [api/objects/library.js](api/objects/library.js) | Live at `/objects` | Hundreds of CC0 (public-domain) 3D props from Poly Haven (packed to GLB on R2, `objects/polyhaven/`). Pipeline: [scripts/fetch-polyhaven-objects.mjs](scripts/fetch-polyhaven-objects.mjs) (glTF→GLB via @gltf-transform) → [scripts/render-glb-thumbnails.mjs](scripts/render-glb-thumbnails.mjs) → [scripts/build-object-library.mjs](scripts/build-object-library.mjs) publishes `objects/library/manifest.json`. Same R2-manifest pattern as the Character/animation libraries (no DB). Cards preview in the 3D viewer (`/app#model=`), place into AR Studio (`/ar/studio?src=`), and download the GLB directly (CC0). AR Studio's tray also has an Objects tab over the same manifest. The grid renders 48 cards at a time (a Load more button, plus an IntersectionObserver that pulls the next chunk as you approach it) and each card is a still thumbnail until you dwell on it, at which point that one card upgrades to a live auto-rotating `<model-viewer>`; at most six stay mounted. The manifest read falls back to the bucket's public CDN domain when the signed S3 read fails (`getPublicObjectBuffer` in [api/_lib/r2.js](api/_lib/r2.js)), so a bad storage credential can no longer empty a library of public CC0 bytes. |
| Agent-Forged Gallery | [pages/forged.html](pages/forged.html) + [src/forged-gallery.js](src/forged-gallery.js) → `/forged`, API [api/forged.js](api/forged.js), writer [api/_lib/x402/pipelines/forge-content.js](api/_lib/x402/pipelines/forge-content.js) | Live at `/forged` | 3D props BOUGHT by the autonomous x402 agents with real USDC: the hourly forge-content pipeline pays `/api/x402/forge` (draft tier), the generated GLB lands in `forge_autonomous_props` with payment provenance (payer wallet, price, Solana settlement signature), and `/forged` renders each prop with its on-chain receipt linked to Solscan. Honest feed: no synthetic entries; before the first paid generation the page shows its designed empty state. Category chips built from the eight families in [api/_lib/x402/pipelines/forge-catalog.js](api/_lib/x402/pipelines/forge-catalog.js) (club-decor, ar-object, diorama-set, avatar-item, vehicle, container, furniture, terrain), prompt search, newest/priciest/most-novel sorts. |
| Motion Swap (avatar body-swap in video) | [pages/motion-swap.html](pages/motion-swap.html) `→ /motion-swap` + [src/motion-swap.js](src/motion-swap.js), API [api/motion-swap.js](api/motion-swap.js), worker [workers/model-video2motion/](workers/model-video2motion) | Live | Upload a video of one person, get it back with a 3D avatar performing their motion. The worker (CPU Cloud Run, MediaPipe pose + hands + multiclass person segmentation, all Apache-2.0) tracks 33 body world landmarks plus 21 per hand each frame, solves them onto the canonical Wolf3D skeleton, body and all 30 finger bones, with an in-house bend-plane IK solver ([pose_solver.py](workers/model-video2motion/pose_solver.py), pure NumPy, unit-tested), and emits a standard `AnimationClip.toJSON()` + person-mask video + per-frame screen anchors. The browser composites in one WebGL scene: footage on a shader quad with the subject pixelated under the mask, avatar retargeted via [src/animation-retarget.js](src/animation-retarget.js) and pinned to the subject's anchor each frame, MediaRecorder export with original audio. Provider mode `video2motion` (`GCP_VIDEO2MOTION_URL`) in [api/_providers/gcp.js](api/_providers/gcp.js). Docs: [docs/motion-swap.md](docs/motion-swap.md). Tests: [test_pose_solver.py](workers/model-video2motion/test_pose_solver.py) (solver) and [test_service.py](workers/model-video2motion/test_service.py) (HTTP contract, ffmpeg normalize/mask encode, SSRF guard, live MediaPipe pass). |
| Smart home (`/smart-home`) | Page [pages/smart-home.html](pages/smart-home.html) `→ /smart-home` and `/smart-home/:id` + [src/home/](src/home) (connect, manage, scene-model, scene-render, scene-fallback, satellite, satellite-link, pcm-player, plan, api). Store [api/_lib/home/store.js](api/_lib/home/store.js), runtime + backpressure [runtime.js](api/_lib/home/runtime.js) + [admission.js](api/_lib/home/admission.js), gate + tools [tools.js](api/_lib/home/tools.js) + [confirm.js](api/_lib/home/confirm.js), roster [members.js](api/_lib/home/members.js), privacy [privacy.js](api/_lib/home/privacy.js), plans + quotas [entitlements.js](api/_lib/home/entitlements.js) + [usage.js](api/_lib/home/usage.js), SSRF pin [api/_lib/home-url-guard.js](api/_lib/home-url-guard.js). HTTP [api/home/](api/home) (index, [id], [id]/call, [id]/activate, [id]/stream, [id]/grants, [id]/members, [id]/confirm, invites/[token], pair, pair/redeem, privacy, plan). Client [packages/home-bridge/](packages/home-bridge/README.md), MCP server [packages/home-mcp/](packages/home-mcp/README.md), hosted MCP tools [api/_mcp/tools/home.js](api/_mcp/tools/home.js). Dial-out for LAN-only houses [services/home-relay/](services/home-relay/README.md) + [home-assistant-integration/](home-assistant-integration) (HACS). Voice [services/home-satellite/](services/home-satellite/README.md) (Wyoming). Harness [scripts/home-test-instance.mjs](scripts/home-test-instance.mjs), load fleet + envelope + chaos [scripts/home-fleet.mjs](scripts/home-fleet.mjs) / [scripts/home-load.mjs](scripts/home-load.mjs) / [scripts/home-chaos.mjs](scripts/home-chaos.mjs) (`npm run home:fleet`, `home:load`, `home:chaos`). Migrations `api/_lib/migrations/*_home_*.sql` | Live | The agent past the screen and into the building. **Zero device code, ever:** Home Assistant owns Zigbee, Z-Wave, Matter, Thread, BLE and 1,500 integrations, and three.ws is the layer in between: a connection record with the token encrypted at rest, a pooled per-home WebSocket, a room graph the 3D scene renders live, intent resolved to the household's own scenes, and one gate in front of everything. **The gate is the product decision:** reads are free, moves toward safety (lock, close, arm) run immediately and never prompt, and moves that OPEN the house (unlock, open a door/gate/garage, disarm) never run from a model call at all. They mint a pending confirmation a signed-in person redeems at `POST /api/home/:id/confirm`, which refuses every bearer principal including one holding `home:act`. It exists because Home Assistant's own `intent__HassTurnOff` is documented as performing an **unlock** on a lock, verified live. Entity and area names are untrusted input travelling in `structuredContent`, never interpolated into prose. Three reachability answers, all shipped: a remote https URL, a browser or MCP server inside the network, and the HACS integration that dials out so no Home Assistant credential ever leaves the house. Docs: [docs/smart-home.md](docs/smart-home.md), [docs/tutorials/connect-your-home.md](docs/tutorials/connect-your-home.md), [docs/home-households.md](docs/home-households.md), [docs/home-privacy.md](docs/home-privacy.md), [docs/home-plans.md](docs/home-plans.md), [docs/ops/home-operations.md](docs/ops/home-operations.md) (SLOs, the alerts, the measured scale envelope, the backpressure ladder, the seven chaos scenarios and the Cloud Run sizing). Evidence: [tasks/home/](tasks/home). Tests: `tests/home-*.test.js`, [tests/e2e/home-connect.spec.js](tests/e2e/home-connect.spec.js), [packages/home-bridge/tests/](packages/home-bridge/tests), [packages/home-mcp/tests/](packages/home-mcp/tests) |
diff --git a/pages/objects.html b/pages/objects.html
index 3c14125c7..150684d01 100644
--- a/pages/objects.html
+++ b/pages/objects.html
@@ -95,6 +95,10 @@
.ch-card {
border: 1px solid var(--stroke); border-radius: var(--radius-lg);
background: var(--surface-glass); overflow: hidden;
+ /* Keep scrolling cheap once a few hundred cards have accumulated: the
+ browser skips layout and paint for the ones off screen. The intrinsic
+ size keeps the scrollbar honest while they are skipped. */
+ content-visibility: auto; contain-intrinsic-size: auto 292px;
transition: border-color var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
display: flex; flex-direction: column;
}
@@ -152,6 +156,7 @@
.ch-state-icon { font-size: 40px; margin-bottom: 12px; }
.ch-state h2 { color: var(--ink); margin: 0 0 8px; font-size: 20px; }
.ch-state p { max-width: 46ch; margin: 0 auto 18px; line-height: 1.55; }
+ .ch-state-detail { font-family: var(--font-mono); font-size: 12.5px; opacity: .75; }
.ch-hbtn {
display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px;
@@ -276,7 +281,12 @@
<div data-role="error" class="ch-state" hidden>
<div class="ch-state-icon">⚠️</div>
<h2 data-i18n="objects.couldn_t_load_objects">Couldn't load objects</h2>
- <p data-role="error-msg" data-i18n="objects.something_went_wrong_loading_the_object_libr">Something went wrong loading the object library.</p>
+ <p data-i18n="objects.something_went_wrong_loading_the_object_libr">Something went wrong loading the object library. Check your connection, then try again.</p>
+ <!-- The reason the request actually failed. It carries no data-i18n on
+ purpose: the i18n pass rewrites every translated node after load,
+ which used to overwrite this text with the generic sentence above
+ the moment it was set. -->
+ <p class="ch-state-detail" data-role="error-msg" hidden></p>
<button class="ch-hbtn ch-hbtn--secondary" data-role="retry" data-i18n="objects.try_again">Try again</button>
</div>
</main>
diff --git a/prompts/finish/200-swarm-100-route-objects.md b/prompts/finish/200-swarm-100-route-objects.md
deleted file mode 100644
index 98459e430..000000000
--- a/prompts/finish/200-swarm-100-route-objects.md
+++ /dev/null
@@ -1,119 +0,0 @@
-# Route audit: /objects (Object Library)
-
-How to run: paste this file's repo path into a fresh Claude Code chat in this
-repository and say "run this work order". This file is fully self-contained:
-it depends on no other prompt file anywhere. If sibling swarm-100 files in
-prompts/finish/ are gone, that work is done; if present, ignore them.
-Every claim below rots; step 0 re-measures, and what you measure wins.
-
-## Operating clause (binding)
-
-- Read CLAUDE.md first. Its rules override everything, including this file.
-- Finish 100% in this session. Never end the turn with a question, an option
- list, or an unexecuted plan. A judgment call goes in one line of the final
- report; it never becomes a question that halts work.
-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real
- funds or any irreversible on-chain write, git push or a production deploy,
- committing content that references a crypto project other than $THREE, and
- destroying unrecoverable data.
-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no
- commented-out code. Real APIs and real integrations only.
-- The em-dash and en-dash characters are banned in everything you write.
-- Concurrent agents share this worktree: stage explicit paths only (never a
- bare add-everything), and commit finished work promptly.
-- Before committing, run: npm run check:rules -- --paths <files you touched>.
- It must exit 0.
-
-## Step 0: re-derive the current state
-
-1. This route's declared entry (path, description, added date):
-
- node -e "const p=require('./data/pages.json');for(const s of p.sections)for(const g of s.pages)if(g.path==='/objects')console.log(JSON.stringify(g,null,2))"
-
-2. Find the serving implementation: grep "/objects" in vercel.json (the live
- route table server/index.mjs boots from), then list matching files in
- pages/ and src/. STRUCTURE.md maps every surface to its directory if the
- grep is ambiguous.
-3. Production right now:
-
- curl -so /dev/null -w '%{http_code}\n' https://three.ws/objects
-
-4. Start (or reuse) the local dev server: npm run dev (vite, port 3000).
-
-## Task: audit this one route end to end, then fix everything found
-
-Route: /objects ("Object Library", section "main").
-Declared purpose: Hundreds of free CC0 3D objects and props: furniture, lighting, electronics, decor. Public domain, no attribution required. Preview live, place it in your room with AR, or download the GLB.
-
-Drive the page in a real headless browser. Playwright is already a dev
-dependency; keep your probe script in the session scratchpad, never in the
-repo.
-
-1. Load http://localhost:3000/objects. Record the HTTP status, every console
- error and warning, and every failed network request.
-2. Exercise it like a first-time user: click the primary actions, run the
- primary flow if one exists, follow the page's internal links. Every button
- must do something real; every link must resolve. If the page renders data,
- prove in the network log that it came from a live endpoint, not a baked-in
- fallback array.
-3. States: verify populated, empty, loading, and error states are designed and
- reachable. Block the page's primary fetch in Playwright and confirm an
- actionable error state appears, not a blank void or a raw exception.
-4. Responsive: render at 320, 768, and 1440 px. No horizontal page scroll, no
- overlapping or clipped controls.
-5. Accessibility basics: one h1; interactive elements are real buttons or
- links with visible focus states; images carry alt text; form fields have
- labels.
-6. Head: a specific title tag and meta description that match the declared
- purpose above.
-7. Fix every defect at its root in the page's real source files and re-run the
- probe until clean. Defects in shared modules are in scope when this route
- exercises them.
-
-## Definition of done
-
-- [ ] Local load of /objects: HTTP 200, zero console errors, zero unhandled
- failed requests (a third-party outage must land in a designed fallback,
- not a broken page).
-- [ ] No dead interactive element on the page: no stub href="#", no button
- without a handler, no link to a missing path.
-- [ ] Empty, loading, error, and populated states verified.
-- [ ] 320 / 768 / 1440 px renders verified clean.
-- [ ] Title and meta description present and specific.
-- [ ] npm test passes; npm run check:rules -- --paths <touched files> exits 0.
-- [ ] Production status from step 0 recorded in the report; if production
- needs a deploy to pick up a fix, the report says so (deploys stay
- owner-gated).
-
-## Never blocked
-
-| Blocker | Resolution (act, do not ask) |
-|---|---|
-| Missing env var or credential | Check .env and .env.local, then the Cloud Run service env, then Secret Manager (the CLAUDE.md self-unblock playbook has the exact commands). If it truly exists nowhere, wire the code fully behind the env var, prove the wiring with a dry run, and name the single missing var in the report. |
-| gcloud not on PATH | Run: export PATH="$HOME/google-cloud-sdk/bin:$PATH" |
-| Dev server port 3000 busy | Another agent may be serving this repo; probe it and reuse if so. Otherwise start your own on a free port: npx vite --port 3101 |
-| Playwright browser missing | npx playwright install chromium |
-| A surface needs a signed-in user | Register a fresh account through the real /register flow against the real API and use it. Never mock the session. |
-| A defect sits in code you did not touch | Fix it if it blocks a Definition of done line (root cause it, never mask it). Otherwise note it in the report and continue. |
-| An unrelated test is red | Same rule. Never pipe npm test through tail; it masks exit codes. |
-
-## Close out (required)
-
-1. Verify every Definition of done line with the actual command output in
- front of you. Never claim a line you did not verify.
-2. Commit with explicit paths and a subject that describes the diff (house
- style: type(scope): what changed and why a reader cares).
-3. Delete this prompt file in that same commit:
-
- git rm prompts/finish/200-swarm-100-route-objects.md
-
- The shrinking directory is this campaign's only progress ledger; there is
- no progress log to update.
-4. Final report: what step 0 measured, what changed (file list), evidence per
- Definition of done line, and any one-line judgment calls. No trailing
- questions, no unexecuted plans.
-
-If a line genuinely cannot pass inside this session (an external party must
-respond, or an owner-gated action is the final step), finish everything else,
-leave this file in place, and state exactly which line remains and who owns
-it. Never delete this file on a partial.
diff --git a/public/locales/en.json b/public/locales/en.json
index acc9fdf3a..b0d85e6cb 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -15226,7 +15226,7 @@
"yes_9": "Yes"
},
"objects": {
- "a_curated_library_of_cc0_3d_objects": "A curated library of CC0 3D objects and props — furniture, lighting, electronics, containers, decor. Every one is public domain: free to use commercially, no attribution required. Preview any object live in your browser, or download the GLB and use it anywhere.",
+ "a_curated_library_of_cc0_3d_objects": "A curated library of CC0 3D objects and props: furniture, lighting, electronics, containers, decor. Every one is public domain: free to use commercially, no attribution required. Preview any object live in your browser, or download the GLB and use it anywhere.",
"a_z": "A → Z",
"avatar_gallery": "Avatar Gallery",
"character_library": "Character Library",
@@ -15235,8 +15235,8 @@
"free_3d_props_ready_to_drop_into": "Free 3D props, ready to drop into any scene",
"generate_a_3d_model": "Generate a 3D model",
"largest_first": "Largest first",
- "meta_description": "Hundreds of free CC0 3D objects and props — furniture, lighting, electronics, containers, decor. Preview any one live, or download the GLB to use anywhere. No attribution required.",
- "meta_og_description": "Free CC0 3D props, ready to drop into any scene. Preview, animate, or use in the Studio.",
+ "meta_description": "Hundreds of free CC0 3D objects and props (furniture, lighting, electronics, containers, decor). Preview any one live, or download the GLB to use anywhere. No attribution required.",
+ "meta_og_description": "Free CC0 3D props, ready to drop into any scene. Preview live or download the GLB, no attribution required.",
"meta_og_title": "Object Library · three.ws",
"meta_title": "Object Library · three.ws",
"meta_twitter_description": "Free CC0 3D props, ready to drop into any scene.",
@@ -15246,10 +15246,11 @@
"object_library": "Object Library",
"object_library_coming_online": "Object library coming online",
"smallest_first": "Smallest first",
- "something_went_wrong_loading_the_object_libr": "Something went wrong loading the object library.",
+ "something_went_wrong_loading_the_object_libr": "Something went wrong loading the object library. Check your connection, then try again.",
"the_cc0_object_library_is_being_staged": "The CC0 object library is being staged. Check back in a moment, or generate your own from a text prompt.",
"try_again": "Try again",
- "z_a": "Z → A"
+ "z_a": "Z → A",
+ "load_more": "Load more"
},
"openai_index": {
"3d_natively_inside_chatgpt": "3D, natively, inside <span class=\"gradient\">ChatGPT</span>.",
diff --git a/src/objects-library.js b/src/objects-library.js
index cf69e5b2e..a7ed56e67 100644
--- a/src/objects-library.js
+++ b/src/objects-library.js
@@ -37,6 +37,7 @@ const els = {
const PAGE_SIZE = 48;
const MAX_LIVE_VIEWERS = 6;
+const HOVER_INTENT_MS = 200;
const state = { all: [], query: '', sort: 'az', category: '', view: [], rendered: 0 };
@@ -234,6 +235,7 @@ function applyView() {
async function load() {
show(els.loading, true); show(els.grid, false); show(els.empty, false);
show(els.emptySearch, false); show(els.error, false); show(els.more, false);
+ show(els.errorMsg, false);
try {
const res = await fetch('/api/objects/library');
if (!res.ok) throw new Error(`HTTP ${res.status}`);
@@ -245,7 +247,10 @@ async function load() {
} catch (err) {
show(els.loading, false); show(els.grid, false); show(els.empty, false);
show(els.emptySearch, false); show(els.more, false); show(els.error, true);
- if (els.errorMsg) els.errorMsg.textContent = `Failed to load objects: ${err?.message || 'network error'}. Check your connection and try again.`;
+ if (els.errorMsg) {
+ els.errorMsg.textContent = `Request failed: ${err?.message || 'network error'}`;
+ show(els.errorMsg, true);
+ }
}
}
@@ -276,12 +281,25 @@ function wire() {
// Delegated so a chunk appended later needs no extra wiring. `pointerover`
// bubbles where `pointerenter` does not, and `focusin` gives a keyboard user
// the same live preview a mouse user gets on hover.
- const upgradeFromEvent = (e) => {
+ //
+ // Hover INTENT, not hover: sweeping the pointer across a row of cards on the
+ // way to the search box would otherwise start a multi-megabyte GLB download
+ // per card it crossed, six of which raced hard enough to crash the renderer
+ // outright in testing. A short dwell means only the card you actually stopped
+ // on goes live. Keyboard focus is already a deliberate act, so it upgrades at
+ // once.
+ let hoverTimer;
+ els.grid?.addEventListener('pointerover', (e) => {
+ const thumb = e.target.closest?.('.ch-card-thumb');
+ if (!thumb) return;
+ clearTimeout(hoverTimer);
+ hoverTimer = setTimeout(() => upgradeThumb(thumb), HOVER_INTENT_MS);
+ });
+ els.grid?.addEventListener('pointerout', () => clearTimeout(hoverTimer));
+ els.grid?.addEventListener('focusin', (e) => {
const thumb = e.target.closest?.('.ch-card-thumb');
if (thumb) upgradeThumb(thumb);
- };
- els.grid?.addEventListener('pointerover', upgradeFromEvent);
- els.grid?.addEventListener('focusin', upgradeFromEvent);
+ });
// Infinite scroll on top of the real button: the sentinel loads the next
// chunk as it nears the viewport, and the button stays the accessible,
diff --git a/tests/animations-library-endpoint.test.js b/tests/animations-library-endpoint.test.js
index 8161dc829..0ee3c99e6 100644
--- a/tests/animations-library-endpoint.test.js
+++ b/tests/animations-library-endpoint.test.js
@@ -13,8 +13,8 @@
import { describe, it, expect, vi } from 'vitest';
-const getObjectBuffer = vi.fn();
-vi.mock('../api/_lib/r2.js', () => ({ getObjectBuffer: (...a) => getObjectBuffer(...a) }));
+const readManifest = vi.fn();
+vi.mock('../api/_lib/r2.js', () => ({ getPublicObjectBuffer: (...a) => readManifest(...a) }));
const { default: handler } = await import('../api/animations/library.js');
@@ -52,7 +52,7 @@ const CLIP = {
describe('GET /api/animations/library', () => {
it('returns an empty library when the manifest has not been uploaded yet', async () => {
const missing = Object.assign(new Error('no such key'), { name: 'NoSuchKey' });
- getObjectBuffer.mockRejectedValue(missing);
+ readManifest.mockRejectedValue(missing);
const res = fakeRes();
await handler(fakeReq(), res);
expect(res.statusCode).toBe(200);
@@ -60,7 +60,7 @@ describe('GET /api/animations/library', () => {
});
it('degrades to an empty library on storage errors instead of failing', async () => {
- getObjectBuffer.mockRejectedValue(new Error('socket hang up'));
+ readManifest.mockRejectedValue(new Error('socket hang up'));
const res = fakeRes();
await handler(fakeReq(), res);
expect(res.statusCode).toBe(200);
@@ -68,7 +68,7 @@ describe('GET /api/animations/library', () => {
});
it('passes through a published { clips } manifest and derives total', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from(JSON.stringify({
+ readManifest.mockResolvedValue(Buffer.from(JSON.stringify({
generated_at: '2026-07-04T00:00:00.000Z',
total: 1,
clips: [CLIP],
@@ -84,14 +84,14 @@ describe('GET /api/animations/library', () => {
});
it('accepts a bare-array manifest shape', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from(JSON.stringify([CLIP])));
+ readManifest.mockResolvedValue(Buffer.from(JSON.stringify([CLIP])));
const res = fakeRes();
await handler(fakeReq(), res);
expect(JSON.parse(res.body).clips).toEqual([CLIP]);
});
it('rejects non-GET methods', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from('[]'));
+ readManifest.mockResolvedValue(Buffer.from('[]'));
const res = fakeRes();
await handler(fakeReq('POST'), res);
expect(res.statusCode).toBe(405);
@@ -101,7 +101,7 @@ describe('GET /api/animations/library', () => {
const CLIPS = Array.from({ length: 5 }, (_, i) => ({ ...CLIP, name: `mx-clip-${i}` }));
it('pages a large manifest with ?limit and exposes next_offset', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from(JSON.stringify({ clips: CLIPS })));
+ readManifest.mockResolvedValue(Buffer.from(JSON.stringify({ clips: CLIPS })));
const res = fakeRes();
await handler(fakeReq('GET', '/api/animations/library?limit=2'), res);
const body = JSON.parse(res.body);
@@ -112,7 +112,7 @@ describe('GET /api/animations/library', () => {
});
it('honors ?offset and returns next_offset=null on the final page', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from(JSON.stringify({ clips: CLIPS })));
+ readManifest.mockResolvedValue(Buffer.from(JSON.stringify({ clips: CLIPS })));
const res = fakeRes();
await handler(fakeReq('GET', '/api/animations/library?limit=2&offset=4'), res);
const body = JSON.parse(res.body);
@@ -122,7 +122,7 @@ describe('GET /api/animations/library', () => {
});
it('returns an empty page (not an error) when offset runs past the end', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from(JSON.stringify({ clips: CLIPS })));
+ readManifest.mockResolvedValue(Buffer.from(JSON.stringify({ clips: CLIPS })));
const res = fakeRes();
await handler(fakeReq('GET', '/api/animations/library?limit=2&offset=99'), res);
const body = JSON.parse(res.body);
@@ -132,7 +132,7 @@ describe('GET /api/animations/library', () => {
});
it('omits pagination fields entirely when ?limit is absent (legacy contract)', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from(JSON.stringify({ clips: CLIPS })));
+ readManifest.mockResolvedValue(Buffer.from(JSON.stringify({ clips: CLIPS })));
const res = fakeRes();
await handler(fakeReq('GET', '/api/animations/library'), res);
const body = JSON.parse(res.body);
diff --git a/tests/api/catalog-endpoint.test.js b/tests/api/catalog-endpoint.test.js
index b47d8b81e..6a04924e1 100644
--- a/tests/api/catalog-endpoint.test.js
+++ b/tests/api/catalog-endpoint.test.js
@@ -39,7 +39,7 @@ const MANIFESTS = {
};
vi.mock('../../api/_lib/r2.js', () => ({
- getObjectBuffer: vi.fn(async (key) => {
+ getPublicObjectBuffer: vi.fn(async (key) => {
const value = MANIFESTS[key];
if (value == null) {
const err = new Error('NoSuchKey');
diff --git a/tests/objects-library-endpoint.test.js b/tests/objects-library-endpoint.test.js
index 1dd0b873d..e776dcaf0 100644
--- a/tests/objects-library-endpoint.test.js
+++ b/tests/objects-library-endpoint.test.js
@@ -17,8 +17,8 @@
import { describe, it, expect, vi } from 'vitest';
-const getObjectBuffer = vi.fn();
-vi.mock('../api/_lib/r2.js', () => ({ getObjectBuffer: (...a) => getObjectBuffer(...a) }));
+const readManifest = vi.fn();
+vi.mock('../api/_lib/r2.js', () => ({ getPublicObjectBuffer: (...a) => readManifest(...a) }));
const { default: handler } = await import('../api/objects/library.js');
@@ -62,7 +62,7 @@ const OBJECT = {
describe('GET /api/objects/library', () => {
it('returns an empty library when the manifest has not been uploaded yet', async () => {
const missing = Object.assign(new Error('no such key'), { name: 'NoSuchKey' });
- getObjectBuffer.mockRejectedValue(missing);
+ readManifest.mockRejectedValue(missing);
const { res, body } = await get();
expect(res.statusCode).toBe(200);
expect(body).toEqual({ objects: [], total: 0, generated_at: null });
@@ -72,7 +72,7 @@ describe('GET /api/objects/library', () => {
});
it('degrades to an empty library on storage errors without caching the emptiness', async () => {
- getObjectBuffer.mockRejectedValue(new Error('socket hang up'));
+ readManifest.mockRejectedValue(new Error('socket hang up'));
const { res, body } = await get();
expect(res.statusCode).toBe(200);
expect(body.objects).toEqual([]);
@@ -80,7 +80,7 @@ describe('GET /api/objects/library', () => {
});
it('passes through a published { objects } manifest and derives total', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from(JSON.stringify({
+ readManifest.mockResolvedValue(Buffer.from(JSON.stringify({
generated_at: '2026-07-21T13:16:14.305Z',
total: 1,
objects: [OBJECT],
@@ -94,13 +94,13 @@ describe('GET /api/objects/library', () => {
});
it('accepts a bare-array manifest shape', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from(JSON.stringify([OBJECT])));
+ readManifest.mockResolvedValue(Buffer.from(JSON.stringify([OBJECT])));
const { body } = await get();
expect(body.objects).toEqual([OBJECT]);
});
it('rejects non-GET methods', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from('[]'));
+ readManifest.mockResolvedValue(Buffer.from('[]'));
const res = fakeRes();
await handler(fakeReq('POST'), res);
expect(res.statusCode).toBe(405);
@@ -108,7 +108,7 @@ describe('GET /api/objects/library', () => {
// ── Bounded pagination (opt-in via ?limit) ──────────────────────────────
const OBJECTS = Array.from({ length: 5 }, (_, i) => ({ ...OBJECT, name: `prop-${i}` }));
- const publish = () => getObjectBuffer.mockResolvedValue(Buffer.from(JSON.stringify({ objects: OBJECTS })));
+ const publish = () => readManifest.mockResolvedValue(Buffer.from(JSON.stringify({ objects: OBJECTS })));
it('pages a large manifest with ?limit and exposes next_offset', async () => {
publish();
@@ -184,15 +184,15 @@ describe('GET /api/objects/library', () => {
// added latency on every client-side pagination bug.
it('rejects a malformed cursor without touching storage', async () => {
publish();
- getObjectBuffer.mockClear();
+ readManifest.mockClear();
const { res } = await get('?limit=abc');
expect(res.statusCode).toBe(400);
- expect(getObjectBuffer).not.toHaveBeenCalled();
+ expect(readManifest).not.toHaveBeenCalled();
});
// ── Corrupt manifests are an outage, not an empty library ────────────────
it('degrades without caching when the manifest is not valid JSON', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from('{"objects": [truncated'));
+ readManifest.mockResolvedValue(Buffer.from('{"objects": [truncated'));
const { res, body } = await get();
expect(res.statusCode).toBe(200);
expect(body.objects).toEqual([]);
@@ -203,7 +203,7 @@ describe('GET /api/objects/library', () => {
// Parses fine, but a `null` / wrong-shape body means a bad upload, and
// caching "no objects" for 300s would outlive the bad upload.
for (const bad of ['null', '{"objects":"nope"}', '"a string"']) {
- getObjectBuffer.mockResolvedValue(Buffer.from(bad));
+ readManifest.mockResolvedValue(Buffer.from(bad));
const { res, body } = await get();
expect(res.statusCode).toBe(200);
expect(body.objects).toEqual([]);
@@ -213,14 +213,14 @@ describe('GET /api/objects/library', () => {
});
it('keeps the normal cache for a manifest that is legitimately empty', async () => {
- getObjectBuffer.mockResolvedValue(Buffer.from('{"objects":[]}'));
+ readManifest.mockResolvedValue(Buffer.from('{"objects":[]}'));
const { res, body } = await get();
expect(body.objects).toEqual([]);
expect(res.getHeader('cache-control')).toContain('s-maxage=300');
});
it('does not cache a degraded response on the paginated path either', async () => {
- getObjectBuffer.mockRejectedValue(new Error('socket hang up'));
+ readManifest.mockRejectedValue(new Error('socket hang up'));
const { res, body } = await get('?limit=2');
expect(res.statusCode).toBe(200);
expect(body.objects).toEqual([]);
diff --git a/tests/r2-public-object-fallback.test.js b/tests/r2-public-object-fallback.test.js
new file mode 100644
index 000000000..d45ed44a0
--- /dev/null
+++ b/tests/r2-public-object-fallback.test.js
@@ -0,0 +1,107 @@
+/**
+ * getPublicObjectBuffer() reads an object whose bytes are public anyway (a CC0
+ * library manifest, a rendered thumbnail) with the signed S3 read first and the
+ * bucket's own public CDN domain as the fallback.
+ *
+ * It exists because of a live outage: on 2026-09-09 the production S3 secret
+ * stopped matching its access key id, every signed GET came back
+ * SignatureDoesNotMatch, and /objects, /character-library, the animation clips
+ * and the asset catalogue behind the agent tools all read as empty, while the
+ * exact same manifests stayed downloadable by anyone on the public domain those
+ * manifests already hand out. A credential fault must not be able to empty a
+ * route that serves public bytes.
+ *
+ * The signed read stays FIRST (it is authoritative and sees a publish the
+ * instant it lands), and a failure of both paths must rethrow the SIGNED error,
+ * because the library endpoints branch on NoSuchKey to tell "not uploaded yet"
+ * apart from "storage is broken".
+ */
+import { describe, it, expect, beforeAll, afterEach, vi } from 'vitest';
+
+const send = vi.fn();
+vi.mock('@aws-sdk/client-s3', () => {
+ class Cmd { constructor(input) { this.input = input; } }
+ return {
+ S3Client: class { send(...a) { return send(...a); } },
+ GetObjectCommand: Cmd,
+ PutObjectCommand: Cmd,
+ DeleteObjectCommand: Cmd,
+ HeadObjectCommand: Cmd,
+ CopyObjectCommand: Cmd,
+ ListObjectsV2Command: Cmd,
+ };
+});
+vi.mock('@aws-sdk/s3-request-presigner', () => ({ getSignedUrl: async () => 'https://signed.example/x' }));
+
+beforeAll(() => {
+ Object.assign(process.env, {
+ S3_ENDPOINT: 'https://s3.example.com',
+ S3_BUCKET: 'test-bucket',
+ S3_PUBLIC_DOMAIN: 'https://cdn.example.com',
+ S3_ACCESS_KEY_ID: 'test-key',
+ S3_SECRET_ACCESS_KEY: 'test-secret',
+ });
+});
+
+const { getPublicObjectBuffer } = await import('../api/_lib/r2.js');
+
+const KEY = 'objects/library/manifest.json';
+
+function signedBody(text) {
+ return { Body: (async function* () { yield Buffer.from(text, 'utf8'); })() };
+}
+function signatureError() {
+ const err = new Error('The request signature we calculated does not match the signature you provided.');
+ err.name = 'SignatureDoesNotMatch';
+ err.$metadata = { httpStatusCode: 403 };
+ return err;
+}
+function noSuchKey() {
+ const err = new Error('NoSuchKey');
+ err.name = 'NoSuchKey';
+ err.$metadata = { httpStatusCode: 404 };
+ return err;
+}
+
+afterEach(() => {
+ send.mockReset();
+ vi.unstubAllGlobals();
+});
+
+describe('getPublicObjectBuffer', () => {
+ it('uses the signed read and never touches the network when it succeeds', async () => {
+ send.mockResolvedValueOnce(signedBody('{"objects":[1]}'));
+ const fetchSpy = vi.fn();
+ vi.stubGlobal('fetch', fetchSpy);
+
+ expect((await getPublicObjectBuffer(KEY)).toString('utf8')).toBe('{"objects":[1]}');
+ expect(fetchSpy).not.toHaveBeenCalled();
+ });
+
+ it('falls back to the public CDN when the credential is rejected', async () => {
+ send.mockRejectedValueOnce(signatureError());
+ const fetchSpy = vi.fn(async () => ({ ok: true, arrayBuffer: async () => Buffer.from('{"objects":[2]}') }));
+ vi.stubGlobal('fetch', fetchSpy);
+
+ expect((await getPublicObjectBuffer(KEY)).toString('utf8')).toBe('{"objects":[2]}');
+ expect(fetchSpy.mock.calls[0][0]).toBe(`https://cdn.example.com/${KEY}`);
+ });
+
+ // The endpoints read NoSuchKey as "the manifest has not been published yet"
+ // and serve a cacheable empty library for it. If a CDN 404 surfaced as its
+ // own error instead, that branch would stop matching and a pre-launch
+ // library would start logging and answering as a storage outage.
+ it('rethrows the signed NoSuchKey when the CDN also has nothing', async () => {
+ send.mockRejectedValueOnce(noSuchKey());
+ vi.stubGlobal('fetch', vi.fn(async () => ({ ok: false, status: 404, arrayBuffer: async () => Buffer.alloc(0) })));
+
+ await expect(getPublicObjectBuffer(KEY)).rejects.toMatchObject({ name: 'NoSuchKey' });
+ });
+
+ it('rethrows the signed error when the public fetch itself throws', async () => {
+ send.mockRejectedValueOnce(signatureError());
+ vi.stubGlobal('fetch', vi.fn(async () => { throw new Error('getaddrinfo ENOTFOUND'); }));
+
+ await expect(getPublicObjectBuffer(KEY)).rejects.toMatchObject({ name: 'SignatureDoesNotMatch' });
+ });
+});