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(clip-director): ask the leaderboard for agents with a realized track record

nirholas0a64fd68686b
diff --git a/pages/character-library.html b/pages/character-library.html
index 51549f572..d5643fc04 100644
--- a/pages/character-library.html
+++ b/pages/character-library.html
@@ -8,21 +8,21 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<meta
name="description"
- content="106 professionally rigged 3D characters, free to use on three.ws. Every one drives the full animation library — idle, walk, run, wave, dance. Preview, animate, or drop into the Widget Studio in one click."
+ content="Professionally rigged 3D characters, free to use on three.ws. Every one drives the full animation library: idle, walk, run, wave, dance. Preview, animate, or drop into the Widget Studio in one click."
data-i18n-attr="content:character_library.meta_description"/>
<meta name="theme-color" content="#000000" />
<link rel="canonical" href="https://three.ws/character-library" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Character Library · three.ws" data-i18n-attr="content:character_library.meta_og_title"/>
- <meta property="og:description" content="106 rigged 3D characters, ready to animate. Preview, animate, or use in the Studio." data-i18n-attr="content:character_library.meta_og_description"/>
+ <meta property="og:description" content="Rigged 3D characters, ready to animate. Preview, animate, or use in the Studio." data-i18n-attr="content:character_library.meta_og_description"/>
<meta property="og:url" content="https://three.ws/character-library" />
<meta property="og:site_name" content="three.ws" />
- <meta property="og:image" content="https://three.ws/api/page-og?s=main&amp;t=Character+Library&amp;d=106+professionally+rigged+3D+characters%2C+free+to+use.+Every+one+drives+the+full+animation+library+and+drops+into+the+Studio%2C+Animation+Studio%2C+and+embed+viewer&amp;p=%2Fcharacter-library" />
+ <meta property="og:image" content="https://three.ws/api/page-og?s=main&amp;t=Character+Library&amp;d=Professionally+rigged+3D+characters%2C+free+to+use.+Every+one+drives+the+full+animation+library+and+drops+into+the+Studio%2C+Animation+Studio%2C+and+embed+viewer.&amp;p=%2Fcharacter-library" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Character Library · three.ws" data-i18n-attr="content:character_library.meta_twitter_title"/>
- <meta name="twitter:description" content="106 rigged 3D characters, ready to animate." data-i18n-attr="content:character_library.meta_twitter_description"/>
- <meta name="twitter:image" content="https://three.ws/api/page-og?s=main&amp;t=Character+Library&amp;d=106+professionally+rigged+3D+characters%2C+free+to+use.+Every+one+drives+the+full+animation+library+and+drops+into+the+Studio%2C+Animation+Studio%2C+and+embed+viewer&amp;p=%2Fcharacter-library" />
+ <meta name="twitter:description" content="Rigged 3D characters, ready to animate." data-i18n-attr="content:character_library.meta_twitter_description"/>
+ <meta name="twitter:image" content="https://three.ws/api/page-og?s=main&amp;t=Character+Library&amp;d=Professionally+rigged+3D+characters%2C+free+to+use.+Every+one+drives+the+full+animation+library+and+drops+into+the+Studio%2C+Animation+Studio%2C+and+embed+viewer.&amp;p=%2Fcharacter-library" />
<meta name="twitter:site" content="@trythreews" />
<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1" />
<meta property="og:locale" content="en_US" />
@@ -34,7 +34,7 @@
<link rel="stylesheet" href="/nav.css" />
<link rel="stylesheet" href="/footer.css" />
<link rel="stylesheet" href="/fonts/fonts.css" />
- <script type="application/ld+json">{"@context":"https://schema.org","@type":"CollectionPage","name":"Character Library","description":"106 professionally rigged 3D characters, free to use on three.ws. Each drives the full animation library and drops into the Studio, Animation Studio, and embed viewer.","url":"https://three.ws/character-library","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
+ <script type="application/ld+json">{"@context":"https://schema.org","@type":"CollectionPage","name":"Character Library","description":"Professionally rigged 3D characters, free to use on three.ws. Each drives the full animation library and drops into the Studio, Animation Studio, and embed viewer.","url":"https://three.ws/character-library","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
<style>
.ch-main { max-width: 1320px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 80px; }
@@ -65,9 +65,20 @@
.ch-search {
width: 100%; padding: 10px 34px 10px 34px; border-radius: var(--radius-md);
border: 1px solid var(--stroke); background: var(--surface-1); color: var(--ink);
- font-size: 14px; outline: none;
+ font-size: 14px;
}
.ch-search:focus { border-color: var(--stroke-strong); }
+ /* The search box used to set `outline: none`, which left keyboard users
+ with a 1px border shift as their only focus cue. Every control on the
+ page now carries the same deliberate accent ring. */
+ .ch-search:focus-visible,
+ .ch-sort:focus-visible,
+ .ch-btn:focus-visible,
+ .ch-hbtn:focus-visible,
+ .ch-card-thumb:focus-visible {
+ outline: 2px solid var(--accent);
+ outline-offset: 2px;
+ }
.ch-search-kbd {
position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
font-family: var(--font-mono); font-size: 11px; color: var(--ink-dim);
@@ -123,6 +134,7 @@
.ch-btn--primary:hover { filter: brightness(1.08); }
.ch-btn--ghost { background: var(--surface-1); color: var(--ink); }
.ch-btn--ghost:hover { border-color: var(--stroke-strong); background: var(--surface-2); }
+ .ch-btn:active { transform: translateY(1px); }
.ch-skeleton-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.ch-skeleton { aspect-ratio: 1 / 1.35; border-radius: var(--radius-lg); border: 1px solid var(--stroke);
@@ -141,8 +153,10 @@
border: 1px solid var(--stroke); cursor: pointer;
}
.ch-hbtn--primary { background: var(--accent); color: var(--accent-ink, #0b0b0f); border-color: transparent; }
+ .ch-hbtn--primary:hover { filter: brightness(1.08); }
.ch-hbtn--secondary { background: var(--surface-1); color: var(--ink); }
.ch-hbtn--secondary:hover { border-color: var(--stroke-strong); }
+ .ch-hbtn:active { transform: translateY(1px); }
@media (max-width: 560px) {
.ch-grid, .ch-skeleton-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@@ -164,10 +178,10 @@
<span class="ch-hero-dot" aria-hidden="true"></span>
<span data-i18n="character_library.character_library">Character Library</span>
</div>
- <h1 data-i18n="character_library.106_rigged_characters_ready_to_animate">106 rigged characters, ready to animate</h1>
+ <h1 data-i18n="character_library.rigged_characters_ready_to_animate">Rigged characters, ready to animate</h1>
<p data-i18n="character_library.a_curated_library_of_professionally_rigged_h">
A curated library of professionally rigged humanoid characters. Every one ships with a skeleton and
- skin weights, so it drives the full three.ws animation library out of the box — idle, walk, run, wave,
+ skin weights, so it drives the full three.ws animation library out of the box: idle, walk, run, wave,
dance. Preview any character live, send it to the Animation Studio, or drop it straight into the Widget Studio.
</p>
<div class="ch-hero-actions">
diff --git a/pages/clip-director.html b/pages/clip-director.html
index 0265acb28..74184d626 100644
--- a/pages/clip-director.html
+++ b/pages/clip-director.html
@@ -52,7 +52,11 @@
.cd-field label { display: block; font-size: 12px; color: var(--cd-faint); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; font-weight: 600; }
.cd-field select, .cd-field input { width: 100%; background: var(--cd-panel-2); border: 1px solid var(--cd-line); border-radius: 10px; color: var(--cd-text); font: inherit; font-size: 15px; padding: 11px 12px; outline: none; }
.cd-field select:focus-visible, .cd-field input:focus-visible { border-color: var(--cd-accent); outline: 2px solid var(--cd-accent); outline-offset: 1px; }
+ .cd-field select:disabled { color: var(--cd-faint); cursor: progress; }
.cd-trade { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; background: var(--cd-panel); border: 1px solid var(--cd-line); border-radius: 14px; padding: 14px 18px; margin-bottom: 18px; }
+ .cd-trade .who { font-size: 13px; font-weight: 700; color: var(--cd-dim); text-decoration: none; }
+ .cd-trade a.who:hover { color: var(--cd-text); text-decoration: underline; }
+ .cd-trade a.who:focus-visible, .cd-trade a.proof:focus-visible { outline: 2px solid var(--cd-accent); outline-offset: 3px; border-radius: 4px; }
.cd-trade .sym { font-weight: 800; font-size: 18px; }
.cd-trade .stat { font-size: 14px; color: var(--cd-dim); } .cd-trade .stat b { color: var(--cd-text); }
.cd-trade .win { color: var(--cd-green); } .cd-trade .loss { color: var(--cd-red); }
@@ -70,7 +74,10 @@
.cd-featstat .gesture { font-size: 26px; line-height: 1; }
.cd-featstat .num { font-size: 24px; font-weight: 800; letter-spacing: -.02em; background: linear-gradient(90deg, var(--cd-accent), var(--cd-accent-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.cd-text { font-size: 13.5px; color: var(--cd-dim); line-height: 1.5; }
- .cd-cta { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--cd-accent-2); }
+ .cd-cta { align-self: flex-start; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--cd-accent-2); text-decoration: none; border-bottom: 1px solid transparent; padding-bottom: 2px; transition: border-color .15s, color .15s; }
+ .cd-cta:hover { border-bottom-color: var(--cd-accent-2); }
+ .cd-cta:active { color: var(--cd-accent); }
+ .cd-cta:focus-visible { outline: 2px solid var(--cd-accent-2); outline-offset: 3px; border-radius: 3px; }
.cd-alt { font-size: 11.5px; color: var(--cd-faint); border-top: 1px dashed var(--cd-line); padding-top: 10px; line-height: 1.45; }
.cd-alt b { color: var(--cd-dim); }
.cd-copy { margin-top: auto; appearance: none; border: 1px solid var(--cd-line); background: var(--cd-panel-2); color: var(--cd-text); font: inherit; font-weight: 600; font-size: 13px; padding: 9px; border-radius: 9px; cursor: pointer; transition: background .15s, border-color .15s; }
@@ -82,7 +89,10 @@
.cd-empty, .cd-error { text-align: center; padding: 48px 20px; border: 1px dashed var(--cd-line); border-radius: 16px; background: var(--cd-panel); }
.cd-empty h3, .cd-error h3 { margin: 0 0 8px; font-size: 18px; }
.cd-empty p, .cd-error p { color: var(--cd-dim); margin: 0 auto 16px; max-width: 46ch; font-size: 14px; line-height: 1.55; }
- .cd-empty a, .cd-error button { display: inline-block; background: var(--cd-accent); color: #06232b; border: none; text-decoration: none; padding: 10px 18px; border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; }
+ .cd-empty a, .cd-error button { display: inline-block; background: var(--cd-accent); color: #06232b; border: none; text-decoration: none; padding: 10px 18px; border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; transition: filter .15s, transform .15s; }
+ .cd-empty a:hover, .cd-error button:hover { filter: brightness(1.12); }
+ .cd-empty a:active, .cd-error button:active { transform: translateY(1px); }
+ .cd-empty a:focus-visible, .cd-error button:focus-visible { outline: 2px solid var(--cd-accent); outline-offset: 3px; }
.cd-skel { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 760px) { .cd-skel { grid-template-columns: repeat(3, 1fr); } }
.cd-skel-card { height: 240px; border-radius: 14px; background: linear-gradient(100deg, var(--cd-panel) 30%, var(--cd-panel-2) 50%, var(--cd-panel) 70%); background-size: 200% 100%; animation: cd-sh 1.3s ease-in-out infinite; border: 1px solid var(--cd-line); }
diff --git a/pages/club.html b/pages/club.html
index 469b13ca6..da76bcbf4 100644
--- a/pages/club.html
+++ b/pages/club.html
@@ -109,6 +109,15 @@
font-size: 13px;
}
#club-top .brand a:hover { color: var(--text); }
+ /* The document's single h1 lives in the top bar so the page always has
+ exactly one, in the room itself, rather than on the transient loader
+ splash or the door dialog (both of which get torn down). It has to
+ read as the brand line it sits in, so the h1 defaults are cleared. */
+ #club-top .club-top-title {
+ margin: 0;
+ font: inherit;
+ color: inherit;
+ }
#club-top .dot {
width: 9px;
height: 9px;
@@ -623,6 +632,14 @@
outline: 2px solid #fff;
outline-offset: 2px;
}
+ /* The stage is a programmatic focus target (see its tabindex="-1"). Show
+ a ring when a keyboard actually landed there, and stay quiet when the
+ gate moves focus in on admission. */
+ #club-stage:focus-visible {
+ outline: 2px solid var(--accent-2);
+ outline-offset: -3px;
+ }
+ #club-stage:focus:not(:focus-visible) { outline: none; }
/* ── Entrance fade ──────────────────────────────────── */
.club-entrance {
@@ -674,7 +691,16 @@
opacity: 1;
transition: opacity 0.7s ease;
}
- .club-loader.is-done { opacity: 0; pointer-events: none; }
+ /* Once faded, the splash must leave the accessibility tree too, not just
+ stop taking clicks: a full-screen `opacity:0` overlay is still read by
+ screen readers, so its wordmark and status line would keep shadowing
+ the room behind it. visibility flips after the fade, never during. */
+ .club-loader.is-done {
+ opacity: 0;
+ pointer-events: none;
+ visibility: hidden;
+ transition: opacity 0.7s ease, visibility 0s linear 0.7s;
+ }
.club-loader-inner { max-width: 420px; width: 100%; }
.club-loader-kicker {
font-size: 10.5px;
@@ -1933,7 +1959,7 @@
<div id="club-loader" class="club-loader" role="status" aria-live="polite">
<div class="club-loader-inner">
<div class="club-loader-kicker">three.ws</div>
- <h1 class="club-loader-title" data-i18n-html="club.poleclub">Pole<span>Club</span></h1>
+ <p class="club-loader-title" data-i18n-html="club.poleclub">Pole<span>Club</span></p>
<p class="club-loader-tagline" data-i18n="club.step_into_the_alley_and_walk_it">Step into the alley and walk it in. Tip a dancer and she takes the pole.</p>
<div class="club-loader-track"><div id="club-loader-bar" class="club-loader-bar"></div></div>
<div id="club-loader-status" class="club-loader-status">Loading the night…</div>
@@ -1996,7 +2022,7 @@
<!-- QUEUE: pay the cover -->
<div class="club-door-state is-queue">
<p class="club-door-eyebrow" data-i18n="club.at_the_door">At the door</p>
- <h1 id="club-door-title" class="club-door-title" data-i18n="club.pole_club">Pole Club</h1>
+ <h2 id="club-door-title" class="club-door-title" data-i18n="club.pole_club">Pole Club</h2>
<p class="club-door-copy" data-i18n-html="club.there_s_a_cover_tonight_pay_0">
There's a cover tonight. Pay <b>$0.01 USDC</b> — the bouncer checks
your wallet on-chain, and if you're on the list, the rope drops and
@@ -2017,21 +2043,21 @@
<div class="club-door-state is-checking">
<div class="club-door-spinner" aria-hidden="true"></div>
<p class="club-door-eyebrow" data-i18n="club.at_the_door_2">At the door</p>
- <h1 class="club-door-title" data-i18n="club.checking_the_list">Checking the list…</h1>
+ <h2 class="club-door-title" data-i18n="club.checking_the_list">Checking the list…</h2>
<p class="club-door-copy" data-i18n="club.verifying_your_wallet_on_chain">Verifying your wallet on-chain.</p>
</div>
<!-- ADMITTED -->
<div class="club-door-state is-admitted" role="status" aria-live="polite">
<div class="club-door-result-icon" aria-hidden="true">🎟️</div>
- <h1 class="club-door-title" data-i18n="club.you_re_in">You're in</h1>
+ <h2 class="club-door-title" data-i18n="club.you_re_in">You're in</h2>
<p class="club-door-tier" id="club-door-tier"></p>
</div>
<!-- DENIED -->
<div class="club-door-state is-denied" role="status" aria-live="polite">
<div class="club-door-result-icon" aria-hidden="true">🚫</div>
- <h1 class="club-door-title" data-i18n="club.not_tonight">Not tonight</h1>
+ <h2 class="club-door-title" data-i18n="club.not_tonight">Not tonight</h2>
<p class="club-door-reason" id="club-door-reason" data-i18n="club.not_on_the_list_tonight">Not on the list tonight.</p>
</div>
</div>
@@ -2044,7 +2070,7 @@
<a href="/" title="three.ws home" data-i18n="club.three_ws" data-i18n-attr="title:club.three_ws_home_title">three.ws</a>
<span>/</span>
<span class="dot" aria-hidden="true"></span>
- <span data-i18n="club.pole_club_2">Pole Club</span>
+ <h1 class="club-top-title" data-i18n="club.pole_club_2">Pole Club</h1>
</div>
<span class="sep"></span>
<span class="tagline" data-i18n="club.tip_in_usdc_she_dances">tip in USDC · she dances</span>
@@ -2067,8 +2093,11 @@
data-i18n="club.8d_off" data-i18n-attr="title:club.8d_audio_orbits_the_sound_ar_title">🎧 8D off</button>
</header>
- <!-- STAGE -->
- <main id="club-stage">
+ <!-- STAGE. tabindex="-1" makes it a real focus target: the skip link at
+ the top of the body and src/club-gate.js (which focuses the stage the
+ moment the velvet rope drops) both call focus() on it, and on a plain
+ <main> that call is a silent no-op that strands keyboard focus. -->
+ <main id="club-stage" tabindex="-1">
<canvas id="club-canvas"></canvas>
<div id="club-status" role="status" aria-live="polite" hidden>Loading…</div>
</main>
diff --git a/pages/collection.html b/pages/collection.html
index 0a5fd90a1..dd3a7bd96 100644
--- a/pages/collection.html
+++ b/pages/collection.html
@@ -46,6 +46,7 @@
--skeleton-sheen: rgba(0,0,0,0.08);
}
*{box-sizing:border-box;margin:0;padding:0;}
+ .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}
html,body{background:var(--bg);color:var(--text);font-family:'Inter',system-ui,sans-serif;min-height:100vh;}
a{color:inherit;text-decoration:none;}
.page-shell{max-width:1100px;margin:0 auto;padding:0 20px 80px;}
@@ -54,9 +55,11 @@
.page-hero p{color:var(--muted);margin-top:8px;font-size:14px;}
/* Tabs */
.col-tabs{display:flex;gap:4px;border-bottom:1px solid var(--line-2);margin-bottom:32px;}
- .col-tab{padding:10px 18px;font-size:13px;font-weight:500;color:var(--muted);cursor:pointer;border-bottom:2px solid transparent;transition:color .15s,border-color .15s;background:none;border-top:none;border-left:none;border-right:none;}
+ .col-tab{display:inline-flex;align-items:center;gap:6px;padding:10px 18px;font-size:13px;font-weight:500;color:var(--muted);cursor:pointer;border-bottom:2px solid transparent;transition:color .15s,border-color .15s;background:none;border-top:none;border-left:none;border-right:none;font-family:inherit;}
.col-tab:hover{color:var(--text);}
.col-tab.active{color:var(--text);border-bottom-color:var(--text);}
+ .col-tab-count{color:var(--dim);font-variant-numeric:tabular-nums;}
+ .col-tab.active .col-tab-count{color:var(--muted);}
/* Grid */
.col-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:16px;}
/* Card */
@@ -86,8 +89,8 @@
@keyframes shimmer{0%{background-position:200% 0;}100%{background-position:-200% 0;}}
.skeleton-card{background:var(--card);border:1px solid var(--line-2);border-radius:var(--radius);padding:18px;display:flex;flex-direction:column;gap:12px;}
.skeleton-row{height:14px;border-radius:4px;}
- /* Empty */
- .col-empty{text-align:center;padding:80px 20px;color:var(--muted);}
+ /* Empty (spans the whole grid so it centres under the tabs, not in column 1) */
+ .col-empty{grid-column:1 / -1;text-align:center;padding:80px 20px;color:var(--muted);}
.col-empty svg{margin-bottom:16px;opacity:.35;}
.col-empty h3{font-size:18px;font-weight:600;color:var(--text);margin-bottom:8px;}
.col-empty p{font-size:14px;line-height:1.5;}
@@ -108,10 +111,22 @@
.col-auth-wall h2{font-size:22px;font-weight:700;margin-bottom:12px;}
.col-auth-wall p{color:var(--muted);font-size:14px;margin-bottom:24px;}
/* Error */
- .col-error{background:rgba(239,68,68,.08);border:1px solid rgba(239,68,68,.25);border-radius:10px;padding:16px 20px;color:#ef4444;font-size:13px;margin-bottom:24px;}
+ .col-error{display:flex;align-items:center;gap:12px;flex-wrap:wrap;background:rgba(239,68,68,.08);border:1px solid rgba(239,68,68,.25);border-radius:10px;padding:16px 20px;color:#ef4444;font-size:13px;margin-bottom:24px;}
+ .col-retry-btn{font:inherit;font-weight:500;padding:6px 14px;border-radius:8px;background:rgba(239,68,68,.12);border:1px solid rgba(239,68,68,.35);color:#ef4444;cursor:pointer;transition:background .15s,border-color .15s;}
+ .col-retry-btn:hover{background:rgba(239,68,68,.2);border-color:rgba(239,68,68,.55);}
+ .col-retry-btn:active{transform:translateY(1px);}
+ /* Focus: every interactive element gets the same visible ring. */
+ .col-tab:focus-visible,.col-cta:focus-visible,.col-retry-btn:focus-visible,.col-empty a:focus-visible,.col-card-nft a:focus-visible,.col-panel:focus-visible{outline:2px solid var(--violet);outline-offset:3px;border-radius:6px;}
+ @media(prefers-reduced-motion:reduce){
+ .skeleton{animation:none;}
+ .col-card,.col-tab,.col-cta,.col-retry-btn{transition:none;}
+ }
@media(max-width:600px){
.col-grid{grid-template-columns:1fr;}
.col-stats{gap:20px;flex-wrap:wrap;}
+ .col-tabs{overflow-x:auto;scrollbar-width:none;}
+ .col-tabs::-webkit-scrollbar{display:none;}
+ .col-tab{white-space:nowrap;}
}
</style>
@@ -150,33 +165,33 @@
<a href="/login?next=/collection" class="col-cta" data-i18n="collection.sign_in">Sign in</a>
</div>
- <div id="col-error" class="col-error" hidden></div>
+ <div id="col-error" class="col-error" role="alert" hidden></div>
<div id="col-stats" class="col-stats" hidden>
<div>
- <div class="col-stat-val" id="stat-skills">—</div>
+ <div class="col-stat-val" id="stat-skills">0</div>
<div class="col-stat-lbl">Owned skills</div>
</div>
<div>
- <div class="col-stat-val" id="stat-subs">—</div>
+ <div class="col-stat-val" id="stat-subs">0</div>
<div class="col-stat-lbl">Active subscriptions</div>
</div>
<div>
- <div class="col-stat-val" id="stat-nfts">—</div>
+ <div class="col-stat-val" id="stat-nfts">0</div>
<div class="col-stat-lbl">NFT receipts</div>
</div>
</div>
<div id="col-main" hidden>
- <div class="col-tabs" role="tablist">
- <button class="col-tab active" role="tab" aria-selected="true" data-panel="skills" data-i18n="collection.skills">Skills</button>
- <button class="col-tab" role="tab" aria-selected="false" data-panel="subscriptions" data-i18n="collection.subscriptions">Subscriptions</button>
+ <div class="col-tabs" role="tablist" aria-label="Collection sections">
+ <button id="tab-skills" class="col-tab active" type="button" role="tab" aria-selected="true" aria-controls="panel-skills" data-panel="skills"><span data-i18n="collection.skills">Skills</span><span class="col-tab-count"></span></button>
+ <button id="tab-subscriptions" class="col-tab" type="button" role="tab" aria-selected="false" aria-controls="panel-subscriptions" tabindex="-1" data-panel="subscriptions"><span data-i18n="collection.subscriptions">Subscriptions</span><span class="col-tab-count"></span></button>
</div>
- <div id="panel-skills" class="col-panel active" role="tabpanel">
+ <div id="panel-skills" class="col-panel active" role="tabpanel" aria-labelledby="tab-skills" tabindex="0">
<div id="skills-grid" class="col-grid"></div>
</div>
- <div id="panel-subscriptions" class="col-panel" role="tabpanel">
+ <div id="panel-subscriptions" class="col-panel" role="tabpanel" aria-labelledby="tab-subscriptions" tabindex="0" hidden>
<div id="subs-grid" class="col-grid"></div>
</div>
</div>
diff --git a/pages/communities.html b/pages/communities.html
index c335aaa50..a533a8800 100644
--- a/pages/communities.html
+++ b/pages/communities.html
@@ -41,6 +41,10 @@
--radius: 16px;
}
html, body { background: var(--bg); color: var(--text); }
+ .sr-only {
+ position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
+ overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
+ }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
-webkit-font-smoothing: antialiased;
@@ -104,6 +108,8 @@
}
.url-field input.is-error { border-color: #f87171; }
.url-field { margin-top: 14px; }
+ .field-error { font-size: 12px; min-height: 16px; margin-top: 6px; color: #f87171; }
+ .field-error.is-ok { color: #34d399; }
.avatar-row { display: flex; gap: 10px; flex-wrap: wrap; }
.avatar-chip {
@@ -145,7 +151,6 @@
transition: border-color .15s, transform .12s, box-shadow .15s;
}
.coin-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 12px 32px rgba(0,0,0,0.4); }
- .coin-card:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.coin-thumb {
width: 46px; height: 46px; border-radius: 50%; position: relative; overflow: hidden;
background: linear-gradient(135deg, rgba(124,92,255,0.45), rgba(0,0,0,0.45));
@@ -256,6 +261,34 @@
.cp-skel-line.w50 { width: 50%; } .cp-skel-line.w30 { width: 30%; }
.cp-skel-stats { height: 80px; border-radius: 12px; background: rgba(255,255,255,0.05); margin-top: 22px; animation: pulse 1.3s ease-in-out infinite; }
.coin-profile-empty { padding: 60px 20px; text-align: center; color: var(--muted); }
+
+ /* Keyboard focus and press feedback, last so they beat the component
+ rules above. Every control on this page is a real button or link, so
+ one ring definition covers the whole surface. */
+ .brand:focus-visible,
+ .topbar nav a:focus-visible,
+ .avatar-chip:focus-visible,
+ .coin-card:focus-visible,
+ .mainland-card:focus-visible,
+ .primary-btn:focus-visible,
+ .ghost-btn:focus-visible,
+ .cp-mint:focus-visible,
+ .cp-social:focus-visible {
+ outline: 2px solid var(--accent);
+ outline-offset: 3px;
+ border-radius: 11px;
+ }
+ .avatar-chip:active, .coin-card:active, .mainland-card:active,
+ .primary-btn:active, .ghost-btn:active { transform: translateY(0) scale(0.98); }
+ .cp-mint:active, .cp-social:active { filter: brightness(0.9); }
+ @media (prefers-reduced-motion: reduce) {
+ .avatar-chip, .coin-card, .mainland-card, .primary-btn, .ghost-btn,
+ .coin-enter, .coin-card .sk, .coin-card.is-skeleton .coin-thumb,
+ .cp-skel-avatar, .cp-skel-line, .cp-skel-stats { transition: none; animation: none; }
+ .avatar-chip:hover, .coin-card:hover, .mainland-card:hover,
+ .primary-btn:hover, .avatar-chip:active, .coin-card:active,
+ .mainland-card:active, .primary-btn:active, .ghost-btn:active { transform: none; }
+ }
</style>
<link rel="canonical" href="https://three.ws/communities">
@@ -275,7 +308,7 @@
<section class="hero">
<h1 data-i18n="communities.every_coin_its_own_world">Every coin, its own world.</h1>
- <p data-i18n="communities.drop_in_an_avatar_and_walk_around">Drop in an avatar and walk around with everyone else who holds the same coin — live, in 3D, right in your browser.</p>
+ <p data-i18n="communities.drop_in_an_avatar_and_walk_around">Drop in an avatar and walk around with everyone else who holds the same coin. Live, in 3D, right in your browser.</p>
<div class="steps"><span data-i18n-html="communities.1_pick_your_avatar"><b>1.</b> Pick your avatar</span><span data-i18n-html="communities.2_choose_a_coin"><b>2.</b> Choose a coin</span><span data-i18n-html="communities.3_you_re_in"><b>3.</b> You're in.</span></div>
</section>
@@ -290,7 +323,8 @@
</div>
<div class="url-field">
<label class="field-label" for="avatar-url-input" data-i18n="communities.or_paste_a_glb_gltf_avatar_url">…or paste a GLB / glTF avatar URL</label>
- <input id="avatar-url-input" type="url" autocomplete="off" spellcheck="false" placeholder="https://…/model.glb" />
+ <input id="avatar-url-input" type="url" autocomplete="off" spellcheck="false" placeholder="https://…/model.glb" aria-describedby="avatar-url-error" />
+ <p id="avatar-url-error" class="field-error" role="alert"></p>
</div>
</div>
<div>
@@ -305,21 +339,23 @@
<button type="button" id="enter-mainland" class="mainland-card" data-i18n-html="communities.mainlandthe_shared_world_everyone_no_coin_re">
<span class="ml-icon">🌐</span>
- <span class="ml-text"><b>Mainland</b><span>The shared world — everyone, no coin required</span></span>
+ <span class="ml-text"><b>Mainland</b><span>The shared world: everyone, no coin required</span></span>
<span class="ml-go">Enter →</span>
</button>
<div class="coin-toolbar">
<div class="coin-search-wrap">
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>
+ <label class="sr-only" for="coin-search">Search coins by name or ticker</label>
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>
<input id="coin-search" type="search" autocomplete="off" placeholder="Search coins by name or ticker…" />
</div>
</div>
- <div id="coin-grid" class="coin-grid"></div>
+ <div id="coin-grid" class="coin-grid" aria-busy="true"></div>
<div class="mint-row">
- <input id="mint-input" type="text" autocomplete="off" spellcheck="false" placeholder="Or paste any Solana mint address to enter its world" />
+ <label class="sr-only" for="mint-input">Solana mint address</label>
+ <input id="mint-input" type="text" autocomplete="off" spellcheck="false" placeholder="Or paste any Solana mint address to enter its world" aria-describedby="mint-error" />
<button type="button" id="mint-enter" class="primary-btn" data-i18n="communities.enter_world">Enter world</button>
</div>
<div id="mint-error" class="mint-error" role="alert"></div>
diff --git a/pages/community.html b/pages/community.html
index fa3b0bee1..ce0ff0ed0 100644
--- a/pages/community.html
+++ b/pages/community.html
@@ -29,21 +29,16 @@
<link rel="stylesheet" href="/mobile.css" />
<script defer src="/footer-newsletter.js"></script>
<style>
- :root {
- color-scheme: dark;
- --bg: #000000;
- --panel: #141414;
- --border: #222222;
- --text: #e8e8f0;
- --muted: #888888;
- --accent: #ffffff;
- }
+ /* Palette is token-derived (see /tokens.css), so this page flips with
+ the site theme switcher instead of staying black on a light canvas. */
* { box-sizing: border-box; }
body {
- font: 15px/1.6 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
- color: var(--text);
+ font-family: var(--font-body);
+ font-size: 15px;
+ line-height: 1.6;
+ color: var(--ink);
margin: 0;
- background: var(--bg);
+ background: var(--bg-0);
min-height: 100vh;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 64px 24px 96px; }
@@ -62,7 +57,7 @@
line-height: 1.1;
font-weight: 600;
}
- .sub { color: var(--muted); font-size: 17px; margin: 0 0 48px; max-width: 620px; line-height: 1.55; }
+ .sub { color: var(--ink-dim); font-size: 17px; margin: 0 0 48px; max-width: 620px; line-height: 1.55; }
.grid {
display: grid;
grid-template-columns: 1fr 1fr;
@@ -71,19 +66,20 @@
}
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }
.card {
- background: var(--panel);
- border: 1px solid var(--border);
+ background: var(--bg-1);
+ border: 1px solid var(--stroke);
border-radius: 16px;
padding: 28px 24px;
display: flex;
flex-direction: column;
gap: 12px;
- transition: border-color 0.15s;
+ transition: border-color 0.15s, transform 0.15s;
}
- .card:hover { border-color: #333333; }
+ .card:hover { border-color: var(--stroke-strong); transform: translateY(-2px); }
+ .card:focus-within { border-color: var(--stroke-strong); }
.card h2 { margin: 0; font-size: 18px; font-weight: 600; }
- .card p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
- .card .icon { font-size: 28px; }
+ .card p { margin: 0; color: var(--ink-dim); font-size: 14.5px; line-height: 1.55; }
+ .card .icon { font-size: 28px; line-height: 1; }
.card-link {
display: inline-flex;
align-items: center;
@@ -98,12 +94,51 @@
.section { margin-bottom: 48px; }
.section h2 { font-size: 22px; margin: 0 0 16px; font-weight: 600; }
- .section p { color: var(--muted); font-size: 15px; line-height: 1.6; max-width: 620px; }
+ .section p { color: var(--ink-dim); font-size: 15px; line-height: 1.6; max-width: 620px; }
.section ul { margin: 12px 0 0; padding-left: 20px; }
- .section li { color: var(--muted); font-size: 14.5px; margin-bottom: 8px; line-height: 1.5; }
- .section li strong { color: var(--text); }
+ .section li { color: var(--ink-dim); font-size: 14.5px; margin-bottom: 8px; line-height: 1.5; }
+ .section li strong { color: var(--ink); }
a { color: var(--accent); }
+ .newsletter-form {
+ display: flex;
+ gap: 10px;
+ margin-top: 18px;
+ max-width: 460px;
+ flex-wrap: wrap;
+ }
+ .newsletter-form input {
+ flex: 1 1 220px;
+ min-width: 0;
+ background: var(--bg-1);
+ border: 1px solid var(--stroke);
+ border-radius: 10px;
+ padding: 11px 14px;
+ color: var(--ink);
+ font: inherit;
+ font-size: 14.5px;
+ }
+ .newsletter-form input::placeholder { color: var(--ink-faint); }
+ .newsletter-form input:hover { border-color: var(--stroke-strong); }
+ .newsletter-form button {
+ flex: 0 0 auto;
+ background: var(--btn-primary-bg);
+ color: var(--btn-primary-fg);
+ border: 1px solid var(--btn-primary-border);
+ border-radius: 10px;
+ padding: 11px 20px;
+ font: inherit;
+ font-size: 14.5px;
+ font-weight: 600;
+ cursor: pointer;
+ transition: background 0.15s;
+ }
+ .newsletter-form button:hover:not(:disabled) { background: var(--btn-primary-bg-hover); }
+ .newsletter-form button:active:not(:disabled) { background: var(--btn-primary-bg-active); }
+ .newsletter-msg { margin-top: 10px; font-size: 13.5px; min-height: 20px; color: var(--ink-dim); }
+ .newsletter-msg.is-error { color: var(--danger); }
+ .newsletter-msg.is-success { color: var(--success); }
+
.activity-head {
display: flex;
align-items: baseline;
@@ -121,63 +156,101 @@
.activity-head a:hover { text-decoration: underline; }
.activity-list {
- border: 1px solid var(--border);
+ border: 1px solid var(--stroke);
border-radius: 16px;
- background: var(--panel);
+ background: var(--bg-1);
overflow: hidden;
}
+ /* The row is a container, never an anchor: it holds a stretched primary
+ link plus a separate profile link, and nesting one <a> inside another
+ is invalid HTML that the parser shreds into three broken rows. */
.activity-row {
+ position: relative;
display: flex;
align-items: center;
gap: 12px;
padding: 14px 18px;
- border-bottom: 1px solid var(--border);
- text-decoration: none;
+ border-bottom: 1px solid var(--stroke);
color: inherit;
transition: background 0.15s;
animation: activity-in 0.35s ease both;
}
@keyframes activity-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
+ @media (prefers-reduced-motion: reduce) {
+ .activity-row { animation: none; }
+ .activity-skeleton { animation: none; }
+ }
.activity-row:last-child { border-bottom: none; }
- .activity-row:hover { background: #1a1a1a; }
+ .activity-row:hover, .activity-row:focus-within { background: var(--surface-2); }
+ .activity-main { position: absolute; inset: 0; z-index: 0; }
+ .activity-row > :not(.activity-main) { position: relative; z-index: 1; pointer-events: none; }
+ .activity-user { pointer-events: auto; color: inherit; text-decoration: none; }
+ .activity-user:hover { text-decoration: underline; }
.activity-avatar {
width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
- background: #1e1e1e; border: 1px solid var(--border);
+ background: var(--surface-2); border: 1px solid var(--stroke);
object-fit: cover; display: flex; align-items: center; justify-content: center;
- color: var(--muted); font-size: 0.95rem; overflow: hidden;
+ color: var(--ink-dim); font-size: 0.95rem; overflow: hidden;
}
.activity-avatar img { width: 100%; height: 100%; object-fit: cover; }
.activity-thumb {
width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
- background: #1e1e1e; object-fit: cover; overflow: hidden;
- display: flex; align-items: center; justify-content: center; color: var(--muted);
+ background: var(--surface-2); object-fit: cover; overflow: hidden;
+ display: flex; align-items: center; justify-content: center; color: var(--ink-dim);
}
.activity-thumb img { width: 100%; height: 100%; object-fit: cover; }
.activity-text { flex: 1; min-width: 0; }
.activity-line {
font-size: 14px;
- color: var(--text);
+ color: var(--ink);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.activity-line strong { font-weight: 600; }
- .activity-verb { color: var(--muted); font-weight: 400; }
- .activity-time { font-size: 12px; color: var(--muted); margin-top: 2px; }
+ .activity-verb { color: var(--ink-dim); font-weight: 400; }
+ .activity-meta {
+ font-size: 12px;
+ color: var(--ink-dim);
+ margin-top: 2px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
.activity-empty, .activity-error {
padding: 32px 18px;
text-align: center;
- color: var(--muted);
+ color: var(--ink-dim);
font-size: 14px;
}
+ .activity-retry {
+ display: inline-block;
+ margin-top: 12px;
+ background: var(--surface-2);
+ border: 1px solid var(--stroke-strong);
+ border-radius: 10px;
+ color: var(--ink);
+ padding: 8px 16px;
+ font: inherit;
+ font-size: 13.5px;
+ font-weight: 600;
+ cursor: pointer;
+ transition: background 0.15s;
+ }
+ .activity-retry:hover:not(:disabled) { background: var(--surface-3); }
.activity-skeleton {
height: 62px;
- border-bottom: 1px solid var(--border);
- background: linear-gradient(90deg, #161616 25%, #1c1c1c 37%, #161616 63%);
+ border-bottom: 1px solid var(--stroke);
+ background: linear-gradient(90deg, var(--surface-1) 25%, var(--surface-3) 37%, var(--surface-1) 63%);
background-size: 400% 100%;
animation: activity-shimmer 1.4s ease infinite;
}
+ .activity-skeleton:last-child { border-bottom: none; }
@keyframes activity-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
+ .sr-only {
+ position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
+ overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
+ }
</style>
<meta name="twitter:card" content="summary_large_image">
@@ -205,7 +278,7 @@
<h2 data-i18n="community.live_activity">Live activity</h2>
<a href="/feed" data-i18n="community.open_the_full_feed">Open the full feed →</a>
</div>
- <div class="activity-list" id="community-activity">
+ <div class="activity-list" id="community-activity" aria-live="polite" aria-busy="true">
<div class="activity-skeleton"></div>
<div class="activity-skeleton"></div>
<div class="activity-skeleton"></div>
@@ -214,37 +287,37 @@
<div class="grid">
<div class="card">
- <span class="icon" data-i18n="community.text">&#x1D54F;</span>
+ <span class="icon" aria-hidden="true" data-i18n="community.text">&#x1D54F;</span>
<h2 data-i18n="community.follow_on_x">Follow on X</h2>
<p data-i18n="community.live_builds_demos_release_notes_and_conversa">Live builds, demos, release notes, and conversations with the team. Most day-to-day updates happen here.</p>
<a class="card-link" href="https://x.com/trythreews" target="_blank" rel="noopener noreferrer" data-i18n="community.trythreews">@trythreews →</a>
</div>
<div class="card">
- <span class="icon">&#128736;</span>
+ <span class="icon" aria-hidden="true">&#128736;</span>
<h2 data-i18n="community.github">GitHub</h2>
<p data-i18n="community.the_codebase_is_public_file_issues_read">The codebase is public. File issues, read the source, or submit a PR. SDKs, examples, and the embed runtime all live here.</p>
<a class="card-link" href="https://github.com/nirholas/three.ws" target="_blank" rel="noopener noreferrer" data-i18n="community.nirholas_three_ws">nirholas/three.ws →</a>
</div>
<div class="card">
- <span class="icon">&#128218;</span>
+ <span class="icon" aria-hidden="true">&#128218;</span>
<h2 data-i18n="community.docs">Docs</h2>
<p data-i18n="community.api_reference_embed_guides_sdk_quickstarts_a">API reference, embed guides, SDK quickstarts, and the Solana agent-kit. Start here if you're integrating.</p>
<a class="card-link" href="/docs" data-i18n="community.read_the_docs">Read the docs →</a>
</div>
<div class="card">
- <span class="icon">&#127891;</span>
+ <span class="icon" aria-hidden="true">&#127891;</span>
<h2 data-i18n="community.tutorials">Tutorials</h2>
<p data-i18n="community.step_by_step_guides_for_creating_your">Step-by-step guides for creating your first agent, embedding on your site, minting on Solana, and adding paid skills.</p>
<a class="card-link" href="/tutorials" data-i18n="community.browse_tutorials">Browse tutorials →</a>
</div>
<div class="card">
- <span class="icon">&#127970;</span>
+ <span class="icon" aria-hidden="true">&#127970;</span>
<h2 data-i18n="community.ibm_user_group">IBM user group</h2>
<p data-i18n="community.a_public_group_on_ibm_community_for_developers">A public group on IBM Community for developers building AI agents with 3D capabilities: spatial reasoning, generative 3D, agentic pipelines, and real-time interactive systems. Threads, blogs, and a platform tour to start from.</p>
<a class="card-link" href="https://community.ibm.com/community/user/groups/community-home?communitykey=e71510cc-d953-408f-9a1c-019f5c0a7016" target="_blank" rel="noopener noreferrer" data-i18n="community.join_the_user_group">Join the user group →</a>
</div>
<div class="card">
- <span class="icon">&#127942;</span>
+ <span class="icon" aria-hidden="true">&#127942;</span>
<h2 data-i18n="community.rankings">Rankings</h2>
<p data-i18n="community.the_cross_surface_leaderboard_creations_remi">The cross-surface leaderboard — creations, remixes, launches, followers, and walk distance. Build a daily streak and earn badges.</p>
<a class="card-link" href="/rankings" data-i18n="community.see_who_s_ranked">See who's ranked →</a>
@@ -264,7 +337,20 @@
<div class="section">
<h2 data-i18n="community.newsletter">Newsletter</h2>
- <p data-i18n="community.weekly_updates_on_features_protocol_changes">Weekly updates on features, protocol changes, and community highlights. No spam — unsubscribe anytime.</p>
+ <p data-i18n="community.weekly_updates_on_features_protocol_changes">Weekly updates on features, protocol changes, and community highlights. No spam, unsubscribe anytime.</p>
+ <form class="newsletter-form" data-newsletter-form novalidate>
+ <label class="sr-only" for="community-newsletter-email">Email address</label>
+ <input
+ id="community-newsletter-email"
+ type="email"
+ name="email"
+ placeholder="[email protected]"
+ autocomplete="email"
+ required
+ />
+ <button type="submit">Subscribe</button>
+ </form>
+ <p class="newsletter-msg" data-newsletter-msg role="status"></p>
</div>
</div>
@@ -286,7 +372,7 @@
world: 'built a world',
restyle: 'restyled a model',
};
- const GLYPH = { avatar: '◎', agent: '🤖', coin: '◉', model: '✦', world: '🌐', restyle: '🎨', follow: '⇢' };
+ const GLYPH = { avatar: '\u25CE', agent: '\u{1F916}', coin: '\u25C9', model: '\u2726', world: '\u{1F310}', restyle: '\u{1F3A8}', follow: '\u21E2' };
function relTime(iso) {
const then = new Date(iso).getTime();
@@ -301,24 +387,31 @@
return d < 30 ? `${d}d ago` : new Date(iso).toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
}
+ // Rows carry two destinations (the item and its creator's profile), so the
+ // item link is a stretched overlay rather than a wrapper: an <a> inside an
+ // <a> is unparseable and the browser splits it into broken fragments.
function rowEl(it) {
const a = it.actor || {};
const name = esc(a.display_name || 'A three.ws creator');
- const nameHtml = a.username ? `<a href="/u/${attr(a.username)}" style="color:inherit;text-decoration:none">${name}</a>` : name;
+ const nameHtml = a.username
+ ? `<a class="activity-user" href="/u/${attr(a.username)}">${name}</a>`
+ : name;
const avatarHtml = a.avatar_url
? `<img src="${attr(a.avatar_url)}" alt="" loading="lazy" referrerpolicy="no-referrer">`
- : GLYPH[it.kind] || '◎';
+ : GLYPH[it.kind] || '\u25CE';
+ const when = esc(relTime(it.created_at));
if (it.kind === 'follow') {
- const t = it.target || {};
+ const target = esc((it.target || {}).display_name || 'a creator');
return `
- <a class="activity-row" href="${attr(it.href)}">
+ <div class="activity-row">
+ <a class="activity-main" href="${attr(it.href)}"><span class="sr-only">${name} followed ${target}</span></a>
<span class="activity-avatar">${avatarHtml}</span>
<div class="activity-text">
- <div class="activity-line"><strong>${nameHtml}</strong> <span class="activity-verb">followed</span> <strong>${esc(t.display_name)}</strong></div>
- <div class="activity-time">${esc(relTime(it.created_at))}</div>
+ <div class="activity-line"><strong>${nameHtml}</strong> <span class="activity-verb">followed</span> <strong>${target}</strong></div>
+ <div class="activity-meta">${when}</div>
</div>
- </a>
+ </div>
`;
}
@@ -327,41 +420,59 @@
: it.kind === 'restyle' && it.isVariant
? 'made a colorway variant'
: VERB[it.kind] || 'shared something';
+ const title = esc(it.title || 'Untitled');
const thumbHtml = it.image
? `<img src="${attr(it.image)}" alt="" loading="lazy" referrerpolicy="no-referrer">`
- : (GLYPH[it.kind] || '◎');
+ : (GLYPH[it.kind] || '\u25CE');
+ const external = it.external ? ' target="_blank" rel="noopener noreferrer"' : '';
return `
- <a class="activity-row" href="${attr(it.href)}"${it.external ? ' target="_blank" rel="noopener"' : ''}>
+ <div class="activity-row">
+ <a class="activity-main" href="${attr(it.href)}"${external}><span class="sr-only">${title}</span></a>
<span class="activity-avatar">${avatarHtml}</span>
<div class="activity-text">
- <div class="activity-line"><strong>${nameHtml}</strong> <span class="activity-verb">${esc(verb)}</span> — ${esc(it.title || 'Untitled')}</div>
- <div class="activity-time">${esc(relTime(it.created_at))}</div>
+ <div class="activity-line"><strong>${nameHtml}</strong> <span class="activity-verb">${esc(verb)}</span></div>
+ <div class="activity-meta">${title} \u00B7 ${when}</div>
</div>
<span class="activity-thumb">${thumbHtml}</span>
- </a>
+ </div>
`;
}
- (async function load() {
- let res;
+ function showError(message) {
+ el.innerHTML = `
+ <div class="activity-error">
+ <div>${esc(message)}</div>
+ <button type="button" class="activity-retry">Try again</button>
+ </div>
+ `;
+ el.querySelector('.activity-retry').addEventListener('click', load);
+ }
+
+ function showSkeleton() {
+ el.innerHTML = '<div class="activity-skeleton"></div>'.repeat(3);
+ }
+
+ async function load() {
+ showSkeleton();
+ el.setAttribute('aria-busy', 'true');
try {
- res = await fetch('/api/users/me/feed?scope=all&limit=10');
+ const res = await fetch('/api/users/me/feed?scope=all&limit=10', { headers: { accept: 'application/json' } });
+ if (!res.ok) throw new Error(`feed responded ${res.status}`);
+ const data = await res.json();
+ const items = Array.isArray(data.items) ? data.items : [];
+ if (!items.length) {
+ el.innerHTML = `<div class="activity-empty">No activity yet. Be the first to <a href="/create">create something</a>.</div>`;
+ return;
+ }
+ el.innerHTML = items.map(rowEl).join('');
} catch {
- el.innerHTML = `<div class="activity-error">Could not load live activity right now.</div>`;
- return;
- }
- if (!res.ok) {
- el.innerHTML = `<div class="activity-error">Could not load live activity right now.</div>`;
- return;
+ showError('Could not load live activity right now.');
+ } finally {
+ el.setAttribute('aria-busy', 'false');
}
- const data = await res.json();
- const items = data.items || [];
- if (!items.length) {
- el.innerHTML = `<div class="activity-empty">Nothing has happened yet — be the first to <a href="/create">create something</a>.</div>`;
- return;
- }
- el.innerHTML = items.map(rowEl).join('');
- })();
+ }
+
+ load();
</script>
<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
<script type="module" src="/i18n.js"></script>
diff --git a/pages/compose.html b/pages/compose.html
index 8fe32432a..454eef998 100644
--- a/pages/compose.html
+++ b/pages/compose.html
@@ -36,13 +36,21 @@
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}
html,body{height:100%;overflow:hidden;background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;}
- /* Root grid */
- #cr{display:grid;grid-template-rows:46px 1fr;grid-template-columns:248px 1fr 288px;height:100vh;overflow:hidden;}
+ /* Screen-reader-only: kept focusable, unlike display:none. */
+ .sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0;}
- /* Topbar */
- #tb{grid-column:1/-1;display:flex;align-items:center;gap:5px;padding:0 10px;background:var(--surface);border-bottom:1px solid var(--border);user-select:none;}
+ /* Root grid. min-width:0 on every track child so a wide toolbar can never
+ force the grid past the viewport (that is what clipped the canvas and
+ the whole right panel off-screen at 320px). */
+ #cr{display:grid;grid-template-rows:46px 1fr;grid-template-columns:248px 1fr 288px;height:100dvh;overflow:hidden;min-width:0;}
+ #cr > *{min-width:0;}
+
+ /* Topbar. Scrolls horizontally when the controls outgrow the viewport, so
+ every button stays reachable on a phone instead of being cut off. */
+ #tb{grid-column:1/-1;display:flex;align-items:center;gap:5px;padding:0 10px;background:var(--surface);border-bottom:1px solid var(--border);user-select:none;overflow-x:auto;overflow-y:hidden;scrollbar-width:none;}
+ #tb::-webkit-scrollbar{height:0;}
.tbl{font-size:13px;font-weight:700;color:#fff;text-decoration:none;letter-spacing:-.01em;flex-shrink:0;}
- .tbp{font-size:12px;font-weight:500;color:var(--ink-dim);padding:0 8px;border-left:1px solid var(--border);}
+ .tbp{font-size:12px;font-weight:500;color:var(--ink-dim);padding:0 8px;border-left:1px solid var(--border);flex-shrink:0;}
.tbs{width:1px;height:18px;background:var(--border);margin:0 1px;flex-shrink:0;}
.tbsp{flex:1;}
.tbg{display:flex;align-items:center;gap:2px;}
@@ -57,8 +65,8 @@
.campw{position:relative;}
#cmenu{position:absolute;top:calc(100% + 6px);left:0;z-index:500;background:var(--surface);border:1px solid var(--border);border-radius:var(--r);padding:4px;min-width:120px;box-shadow:0 12px 40px rgba(0,0,0,.55);}
#cmenu[hidden]{display:none;}
- .cmi{padding:5px 10px;border-radius:var(--rs);font-size:12px;color:var(--ink-dim);cursor:pointer;transition:background .08s,color .08s;display:flex;align-items:center;justify-content:space-between;gap:10px;}
- .cmi:hover{background:rgba(255,255,255,.07);color:var(--ink);}
+ .cmi{width:100%;padding:5px 10px;border:none;background:none;font-family:inherit;text-align:left;border-radius:var(--rs);font-size:12px;color:var(--ink-dim);cursor:pointer;transition:background .08s,color .08s;display:flex;align-items:center;justify-content:space-between;gap:10px;}
+ .cmi:hover,.cmi:focus-visible{background:rgba(255,255,255,.07);color:var(--ink);}
.cmik{font-size:9px;font-family:var(--mono);opacity:.4;}
#ss{font-size:11px;color:var(--ink-dim);opacity:0;transition:opacity .3s;padding:0 4px;}
#ss.v{opacity:1;}
@@ -69,16 +77,20 @@
.phb{padding:2px 8px;border-radius:var(--rs);background:rgba(255,255,255,.05);border:1px solid var(--border);color:var(--ink-dim);font-size:11px;cursor:pointer;transition:background .08s,color .08s;}
.phb:hover{background:rgba(255,255,255,.1);color:var(--ink);}
#ol{flex:1;overflow-y:auto;padding:2px 0;}
- .or{display:flex;align-items:center;gap:5px;padding:5px 8px 5px 10px;cursor:pointer;border-left:2px solid transparent;transition:background .08s;}
+ .or{display:flex;align-items:center;gap:5px;padding:0 8px 0 0;border-left:2px solid transparent;transition:background .08s;}
.or:hover{background:rgba(255,255,255,.03);}
.or.sel{background:rgba(99,102,241,.1);border-left-color:var(--accent);}
+ /* The row's select target is a real button, so the hierarchy is keyboard
+ navigable and the hide/remove buttons are not nested inside a control. */
+ .ob{flex:1;min-width:0;display:flex;align-items:center;gap:5px;padding:5px 4px 5px 10px;background:none;border:none;font-family:inherit;text-align:left;cursor:pointer;color:inherit;}
.oi{flex:0 0 15px;text-align:center;font-size:12px;color:var(--ink-mute);}
.on{flex:1;min-width:0;font-size:12px;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink);}
.oni{flex:1;background:rgba(99,102,241,.12);border:1px solid var(--accent-border);border-radius:3px;color:var(--ink);font-size:12px;padding:1px 5px;outline:none;}
.ot{font-size:9px;font-weight:600;letter-spacing:.04em;padding:1px 5px;border-radius:3px;background:rgba(255,255,255,.06);color:var(--ink-mute);text-transform:uppercase;white-space:nowrap;flex-shrink:0;}
.ot.b{background:rgba(99,102,241,.15);color:var(--accent-text);}
+ /* Revealed on focus too, or a keyboard user could never reach hide/remove. */
.oa{display:flex;gap:1px;opacity:0;transition:opacity .1s;}
- .or:hover .oa{opacity:1;}
+ .or:hover .oa,.or:focus-within .oa{opacity:1;}
.oab{width:18px;height:18px;background:none;border:none;cursor:pointer;font-size:11px;color:var(--ink-mute);border-radius:3px;text-align:center;line-height:18px;transition:background .08s,color .08s;}
.oab:hover{background:rgba(255,255,255,.08);color:var(--ink);}
.oab.d:hover{background:rgba(248,113,113,.12);color:var(--danger);}
@@ -135,6 +147,9 @@
.aplk:hover{opacity:1;}
.apsk{font-size:11px;color:var(--ink-dim);background:none;border:1px solid var(--border);border-radius:var(--r);padding:6px 16px;cursor:pointer;transition:background .1s,color .1s;}
.apsk:hover{background:rgba(255,255,255,.06);color:var(--ink);}
+ /* Persistent load error: a toast vanishes before a user can read the cause. */
+ #ape{display:none;max-width:350px;font-size:11px;line-height:1.5;color:var(--danger);background:rgba(248,113,113,.09);border:1px solid rgba(248,113,113,.28);border-radius:var(--r);padding:7px 11px;}
+ #ape.on{display:block;}
/* Right panel */
#pf{background:var(--surface);border-left:1px solid var(--border);display:flex;flex-direction:column;overflow:hidden;}
@@ -175,18 +190,21 @@
.gh a{font-size:10px;color:var(--ink-mute);text-decoration:none;text-transform:none;letter-spacing:normal;transition:color .1s;}
.gh a:hover{color:var(--accent-text);}
#gl{flex:1;overflow-y:auto;display:grid;grid-template-columns:1fr 1fr;gap:5px;padding:0 8px 10px;align-content:start;}
- .gc{aspect-ratio:1;border-radius:8px;overflow:hidden;position:relative;cursor:pointer;background:var(--surface2);border:1px solid var(--border);transition:border-color .12s,transform .1s;}
- .gc:hover{border-color:var(--accent-border);transform:scale(1.02);}
+ .gc{aspect-ratio:1;border-radius:8px;overflow:hidden;position:relative;cursor:pointer;background:var(--surface2);border:1px solid var(--border);transition:border-color .12s,transform .1s;padding:0;display:block;width:100%;font-family:inherit;}
+ .gc:hover,.gc:focus-visible{border-color:var(--accent-border);transform:scale(1.02);}
.gc img{width:100%;height:100%;object-fit:cover;display:block;}
.gco{position:absolute;inset:0;background:linear-gradient(to top,rgba(0,0,0,.75) 0%,transparent 55%);display:flex;flex-direction:column;justify-content:flex-end;padding:6px;opacity:0;transition:opacity .12s;}
- .gc:hover .gco{opacity:1;}
+ .gc:hover .gco,.gc:focus-visible .gco{opacity:1;}
.gcp{font-size:10px;color:#fff;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;}
.gca{font-size:10px;font-weight:600;color:var(--accent-text);background:rgba(99,102,241,.28);border-radius:4px;padding:2px 6px;margin-top:3px;text-align:center;}
.gcg{width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10px;color:rgba(255,255,255,.2);text-align:center;padding:8px;}
- .ge{grid-column:1/-1;text-align:center;padding:20px 0;font-size:11px;color:var(--ink-mute);}
+ .ge{grid-column:1/-1;text-align:center;padding:20px 8px;font-size:11px;color:var(--ink-mute);line-height:1.6;}
+ .geb{margin-top:8px;padding:4px 12px;border-radius:var(--rs);background:rgba(255,255,255,.05);border:1px solid var(--border);color:var(--ink-dim);font-size:11px;font-family:inherit;cursor:pointer;transition:background .1s,color .1s;}
+ .geb:hover{background:rgba(255,255,255,.1);color:var(--ink);}
#dz{margin:0 8px 8px;border:1px dashed rgba(255,255,255,.09);border-radius:var(--r);padding:9px;text-align:center;font-size:10px;color:var(--ink-mute);cursor:pointer;transition:border-color .12s,background .12s;flex-shrink:0;}
- #dz:hover,#dz.dh{border-color:var(--accent-border);background:rgba(99,102,241,.04);color:var(--accent-text);}
- #dz input{display:none;}
+ #dz:hover,#dz.dh,#dz:focus-within{border-color:var(--accent-border);background:rgba(99,102,241,.04);color:var(--accent-text);}
+ /* sr-only, not display:none — a hidden file input cannot take keyboard focus. */
+ #dz input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none;}
/* Avatar modal */
#am{position:fixed;inset:0;z-index:9000;background:rgba(0,0,0,.65);backdrop-filter:blur(6px);display:flex;align-items:center;justify-content:center;}
@@ -221,8 +239,34 @@
::-webkit-scrollbar-thumb{background:rgba(255,255,255,.09);border-radius:2px;}
::-webkit-scrollbar-thumb:hover{background:rgba(255,255,255,.16);}
- @media(max-width:900px){#cr{grid-template-columns:0 1fr 272px;}#po{display:none;}}
- @media(max-width:600px){#cr{grid-template-columns:1fr;grid-template-rows:46px 1fr 260px;}#pf{grid-row:3;}#cst{display:none;}}
+ /* Below 900px the scene panel becomes an overlay drawer instead of being
+ hidden outright: `display:none` removed it from the grid, which shunted
+ the canvas into the 0px track and left it invisible, and it also stranded
+ the hierarchy, inspector and bone-attach UI with no way to reach them. */
+ #btn-panel{display:none;}
+ #poscrim{display:none;}
+ @media(max-width:900px){
+ #cr{grid-template-columns:1fr 272px;}
+ #cw{grid-column:1;}
+ #pf{grid-column:2;}
+ #btn-panel{display:inline-flex;}
+ #po{position:fixed;top:46px;left:0;bottom:0;width:min(268px,82vw);z-index:600;transform:translateX(-100%);transition:transform .22s ease;box-shadow:0 0 40px rgba(0,0,0,.5);}
+ #po.open{transform:none;}
+ #poscrim{display:block;position:fixed;inset:46px 0 0;z-index:590;background:rgba(0,0,0,.5);opacity:0;pointer-events:none;transition:opacity .22s;border:0;padding:0;}
+ #poscrim.open{opacity:1;pointer-events:auto;}
+ }
+ @media(max-width:600px){
+ #cr{grid-template-columns:1fr;grid-template-rows:46px 1fr 262px;}
+ #cw{grid-column:1;grid-row:2;}
+ #pf{grid-column:1;grid-row:3;border-left:none;border-top:1px solid var(--border);}
+ #cst{display:none;}
+ #ap{padding:20px 16px;gap:11px;}
+ .apr{flex-direction:column;}
+ .apbt{width:100%;}
+ }
+ @media(prefers-reduced-motion:reduce){
+ *,*::before,*::after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important;}
+ }
</style>
<link rel="canonical" href="https://three.ws/compose">
@@ -241,8 +285,9 @@
<!-- Topbar -->
<header id="tb">
<a href="/" class="tbl" data-i18n="compose.three_ws">three.ws</a>
- <span class="tbp" data-i18n="compose.scene_composer">Scene Composer</span>
+ <h1 class="tbp" data-i18n="compose.scene_composer">Scene Composer</h1>
<div class="tbs"></div>
+ <button class="btn" id="btn-panel" type="button" title="Scene panel" aria-expanded="false" aria-controls="po" data-i18n-attr="title:compose.scene_panel_title">☰</button>
<div class="tbg">
<button class="btn" id="btn-undo" title="Undo (Ctrl+Z)" disabled data-i18n-attr="title:compose.undo_ctrl_z_title">↩</button>
<button class="btn" id="btn-redo" title="Redo (Ctrl+Y)" disabled data-i18n-attr="title:compose.redo_ctrl_y_title">↪</button>
@@ -260,14 +305,14 @@
</div>
<div class="tbs"></div>
<div class="tbg campw">
- <button class="btn" id="btn-cam" title="Camera views" data-i18n="compose.view" data-i18n-attr="title:compose.camera_views_title">📷 View ▾</button>
- <div id="cmenu" hidden>
- <div class="cmi" data-cam="front">Front <span class="cmik" data-i18n="compose.num1">Num1</span></div>
- <div class="cmi" data-cam="back">Back</div>
- <div class="cmi" data-cam="left">Left <span class="cmik" data-i18n="compose.num3">Num3</span></div>
- <div class="cmi" data-cam="right">Right</div>
- <div class="cmi" data-cam="top">Top <span class="cmik" data-i18n="compose.num7">Num7</span></div>
- <div class="cmi" data-cam="iso">Isometric</div>
+ <button class="btn" id="btn-cam" title="Camera views" aria-haspopup="true" aria-expanded="false" aria-controls="cmenu" data-i18n="compose.view" data-i18n-attr="title:compose.camera_views_title">📷 View ▾</button>
+ <div id="cmenu" hidden role="menu" aria-label="Camera views">
+ <button type="button" class="cmi" role="menuitem" data-cam="front">Front <span class="cmik" data-i18n="compose.num1">Num1</span></button>
+ <button type="button" class="cmi" role="menuitem" data-cam="back">Back</button>
+ <button type="button" class="cmi" role="menuitem" data-cam="left">Left <span class="cmik" data-i18n="compose.num3">Num3</span></button>
+ <button type="button" class="cmi" role="menuitem" data-cam="right">Right</button>
+ <button type="button" class="cmi" role="menuitem" data-cam="top">Top <span class="cmik" data-i18n="compose.num7">Num7</span></button>
+ <button type="button" class="cmi" role="menuitem" data-cam="iso">Isometric</button>
</div>
</div>
<div class="tbsp"></div>
@@ -279,11 +324,12 @@
</header>
<!-- Left panel -->
- <aside id="po">
+ <aside id="po" aria-label="Scene objects and inspector">
<div class="ph">Scene <button class="phb" id="btn-load-av" data-i18n="compose.load_avatar">Load Avatar</button></div>
<div id="ol"></div>
<div id="ins"><div class="ie">Select an object</div></div>
</aside>
+ <button id="poscrim" type="button" tabindex="-1" aria-label="Close scene panel"></button>
<!-- Canvas -->
<main id="cw">
@@ -298,9 +344,11 @@
<div class="apt">Start with an Avatar</div>
<div class="apb">Load an avatar to attach items to its bones, or start fresh and build freely.</div>
<div class="apr">
- <input class="api" type="url" id="av-url" placeholder="Paste GLB URL or avatar ID…" autocomplete="off" />
+ <label class="sr" for="av-url" data-i18n="compose.avatar_glb_url_or_id">Avatar GLB URL or avatar ID</label>
+ <input class="api" type="text" id="av-url" placeholder="Paste GLB URL or avatar ID…" autocomplete="off" spellcheck="false" />
<button class="apbt" id="btn-load-url" data-i18n="compose.load">Load</button>
</div>
+ <p id="ape" role="alert"></p>
<span class="apor" data-i18n="compose.or">or</span>
<button class="aplk" id="btn-browse-av" data-i18n="compose.browse_my_avatars">Browse my avatars</button>
<button class="apsk" id="btn-skip" data-i18n="compose.start_with_empty_scene">Start with empty scene</button>
@@ -325,6 +373,7 @@
</div>
</div>
<div class="pw">
+ <label class="sr" for="fp" data-i18n="compose.describe_the_item_to_forge">Describe the item to forge</label>
<textarea id="fp" placeholder="A glowing katana with blue neon energy…" rows="3"></textarea>
<div class="sps" id="sps"></div>
<button id="fb" data-i18n-html="compose.forge"><span class="bs"></span><span class="bl">⚡ Forge</span></button>
diff --git a/src/character-library.js b/src/character-library.js
index 71f2db878..a9380fb6f 100644
--- a/src/character-library.js
+++ b/src/character-library.js
@@ -1,6 +1,6 @@
// /character-library — the Mixamo character library gallery.
//
-// Browses the 106 professionally rigged humanoid characters served by
+// Browses the professionally rigged humanoid characters served by
// GET /api/avatars/library (manifest on R2, mirroring the /animations gallery).
// Each card renders a live <model-viewer> off the GLB's CDN url and deep-links
// into the three viewers that accept a raw model URL:
@@ -8,8 +8,9 @@
// Use → /studio?model=<glb> (widget studio)
// Animate → /pose?src=<glb> (animation studio; r2.dev is a trusted host)
//
-// The library is small (106 entries) so the whole manifest is fetched once and
-// filtered/sorted client-side — no pagination round-trips, instant search.
+// The library is small (a hundred or so entries) so the whole manifest is
+// fetched once and filtered/sorted client-side: no pagination round-trips,
+// instant search.
const els = {
grid: document.querySelector('[data-role="grid"]'),
@@ -51,6 +52,13 @@ function formatBytes(n) {
return mb >= 1 ? `${mb.toFixed(1)} MB` : `${Math.round(n / 1024)} KB`;
}
+// A card's <model-viewer> is deliberately control-free. model-viewer reads
+// `camera-controls` as a boolean attribute, so the old `camera-controls="false"`
+// switched controls ON: it made every thumbnail drag-orbit under the link that
+// wraps it, and it gave each of the hundred-plus cards a keyboard tab stop with
+// nothing to operate. Dropping the attribute leaves auto-rotate (which does not
+// need controls) and hands the click straight to the viewer link. The `disable-*`
+// attributes went with it; they only ever qualified camera-controls.
function renderCard(a) {
const glbUrl = a.url || '';
const previewUrl = glbUrl ? `/app#model=${encodeURIComponent(glbUrl)}` : '#';
@@ -69,11 +77,7 @@ function renderCard(a) {
class="ch-card-mv"
reveal="manual"
loading="lazy"
- disable-zoom
- disable-pan
- disable-tap
interaction-prompt="none"
- camera-controls="false"
auto-rotate
rotation-per-second="20deg"
environment-image="neutral"
@@ -216,9 +220,12 @@ async function load() {
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
state.all = Array.isArray(data.avatars) ? data.avatars : [];
+ // The hero used to hard-code "106" in its headline, which went stale the
+ // moment the 107th character landed on R2. The manifest is now the only
+ // place the number lives, and it renders here.
if (els.heroStats) {
els.heroStats.textContent = state.all.length
- ? `${state.all.length} rigged characters · ready to animate`
+ ? `${state.all.length} rigged characters · free to use`
: '';
}
applyView();
@@ -228,7 +235,13 @@ async function load() {
show(els.empty, false);
show(els.emptySearch, false);
show(els.error, true);
- if (els.errorMsg) els.errorMsg.textContent = `Failed to load characters: ${err?.message || 'network error'}`;
+ if (els.errorMsg) {
+ // The catalog pass lands after /api/locale resolves and would otherwise
+ // revert this concrete reason back to the generic placeholder shipped in
+ // the HTML. data-i18n-owned hands the element to this script for good.
+ els.errorMsg.dataset.i18nOwned = '1';
+ els.errorMsg.textContent = `Failed to load characters: ${err?.message || 'network error'}`;
+ }
}
}
diff --git a/src/clash.js b/src/clash.js
index 904f32323..aebab6c78 100644
--- a/src/clash.js
+++ b/src/clash.js
@@ -77,22 +77,33 @@ function fmtUsd(n) {
return `$${n < 1 ? n.toFixed(3) : n.toLocaleString(undefined, { maximumFractionDigits: 2 })}`;
}
-async function apiGet(action, params = '') {
- const r = await fetch(`${API}/${action}${params}`, { credentials: 'include' });
+// One network boundary for every call. A fetch that never reaches the server
+// rejects with a raw TypeError ("Failed to fetch"), which used to land verbatim
+// in the arena's error card; a visitor cannot act on that string, so the
+// transport failure is named here instead and tagged so callers can tell it
+// apart from a real server answer.
+async function apiFetch(action, params, init) {
+ let r;
+ try {
+ r = await fetch(`${API}/${action}${params}`, init);
+ } catch (cause) {
+ throw Object.assign(new Error('Couldn’t reach the battle server. Check your connection and try again.'), { code: 'network_error', cause });
+ }
const body = await r.json().catch(() => ({}));
if (!r.ok) throw Object.assign(new Error(body.error_description || body.error || `HTTP ${r.status}`), { status: r.status, code: body.error });
return body.data;
}
+
+async function apiGet(action, params = '') {
+ return apiFetch(action, params, { credentials: 'include' });
+}
async function apiPost(action, payload) {
- const r = await fetch(`${API}/${action}`, {
+ return apiFetch(action, '', {
method: 'POST',
credentials: 'include',
headers: { 'content-type': 'application/json' },
body: JSON.stringify(payload),
});
- const body = await r.json().catch(() => ({}));
- if (!r.ok) throw Object.assign(new Error(body.error_description || body.error || `HTTP ${r.status}`), { status: r.status, code: body.error });
- return body.data;
}
// ── Avatar (image or seeded initials) ────────────────────────────────────────
diff --git a/src/clip-director-page.js b/src/clip-director-page.js
index 68a1b28f8..00954c5ee 100644
--- a/src/clip-director-page.js
+++ b/src/clip-director-page.js
@@ -1,6 +1,7 @@
// Clip Director page, turn a real closed trade into shareable cards per surface.
-// Populates a trader picker from the live mirror leaderboard, then fetches
-// /api/clip-director for the selected agent's most notable close and renders one
+// Populates a trader picker from the live mirror leaderboard (restricted to
+// agents that actually have a closed round-trip, since a clip is minted from
+// one), then fetches /api/clip-director for the selected agent and renders one
// card per surface (X / Telegram / Feed) with a copyable payload. Every state is
// designed: loading, empty (no closed trades), error, populated.
@@ -16,32 +17,57 @@ const SURFACES = [
{ key: 'feed', label: 'In-app Feed' },
];
const GESTURE_EMOJI = { celebrate: '🎉', point: '👉', wave: '👋', shrug: '🤷', sweat: '😰' };
-const CTA_LABEL = { 'fork-this-trade': 'Fork this trade', 'copy-the-agent': 'Copy the agent', 'view-track-record': 'View track record' };
+// Each CTA the director can pick resolves to a real destination on this site, so
+// the call to action on a card is a link the reader can follow, not a label.
+const CTA = {
+ 'fork-this-trade': { label: 'Fork this trade', href: () => '/mirror' },
+ 'copy-the-agent': { label: 'Copy the agent', href: () => '/mirror' },
+ 'view-track-record': { label: 'View track record', href: (agentId) => (agentId ? `/agents/${encodeURIComponent(agentId)}` : '/leaderboard') },
+};
function esc(s) {
return String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
}
+function deepLinkedAgentId() {
+ const wanted = (new URLSearchParams(location.search).get('agent_id') || '').trim();
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(wanted) ? wanted : '';
+}
+
async function loadLeaders() {
+ const wanted = deepLinkedAgentId();
+ agentSel.innerHTML = '<option value="">Loading leaders…</option>';
+ agentSel.disabled = true;
try {
- const res = await fetch('/api/mirror/leaderboard?sort=score&limit=40', { headers: { accept: 'application/json' } });
+ // settled_min=1 is the whole point of this call: a clip needs a closed
+ // round-trip, and the composite score does not correlate with having one,
+ // so asking for the top N by score and filtering here would (and did) drop
+ // every eligible agent off the end of the window.
+ const res = await fetch('/api/mirror/leaderboard?sort=score&limit=50&settled_min=1', { headers: { accept: 'application/json' } });
if (!res.ok) throw new Error(String(res.status));
const data = await res.json();
const leaders = (data?.data?.leaders || []).filter((l) => l.settled > 0);
- if (!leaders.length) {
+ const options = leaders.map((l) =>
+ `<option value="${esc(l.agent_id)}">${esc(l.name || 'Unnamed')}: ${l.settled} trade${l.settled === 1 ? '' : 's'}${l.win_rate != null ? `, ${l.win_rate}% win` : ''}</option>`);
+ // A shared link can point at an agent outside the ranked window (or a
+ // private one that never ranks). Honour it rather than dropping the
+ // visitor on an empty board; the option gets its real name once the clip
+ // loads, and an unknown id lands in the designed error state.
+ if (wanted && !leaders.some((l) => l.agent_id === wanted)) {
+ options.unshift(`<option value="${esc(wanted)}">Shared agent</option>`);
+ }
+ if (!options.length) {
agentSel.innerHTML = '<option value="">No agents with closed trades yet</option>';
renderEmpty('No agent has a closed on-chain trade yet. Clips are minted from real closed round-trips, so the board fills as agents trade.');
return;
}
- agentSel.innerHTML = leaders.map((l) =>
- `<option value="${esc(l.agent_id)}">${esc(l.name || 'Unnamed')}: ${l.settled} trade${l.settled === 1 ? '' : 's'}${l.win_rate != null ? `, ${l.win_rate}% win` : ''}</option>`).join('');
- // Deep-link support: ?agent_id=<uuid> preselects.
- const wanted = new URLSearchParams(location.search).get('agent_id');
- if (wanted && leaders.some((l) => l.agent_id === wanted)) agentSel.value = wanted;
+ agentSel.innerHTML = options.join('');
+ agentSel.disabled = false;
+ if (wanted) agentSel.value = wanted;
loadClips(agentSel.value);
} catch {
agentSel.innerHTML = '<option value="">Could not load leaders</option>';
- renderError('The trader leaderboard is unreachable right now.');
+ renderError('The trader leaderboard is unreachable right now.', loadLeaders);
}
}
@@ -60,7 +86,9 @@ function renderEmpty(msg) {
</div>`;
}
-function renderError(msg) {
+// `retry` is what the failed step actually was: retrying the clip fetch when the
+// picker never loaded would be a button that does nothing.
+function renderError(msg, retry) {
tradeEl.innerHTML = '';
resultEl.innerHTML = `
<div class="cd-error">
@@ -68,7 +96,7 @@ function renderError(msg) {
<p>${esc(msg || 'The clip service is unreachable right now.')}</p>
<button type="button" id="cdRetry">Try again</button>
</div>`;
- document.getElementById('cdRetry')?.addEventListener('click', () => loadClips(agentSel.value));
+ document.getElementById('cdRetry')?.addEventListener('click', retry || (() => loadClips(agentSel.value)));
}
function renderTrade(agent, trade, proof) {
@@ -78,8 +106,12 @@ function renderTrade(agent, trade, proof) {
: trade.realized_pnl_sol != null ? `${trade.realized_pnl_sol > 0 ? '+' : ''}${trade.realized_pnl_sol} SOL`
: trade.pnl_pct != null ? `${trade.pnl_pct}%` : 'closed';
const sym = trade.symbol || trade.name || (trade.mint ? trade.mint.slice(0, 6) : 'coin');
+ const who = agent?.id
+ ? `<a class="who" href="/agents/${encodeURIComponent(agent.id)}">${esc(agent.name || 'This agent')}</a>`
+ : `<span class="who">${esc(agent?.name || 'This agent')}</span>`;
tradeEl.innerHTML = `
<div class="cd-trade">
+ ${who}
<span class="sym">${esc(sym.startsWith('$') ? sym : `$${sym}`)}</span>
<span class="stat">Result <b class="${cls}">${esc(headline)}</b></span>
${trade.hold_min != null ? `<span class="stat">Held <b>${trade.hold_min < 60 ? `${trade.hold_min}m` : `${Math.round(trade.hold_min / 60)}h`}</b></span>` : ''}
@@ -88,9 +120,10 @@ function renderTrade(agent, trade, proof) {
</div>`;
}
-function clipCard(surface, label, clip) {
+function clipCard(surface, label, clip, agentId) {
const gesture = GESTURE_EMOJI[clip.avatar_gesture] || '🎯';
- const copyPayload = `${clip.hook}\n\n${clip.body}\n\n(${CTA_LABEL[clip.cta] || clip.cta} · verifiable on-chain · three.ws)`;
+ const cta = CTA[clip.cta] || { label: clip.cta, href: () => '/leaderboard' };
+ const copyPayload = `${clip.hook}\n\n${clip.body}\n\n(${cta.label} · verifiable on-chain · three.ws)`;
return `
<article class="cd-card ${surface}">
<div class="cd-card-head"><span class="dot"></span>${esc(label)}</div>
@@ -98,34 +131,60 @@ function clipCard(surface, label, clip) {
<div class="cd-hook">${esc(clip.hook)}</div>
<div class="cd-featstat"><span class="gesture" title="${esc(clip.avatar_gesture)} reaction" aria-hidden="true">${gesture}</span><span class="num">${esc(clip.feature_stat)}</span></div>
<div class="cd-text">${esc(clip.body)}</div>
- <div class="cd-cta">${esc(CTA_LABEL[clip.cta] || clip.cta)}</div>
+ <a class="cd-cta" href="${esc(cta.href(agentId))}">${esc(cta.label)} →</a>
<div class="cd-alt"><b>Alt text.</b> ${esc(clip.alt_text)}</div>
<button type="button" class="cd-copy" data-payload="${esc(copyPayload)}">Copy ${esc(label.split(' ')[0])} text</button>
</div>
</article>`;
}
+// navigator.clipboard is unavailable outside a secure context and can be denied
+// by permissions policy, so the fallback actually copies (a selected off-screen
+// textarea + execCommand) instead of telling the reader to press a key that has
+// nothing selected.
+function copyText(text) {
+ if (navigator.clipboard?.writeText) {
+ return navigator.clipboard.writeText(text).catch(() => legacyCopy(text));
+ }
+ return legacyCopy(text);
+}
+
+function legacyCopy(text) {
+ const ta = document.createElement('textarea');
+ ta.value = text;
+ ta.setAttribute('readonly', '');
+ ta.style.cssText = 'position:fixed;top:0;left:-9999px;opacity:0';
+ document.body.appendChild(ta);
+ ta.select();
+ ta.setSelectionRange(0, text.length);
+ const ok = document.execCommand('copy');
+ ta.remove();
+ return ok ? Promise.resolve() : Promise.reject(new Error('copy_unavailable'));
+}
+
function renderClips(agent, data) {
renderTrade(agent, data.trade, data.proof);
const cards = SURFACES.map(({ key, label }) => {
const clip = data.clips.find((c) => c.surface === key);
- return clip ? clipCard(key, label, clip) : '';
+ return clip ? clipCard(key, label, clip, agent?.id) : '';
}).join('');
resultEl.innerHTML = `
<div class="cd-grid">${cards}</div>
<div class="cd-note"><b>Honest by design.</b> Wins and losses both get a card, always with a verifiable on-chain angle. The number you see is a real closed round-trip, never a screenshot.</div>`;
for (const btn of resultEl.querySelectorAll('.cd-copy')) {
+ const original = btn.textContent;
btn.addEventListener('click', async () => {
+ clearTimeout(btn.dataset.timer);
try {
- await navigator.clipboard.writeText(btn.dataset.payload);
- const original = btn.textContent;
+ await copyText(btn.dataset.payload);
btn.textContent = 'Copied ✓';
btn.classList.add('done');
- setTimeout(() => { btn.textContent = original; btn.classList.remove('done'); }, 1600);
} catch {
- btn.textContent = 'Press Ctrl+C';
+ btn.textContent = 'Copy blocked by browser';
+ btn.classList.remove('done');
}
+ btn.dataset.timer = setTimeout(() => { btn.textContent = original; btn.classList.remove('done'); }, 1600);
});
}
}
@@ -144,6 +203,7 @@ async function loadClips(agentId) {
}
const data = await res.json();
if (seq !== reqSeq) return;
+ labelOption(agentId, data.agent?.name);
if (!data.clips || data.clips.length === 0) return renderEmpty(data.empty);
renderClips(data.agent, data);
} catch {
@@ -152,5 +212,14 @@ async function loadClips(agentId) {
}
}
+// A deep-linked agent enters the picker as "Shared agent" because the ranking
+// never carried its name. The clip response does, so the option stops lying as
+// soon as the answer lands.
+function labelOption(agentId, name) {
+ if (!name) return;
+ const opt = [...agentSel.options].find((o) => o.value === agentId);
+ if (opt && opt.textContent === 'Shared agent') opt.textContent = name;
+}
+
agentSel.addEventListener('change', () => loadClips(agentSel.value));
loadLeaders();
diff --git a/src/coin-pages.css b/src/coin-pages.css
index 1027c4e0f..695b01195 100644
--- a/src/coin-pages.css
+++ b/src/coin-pages.css
@@ -966,6 +966,39 @@ html.cv-page,
color: var(--cv-accent);
}
+/* A secondary strip that failed (the /coins global stats bar) states it in one
+ quiet line rather than collapsing to a blank void. Same visual language as
+ .cv-liq-offline so the two degraded strips read as one system. */
+.cv-inline-note {
+ color: var(--cv-text-3);
+ font-size: 0.8125rem;
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ margin: 0;
+}
+.cv-inline-note .dot {
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: var(--cv-text-3);
+ flex-shrink: 0;
+}
+
+/* Load-more outcomes that are not another page of rows: the end of the feed,
+ and a failed fetch that must not read as a broken button. */
+.cv-load-end,
+.cv-load-err {
+ margin: 1.25rem 0 0;
+ text-align: center;
+ font-size: 0.8125rem;
+ color: var(--cv-text-3);
+}
+.cv-load-err {
+ margin-top: 0.625rem;
+ color: var(--cv-down);
+}
+
/* An in-prose control that acts on this page (retry, clear a filter) is a button,
not a link: it navigates nowhere. It still reads as a link so the sentence it
sits in keeps working, and it gets the keyboard and focus behaviour a native
diff --git a/src/coins-index.js b/src/coins-index.js
index e2527fa87..452d6b341 100644
--- a/src/coins-index.js
+++ b/src/coins-index.js
@@ -56,6 +56,7 @@ function fgClass(v) {
async function loadStats() {
const el = $('cv-stats');
+ if (!el) return; // shell navigation left /coins before the retry landed
el.innerHTML =
'<div style="display:grid;gap:1rem;grid-template-columns:repeat(auto-fit,minmax(170px,1fr))">' +
Array.from({ length: 6 }, () => '<div class="cv-skel" style="height:6rem"></div>').join('') +
@@ -109,17 +110,47 @@ async function loadStats() {
}
el.innerHTML = cards.length
? `<div style="display:grid;gap:1rem;grid-template-columns:repeat(auto-fit,minmax(170px,1fr))">${cards.join('')}</div>`
- : '';
+ : statsNote('No global market stats are being reported right now.');
} catch {
- el.innerHTML = ''; // Stats bar is an enhancement — the table is the page.
+ // The stats bar is an enhancement (the table is the page), so its failure
+ // stays quiet. Quiet is not silent: a blank strip reads as "this page has
+ // no stats", so say what happened and offer the retry.
+ el.innerHTML = statsNote('Global market stats are unavailable right now.');
}
+ el.querySelector('[data-act="retry-stats"]')?.addEventListener('click', loadStats);
+}
+
+// Same visual language as the liquidations offline line: one quiet row, a dot,
+// and an inline retry.
+function statsNote(message) {
+ return `<p class="cv-inline-note" role="status"><span class="dot" aria-hidden="true"></span>${esc(message)} <button type="button" class="cv-linkbtn" data-act="retry-stats">Try again</button>.</p>`;
}
// ── Market table ────────────────────────────────────────────────────────────
// Row/column/sort primitives are shared with the /markets hub — see
// src/shared/market-table.js.
-const state = { coins: [], sortKey: 'rank', sortDir: 'asc', page: 1, loadingMore: false };
+const state = {
+ coins: [],
+ sortKey: 'rank',
+ sortDir: 'asc',
+ page: 1,
+ loadingMore: false,
+ // The three no-rows outcomes are different problems: a failed first fetch is
+ // retryable, an upstream that answered with nothing is not the user's doing,
+ // and a failed load-more must not look like the button is broken.
+ errorStatus: null,
+ moreErrorStatus: null,
+ exhausted: false,
+};
+
+// A 429 is our own per-IP budget, not an upstream outage: telling the user to
+// retry immediately would only spend the next token they have.
+function whyFailed(status) {
+ return status === 429
+ ? 'You have requested this feed too many times in a row. Give it a minute, then'
+ : 'The market data provider did not answer.';
+}
function sortedCoins() {
const copy = [...state.coins];
@@ -137,8 +168,10 @@ function renderTable() {
const el = $('cv-market');
if (!el) return; // shell navigation left /coins while a fetch was in flight
if (!state.coins.length) {
- el.innerHTML =
- '<div class="cv-empty">Market data is temporarily unavailable. Please try again shortly.</div>';
+ el.innerHTML = state.errorStatus
+ ? `<div class="cv-empty">Market data could not be loaded. ${whyFailed(state.errorStatus)} <button type="button" class="cv-linkbtn" data-act="retry">${state.errorStatus === 429 ? 'load it again' : 'Try again'}</button>.</div>`
+ : '<div class="cv-empty">No coins are being reported right now. <button type="button" class="cv-linkbtn" data-act="retry">Refresh</button> to check again.</div>';
+ el.querySelector('[data-act="retry"]')?.addEventListener('click', loadCoins);
return;
}
@@ -150,6 +183,19 @@ function renderTable() {
const rows = sortedCoins().map(coinRow).join('');
+ // Footer: the button while more rows exist, an end-of-list line once the feed
+ // is exhausted (a button that can never add another row is a dead control),
+ // and an explanation when a load-more failed so the click never looks ignored.
+ const moreError =
+ state.moreErrorStatus === 429
+ ? 'More coins could not be loaded. You have requested this feed too many times in a row. Give it a minute, then press Load more coins again.'
+ : 'More coins could not be loaded. The market data provider did not answer. Press Load more coins again.';
+ const footer = state.exhausted
+ ? `<p class="cv-load-end" role="status">That is every coin the market feed ranks (${state.coins.length.toLocaleString('en-US')} in total).</p>`
+ : `<button type="button" class="cv-load-more" id="cv-load-more"${state.loadingMore ? ' disabled' : ''}>
+ ${state.loadingMore ? 'Loading…' : 'Load more coins'}
+ </button>` + (state.moreErrorStatus ? `<p class="cv-load-err" role="status">${moreError}</p>` : '');
+
el.innerHTML = `
<div class="cv-table-wrap">
<table class="cv-table">
@@ -157,9 +203,7 @@ function renderTable() {
<tbody>${rows}</tbody>
</table>
</div>
- <button type="button" class="cv-load-more" id="cv-load-more"${state.loadingMore ? ' disabled' : ''}>
- ${state.loadingMore ? 'Loading…' : 'Load more coins'}
- </button>`;
+ ${footer}`;
el.querySelectorAll('th[data-key]').forEach((th) => {
const activate = () => {
@@ -193,33 +237,49 @@ function renderTable() {
$('cv-load-more')?.addEventListener('click', loadMore);
}
+const PER_PAGE = 100;
+
async function loadCoins() {
const el = $('cv-market');
+ if (!el) return; // shell navigation left /coins before the retry landed
el.innerHTML =
'<div class="cv-table-wrap" style="padding:0.75rem">' +
Array.from({ length: 12 }, () => '<div class="cv-skel" style="height:2.5rem;margin:0.375rem 0"></div>').join('') +
'</div>';
try {
- const { coins } = await getJson('/api/coin/markets?page=1&per_page=100');
+ const { coins } = await getJson(`/api/coin/markets?page=1&per_page=${PER_PAGE}`);
state.coins = coins;
state.page = 1;
- } catch {
+ state.errorStatus = null;
+ state.exhausted = coins.length < PER_PAGE;
+ } catch (err) {
state.coins = [];
+ state.errorStatus = err.status || 0;
+ state.exhausted = false;
}
+ state.moreErrorStatus = null;
renderTable();
}
async function loadMore() {
if (state.loadingMore) return;
state.loadingMore = true;
+ state.moreErrorStatus = null;
renderTable();
try {
- const { coins } = await getJson(`/api/coin/markets?page=${state.page + 1}&per_page=100`);
+ const { coins } = await getJson(`/api/coin/markets?page=${state.page + 1}&per_page=${PER_PAGE}`);
const seen = new Set(state.coins.map((c) => c.id));
- state.coins.push(...coins.filter((c) => !seen.has(c.id)));
+ const fresh = coins.filter((c) => !seen.has(c.id));
+ state.coins.push(...fresh);
state.page += 1;
- } catch {
- // keep what we have; button re-enables for a retry
+ // The endpoint caps `page`, so past the last page it replays rows we
+ // already have. Either signal means there is nothing left to load, and the
+ // button retires rather than pretending forever.
+ state.exhausted = !fresh.length || coins.length < PER_PAGE;
+ } catch (err) {
+ // Keep the rows we have and say why the click added none, so the button
+ // never reads as broken.
+ state.moreErrorStatus = err.status || 0;
}
state.loadingMore = false;
renderTable();
@@ -235,21 +295,31 @@ function wireSearch() {
let items = [];
let active = -1;
let lastQuery = '';
+ let searchErrorStatus = null;
function close() {
pop.hidden = true;
input.setAttribute('aria-expanded', 'false');
+ input.removeAttribute('aria-activedescendant');
active = -1;
}
function renderPop() {
- if (!items.length) {
+ if (searchErrorStatus) {
+ // A search that answers with nothing at all is a dead end: say the
+ // lookup failed rather than closing the panel as if nothing happened.
+ pop.innerHTML = `<div class="none">${
+ searchErrorStatus === 429
+ ? 'Coin search is rate limited right now. Give it a minute, then type to search again.'
+ : 'Coin search is unavailable right now. The market data provider did not answer. Type to search again.'
+ }</div>`;
+ } else if (!items.length) {
pop.innerHTML = `<div class="none">No coins match “${esc(lastQuery)}”.</div>`;
} else {
pop.innerHTML = items
.map(
(c, i) => `
- <a href="/coin/${encodeURIComponent(c.id)}" role="option" data-active="${i === active ? 1 : 0}" aria-selected="${i === active}">
+ <a id="cv-search-opt-${i}" href="/coin/${encodeURIComponent(c.id)}" role="option" data-active="${i === active ? 1 : 0}" aria-selected="${i === active}">
${c.thumb ? `<img loading="lazy" decoding="async" src="${esc(c.thumb)}" alt="" width="20" height="20" data-no-dark-filter />` : ''}
<span>${esc(c.name)}</span>
<span class="sym">${esc(c.symbol)}</span>
@@ -260,6 +330,10 @@ function wireSearch() {
}
pop.hidden = false;
input.setAttribute('aria-expanded', 'true');
+ // Screen readers follow the active option through aria-activedescendant;
+ // data-active only moves the highlight visually.
+ if (active >= 0 && items[active]) input.setAttribute('aria-activedescendant', `cv-search-opt-${active}`);
+ else input.removeAttribute('aria-activedescendant');
}
input.addEventListener('input', () => {
@@ -275,10 +349,13 @@ function wireSearch() {
lastQuery = q;
items = coins;
active = -1;
- renderPop();
- } catch {
- close();
+ searchErrorStatus = null;
+ } catch (err) {
+ items = [];
+ active = -1;
+ searchErrorStatus = err.status || 0;
}
+ renderPop();
}, 250);
});
diff --git a/src/collection.js b/src/collection.js
index 00a0f5392..d5b88712b 100644
--- a/src/collection.js
+++ b/src/collection.js
@@ -39,52 +39,60 @@ function explorerUrl(mint, network) {
}
function skillCard(p) {
+ const agentName = p.agent_name || 'Unknown agent';
const thumb = p.agent_thumbnail
- ? `<img class="col-card-avatar" src="${p.agent_thumbnail}" alt="${p.agent_name || ''}" loading="lazy">`
- : `<div class="col-card-avatar placeholder">⚡</div>`;
+ ? `<img class="col-card-avatar" src="${esc(p.agent_thumbnail)}" alt="${esc(agentName)}" loading="lazy">`
+ : `<div class="col-card-avatar placeholder" aria-hidden="true">⚡</div>`;
const kindBadge = p.kind === 'trial'
? '<span class="badge badge-amber">Trial</span>'
: '<span class="badge badge-green">Owned</span>';
const nftLine = p.skill_nft_mint
- ? `<div class="col-card-nft">NFT: <a href="${explorerUrl(p.skill_nft_mint, p.skill_nft_network)}" target="_blank" rel="noopener">${p.skill_nft_mint.slice(0,6)}…${p.skill_nft_mint.slice(-4)}</a></div>`
+ ? `<div class="col-card-nft">NFT: <a href="${esc(explorerUrl(p.skill_nft_mint, p.skill_nft_network))}" target="_blank" rel="noopener">${esc(`${p.skill_nft_mint.slice(0, 6)}…${p.skill_nft_mint.slice(-4)}`)}</a></div>`
: '';
- const priceLine = p.amount ? `<span class="badge badge-muted">${fmtAmount(p.amount, p.currency_mint)}</span>` : '';
+ const priceLine = p.amount ? `<span class="badge badge-muted">${esc(fmtAmount(p.amount, p.currency_mint))}</span>` : '';
// Wallet chip for the publishing agent, only when the purchase record carries
// its custodial Solana address. The buyer doesn't own the publisher agent, so
// the chip renders isOwner:false (◎ Tip), letting the holder tip the creator
// straight from their collection. getWalletStatus returns null without an
// address, so showPending:false means the chip simply doesn't render.
+ // Field names match what /api/users/me/purchased-skills actually selects
+ // (agent_solana_*, aliased off agent_identities.meta). Reading the un-prefixed
+ // names alone silently dropped every vanity address into a plain one.
const agentRecord = {
id: p.agent_id,
name: p.agent_name,
solana_address: p.solana_address || p.agent_solana_address || null,
- solana_vanity_prefix: p.solana_vanity_prefix || null,
- solana_vanity_suffix: p.solana_vanity_suffix || null,
+ solana_vanity_prefix: p.solana_vanity_prefix || p.agent_solana_vanity_prefix || null,
+ solana_vanity_suffix: p.solana_vanity_suffix || p.agent_solana_vanity_suffix || null,
avatar_thumbnail_url: p.agent_thumbnail || null,
};
const walletLine = agentRecord.solana_address
? `<div class="col-card-wallet" style="margin-top:8px">${walletChipHTML(agentRecord, { isOwner: false, showPending: false, dense: true })}</div>`
: '';
+ const agentHref = p.agent_id
+ ? `/marketplace/agents/${encodeURIComponent(p.agent_id)}`
+ : '/marketplace';
+
return `
<article class="col-card">
<div class="col-card-header">
${thumb}
<div class="col-card-meta">
- <div class="col-card-skill">${p.skill}</div>
- <div class="col-card-agent">${p.agent_name || 'Unknown agent'}</div>
+ <div class="col-card-skill">${esc(p.skill)}</div>
+ <div class="col-card-agent">${esc(agentName)}</div>
</div>
</div>
${walletLine}
<div class="col-card-badges">${kindBadge}${priceLine}</div>
${nftLine}
<div class="col-card-footer">
- <span class="col-card-date">Purchased ${fmtDate(p.confirmed_at || p.created_at)}</span>
- <a href="/marketplace/agents/${p.agent_id}" class="col-cta">View agent</a>
+ <span class="col-card-date">Purchased ${esc(fmtDate(p.confirmed_at || p.created_at))}</span>
+ <a href="${esc(agentHref)}" class="col-cta">View agent<span class="sr-only"> ${esc(agentName)}</span></a>
</div>
</article>`;
}
@@ -120,7 +128,7 @@ function subCard(s) {
return `
<article class="col-card">
<div class="col-card-header">
- <div class="col-card-avatar placeholder">${initial}</div>
+ <div class="col-card-avatar placeholder" aria-hidden="true">${initial}</div>
<div class="col-card-meta">
<div class="col-card-skill">${esc(planName)}</div>
<div class="col-card-agent">by ${esc(creator)}</div>
@@ -129,7 +137,7 @@ function subCard(s) {
<div class="col-card-badges">${statusBadge}${priceLine}</div>
<div class="col-card-footer">
<span class="col-sub-expiry ${expiryClass}">${esc(expiryText)}</span>
- <a href="${creatorHref}" class="col-cta">View creator</a>
+ <a href="${esc(creatorHref)}" class="col-cta">View creator<span class="sr-only"> ${esc(creator)}</span></a>
</div>
</article>`;
}
@@ -156,16 +164,16 @@ function emptyState(panel) {
if (panel === 'skills') {
return `
<div class="col-empty">
- <svg width="48" height="48" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>
+ <svg width="48" height="48" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24" aria-hidden="true"><path d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>
<h3>No skills yet</h3>
<p>Browse the <a href="/marketplace">marketplace</a> and unlock premium agent skills.</p>
</div>`;
}
return `
<div class="col-empty">
- <svg width="48" height="48" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
+ <svg width="48" height="48" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24" aria-hidden="true"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
<h3>No subscriptions</h3>
- <p>Active agent subscriptions appear here once you subscribe.</p>
+ <p>Browse the <a href="/marketplace">marketplace</a> and subscribe to a creator to see it here.</p>
</div>`;
}
diff --git a/src/shared/converter-state.js b/src/shared/converter-state.js
new file mode 100644
index 000000000..418d59ad2
--- /dev/null
+++ b/src/shared/converter-state.js
@@ -0,0 +1,187 @@
+// Pure logic behind /converter: USD-anchored conversion math, amount / asset
+// formatting, and the shareable-URL codec. Everything here is DOM-free and
+// side-effect-free so the browser module (src/converter.js) stays a thin
+// rendering layer and this can be unit tested directly.
+//
+// Asset shapes used throughout:
+// crypto: { kind:'crypto', id, symbol, name, image, priceUSD }
+// fiat: { kind:'fiat', code, name, unit, per_btc }
+// `per_btc` is the fiat's units per 1 BTC, as served by /api/coin/rates. A
+// `usdPerBtc` anchor turns that into units per 1 USD, which is what the math
+// below runs on.
+
+/** Placeholder glyph for a value the page cannot compute yet. */
+export const EMPTY = '\u2014';
+
+/** Largest amount the converter accepts. Beyond this the result is noise. */
+export const MAX_AMOUNT = 1e15;
+
+// ── Conversion math (USD anchored) ────────────────────────────────────────────
+
+/** Units of `fiat` per 1 USD, derived from the shared BTC anchor. */
+export function fiatPerUsd(fiat, usdPerBtc) {
+ if (!fiat || !Number.isFinite(fiat.per_btc)) return NaN;
+ if (!Number.isFinite(usdPerBtc) || usdPerBtc <= 0) return NaN;
+ return fiat.per_btc / usdPerBtc;
+}
+
+/** USD value of `amount` units of `asset`. Null when the asset has no price. */
+export function toUsd(amount, asset, usdPerBtc) {
+ if (!asset || !Number.isFinite(amount)) return null;
+ if (asset.kind === 'crypto') {
+ if (!Number.isFinite(asset.priceUSD)) return null;
+ return amount * asset.priceUSD;
+ }
+ const perUsd = fiatPerUsd(asset, usdPerBtc);
+ if (!Number.isFinite(perUsd) || perUsd <= 0) return null;
+ return amount / perUsd;
+}
+
+/** Express a USD value in `asset`. Null when the asset has no usable price. */
+export function fromUsd(valueUsd, asset, usdPerBtc) {
+ if (!asset || !Number.isFinite(valueUsd)) return null;
+ if (asset.kind === 'crypto') {
+ if (!Number.isFinite(asset.priceUSD) || asset.priceUSD <= 0) return null;
+ return valueUsd / asset.priceUSD;
+ }
+ const perUsd = fiatPerUsd(asset, usdPerBtc);
+ if (!Number.isFinite(perUsd)) return null;
+ return valueUsd * perUsd;
+}
+
+/**
+ * Convert `amount` of `from` into `to`. One formula covers all four
+ * directions: crypto to crypto, crypto to fiat, fiat to crypto, fiat to fiat.
+ * Null whenever either leg is missing a live price.
+ */
+export function convert(amount, from, to, usdPerBtc) {
+ const usd = toUsd(amount, from, usdPerBtc);
+ if (usd == null) return null;
+ return fromUsd(usd, to, usdPerBtc);
+}
+
+// ── Formatting ────────────────────────────────────────────────────────────────
+
+/**
+ * Fiat amount with the currency's own unit symbol and thousands separators.
+ * Alphabetic units ("Fr.", "R$", "kr") take a space; glyphs ("$", "EUR sign",
+ * "rupee sign") hug the number.
+ */
+export function formatFiatAmount(n, unit) {
+ if (n == null || !Number.isFinite(n)) return EMPTY;
+ const sign = n < 0 ? '-' : '';
+ const abs = Math.abs(n);
+ let body;
+ if (abs !== 0 && abs < 0.01) body = abs.toPrecision(4);
+ else body = abs.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
+ const u = unit || '';
+ const sep = /[A-Za-z.]$/.test(u) ? ' ' : '';
+ return `${sign}${u}${sep}${body}`;
+}
+
+/**
+ * Crypto amount: full precision for whole coins, significant figures for the
+ * deep decimals a fiat to BTC conversion produces (e.g. 0.00001587 BTC).
+ */
+export function formatCryptoAmount(n) {
+ if (n == null || !Number.isFinite(n)) return EMPTY;
+ if (n === 0) return '0';
+ const abs = Math.abs(n);
+ if (abs >= 1) return n.toLocaleString('en-US', { maximumFractionDigits: 8 });
+ const s = n.toPrecision(6);
+ const expanded = s.includes('e') ? Number(s).toFixed(18) : s;
+ return expanded.replace(/(\.\d*?)0+$/, '$1').replace(/\.$/, '');
+}
+
+/** Format `n` in whatever `asset` is: used by the result field and rate line. */
+export function formatInAsset(n, asset) {
+ if (!asset) return EMPTY;
+ return asset.kind === 'fiat' ? formatFiatAmount(n, asset.unit) : formatCryptoAmount(n);
+}
+
+/** Short ticker shown on the asset button and in the rate line. */
+export function assetCode(asset) {
+ if (!asset) return '';
+ return asset.kind === 'fiat' ? asset.code : asset.symbol;
+}
+
+// ── Shareable URL codec ───────────────────────────────────────────────────────
+//
+// A converter URL carries the whole view: /converter?from=bitcoin&to=EUR&amount=3
+// Fiat sides use their ISO code (USD, EUR); crypto sides use their coin id
+// (bitcoin, ethereum). Resolution checks the fiat table first, so a ref is
+// unambiguous without a type prefix and the URL stays readable.
+
+/**
+ * Parse a normalized amount out of user text or a URL parameter. Returns NaN
+ * for anything that is not a finite, non-negative, in-range number so callers
+ * have one "no usable amount" signal.
+ */
+export function parseAmount(raw) {
+ if (raw == null) return NaN;
+ const text = String(raw).replace(/[,\s]/g, '').trim();
+ if (!text || text.length > 24) return NaN;
+ if (!/^\d*\.?\d*$/.test(text)) return NaN;
+ const n = Number(text);
+ if (!Number.isFinite(n) || n < 0 || n > MAX_AMOUNT) return NaN;
+ return n;
+}
+
+/** Serialize an amount back into URL form without trailing float noise. */
+function amountParam(n) {
+ if (!Number.isFinite(n)) return null;
+ // Avoid exponent notation, which parseAmount deliberately rejects.
+ const fixed = n < 1e-6 && n > 0 ? n.toFixed(12).replace(/0+$/, '') : String(n);
+ return fixed.includes('e') ? n.toFixed(12).replace(/0+$/, '').replace(/\.$/, '') : fixed;
+}
+
+/** The URL ref for an asset: its ISO code (fiat) or coin id (crypto). */
+export function assetRef(asset) {
+ if (!asset) return null;
+ return asset.kind === 'fiat' ? asset.code : asset.id;
+}
+
+/**
+ * Build the query string for the current view. Returns "" when there is
+ * nothing worth sharing, so the canonical /converter URL stays clean.
+ */
+export function buildConverterQuery({ from, to, amount } = {}) {
+ const params = new URLSearchParams();
+ const f = assetRef(from);
+ const t = assetRef(to);
+ if (f) params.set('from', f);
+ if (t) params.set('to', t);
+ const a = amountParam(amount);
+ if (a != null && a !== '1') params.set('amount', a);
+ const q = params.toString();
+ return q ? `?${q}` : '';
+}
+
+/**
+ * Read a converter view out of a query string. `amount` is NaN when absent or
+ * unusable; refs are trimmed, length-capped strings or null.
+ */
+export function parseConverterQuery(search) {
+ const params = new URLSearchParams(search || '');
+ const ref = (key) => {
+ const v = params.get(key);
+ if (!v) return null;
+ const trimmed = v.trim();
+ // Coin ids and ISO codes are short slugs; anything longer is not a ref.
+ if (!trimmed || trimmed.length > 64 || !/^[A-Za-z0-9._-]+$/.test(trimmed)) return null;
+ return trimmed;
+ };
+ return { from: ref('from'), to: ref('to'), amount: parseAmount(params.get('amount')) };
+}
+
+/**
+ * Turn a URL ref into an asset descriptor the page can load. Fiat wins when the
+ * uppercased ref names a currency in `fiatByCode`; everything else is treated
+ * as a coin id. Null for an empty ref.
+ */
+export function resolveAssetRef(ref, fiatByCode) {
+ if (!ref) return null;
+ const upper = ref.toUpperCase();
+ if (fiatByCode && fiatByCode.has(upper)) return { kind: 'fiat', code: upper };
+ return { kind: 'crypto', id: ref.toLowerCase() };
+}
diff --git a/src/ui-juice.js b/src/ui-juice.js
index a21e73aba..3e1288dff 100644
--- a/src/ui-juice.js
+++ b/src/ui-juice.js
@@ -379,8 +379,48 @@ export function liveDot(state = 'idle', opts = {}) {
+ `</span>`;
}
+function stampLiveDot(live, state, label) {
+ live.dataset.state = state;
+ const txt = live.querySelector('.juice-live-txt');
+ if (txt && label != null) txt.textContent = label;
+}
+
+// A live badge is usually authored inside a line of copy, and on four surfaces
+// (/clash, /leaderboard, /labor-market, /signals) that line carries
+// `data-i18n-html`. The catalog value for such a key is a frozen snapshot of the
+// original markup, badge included, so the i18n pass reinstates the authored
+// state ("connecting") over whatever the page has since learned. The pass is
+// async, so it always lands after the first setLiveDot call, and a surface that
+// then stops polling (an unconfigured upstream, a settled stream) is left
+// showing an amber "connecting" that contradicts the page beneath it.
+//
+// Re-stamp the last requested state whenever the badge's container swaps its
+// children out. Watching the container rather than listening for an i18n event
+// keeps this correct for every writer: the boot-time document pass, a locale
+// switch, and the injected-content observer all rewrite children the same way.
+const liveDotWanted = new WeakMap(); // container -> { state, label }
+const liveDotWatched = new WeakSet(); // containers already observed
+
+function watchLiveDot(live, state, label) {
+ const host = live.closest?.('[data-i18n-html]') || live.parentElement;
+ if (!host) return;
+ liveDotWanted.set(host, { state, label });
+ if (liveDotWatched.has(host) || typeof MutationObserver !== 'function') return;
+ liveDotWatched.add(host);
+ // childList only, no subtree: the re-stamp writes an attribute and a text
+ // node deeper down, so it can never retrigger this observer.
+ const observer = new MutationObserver(() => {
+ const want = liveDotWanted.get(host);
+ const next = host.querySelector('.juice-live');
+ if (!want || !next || next.dataset.state === want.state) return;
+ stampLiveDot(next, want.state, want.label);
+ });
+ observer.observe(host, { childList: true });
+}
+
/**
- * Update an existing `.juice-live` element's state + label in place.
+ * Update an existing `.juice-live` element's state + label in place, and keep it
+ * updated if something later rewrites the markup around it (see above).
* @param {HTMLElement} el a `.juice-live` element (or container of one)
* @param {'live'|'connecting'|'idle'|'error'} state
* @param {string} [label]
@@ -389,9 +429,8 @@ export function setLiveDot(el, state, label) {
if (!el) return;
const live = el.classList && el.classList.contains('juice-live') ? el : el.querySelector && el.querySelector('.juice-live');
if (!live) return;
- live.dataset.state = state;
- const txt = live.querySelector('.juice-live-txt');
- if (txt && label != null) txt.textContent = label;
+ stampLiveDot(live, state, label);
+ watchLiveDot(live, state, label);
}
// ── 8. rippleOnce ───────────────────────────────────────────────────────────────
diff --git a/tests/api/x-memory-seed-consent.test.js b/tests/api/x-memory-seed-consent.test.js
index 86b87b47f..8f6f7b7f1 100644
--- a/tests/api/x-memory-seed-consent.test.js
+++ b/tests/api/x-memory-seed-consent.test.js
@@ -96,9 +96,11 @@ vi.mock('../../api/_lib/auth.js', () => ({
vi.mock('../../api/_lib/csrf.js', () => ({ requireCsrf: vi.fn(async () => true) }));
const xSeed = vi.fn(async () => ({ success: true, limit: 1, remaining: 0, reset: 1 }));
+const xSeedRefund = vi.fn(async () => true);
vi.mock('../../api/_lib/rate-limit.js', () => ({
limits: {
xSeed: (...a) => xSeed(...a),
+ xSeedRefund: (...a) => xSeedRefund(...a),
authIp: vi.fn(async () => ({ success: true })),
},
clientIp: vi.fn(() => '127.0.0.1'),
@@ -192,6 +194,7 @@ beforeEach(() => {
dbState.queries = [];
dbState.inserts = [];
xSeed.mockResolvedValue({ success: true, limit: 1, remaining: 0, reset: 1 });
+ xSeedRefund.mockResolvedValue(true);
vi.stubGlobal('fetch', vi.fn(async () => {
throw new Error('the network must not be touched on a refusal path');
}));
@@ -503,6 +506,125 @@ describe('POST /api/agents/:id/memory/seed/x seeding', () => {
expect(res.json).toMatchObject({ error: 'rate_limited' });
expect(globalThis.fetch).not.toHaveBeenCalled();
});
+
+ // Everything past the rate-limit charge either stores rows or hands the
+ // window back. Without that, an outage at X, a revoked connection, or a
+ // timeline of nothing but replies costs the owner six hours for a run that
+ // never touched their agent.
+ describe('a run that stores nothing gives the window back', () => {
+ function xError(status, headers = {}) {
+ return {
+ ok: false,
+ status,
+ headers: { get: (k) => headers[k.toLowerCase()] ?? null },
+ text: async () => `{"title":"error ${status}"}`,
+ json: async () => ({ title: `error ${status}` }),
+ };
+ }
+
+ beforeEach(() => {
+ dbState.connection = liveConnection();
+ dbState.consent = liveConsent();
+ });
+
+ it('refunds and says to reconnect when X refuses the profile read', async () => {
+ vi.stubGlobal('fetch', vi.fn(async () => xError(401)));
+
+ const res = await call({ method: 'POST', body: {} });
+
+ expect(res.statusCode).toBe(502);
+ expect(res.json).toMatchObject({ error: 'x_read_denied', window_refunded: true });
+ expect(res.json.error_description).toMatch(/reconnect x/i);
+ expect(xSeedRefund).toHaveBeenCalledWith(AGENT);
+ expect(dbState.inserts).toHaveLength(0);
+ expect(dbState.queries.some((c) => /^DELETE FROM agent_memories/i.test(c.q))).toBe(false);
+ });
+
+ it('refunds and names the wait when X rate limits the posts read', async () => {
+ const reset = Math.floor((Date.now() + 9 * 60_000) / 1000);
+ vi.stubGlobal('fetch', vi.fn(async (url) => {
+ if (String(url).includes('/2/users/me')) {
+ return { ok: true, json: async () => profilePayload };
+ }
+ return xError(429, { 'x-rate-limit-reset': String(reset) });
+ }));
+
+ const res = await call({ method: 'POST', body: {} });
+
+ expect(res.statusCode).toBe(503);
+ expect(res.json).toMatchObject({ error: 'x_rate_limited', window_refunded: true });
+ expect(res.json.retry_at).toBe(new Date(reset * 1000).toISOString());
+ expect(res.json.error_description).toMatch(/about 9 minutes/);
+ expect(dbState.inserts).toHaveLength(0);
+ });
+
+ it('refunds when the access token cannot be refreshed', async () => {
+ dbState.connection = liveConnection({ expires_at: new Date(Date.now() - 1000).toISOString() });
+ vi.stubGlobal('fetch', vi.fn(async () => ({
+ ok: false,
+ status: 400,
+ text: async () => 'invalid_grant',
+ })));
+
+ const res = await call({ method: 'POST', body: {} });
+
+ expect(res.statusCode).toBe(502);
+ expect(res.json).toMatchObject({ error: 'x_token_expired', window_refunded: true });
+ expect(xSeedRefund).toHaveBeenCalledWith(AGENT);
+ expect(dbState.inserts).toHaveLength(0);
+ });
+
+ it('refunds on an account mismatch, which reads nothing of the new account', async () => {
+ vi.stubGlobal('fetch', vi.fn(async (url) => {
+ if (String(url).includes('/2/users/me')) {
+ return { ok: true, json: async () => ({ data: { ...profilePayload.data, id: 'x-account-77' } }) };
+ }
+ return { ok: true, json: async () => postsPayload };
+ }));
+
+ const res = await call({ method: 'POST', body: {} });
+
+ expect(res.statusCode).toBe(409);
+ expect(res.json).toMatchObject({ error: 'account_mismatch', window_refunded: true });
+ });
+
+ it('keeps the previous batch when a run yields no usable fact', async () => {
+ dbState.seededCount = 4;
+ vi.stubGlobal('fetch', vi.fn(async (url) => {
+ if (String(url).includes('/2/users/me')) {
+ // No name, no bio: nothing the derived-fact fallback can state.
+ return {
+ ok: true,
+ json: async () => ({
+ data: { id: 'x-account-42', username: '', name: '', public_metrics: {} },
+ }),
+ };
+ }
+ return { ok: true, json: async () => ({ data: [] }) };
+ }));
+ llmComplete.mockResolvedValue({ text: '[]' });
+
+ const res = await call({ method: 'POST', body: {} });
+
+ expect(res.statusCode).toBe(502);
+ expect(res.json).toMatchObject({ error: 'seed_empty', window_refunded: true, posts_read: 0 });
+ // The delete that clears the old batch must not have run: a re-seed that
+ // found nothing leaves the good memories in place.
+ expect(dbState.queries.some((c) => /^DELETE FROM agent_memories/i.test(c.q))).toBe(false);
+ expect(dbState.inserts).toHaveLength(0);
+ });
+
+ it('still reports the failure when the refund itself fails', async () => {
+ xSeedRefund.mockRejectedValue(new Error('redis down'));
+ vi.stubGlobal('fetch', vi.fn(async () => xError(503)));
+
+ const res = await call({ method: 'POST', body: {} });
+
+ expect(res.statusCode).toBe(502);
+ expect(res.json).toMatchObject({ error: 'x_unavailable', window_refunded: false });
+ expect(res.json.error_description).not.toMatch(/did not use up/);
+ });
+ });
});
describe('DELETE /api/agents/:id/memory/seed/x', () => {
diff --git a/tests/api/x-seed-reaches-replies.test.js b/tests/api/x-seed-reaches-replies.test.js
new file mode 100644
index 000000000..94f817559
--- /dev/null
+++ b/tests/api/x-seed-reaches-replies.test.js
@@ -0,0 +1,163 @@
+// The seeded-memory promise, pinned end to end.
+//
+// The X consent screen tells an owner that after they agree, the agent's next
+// replies speak from the distilled facts. Three modules have to agree for that
+// to be true, and nothing forced them to:
+//
+// api/_lib/x-memory-seed.js decides the tier each seeded row is written at,
+// api/_lib/memory-store.js decides which tiers are always paged into a
+// reply (computeContext), and
+// api/chat.js renders those entries into the system prompt.
+//
+// Each was free to move on its own: rename the tier, narrow the predicate, drop
+// the prompt block, and the consent screen would keep making a promise the
+// pipeline no longer keeps, silently and with every test still green. This file
+// runs all three for real against one seed and asserts a fact distilled from a
+// post reaches the text the model is given.
+
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+const AGENT = '11111111-2222-4333-8444-555555555555';
+
+const sqlMock = vi.fn();
+vi.mock('../../api/_lib/db.js', async () => {
+ const actual = await vi.importActual('../../api/_lib/db.js');
+ return {
+ sqlValues: actual.sqlValues,
+ sql: sqlMock,
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
+ };
+});
+
+vi.mock('../../api/_lib/embeddings.js', () => ({
+ embeddingsConfigured: () => false,
+ defaultIngestEmbedderTag: () => null,
+ embedPassages: vi.fn(),
+ scoreRowsBySpace: vi.fn(),
+}));
+
+const { buildSeedMemories, X_SEED_LIMITS, X_SEED_TAG } = await import(
+ '../../api/_lib/x-memory-seed.js'
+);
+const { computeContext } = await import('../../api/_lib/memory-store.js');
+const { buildSystemPrompt } = await import('../../api/chat.js');
+
+const FACTS = [
+ 'Builds avatar retargeting tooling and cares most about how legs land.',
+ 'Treats settlement latency on Solana as the core of a payments product.',
+ 'Prefers deleting code to adding it.',
+ 'Writes short, declarative posts with no hedging.',
+ 'Runs an open changelog and ships in public.',
+ 'Reads graphics papers on weekends.',
+ 'Keeps a strong opinion that documentation is part of a feature.',
+];
+
+// The rows the seeder actually writes, given as a real seed would build them.
+const seededRows = buildSeedMemories({
+ facts: FACTS,
+ profile: { username: 'qauser', name: 'QA User' },
+ topics: [{ topic: 'avatars', count: 4 }],
+ source: 'model',
+ seededAt: '2026-08-17T00:00:00.000Z',
+});
+
+// A stand-in for `agent_memories` that applies computeContext's own predicate
+// rather than a restatement of it: the query text is read, so narrowing the
+// predicate in memory-store.js changes what this returns.
+function tableRows() {
+ return seededRows.map((m, i) => ({
+ id: `mem-${i + 1}`,
+ agent_id: AGENT,
+ type: m.type,
+ content: m.content,
+ tags: m.tags,
+ context: m.context,
+ salience: m.salience,
+ tier: m.tier,
+ pinned: false,
+ embedder: null,
+ embedding: null,
+ access_count: 0,
+ is_public: false,
+ created_at: '2026-08-17T00:00:00.000Z',
+ updated_at: '2026-08-17T00:00:00.000Z',
+ last_accessed_at: null,
+ expires_at: null,
+ }));
+}
+
+beforeEach(() => {
+ sqlMock.mockReset();
+ sqlMock.mockImplementation((strings) => {
+ const q = (Array.isArray(strings) ? strings.join('?') : String(strings))
+ .replace(/\s+/g, ' ')
+ .trim();
+ const rows = tableRows();
+ if (/COUNT\(\*\)::int AS total/i.test(q)) {
+ return Promise.resolve([
+ {
+ total: rows.length,
+ working: rows.filter((r) => r.tier === 'working').length,
+ recall: rows.filter((r) => r.tier === 'recall').length,
+ archival: 0,
+ embedded: 0,
+ },
+ ]);
+ }
+ // computeContext's predicate, evaluated instead of assumed.
+ const pinnedOrWorking = /pinned = true OR tier = 'working'/i.test(q);
+ return Promise.resolve(pinnedOrWorking ? rows.filter((r) => r.pinned || r.tier === 'working') : rows);
+ });
+});
+
+describe('a seeded X memory reaches the reply the model writes', () => {
+ it('lands the top facts in the always-in-context set the chat path loads', async () => {
+ const ctx = await computeContext(AGENT);
+ const contents = ctx.entries.map((e) => e.content);
+
+ expect(ctx.entries).toHaveLength(X_SEED_LIMITS.workingTierFacts);
+ expect(contents).toContain(FACTS[0]);
+ // Ranked: the highest-salience fact leads the context the model sees.
+ expect(contents[0]).toBe(FACTS[0]);
+ // And they are the seeded rows, identifiable for revocation.
+ for (const entry of ctx.entries) {
+ expect(entry.tags).toContain(X_SEED_TAG);
+ expect(entry.context.source).toBe('x_seed');
+ }
+ });
+
+ it('renders those facts into the system prompt the model is given', async () => {
+ const ctx = await computeContext(AGENT);
+ const recalled = ctx.entries.map((m) => ({
+ id: m.id,
+ type: m.type,
+ tier: m.tier,
+ salience: m.salience,
+ snippet: String(m.content).slice(0, 160),
+ match: 'context',
+ }));
+
+ const prompt = buildSystemPrompt({}, 'You are QA Agent.', recalled, []);
+
+ expect(prompt.text).toContain(FACTS[0]);
+ expect(prompt.text).toContain(FACTS[1]);
+ expect(prompt.text).toMatch(/What you remember/);
+ // Recalled memories are the per-message half of the prompt: they must stay
+ // out of the byte-identical `stable` block, or the Anthropic prompt cache
+ // would serve one conversation's memories to the next.
+ expect(prompt.volatile).toContain(FACTS[0]);
+ expect(prompt.stable).not.toContain(FACTS[0]);
+ });
+
+ it('keeps a seed with no facts out of the prompt rather than emitting an empty block', () => {
+ const prompt = buildSystemPrompt({}, 'You are QA Agent.', [], []);
+ expect(prompt.text).not.toMatch(/What you remember/);
+ });
+
+ it('carries the lower-ranked facts at a tier search can still reach', () => {
+ const recallTier = seededRows.slice(X_SEED_LIMITS.workingTierFacts);
+ expect(recallTier.length).toBeGreaterThan(0);
+ for (const row of recallTier) expect(row.tier).toBe('recall');
+ });
+});