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(alpha-copilot): stop the i18n pass reverting the ID-entry toggle label

nirholasa293d0b8158e
diff --git a/src/alpha-copilot.css b/src/alpha-copilot.css
index 3cc7cab18..d2117c4a4 100644
--- a/src/alpha-copilot.css
+++ b/src/alpha-copilot.css
@@ -67,6 +67,8 @@ body {
transition: color var(--duration-fast);
}
.ac-pick-idtoggle:hover { color: var(--wallet-accent); }
+.ac-pick-idtoggle:active { color: var(--ink-bright); }
+.ac-pick-idtoggle:focus-visible { outline: none; color: var(--wallet-accent); box-shadow: 0 0 0 3px var(--wallet-accent-soft); border-radius: var(--radius-sm); }
.ac-pick-rail {
display: flex; gap: var(--space-sm); overflow-x: auto; padding: var(--space-2xs) 2px var(--space-sm);
@@ -83,8 +85,12 @@ body {
transition: border-color var(--duration-fast), background var(--duration-fast), transform var(--duration-instant);
}
.ac-agent-card:hover { border-color: var(--wallet-stroke); background: var(--surface-1); transform: translateY(-1px); }
-.ac-agent-card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--wallet-accent-soft); }
.ac-agent-card.is-active { border-color: var(--wallet-stroke-strong); background: var(--wallet-accent-soft); box-shadow: 0 0 0 1px var(--wallet-stroke-strong) inset; }
+/* After `.is-active` on purpose: both selectors weigh the same, so the later one
+ wins and the selected card would otherwise keep its inset ring and show no
+ focus ring at all when a keyboard user tabs onto it. */
+.ac-agent-card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--wallet-accent-soft); }
+.ac-agent-card.is-active:focus-visible { box-shadow: 0 0 0 1px var(--wallet-stroke-strong) inset, 0 0 0 3px var(--wallet-accent-soft); }
.ac-agent-av { flex: 0 0 auto; width: 40px; height: 40px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.ac-agent-av img { width: 100%; height: 100%; object-fit: cover; }
.ac-agent-initials { font-family: var(--font-display); font-size: var(--text-sm); color: var(--wallet-accent); font-weight: 700; }
@@ -178,6 +184,8 @@ body {
.ac-stage-role { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--wallet-accent); }
.ac-stage-link { flex: 0 0 auto; font-size: var(--text-2xs); font-family: var(--font-mono); color: var(--ink-faint); text-decoration: none; padding: var(--space-2xs) var(--space-xs); border: 1px solid var(--stroke); border-radius: var(--radius-sm); transition: color var(--duration-fast), border-color var(--duration-fast); }
.ac-stage-link:hover { color: var(--ink); border-color: var(--wallet-stroke); }
+.ac-stage-link:active { transform: translateY(1px); }
+.ac-stage-link:focus-visible { outline: none; color: var(--ink); border-color: var(--wallet-stroke-strong); box-shadow: 0 0 0 3px var(--wallet-accent-soft); }
.ac-speak { display: flex; gap: var(--space-sm); align-items: flex-start; padding: var(--space-md); border-top: 1px solid var(--stroke); background: var(--wallet-accent-soft); }
.ac-speak.is-speaking { animation: ac-glow 1.4s ease-in-out infinite; }
@keyframes ac-glow { 50% { background: var(--wallet-accent-fill); } }
@@ -305,7 +313,9 @@ body {
.ac-drawer-card { position: relative; width: min(440px, 94vw); background: var(--bg-1); border: 1px solid var(--wallet-stroke); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); padding: var(--space-lg); animation: ac-rise var(--duration-base) var(--ease-emphasized); }
@keyframes ac-rise { from { transform: translateY(12px); opacity: 0; } }
.ac-modal-x { position: absolute; top: var(--space-sm); right: var(--space-sm); width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--stroke); color: var(--ink-dim); cursor: pointer; font-size: 18px; line-height: 1; }
-.ac-modal-x:hover { color: var(--ink); }
+.ac-modal-x:hover { color: var(--ink); border-color: var(--wallet-stroke); }
+.ac-modal-x:active { transform: translateY(1px); }
+.ac-modal-x:focus-visible { outline: none; color: var(--ink); box-shadow: 0 0 0 3px var(--wallet-accent-soft); }
.ac-drawer-card h3 { font-family: var(--font-display); margin: 0 0 var(--space-md); color: var(--ink-bright); }
.ac-act-lead { font-size: var(--text-base); color: var(--ink); margin: 0 0 var(--space-md); }
.ac-act-quote { background: var(--surface-1); border: 1px solid var(--stroke); border-radius: var(--radius-md); padding: var(--space-sm) var(--space-md); margin-bottom: var(--space-md); font-size: var(--text-sm); color: var(--ink-dim); }
@@ -320,6 +330,8 @@ body {
.ac-act-done p { color: var(--ink); margin: 0 0 var(--space-sm); }
.ac-act-audit { display: inline-block; margin-top: var(--space-sm); color: var(--wallet-accent); font-size: var(--text-sm); text-decoration: none; }
.ac-act-audit:hover { text-decoration: underline; }
+.ac-act-audit:active { color: var(--ink-bright); }
+.ac-act-audit:focus-visible { outline: none; text-decoration: underline; box-shadow: 0 0 0 3px var(--wallet-accent-soft); border-radius: var(--radius-sm); }
@media (prefers-reduced-motion: reduce) {
.ac-live-dot, .ac-thinking span, .ac-skel-line, .ac-skel-orb, .ac-speak.is-speaking, .ac-drawer-card,
diff --git a/src/alpha-copilot.js b/src/alpha-copilot.js
index 389c0b87e..05a659bc9 100644
--- a/src/alpha-copilot.js
+++ b/src/alpha-copilot.js
@@ -23,6 +23,18 @@ const LS_KEY = 'ac_last_agent';
const $ = (sel, root = document) => root.querySelector(sel);
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
+// Copy in the markup carries `data-i18n` keys, and the runtime i18n pass rewrites
+// those nodes from the catalog whenever it runs (boot, and again on every locale
+// change). Writing straight over such a node loses the new string on the next
+// pass: the "Hide ID entry" toggle label flipped back to "Use an agent ID" with
+// the row still open. Dropping the key hands ownership of that node to the JS.
+function setOwnText(el, text) {
+ if (!el) return;
+ el.removeAttribute('data-i18n');
+ el.removeAttribute('data-i18n-html');
+ el.textContent = text;
+}
+
// ── formatting ──────────────────────────────────────────────────────────────
const num = (v) => (v == null || !Number.isFinite(Number(v)) ? null : Number(v));
function fmtUsd(v) {
@@ -142,6 +154,7 @@ function agentCard(a) {
node.type = 'button';
node.className = 'ac-agent-card';
node.setAttribute('role', 'option');
+ node.setAttribute('aria-selected', 'false');
node.dataset.id = a.id;
const meta = a.featured ? 'Featured' : a.onchain ? esc(a.onchain.network || 'on-chain') : a.chats ? `${a.chats.toLocaleString()} chats` : a.skill ? esc(a.skill.replace(/[-_]/g, ' ')) : 'agent';
const fallback = `<span class="ac-agent-initials">${esc(initials(a.name))}</span>`;
@@ -158,14 +171,20 @@ function agentCard(a) {
return node;
}
+// The rail is a listbox, so the highlight has to reach the accessibility tree
+// too: a screen reader gets "selected" from aria-selected, never from a class.
function markActiveCard(id) {
- dom.gallery.querySelectorAll('.ac-agent-card').forEach((c) => c.classList.toggle('is-active', c.dataset.id === id));
+ dom.gallery.querySelectorAll('.ac-agent-card[role="option"]').forEach((c) => {
+ const on = c.dataset.id === id;
+ c.classList.toggle('is-active', on);
+ c.setAttribute('aria-selected', String(on));
+ });
}
function revealIdRow(open) {
dom.idRow.hidden = !open;
dom.idToggle.setAttribute('aria-expanded', String(open));
- dom.idToggle.textContent = open ? 'Hide ID entry' : 'Use an agent ID';
+ setOwnText(dom.idToggle, open ? 'Hide ID entry' : 'Use an agent ID');
if (open) dom.agentInput.focus();
}
@@ -235,8 +254,18 @@ function setCount(n) {
} else dom.launchesCount.hidden = true;
}
+// The launches column is the page's call to action, so it must never render as
+// an empty box. Before an agent is on stage (first paint, or every agent source
+// down) it says what to do next instead of showing nothing at all.
+function showLaunchesIdle(message) {
+ setCount(0);
+ dom.launchesList.innerHTML = `<div class="ac-state"><div class="ac-state-orb" aria-hidden="true"></div><p>${esc(message)}</p></div>`;
+}
+const IDLE_PICK = 'Pick a co-pilot above and the live launches it can read land here.';
+const IDLE_ID = 'Load an agent by ID above and the live launches it can read land here.';
+
async function loadCandidates() {
- if (!state.agent) return;
+ if (!state.agent) { showLaunchesIdle(IDLE_PICK); return; }
setCount(0);
dom.launchesList.innerHTML = skeletonLaunches(4);
let items = [];
@@ -338,6 +367,8 @@ function markActiveLaunch(mint) {
// ── the read ────────────────────────────────────────────────────────────────
function resetRead() {
state.read = null;
+ state.activeMint = null;
+ markActiveLaunch(null);
dom.readEmpty.hidden = false;
dom.readBody.hidden = true;
dom.readBody.innerHTML = '';
@@ -609,9 +640,20 @@ function openActDrawer(data) {
});
}
+// Focus follows the dialog: opening it moves the caret inside (otherwise a
+// keyboard user keeps tabbing the page behind an aria-modal overlay) and closing
+// it hands focus back to whatever opened it.
+let drawerReturnFocus = null;
function showDrawer(open) {
dom.actDrawer.hidden = !open;
document.body.style.overflow = open ? 'hidden' : '';
+ if (open) {
+ drawerReturnFocus = document.activeElement;
+ dom.actDrawer.querySelector('.ac-modal-x')?.focus();
+ } else if (drawerReturnFocus) {
+ try { drawerReturnFocus.focus(); } catch { /* the trigger left the DOM */ }
+ drawerReturnFocus = null;
+ }
}
function wireDrawer() {
dom.actDrawer.addEventListener('click', (e) => {
@@ -649,6 +691,7 @@ async function resolveInitialAgent() {
async function init() {
cacheDom();
wireDrawer();
+ showLaunchesIdle(IDLE_PICK);
dom.idToggle.addEventListener('click', () => revealIdRow(dom.idRow.hidden));
dom.agentLoad.addEventListener('click', () => {
const id = parseAgentId(dom.agentInput.value);
@@ -673,7 +716,8 @@ async function init() {
// as a fallback only if the gallery also came up empty.
await galleryP;
if (!state.gallery.length) {
- dom.avatarPlaceholder.querySelector('span:last-child').textContent = 'Enter an agent ID (or paste a profile URL) to begin.';
+ setOwnText(dom.avatarPlaceholder.querySelector('span:last-child'), 'Enter an agent ID (or paste a profile URL) to begin.');
+ showLaunchesIdle(IDLE_ID);
}
}
await galleryP;