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.

Make the dashboard Avatars Community tab deep-linkable

nirholasc82bf0342cf9
diff --git a/src/dashboard-next/pages/avatars.js b/src/dashboard-next/pages/avatars.js
index 748de5c1e..e531a0406 100644
--- a/src/dashboard-next/pages/avatars.js
+++ b/src/dashboard-next/pages/avatars.js
@@ -34,6 +34,7 @@ const integerNum = new Intl.NumberFormat('en');
const state = {
tab: /** @type {'mine'|'community'} */ ('mine'),
all: /** @type {any[]} */ ([]),
+ loaded: false,
nextCursor: /** @type {string|null} */ (null),
loadingMore: false,
filter: { q: '', visibility: 'all', sort: 'newest' },
@@ -134,9 +135,25 @@ const state = {
wireFilters(main);
wireCommunityFilters(main);
wireNewMenu(main);
- await loadInitial(main);
+
+ // Deep-link support: /dashboard/avatars#community opens straight on the
+ // Community tab (shareable / bookmarkable), and back/forward navigation
+ // between the two tabs works via hashchange.
+ window.addEventListener('hashchange', () => {
+ switchTab(main, tabFromHash());
+ });
+
+ if (tabFromHash() === 'community') {
+ switchTab(main, 'community');
+ } else {
+ await loadInitial(main);
+ }
})();
+function tabFromHash() {
+ return (location.hash || '').replace('#', '') === 'community' ? 'community' : 'mine';
+}
+
// ── Tab switching ────────────────────────────────────────────────────────
function wireTabs(root) {
@@ -179,6 +196,12 @@ function switchTab(root, tab) {
const grid = root.querySelector('[data-grid]');
grid.dataset.ids = '';
+ // Reflect the active tab in the URL without adding history noise per click.
+ const targetHash = isCommunity ? '#community' : '';
+ if ((location.hash || '') !== targetHash) {
+ history.replaceState(null, '', `${location.pathname}${location.search}${targetHash}`);
+ }
+
if (isCommunity) {
if (state.community.loaded) {
renderCommunityGrid(root);
@@ -188,8 +211,12 @@ function switchTab(root, tab) {
}
} else {
teardownCommunityObserver();
- renderGrid(root);
- setupLoadMore(root);
+ if (state.loaded) {
+ renderGrid(root);
+ setupLoadMore(root);
+ } else {
+ loadInitial(root);
+ }
}
}
@@ -204,6 +231,7 @@ async function loadInitial(root) {
const data = await get(`/api/avatars?limit=${PAGE_SIZE}`);
state.all = Array.isArray(data?.avatars) ? data.avatars : [];
state.nextCursor = data?.next_cursor || null;
+ state.loaded = true;
renderGrid(root);
setupLoadMore(root);
} catch (err) {