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
fix(atlas): design the state where the route index loads but describes nothing
nirholas63109e731185
diff --git a/pages/atlas.html b/pages/atlas.htmlindex 9c155dfbb..83d28bc9d 100644--- a/pages/atlas.html+++ b/pages/atlas.html@@ -80,7 +80,13 @@gap: 10px;padding: 12px 14px;margin: 0 0 var(--space-md);- background: var(--surface-1);+ /* Sticky, so it MUST be opaque: --surface-1 is a 3% white wash and on+ its own let every scrolled card read straight through the search+ box. Painting the wash over the page background keeps the intended+ tint in both themes and hides what passes underneath. */+ background:+ linear-gradient(var(--surface-1), var(--surface-1)),+ var(--bg-0);border: 1px solid var(--stroke-strong);border-radius: var(--radius-lg);}@@ -95,6 +101,12 @@}.at-search input {flex: 1;+ /* body is a flex column site-wide, so <main> is shrink-to-fit and can+ never render narrower than its own min-content. A text input carries+ a `size`-derived intrinsic width that min-width:0 does not clear, and+ it dragged the whole page 7px past a 320px viewport. width:0 drops+ that contribution; flex:1 grows the field back to fill the row. */+ width: 0;min-width: 0;background: none;border: 0;@@ -155,7 +167,8 @@/* Intent cards */.at-intents {display: grid;- grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));+ /* min() so a 280px track never outgrows a 320px phone viewport. */+ grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));gap: 12px;margin: 0 0 calc(var(--space-md) * 2);}@@ -239,7 +252,7 @@}.at-grid {display: grid;- grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));+ grid-template-columns: repeat(auto-fill, minmax(min(268px, 100%), 1fr));gap: 2px;}.at-card {diff --git a/public/atlas.js b/public/atlas.jsindex 5c628128e..60fbbbe4c 100644--- a/public/atlas.js+++ b/public/atlas.js@@ -655,28 +655,39 @@ import { rankPages, rankIntents, highlight } from './atlas/score.js';return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT';}+ // Cmd/Ctrl+K belongs to Atlas everywhere, so it is claimed in the capture+ // phase before any page can intercept it.document.addEventListener('keydown',function (e) {if (e.defaultPrevented) return;var mod = e.metaKey || e.ctrlKey;- if (mod && !e.altKey && (e.key === 'k' || e.key === 'K')) {- e.preventDefault();- if (open) close();- else show('');- return;- }- if (open) return;- // "/" is the other muscle-memory shortcut, but only when the visitor- // is not already typing somewhere. Never steal it from a form.- if (e.key === '/' && !mod && !e.altKey && !isTypingTarget(e.target)) {- e.preventDefault();- show('');- }+ if (!mod || e.altKey) return;+ if (e.key !== 'k' && e.key !== 'K') return;+ e.preventDefault();+ if (open) close();+ else show('');},true,);+ // "/" is the other muscle-memory shortcut, but it is shared: ~20 pages bind+ // it to focus their own search or address field, and the page's field is+ // what a visitor on that page means by "/". This listener therefore runs in+ // the BUBBLE phase (no capture flag) and Atlas is injected last on the page,+ // so every page-level document listener has already had its turn; a page+ // that handled "/" leaves defaultPrevented set and Atlas stands down. In the+ // capture phase Atlas won unconditionally and those page shortcuts were dead+ // on arrival, including the "Press / to focus" hint printed on /airdrops.+ document.addEventListener('keydown', function (e) {+ if (e.defaultPrevented || open) return;+ var mod = e.metaKey || e.ctrlKey;+ // Never steal it from a form.+ if (e.key !== '/' || mod || e.altKey || isTypingTarget(e.target)) return;+ e.preventDefault();+ show('');+ });+// Any element on any page can open Atlas by declaring itself.document.addEventListener('click', function (e) {var trigger = e.target.closest && e.target.closest('[data-atlas-open]');diff --git a/src/atlas-page.js b/src/atlas-page.jsindex bd0488f61..f96c18e10 100644--- a/src/atlas-page.js+++ b/src/atlas-page.js@@ -114,11 +114,37 @@ function sectionPages(id) {return index.pages.filter((p) => p[3] === id);}+/**+ * The designed state for "the index loaded, but it describes nothing". It is+ * reachable in practice: a build that ships an index generated from an empty or+ * partial route table serves a valid 200 with zero pages, and without this the+ * page renders a headline over a void with no way forward.+ */+function renderEmpty() {+ const state = el('div', 'at-state');+ state.appendChild(el('strong', null, 'The map is empty'));+ state.appendChild(+ document.createTextNode('This build shipped a route index with no pages in it. '),+ );+ const link = el('a', null, 'The sitemap');+ link.href = '/sitemap';+ state.appendChild(link);+ state.appendChild(document.createTextNode(' is generated separately and still lists every page.'));+ $body.appendChild(state);+ $live.textContent = 'The route index is empty. Use the sitemap instead.';+}+/** Grouped browse view: every section, every page. */function renderBrowse() {$body.textContent = '';renderRail(null);+ if (!index.pages.length) {+ $intentsWrap.hidden = true;+ renderEmpty();+ return;+ }+for (const section of index.sections) {const pages = sectionPages(section.id);if (!pages.length) continue;@@ -142,10 +168,10 @@ function renderBrowse() {$body.appendChild(wrap);}- $intentsWrap.hidden = false;$intents.textContent = '';+ $intentsWrap.hidden = index.intents.length === 0;for (const intent of index.intents) $intents.appendChild(intentCard(intent));- $intentCount.textContent = `${index.intents.length} shortcuts`;+ $intentCount.textContent = `${index.intents.length} ${index.intents.length === 1 ? 'shortcut' : 'shortcuts'}`;$live.textContent = `${index.pageCount} pages across ${index.sections.length} sections.`;watchSections();@@ -273,6 +299,10 @@ $clear.addEventListener('click', () => {syncUrl();});+// The skeletons say "loading" to anyone who can see them. The live region is+// the same message for anyone who cannot.+$live.textContent = 'Loading the map.';+fetch(INDEX_URL, { credentials: 'omit' }).then((r) => {if (!r.ok) throw new Error(`atlas index ${r.status}`);diff --git a/tests/atlas.test.js b/tests/atlas.test.jsindex 6a743593f..fc587962d 100644--- a/tests/atlas.test.js+++ b/tests/atlas.test.js@@ -27,6 +27,35 @@ import { shouldInject, injectInto, ATLAS_TAG } from '../scripts/inject-atlas.mjsconst root = resolve(import.meta.dirname, '..');const index = JSON.parse(readFileSync(resolve(root, 'public/atlas-index.json'), 'utf8'));+/**+ * Every `document.addEventListener('keydown', …)` call in a source file, with+ * its handler body and whether it asked for the capture phase. Depth-aware so a+ * handler containing its own parens and commas is read whole.+ * @param {string} src+ * @returns {Array<{ body: string, capture: boolean }>}+ */+function keydownRegistrations(src) {+ const out = [];+ const OPEN = "document.addEventListener(";+ for (let i = src.indexOf(OPEN); i !== -1; i = src.indexOf(OPEN, i + 1)) {+ let depth = 0;+ let end = -1;+ for (let j = i + OPEN.length - 1; j < src.length; j++) {+ const ch = src[j];+ if (ch === '(') depth++;+ else if (ch === ')') {+ depth--;+ if (depth === 0) { end = j; break; }+ }+ }+ if (end === -1) continue;+ const args = src.slice(i + OPEN.length, end);+ if (!/^\s*'keydown'/.test(args)) continue;+ out.push({ body: args, capture: /,\s*true\s*,?\s*$/.test(args) });+ }+ return out;+}+/** First result's path for a query, which is the only rank most people ever see. */const top = (q) => rankPages(q, index.pages)[0]?.page[0];const paths = (q, n = 5) => rankPages(q, index.pages).slice(0, n).map((r) => r.page[0]);@@ -239,6 +268,26 @@ describe('injection coverage', () => {}});+ it('leaves "/" to the page and keeps Cmd+K for itself', () => {+ // Atlas used to claim "/" in the CAPTURE phase, which beat every page+ // listener no matter when it registered. ~20 pages bind "/" to focus their+ // own search or address field (/airdrops even prints "Press / to focus"+ // under its form), and all of them were dead on arrival. "/" now listens in+ // the bubble phase so a page that handled it leaves defaultPrevented set+ // and Atlas stands down; Cmd+K stays in capture because it belongs to+ // Atlas everywhere.+ const src = readFileSync(resolve(root, 'public/atlas.js'), 'utf8');+ const calls = keydownRegistrations(src);+ expect(calls.length, 'atlas registers exactly two keydown listeners').toBe(2);+ const slash = calls.find((c) => c.body.includes("e.key !== '/'") || c.body.includes("e.key === '/'"));+ const cmdK = calls.find((c) => /e\.key (!==|===) 'k'/.test(c.body));+ expect(slash, 'a "/" keydown listener').toBeTruthy();+ expect(cmdK, 'a Cmd+K keydown listener').toBeTruthy();+ expect(slash.capture, '"/" must NOT be captured, or page shortcuts never fire').toBe(false);+ expect(cmdK.capture, 'Cmd+K stays in the capture phase').toBe(true);+ expect(slash.body, '"/" handler must yield to a page that already handled it').toContain('defaultPrevented');+ });+it('is wired into the build, not just available to it', () => {// The first release of Atlas was complete and loaded by nothing. This test// is the reason that cannot happen twice.