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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(avatar): add queueRestyle function to re-render outdated avatar thumbnails
nirholas34fd5dfc32b0
diff --git a/api/_lib/avatar-thumbs.js b/api/_lib/avatar-thumbs.jsindex c55dd92d8..fb31d35b9 100644--- a/api/_lib/avatar-thumbs.js+++ b/api/_lib/avatar-thumbs.js@@ -322,6 +322,40 @@ export async function renderBatch({ limit = 5, concurrency = 1, onResult } = {})};}+// Restyle: re-queue avatars whose poster was baked by an older renderer (flat+// dark background, dead-on camera) so the normal claim/render path re-renders+// them with the current look. Only server-rendered keys (`thumb/<uuid>.png`,+// exactly what thumbKeyFor writes) are cleared — client-uploaded customizer+// snapshots and adopted forge previews are user/creation content, never touched.+// While a key is cleared the card falls back to /api/avatars/:id/og, which+// renders on demand with the current pipeline, so the surface never goes blank.+// Most-viewed public avatars first, same priority as the claim query.+export async function queueRestyle({ limit = 100 } = {}) {+ const rows = await sql`+ WITH victims AS (+ SELECT id FROM avatars+ WHERE deleted_at IS NULL+ AND storage_key IS NOT NULL+ AND thumbnail_key ~ '^thumb/[0-9a-f-]{36}\\.png$'+ ORDER BY featured DESC, (visibility = 'public') DESC,+ view_count DESC NULLS LAST, created_at DESC+ LIMIT ${limit}+ )+ UPDATE avatars a+ SET thumbnail_key = NULL, updated_at = now()+ FROM victims v+ WHERE a.id = v.id+ RETURNING a.id+ `;+ // A cleared avatar may sit in the ledger as retired from an old failure;+ // wipe those rows so the re-render is not silently skipped.+ if (rows.length) {+ const ids = rows.map((r) => r.id);+ await sql`DELETE FROM avatar_thumbnail_backfill WHERE avatar_id = any(${ids}::uuid[])`.catch(() => {});+ }+ return { queued: rows.length };+}+// Repair: forget every ledger row whose failure was the browser dying rather than// the model being bad. A row's absence means "never attempted", so the avatar// re-enters the candidate set with a clean slate.diff --git a/scripts/backfill-avatar-thumbnails.mjs b/scripts/backfill-avatar-thumbnails.mjsindex b7ac6f525..56be24727 100644--- a/scripts/backfill-avatar-thumbnails.mjs+++ b/scripts/backfill-avatar-thumbnails.mjs@@ -39,6 +39,11 @@* (an OOM-killed chromium fails every render in the batch* with "Connection closed."; genuinely broken models record a* model-attributable error and are never reset)+ * --restyle=N re-queue up to N posters baked by an older renderer so+ * they re-render with the current camera/backdrop. Only+ * server-rendered thumb/<uuid>.png keys are cleared; user+ * snapshots and forge previews are never touched. Run after+ * deploying a renderer change, with --limit sized to match.** Unlike the previous version this talks to Postgres + R2 directly, so it needs* no ADMIN_BEARER and no running server.@@ -50,6 +55,7 @@ import {coverage,ensureBackfillSchema,resetInfrastructureFailures,+ queueRestyle,MAX_ATTEMPTS,} from '../api/_lib/avatar-thumbs.js';@@ -99,6 +105,16 @@ async function main() {await printCoverage('after reset');}+ // Re-queue posters baked by an older renderer (flat dark background, dead-on+ // camera) so this run re-renders them with the current look. Only clears+ // server-rendered thumb/<uuid>.png keys — user-uploaded snapshots and forge+ // previews are never touched. Run AFTER deploying a renderer change; pair+ // with --limit sized to match.+ if (num('restyle', 0) > 0) {+ const { queued } = await queueRestyle({ limit: num('restyle', 0) });+ console.log(`[backfill] restyle: cleared ${queued} old server-rendered poster(s) for re-render`);+ }+// ── Phase 1: free adoption ────────────────────────────────────────────────if (!RENDER_ONLY) {let totalAdopted = 0;