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(avatar-gallery-picker): give the grid a real load-failure state with a retry

nirholas5763ec455b32
diff --git a/src/avatar-gallery-picker.css b/src/avatar-gallery-picker.css
index e041ab8f7..1f84052e2 100644
--- a/src/avatar-gallery-picker.css
+++ b/src/avatar-gallery-picker.css
@@ -437,6 +437,35 @@
line-height: 1.5;
}
.agp-error { color: var(--danger, #f87171); border-color: rgba(248, 113, 113, 0.2); }
+.agp-error-title {
+ margin: 0 0 6px;
+ font-weight: 600;
+ font-size: 14px;
+}
+.agp-error-detail {
+ margin: 0 auto 14px;
+ max-width: 42ch;
+ color: var(--ink-dim, #888888);
+}
+.agp-error-retry {
+ font: inherit;
+ color: var(--ink, #fafafa);
+ background: rgba(255, 255, 255, 0.06);
+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.16));
+ border-radius: 8px;
+ padding: 7px 16px;
+ cursor: pointer;
+ transition: background 140ms ease, border-color 140ms ease;
+}
+.agp-error-retry:hover {
+ background: rgba(255, 255, 255, 0.12);
+ border-color: rgba(255, 255, 255, 0.28);
+}
+.agp-error-retry:active { transform: translateY(1px); }
+.agp-error-retry:focus-visible {
+ outline: 2px solid var(--ink, #fafafa);
+ outline-offset: 2px;
+}
/* ── Load more ──────────────────────────────────────────────────────── */
diff --git a/src/avatar-gallery-picker.js b/src/avatar-gallery-picker.js
index 81057d678..6020a7d1f 100644
--- a/src/avatar-gallery-picker.js
+++ b/src/avatar-gallery-picker.js
@@ -411,10 +411,7 @@ export class AvatarGalleryPicker {
} catch (err) {
if (this._state.totalLoaded === 0) {
this._els.grid.innerHTML = '';
- const errDiv = document.createElement('div');
- errDiv.className = 'agp-error';
- errDiv.textContent = `Failed to load: ${err.message}`;
- this._els.grid.appendChild(errDiv);
+ this._els.grid.appendChild(this._errorState(err));
}
} finally {
this._state.loading = false;
@@ -422,6 +419,38 @@ export class AvatarGalleryPicker {
}
}
+ // A dead "Failed to load: Failed to fetch" left the only path out of the
+ // picker as closing it. Say what happened in plain words and offer the retry.
+ _errorState(err) {
+ const box = document.createElement('div');
+ box.className = 'agp-error';
+ box.setAttribute('role', 'alert');
+
+ const title = document.createElement('p');
+ title.className = 'agp-error-title';
+ title.textContent = 'Could not load avatars';
+ box.appendChild(title);
+
+ const detail = document.createElement('p');
+ detail.className = 'agp-error-detail';
+ detail.textContent = /failed to fetch|networkerror|load failed/i.test(err?.message || '')
+ ? 'The request did not reach three.ws. Check your connection, then try again.'
+ : `The avatar service answered with ${err?.message || 'an unexpected error'}.`;
+ box.appendChild(detail);
+
+ const retry = document.createElement('button');
+ retry.type = 'button';
+ retry.className = 'agp-error-retry';
+ retry.textContent = 'Try again';
+ retry.addEventListener('click', () => {
+ this._els.grid.innerHTML = '';
+ this._renderSkeletons(6);
+ this._loadPage();
+ });
+ box.appendChild(retry);
+ return box;
+ }
+
_hydratePreselection() {
if (!this.opts.selectedId || this._state.selected) return;
const match = this._state.cardsById.get(this.opts.selectedId);