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(airdrops): keep the filter chips honest and give the address field its promised shortcut

nirholas688b2d86e54a
diff --git a/pages/airdrops.html b/pages/airdrops.html
index 556b407bf..91777d3d3 100644
--- a/pages/airdrops.html
+++ b/pages/airdrops.html
@@ -129,7 +129,7 @@
<div class="ad-feed-head">
<h2 class="ad-section-h">Programs</h2>
- <div class="ad-filters" role="tablist" aria-label="Filter by eligibility">
+ <div class="ad-filters" role="group" aria-label="Filter by eligibility">
<button type="button" class="ad-filter active" data-filter="all" aria-pressed="true">All</button>
<button type="button" class="ad-filter" data-filter="qualified" aria-pressed="false">Qualified</button>
<button type="button" class="ad-filter" data-filter="in_progress" aria-pressed="false">In progress</button>
diff --git a/src/airdrops.css b/src/airdrops.css
index 09b2fdf21..25fbab8c7 100644
--- a/src/airdrops.css
+++ b/src/airdrops.css
@@ -29,6 +29,25 @@
border: 0;
}
+/* One designed focus ring for every interactive element on the page, in the
+ * page's own accent language rather than whatever ring the browser happens to
+ * ship. Keyboard-only (:focus-visible), so pointer users never see it. */
+.ad-go:focus-visible,
+.ad-filter:focus-visible,
+.ad-chip-btn:focus-visible,
+.ad-recent-chip:focus-visible,
+.ad-card-src:focus-visible,
+.ad-form-hint a:focus-visible {
+ outline: 2px solid var(--cv-accent, #60a5fa);
+ outline-offset: 2px;
+ border-radius: var(--cv-radius-sm, 4px);
+}
+.ad-filter:focus-visible,
+.ad-chip-btn:focus-visible,
+.ad-recent-chip:focus-visible {
+ border-radius: 999px;
+}
+
/* ---------------- Hero + form (mirrors the portfolio page) ---------------- */
.ad-hero { max-width: 46rem; }
@@ -368,7 +387,11 @@
.ad-grid {
display: grid;
- grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
+ /* min(20rem, 100%) and not a bare 20rem: at 320px the container's inner
+ width is narrower than the 20rem track, so a bare minimum builds a track
+ wider than its own container and the right edge of every card (status
+ pill, score number) is clipped off screen. */
+ grid-template-columns: repeat(auto-fill, minmax(min(20rem, 100%), 1fr));
gap: 0.9rem;
}
.ad-card {
@@ -496,13 +519,34 @@
color: var(--cv-text-2, #a1a1aa);
margin: 0.2rem 0 0.9rem;
}
-.ad-empty-filter {
+/* One empty-state treatment, used wherever a grid comes back with nothing:
+ * a filter bucket with no programs, or a registry that returned zero entries. */
+.ad-empty {
font-size: 0.8rem;
color: var(--cv-text-3, #64748b);
padding: 1.2rem;
text-align: center;
+ line-height: 1.6;
border: 1px dashed var(--cv-border, #27272a);
border-radius: var(--cv-radius-md, 8px);
+ grid-column: 1 / -1;
+}
+.ad-empty b { color: var(--cv-text-2, #a1a1aa); font-weight: 600; }
+.ad-empty button {
+ font: inherit;
+ font-size: 0.78rem;
+ color: var(--cv-accent, #60a5fa);
+ background: none;
+ border: none;
+ padding: 0;
+ cursor: pointer;
+ text-decoration: underline;
+}
+.ad-empty button:hover { color: var(--cv-text, #fafafa); }
+.ad-empty button:focus-visible {
+ outline: 2px solid var(--cv-accent, #60a5fa);
+ outline-offset: 2px;
+ border-radius: var(--cv-radius-sm, 4px);
}
/* ---------------- States ---------------- */
diff --git a/src/airdrops.js b/src/airdrops.js
index 19a5617b7..097333c53 100644
--- a/src/airdrops.js
+++ b/src/airdrops.js
@@ -94,8 +94,16 @@ async function loadDirectory() {
const res = await fetch('/api/crypto/airdrops', { headers: { accept: 'application/json' } });
const body = await res.json().catch(() => null);
if (!res.ok) return renderError(res.status, body);
- $('ad-dir-sub').textContent = `${body.registry.length} programs · registry updated ${body.updated}`;
- $('ad-dir-grid').innerHTML = body.registry.map((e) => directoryCard(e)).join('');
+ const entries = Array.isArray(body?.registry) ? body.registry : [];
+ $('ad-dir-sub').textContent = entries.length
+ ? `${entries.length} programs · registry updated ${body.updated}`
+ : `registry updated ${body.updated}`;
+ $('ad-dir-grid').innerHTML = entries.length
+ ? entries.map((e) => directoryCard(e)).join('')
+ : `<p class="ad-empty"><b>No programs are being tracked right now.</b><br />
+ The registry is between updates. You can still scan a wallet: paste an address above and the
+ scan reports its measured on-chain activity, or open the
+ <a class="ad-card-src" href="/portfolio">wallet portfolio</a> for balances.</p>`;
show('directory');
enterStagger($('ad-dir-grid').children);
} catch (err) {
@@ -146,7 +154,6 @@ async function lookup(address, { push = true } = {}) {
return;
}
state.data = body;
- state.filter = 'all';
saveRecent(address);
renderReport(body);
show('report');
@@ -207,7 +214,9 @@ function renderReport(d) {
$('ad-c-tracked').textContent = d.summary.tracked;
renderActivity(d);
- renderCards();
+ // setFilter, not renderCards: a new wallet resets the bucket to All, and the
+ // filter chips have to follow it or they claim a filter that is not applied.
+ setFilter('all');
renderOtherFamily(d);
$('ad-report-fineprint').textContent =
@@ -274,13 +283,28 @@ function renderCards() {
: d.opportunities.filter((o) => o.eligibility === state.filter);
const grid = $('ad-grid');
if (!list.length) {
- grid.innerHTML = `<p class="ad-empty-filter">No programs in this bucket for this wallet. Try another filter.</p>`;
+ grid.innerHTML = d.opportunities.length
+ ? `<p class="ad-empty">No programs scored <b>${escapeHtml(eligLabel(state.filter).replace('✓ ', ''))}</b> for this wallet.
+ <button type="button" data-clear-filter>Show all ${d.opportunities.length} programs</button></p>`
+ : `<p class="ad-empty"><b>No programs are tracked for this chain yet.</b><br />
+ Nothing in the registry targets ${escapeHtml(d.family === 'solana' ? 'Solana' : 'EVM')} wallets right now.
+ The measured activity above is still real, and the other chain family is listed below.</p>`;
return;
}
grid.innerHTML = list.map((o) => opportunityCard(o)).join('');
enterStagger(grid.children);
}
+function setFilter(name) {
+ state.filter = name;
+ document.querySelectorAll('.ad-filter').forEach((b) => {
+ const on = b.dataset.filter === name;
+ b.classList.toggle('active', on);
+ b.setAttribute('aria-pressed', String(on));
+ });
+ if (state.data) renderCards();
+}
+
function opportunityCard(o) {
const nextStep = o.missing.find((m) => !m.unknown)?.recommendation || o.missing[0]?.recommendation || null;
return `<article class="ad-card">
@@ -364,19 +388,20 @@ function init() {
});
$('ad-retry').addEventListener('click', () => {
- if (state.address) lookup(state.address);
+ // Prefer whatever is in the field: after a bad-address error the visitor
+ // fixes it there, and retrying the old address would ignore the fix.
+ const typed = $('ad-address').value.trim();
+ if (typed && detectFamily(typed)) lookup(typed);
+ else if (state.address) lookup(state.address);
else loadDirectory();
});
document.querySelectorAll('.ad-filter').forEach((btn) => {
- btn.addEventListener('click', () => {
- state.filter = btn.dataset.filter;
- document.querySelectorAll('.ad-filter').forEach((b) => {
- b.classList.toggle('active', b === btn);
- b.setAttribute('aria-pressed', String(b === btn));
- });
- if (state.data) renderCards();
- });
+ btn.addEventListener('click', () => setFilter(btn.dataset.filter));
+ });
+
+ $('ad-grid').addEventListener('click', (e) => {
+ if (e.target.closest('[data-clear-filter]')) setFilter('all');
});
$('ad-copy-addr').addEventListener('click', () => {
@@ -386,17 +411,34 @@ function init() {
copyWithFeedback($('ad-share'), location.href, 'Link copied');
});
+ // "/" focuses the address field, as the hint under the form promises. The
+ // preventDefault is what tells the site-wide Atlas palette to stand down:
+ // it also listens for "/" and opens the search dialog when no page claimed
+ // the key first. Modified presses and typing targets are left alone.
document.addEventListener('keydown', (e) => {
- if (e.key === '/' && !/^(input|textarea|select)$/i.test(document.activeElement?.tagName || '')) {
- e.preventDefault();
- $('ad-address').focus();
- }
+ if (e.key !== '/' || e.metaKey || e.ctrlKey || e.altKey) return;
+ const target = e.target instanceof Element ? e.target : document.activeElement;
+ if (target?.isContentEditable) return;
+ if (/^(input|textarea|select)$/i.test(target?.tagName || '')) return;
+ e.preventDefault();
+ $('ad-address').focus();
});
const params = new URLSearchParams(location.search);
const address = (params.get('address') || '').trim();
- if (address && detectFamily(address)) lookup(address, { push: false });
- else loadDirectory();
+ if (address && detectFamily(address)) {
+ lookup(address, { push: false });
+ } else if (address) {
+ // A shared link with a broken address: keep what the visitor arrived with
+ // in the field and say why nothing was scanned, rather than silently
+ // dropping it and showing the directory as though no address was given.
+ $('ad-address').value = address;
+ renderError(400, {
+ message: 'The address in this link is not a valid Solana or Ethereum address. Fix it above and check again.',
+ });
+ } else {
+ loadDirectory();
+ }
}
init();
diff --git a/tests/airdrops-page.test.js b/tests/airdrops-page.test.js
index b6d1ef5dd..41ad169e7 100644
--- a/tests/airdrops-page.test.js
+++ b/tests/airdrops-page.test.js
@@ -133,6 +133,43 @@ describe('page structure', () => {
expect(js).toContain("show('directory')");
});
+ it('designs an empty state for every grid that can come back empty', () => {
+ // Both grids can legitimately render zero cards: a registry between
+ // updates, and a filter bucket no program landed in. Neither may leave a
+ // blank void where the cards were.
+ expect(js).toContain('No programs are being tracked right now');
+ expect(js).toContain('data-clear-filter');
+ expect(css).toContain('.ad-empty {');
+ });
+
+ it('resets the filter chips with the bucket on a new lookup', () => {
+ // state.filter and the chips are one thing: setting the bucket back to
+ // "all" without repainting the chips leaves a chip claiming a filter that
+ // is not applied.
+ expect(js).toContain("setFilter('all')");
+ expect(js).not.toMatch(/state\.filter\s*=\s*'all'\s*;\s*\n\s*saveRecent/);
+ });
+
+ it('tells a visitor why a shared link with a broken address scanned nothing', () => {
+ expect(js).toContain('The address in this link is not a valid Solana or Ethereum address');
+ });
+
+ it('claims the "/" shortcut its own hint promises', () => {
+ // The site-wide Atlas palette also listens for "/" and stands down only on
+ // defaultPrevented (see tests/atlas.test.js). Without the preventDefault
+ // here the hint under the form is a lie.
+ expect(html).toContain('Press <kbd>/</kbd> to focus');
+ expect(js).toMatch(/e\.key !== '\/'[\s\S]{0,400}e\.preventDefault\(\)/);
+ });
+
+ it('never builds a card track wider than its own container', () => {
+ // A bare minmax(20rem, …) track is wider than the 320px container's inner
+ // width, so every card's right edge (status pill, score) is clipped off
+ // screen on a small phone.
+ const grid = css.slice(css.indexOf('.ad-grid {'));
+ expect(grid.slice(0, grid.indexOf('}'))).toContain('minmax(min(20rem, 100%), 1fr)');
+ });
+
it('respects a reduced-motion preference', () => {
expect(css).toContain('@media (prefers-reduced-motion: reduce)');
});