Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(arena): validate the tournament window before building the payload, and link sign-in from 401s
nirholasbed49e49302f
diff --git a/src/arena/arena.css b/src/arena/arena.cssindex e93f57f56..23719a4ed 100644--- a/src/arena/arena.css+++ b/src/arena/arena.css@@ -1270,6 +1270,16 @@margin: 0.5rem 0 0;min-height: 1em;}+.form-error-link {+ color: inherit;+ font-weight: var(--weight-semibold);+ text-underline-offset: 2px;+}+.form-error-link:focus-visible {+ outline: var(--focus-ring-width) solid var(--focus-ring-color);+ outline-offset: var(--focus-ring-offset);+ border-radius: var(--radius-sm);+}/* Toast */.arena-toast {diff --git a/src/arena/arena.js b/src/arena/arena.jsindex ca91f7e73..36b3728ab 100644--- a/src/arena/arena.js+++ b/src/arena/arena.js@@ -1151,20 +1151,36 @@ function openCreateModal() {onsubmit: async (e) => {e.preventDefault();err.textContent = '';+ // Validate the window BEFORE building the payload: a cleared+ // datetime-local input yields an Invalid Date, and .toISOString()+ // would throw out of this handler with nothing shown to the user.+ const startsAt = new Date(startI.value);+ const endsAt = new Date(endI.value);+ if (!nameI.value.trim()) {+ err.textContent = 'Give your tournament a name.';+ nameI.focus();+ return;+ }+ if (Number.isNaN(startsAt.getTime()) || Number.isNaN(endsAt.getTime())) {+ err.textContent = 'Set both a start and an end time for the trading window.';+ (Number.isNaN(startsAt.getTime()) ? startI : endI).focus();+ return;+ }+ if (endsAt <= startsAt) {+ err.textContent = 'The window has to end after it starts.';+ endI.focus();+ return;+ }const payload = {name: nameI.value.trim(),description: descI.value.trim() || undefined,network: NETWORK,scoring: scoringI.value,bracket: bracketI.value,- starts_at: new Date(startI.value).toISOString(),- ends_at: new Date(endI.value).toISOString(),+ starts_at: startsAt.toISOString(),+ ends_at: endsAt.toISOString(),prize_pool_three: bracketI.value === 'prize' ? Number(prizeI.value || 0) : 0,};- if (!payload.name) {- err.textContent = 'Give your tournament a name.';- return;- }submit.disabled = true;submit.textContent = 'Creating…';try {@@ -1177,7 +1193,7 @@ function openCreateModal() {toast('Tournament created');location.hash = `#/t/${out.tournament.id}`;} catch (ex) {- err.textContent = ex.status === 401 ? 'Sign in to create a tournament.' : ex.message;+ showFormError(err, ex, 'create a tournament');submit.disabled = false;submit.textContent = 'Create';}@@ -1227,7 +1243,7 @@ async function openJoinModal(t) {toast('Entered the arena. Good luck.');renderDetail(t.id);} catch (ex) {- err.textContent = ex.message;+ showFormError(err, ex, 'enter a tournament');submit.disabled = false;submit.textContent = 'Join';}@@ -1300,6 +1316,23 @@ async function openJoinModal(t) {}}+/**+ * Render a submit failure into a form's error line. A 401 is the common one and+ * it needs a way out, not just a sentence: link straight to the sign-in surface+ * so the visitor is never told to sign in without being shown where.+ */+function showFormError(node, ex, action) {+ if (ex.status === 401) {+ node.replaceChildren(+ document.createTextNode(`You need an account to ${action}. `),+ h('a', { href: '/app', class: 'form-error-link' }, 'Sign in'),+ document.createTextNode(', then come back to this page.'),+ );+ return;+ }+ node.textContent = ex.message || 'Something went wrong. Try again.';+}+function field(label, input, hint) {const id = `f-${Math.random().toString(36).slice(2, 8)}`;input.id = id;