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: repair retired IPFS gateways + polish CoinCommunities chat/reconnect

nirholas86a3d82fbc06
diff --git a/api/_lib/coin-communities.js b/api/_lib/coin-communities.js
index 6fa2041f8..711660b21 100644
--- a/api/_lib/coin-communities.js
+++ b/api/_lib/coin-communities.js
@@ -14,6 +14,7 @@
// designed locked state, reads still work.
import { configureApi, api } from '@coin-communities/sdk/node';
+import { normalizeGatewayURL } from '../../src/ipfs.js';
// Solana mint addresses — base58, 32–44 chars. Communities are keyed by these.
const BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
@@ -154,7 +155,7 @@ export function toWorldCard(c) {
return {
token: c.tokenAddress,
symbol: c.tokenSymbol || null,
- image: c.tokenHighResImageUrl || c.tokenImageUrl || null,
+ image: normalizeGatewayURL(c.tokenHighResImageUrl || c.tokenImageUrl || '') || null,
chainId: c.chainId ?? null,
members: c.memberCount ?? 0,
posts: c.postCount ?? 0,
diff --git a/api/agents/_id/memory/[cid].js b/api/agents/_id/memory/[cid].js
index 31237f4d1..a29f575e9 100644
--- a/api/agents/_id/memory/[cid].js
+++ b/api/agents/_id/memory/[cid].js
@@ -5,7 +5,7 @@ import { limits, clientIp } from '../../../_lib/rate-limit.js';
const IPFS_GATEWAYS = [
'https://dweb.link/ipfs/',
- 'https://cloudflare-ipfs.com/ipfs/',
+ 'https://flk-ipfs.xyz/ipfs/',
'https://ipfs.io/ipfs/',
];
diff --git a/api/pinning/[action].js b/api/pinning/[action].js
index 5ba513c6a..d1470c150 100644
--- a/api/pinning/[action].js
+++ b/api/pinning/[action].js
@@ -221,7 +221,7 @@ export default wrap(async (req, res) => {
provider: activeProviders[0] || null,
gatewayUrls: [
`https://ipfs.io/ipfs/${cid}`,
- `https://cloudflare-ipfs.com/ipfs/${cid}`,
+ `https://flk-ipfs.xyz/ipfs/${cid}`,
`https://dweb.link/ipfs/${cid}`,
],
});
diff --git a/api/pump/[action].js b/api/pump/[action].js
index e909290c0..f5dced516 100644
--- a/api/pump/[action].js
+++ b/api/pump/[action].js
@@ -46,6 +46,7 @@ import { env } from '../_lib/env.js';
import { limits, clientIp } from '../_lib/rate-limit.js';
import { parse } from '../_lib/validate.js';
import { randomToken } from '../_lib/crypto.js';
+import { normalizeGatewayURL } from '../../src/ipfs.js';
import {
getConnection,
getPumpSdk,
@@ -2428,6 +2429,20 @@ const PUMP_FRONTEND_BASE = 'https://frontend-api-v3.pump.fun';
const TRENDING_CACHE = { at: 0, body: null };
const TRENDING_TTL_MS = 15_000;
+// pump.fun hands back image URLs on the retired cf-ipfs.com gateway, which no
+// longer resolves in the browser. Repair the image fields onto a working
+// gateway before the feed reaches any client (play lobby, home card, etc.).
+function repairCoinImages(coins) {
+ if (!Array.isArray(coins)) return coins;
+ for (const c of coins) {
+ if (!c || typeof c !== 'object') continue;
+ if (c.image_uri) c.image_uri = normalizeGatewayURL(c.image_uri);
+ if (c.image) c.image = normalizeGatewayURL(c.image);
+ if (c.metadata_uri) c.metadata_uri = normalizeGatewayURL(c.metadata_uri);
+ }
+ return coins;
+}
+
async function handleTrending(req, res) {
if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
if (!method(req, res, ['GET'])) return;
@@ -2449,7 +2464,7 @@ async function handleTrending(req, res) {
const resp = await fetch(upstream, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(8000) });
if (!resp.ok) return error(res, 502, 'upstream_failed', `pump.fun returned ${resp.status}`);
const body = await resp.json();
- const arr = Array.isArray(body) ? body : Array.isArray(body?.coins) ? body.coins : [];
+ const arr = repairCoinImages(Array.isArray(body) ? body : Array.isArray(body?.coins) ? body.coins : []);
TRENDING_CACHE.at = now;
TRENDING_CACHE.body = arr;
res.setHeader('cache-control', 'public, max-age=15');
@@ -2519,7 +2534,7 @@ async function handleSearch(req, res) {
const resp = await fetch(upstream, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(8000) });
if (!resp.ok) return error(res, 502, 'upstream_failed', `pump.fun returned ${resp.status}`);
const body = await resp.json();
- const arr = Array.isArray(body) ? body : Array.isArray(body?.coins) ? body.coins : [];
+ const arr = repairCoinImages(Array.isArray(body) ? body : Array.isArray(body?.coins) ? body.coins : []);
return json(res, 200, arr);
}
diff --git a/multiplayer/deploy-cloudrun.sh b/multiplayer/deploy-cloudrun.sh
new file mode 100755
index 000000000..00d49a3e0
--- /dev/null
+++ b/multiplayer/deploy-cloudrun.sh
@@ -0,0 +1,64 @@
+#!/usr/bin/env bash
+#
+# Deploy the three.ws multiplayer (Colyseus) server to Google Cloud Run.
+#
+# Cloud Run builds the local Dockerfile via Cloud Build (no local docker push),
+# terminates TLS, and hands back a stable https URL. The client connects to the
+# wss:// form of that URL — wire it into pages/play.html's <meta name="game-server">.
+#
+# Prereqs (one time):
+# gcloud auth login
+# gcloud config set project YOUR_PROJECT_ID
+# gcloud services enable run.googleapis.com cloudbuild.googleapis.com
+#
+# Then from this directory:
+# ./deploy-cloudrun.sh
+#
+# Override any of these via env, e.g. REGION=europe-west1 ./deploy-cloudrun.sh
+set -euo pipefail
+
+SERVICE="${SERVICE:-three-ws-multiplayer}"
+REGION="${REGION:-us-central1}"
+ALLOWED_ORIGINS="${ALLOWED_ORIGINS:-https://three.ws,https://www.three.ws}"
+PROJECT="$(gcloud config get-value project 2>/dev/null)"
+
+if [[ -z "${PROJECT}" || "${PROJECT}" == "(unset)" ]]; then
+ echo "No GCP project set. Run: gcloud config set project YOUR_PROJECT_ID" >&2
+ exit 1
+fi
+
+echo "Deploying '${SERVICE}' to Cloud Run (project=${PROJECT}, region=${REGION})..."
+
+# Flags that matter for a long-lived Colyseus game server on Cloud Run:
+# --no-cpu-throttling : keep CPU allocated between requests so the room
+# simulation/patch loop never stalls (the #1 gotcha).
+# --min-instances 1 : rooms live in-memory; never cold-start them away.
+# --max-instances 1 : matchmaking is per-process. Stay single-instance until
+# @colyseus/redis-presence is wired (see README scaling).
+# --session-affinity : best-effort sticky sessions for WS reconnects.
+# --timeout 3600 : Cloud Run's max WS lifetime (60 min); client reconnects.
+# --port 2567 : container listens here (matches Dockerfile/fly.toml).
+gcloud run deploy "${SERVICE}" \
+ --source . \
+ --region "${REGION}" \
+ --platform managed \
+ --allow-unauthenticated \
+ --port 2567 \
+ --no-cpu-throttling \
+ --min-instances 1 \
+ --max-instances 1 \
+ --memory 512Mi \
+ --cpu 1 \
+ --timeout 3600 \
+ --session-affinity \
+ --set-env-vars "NODE_ENV=production,ALLOWED_ORIGINS=${ALLOWED_ORIGINS}"
+
+URL="$(gcloud run services describe "${SERVICE}" --region "${REGION}" --format 'value(status.url)')"
+WSS="${URL/https:/wss:}"
+
+echo
+echo "Deployed: ${URL}"
+echo "Health: ${URL}/health"
+echo
+echo "Wire the client by setting this in pages/play.html:"
+echo " <meta name=\"game-server\" content=\"${WSS}\">"
diff --git a/public/features.json b/public/features.json
index 9c0179a28..41e1a71a2 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-05-30T08:53:32.741Z",
+ "generated_at": "2026-05-30T10:28:41.252Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/src/erc8004/enumeration.js b/src/erc8004/enumeration.js
index f03d066f8..baab83717 100644
--- a/src/erc8004/enumeration.js
+++ b/src/erc8004/enumeration.js
@@ -13,7 +13,7 @@ import { getIdentityRegistry } from './agent-registry.js';
const IPFS_GATEWAYS = [
(cid) => `https://ipfs.io/ipfs/${cid}`,
- (cid) => `https://cloudflare-ipfs.com/ipfs/${cid}`,
+ (cid) => `https://flk-ipfs.xyz/ipfs/${cid}`,
(cid) => `https://dweb.link/ipfs/${cid}`,
];
diff --git a/src/erc8004/resolver.js b/src/erc8004/resolver.js
index 9216ad6aa..8a484f394 100644
--- a/src/erc8004/resolver.js
+++ b/src/erc8004/resolver.js
@@ -103,7 +103,7 @@ export function toPublicUrl(ref, { embed = false, origin } = {}) {
const IPFS_GATEWAYS = [
'https://ipfs.io/ipfs/',
'https://dweb.link/ipfs/',
- 'https://cloudflare-ipfs.com/ipfs/',
+ 'https://flk-ipfs.xyz/ipfs/',
'https://gateway.pinata.cloud/ipfs/',
];
const AR_GATEWAY = 'https://arweave.net/';
diff --git a/src/game/coincommunities-ui.js b/src/game/coincommunities-ui.js
index f5b0ca19c..3f7c7479a 100644
--- a/src/game/coincommunities-ui.js
+++ b/src/game/coincommunities-ui.js
@@ -201,12 +201,34 @@ export class CommunityUI {
this.chatLog = el('div', { class: 'cc-chat-log' });
this.chatInput = el('input', {
type: 'text', maxlength: '200', placeholder: 'Say something…',
- onkeydown: (e) => { if (e.key === 'Enter') this._sendChat(); e.stopPropagation(); },
+ onkeydown: (e) => {
+ if (e.key === 'Enter') this._sendChat();
+ else if (e.key === 'Escape') this.chatInput.blur();
+ e.stopPropagation();
+ },
});
- const chat = el('div', { id: 'cc-chat' }, [
+ this.chatUnread = el('span', { class: 'cc-chat-unread', hidden: true });
+ this.chatChevron = el('span', { class: 'cc-chat-chevron', text: '▾' });
+ const head = el('div', {
+ class: 'cc-chat-head', role: 'button', tabindex: '0', 'aria-label': 'Toggle chat',
+ onclick: () => this.toggleChat(),
+ onkeydown: (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); this.toggleChat(); } },
+ }, [
+ el('span', { class: 'cc-chat-title' }, [el('span', { class: 'cc-chat-ico', text: '💬' }), document.createTextNode('Chat')]),
+ this.chatUnread,
+ this.chatChevron,
+ ]);
+ this.chatBody = el('div', { class: 'cc-chat-body' }, [
this.chatLog,
- el('div', { class: 'cc-chat-input' }, [this.chatInput, el('button', { text: 'Send', onclick: () => this._sendChat() })]),
+ el('div', { class: 'cc-chat-input' }, [this.chatInput, el('button', { class: 'cc-chat-send', text: 'Send', onclick: () => this._sendChat() })]),
]);
+ this.chat = el('div', { id: 'cc-chat' }, [head, this.chatBody]);
+ // Default: collapsed on touch (small screens), open on desktop — unless the
+ // user has expressed a preference before.
+ const stored = localStorage.getItem('cc-chat-min');
+ this._unread = 0;
+ this.toggleChat(stored != null ? stored === '1' : matchMedia('(pointer: coarse)').matches);
+ const chat = this.chat;
this.emoteTray = el('div', { id: 'cc-emotes' });
@@ -244,6 +266,8 @@ export class CommunityUI {
if (coin.image) { this.coinImg.src = coin.image; this.coinImg.style.display = ''; }
else this.coinImg.style.display = 'none';
this.chatLog.textContent = '';
+ this._unread = 0;
+ this.chatUnread.hidden = true;
}
showLobby() {
@@ -261,12 +285,46 @@ export class CommunityUI {
setOnline(n) { this.onlineCount.textContent = `${n} online`; }
addChat({ name, text, mine }) {
+ const t = new Date();
+ const stamp = `${String(t.getHours()).padStart(2, '0')}:${String(t.getMinutes()).padStart(2, '0')}`;
+ // Stick to bottom only if the user is already near it, so reading scrollback
+ // isn't yanked away when a new message lands.
+ const nearBottom = this.chatLog.scrollHeight - this.chatLog.scrollTop - this.chatLog.clientHeight < 60;
const row = el('div', { class: 'cc-chat-msg' + (mine ? ' cc-mine' : '') }, [
- el('b', { text: name + ':' }), document.createTextNode(text),
+ el('span', { class: 'cc-chat-meta' }, [
+ el('b', { text: name }),
+ el('time', { text: stamp }),
+ ]),
+ el('span', { class: 'cc-chat-text', text }),
]);
this.chatLog.appendChild(row);
- while (this.chatLog.children.length > 60) this.chatLog.removeChild(this.chatLog.firstChild);
- this.chatLog.scrollTop = this.chatLog.scrollHeight;
+ while (this.chatLog.children.length > 200) this.chatLog.removeChild(this.chatLog.firstChild);
+ if (nearBottom || mine) this.chatLog.scrollTop = this.chatLog.scrollHeight;
+ if (this._chatMin && !mine) {
+ this._unread += 1;
+ this.chatUnread.textContent = this._unread > 99 ? '99+' : String(this._unread);
+ this.chatUnread.hidden = false;
+ }
+ }
+
+ /** Collapse/expand the chat sidebar. Pass a boolean to force a state. */
+ toggleChat(force) {
+ this._chatMin = typeof force === 'boolean' ? force : !this._chatMin;
+ this.chat.classList.toggle('cc-min', this._chatMin);
+ this.chatChevron.textContent = this._chatMin ? '▴' : '▾';
+ this.chat.setAttribute('aria-expanded', String(!this._chatMin));
+ localStorage.setItem('cc-chat-min', this._chatMin ? '1' : '0');
+ if (!this._chatMin) {
+ this._unread = 0;
+ this.chatUnread.hidden = true;
+ this.chatLog.scrollTop = this.chatLog.scrollHeight;
+ }
+ }
+
+ /** Open the sidebar (if collapsed) and put the cursor in the input. */
+ focusChat() {
+ if (this._chatMin) this.toggleChat(false);
+ this.chatInput.focus();
}
get chatFocused() { return document.activeElement === this.chatInput; }
diff --git a/src/game/coincommunities.css b/src/game/coincommunities.css
index 945995e23..f4ff69c14 100644
--- a/src/game/coincommunities.css
+++ b/src/game/coincommunities.css
@@ -192,30 +192,72 @@ html, body {
#cc-status[data-state="offline"], #cc-status[data-state="failed"] { cursor: pointer; }
@keyframes cc-pulse { 50% { opacity: 0.35; } }
-/* chat */
-#cc-chat { position: fixed; left: 14px; bottom: 14px; width: min(340px, 80vw); z-index: 21; }
+/* chat sidebar — dockable, minimizable, persistent log */
+#cc-chat {
+ position: fixed; left: 14px; bottom: 14px; width: min(340px, 82vw);
+ max-height: min(60vh, 520px); z-index: 21;
+ display: flex; flex-direction: column; overflow: hidden;
+ background: var(--cc-panel); border: 1px solid var(--cc-edge);
+ border-radius: var(--cc-radius); box-shadow: var(--cc-shadow);
+ backdrop-filter: blur(8px); transition: max-height 0.22s ease;
+}
+.cc-chat-head {
+ display: flex; align-items: center; gap: 8px; flex: none;
+ padding: 9px 12px; cursor: pointer; user-select: none;
+ border-bottom: 1px solid var(--cc-edge);
+}
+.cc-chat-head:hover { background: rgba(95, 161, 207, 0.08); }
+.cc-chat-head:focus-visible { outline: 2px solid var(--cc-edge-hi); outline-offset: -2px; }
+.cc-chat-title { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13px; color: var(--cc-text); }
+.cc-chat-ico { font-size: 14px; }
+.cc-chat-unread {
+ margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
+ display: inline-flex; align-items: center; justify-content: center;
+ background: var(--cc-accent2); color: #fff; font-size: 11px; font-weight: 700;
+ border-radius: 999px; box-shadow: 0 0 8px rgba(124, 92, 255, 0.6);
+}
+.cc-chat-unread[hidden] { display: none; }
+.cc-chat-chevron { margin-left: auto; color: var(--cc-dim); font-size: 12px; transition: color 0.12s ease; }
+.cc-chat-unread:not([hidden]) + .cc-chat-chevron { margin-left: 8px; }
+.cc-chat-head:hover .cc-chat-chevron { color: var(--cc-text); }
+.cc-chat-body { display: flex; flex-direction: column; min-height: 0; padding: 10px; gap: 8px; }
+#cc-chat.cc-min { max-height: 39px; }
+#cc-chat.cc-min .cc-chat-head { border-bottom: none; }
+#cc-chat.cc-min .cc-chat-body { display: none; }
+
.cc-chat-log {
- display: flex; flex-direction: column; gap: 5px; max-height: 34vh; overflow-y: auto;
- margin-bottom: 8px; padding-right: 4px; mask-image: linear-gradient(180deg, transparent, #000 22%);
+ display: flex; flex-direction: column; gap: 6px; overflow-y: auto;
+ flex: 1; min-height: 0; padding-right: 2px;
}
-.cc-chat-msg {
- background: var(--cc-panel); border: 1px solid var(--cc-edge); border-radius: 11px;
- padding: 6px 11px; font-size: 13px; align-self: flex-start; max-width: 100%;
- animation: cc-msg-in 0.18s ease; word-break: break-word;
+.cc-chat-log::-webkit-scrollbar { width: 6px; }
+.cc-chat-log::-webkit-scrollbar-thumb { background: var(--cc-edge); border-radius: 3px; }
+.cc-chat-log:empty::before {
+ content: "No messages yet — say hi 👋"; color: var(--cc-dim); font-size: 12px;
+ margin: auto; padding: 18px 0; text-align: center;
}
-.cc-chat-msg b { color: var(--cc-accent); margin-right: 5px; }
-.cc-chat-msg.cc-mine b { color: var(--cc-green); }
+.cc-chat-msg {
+ background: rgba(255, 255, 255, 0.04); border: 1px solid var(--cc-edge); border-radius: 10px;
+ padding: 5px 10px; font-size: 13px; align-self: flex-start; max-width: 100%;
+ animation: cc-msg-in 0.18s ease; word-break: break-word; line-height: 1.35;
+}
+.cc-chat-meta { display: flex; align-items: baseline; gap: 6px; margin-bottom: 1px; }
+.cc-chat-meta b { color: var(--cc-accent); font-size: 12px; }
+.cc-chat-meta time { color: var(--cc-dim); font-size: 10px; font-variant-numeric: tabular-nums; }
+.cc-chat-msg.cc-mine { align-self: flex-end; background: rgba(95, 161, 207, 0.14); }
+.cc-chat-msg.cc-mine .cc-chat-meta b { color: var(--cc-green); }
+.cc-chat-text { display: block; color: var(--cc-text); }
@keyframes cc-msg-in { from { opacity: 0; transform: translateY(6px); } }
.cc-chat-input {
- display: flex; gap: 7px; background: var(--cc-panel); border: 1px solid var(--cc-edge);
- border-radius: 11px; padding: 7px 9px;
+ display: flex; gap: 7px; flex: none; background: rgba(0, 0, 0, 0.22);
+ border: 1px solid var(--cc-edge); border-radius: 10px; padding: 6px 8px;
}
-.cc-chat-input input { flex: 1; background: none; border: none; color: var(--cc-text); font-size: 13px; outline: none; }
+.cc-chat-input input { flex: 1; min-width: 0; background: none; border: none; color: var(--cc-text); font-size: 13px; outline: none; }
.cc-chat-input input::placeholder { color: var(--cc-dim); }
-.cc-chat-input button {
+.cc-chat-send {
background: var(--cc-accent); border: none; color: #04223a; font-weight: 700;
- border-radius: 8px; padding: 0 12px; cursor: pointer; font-size: 13px;
+ border-radius: 8px; padding: 0 12px; cursor: pointer; font-size: 13px; transition: filter 0.12s ease;
}
+.cc-chat-send:hover { filter: brightness(1.08); }
/* emote tray */
#cc-emotes {
@@ -240,14 +282,18 @@ html, body {
text-shadow: 0 1px 3px rgba(0,0,0,0.85); padding: 1px 6px;
}
.cc-bubble {
- background: #fff; color: #11203a; font-size: 13px; font-weight: 600;
- padding: 5px 10px; border-radius: 12px; max-width: 220px; white-space: normal;
- box-shadow: 0 4px 14px rgba(0,0,0,0.4); animation: cc-msg-in 0.18s ease;
-}
-.cc-bubble::after {
- content: ""; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%);
- border: 6px solid transparent; border-top-color: #fff; border-bottom: 0;
-}
+ background: #fff; color: #11203a; font-size: 13px; font-weight: 600; text-align: center;
+ padding: 7px 12px; border-radius: 16px; max-width: 220px; white-space: normal;
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); animation: cc-bubble-in 0.2s ease;
+}
+/* thought-bubble tail: two shrinking puffs trailing down toward the avatar */
+.cc-bubble::before, .cc-bubble::after {
+ content: ""; position: absolute; left: 50%; background: #fff; border-radius: 50%;
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
+}
+.cc-bubble::before { width: 12px; height: 12px; bottom: -8px; transform: translateX(-135%); }
+.cc-bubble::after { width: 7px; height: 7px; bottom: -18px; transform: translateX(-45%); }
+@keyframes cc-bubble-in { from { opacity: 0; } }
#cc-hint {
position: fixed; right: 14px; bottom: 14px; z-index: 19;
diff --git a/src/game/coincommunities.js b/src/game/coincommunities.js
index a078970c0..9352a4f77 100644
--- a/src/game/coincommunities.js
+++ b/src/game/coincommunities.js
@@ -23,6 +23,7 @@ import nipplejs from 'nipplejs';
import { AnimationManager } from '../animation-manager.js';
import { CommunityNet } from './community-net.js';
import { CommunityUI } from './coincommunities-ui.js';
+import { normalizeGatewayURL } from '../ipfs.js';
const AVATAR_DEFAULT = '/avatars/default.glb';
const MANIFEST_URL = '/animations/manifest.json';
@@ -214,7 +215,7 @@ export class CoinCommunities {
const p = new URLSearchParams(location.search);
const mint = p.get('coin');
if (mint) {
- this.enter({ mint, name: p.get('name') || '', symbol: p.get('symbol') || '', image: p.get('image') || '' });
+ this.enter({ mint, name: p.get('name') || '', symbol: p.get('symbol') || '', image: normalizeGatewayURL(p.get('image') || '') });
}
}
@@ -233,7 +234,7 @@ export class CoinCommunities {
mint: c.mint || c.address,
name: (c.name || '').trim() || 'Unnamed coin',
symbol: (c.symbol || '').trim(),
- image: c.image_uri || c.image || c.imageUri || '',
+ image: normalizeGatewayURL(c.image_uri || c.image || c.imageUri || ''),
marketCap: c.usd_market_cap || c.market_cap_usd || c.marketCap || 0,
})).filter((c) => c.mint);
this.ui.setCoins(list);
@@ -436,6 +437,7 @@ export class CoinCommunities {
_bindInput() {
window.addEventListener('keydown', (e) => {
if (this.ui.chatFocused) return;
+ if (e.key === 'Enter' && this.phase === 'world') { e.preventDefault(); this.ui.focusChat(); return; }
this.keys.add(e.key.toLowerCase());
});
window.addEventListener('keyup', (e) => this.keys.delete(e.key.toLowerCase()));
diff --git a/src/game/community-net.js b/src/game/community-net.js
index 87e3a5ce9..2ab15cb64 100644
--- a/src/game/community-net.js
+++ b/src/game/community-net.js
@@ -12,6 +12,9 @@
import { Client, getStateCallbacks } from 'colyseus.js';
const ROOM_NAME = 'walk_world';
+const RECONNECT_BASE_MS = 3000;
+const RECONNECT_MAX_MS = 60_000;
+const MAX_RECONNECT_ATTEMPTS = 6;
const SEND_HZ = 15;
const SEND_INTERVAL_MS = 1000 / SEND_HZ;
const POSITION_EPSILON = 0.01;
@@ -65,6 +68,7 @@ export class CommunityNet {
this._lastSent = null;
this._lastSentAt = 0;
this._reconnectTimer = null;
+ this._reconnectAttempts = 0;
this._destroyed = false;
}
@@ -119,6 +123,7 @@ export class CommunityNet {
});
this.room.onError((code, message) => console.warn('[community-net] room.onError', code, message));
+ this._reconnectAttempts = 0;
this._setStatus('online');
this._emit('ready', {
mint: this.room.state.coin,
@@ -133,9 +138,20 @@ export class CommunityNet {
}
}
+ // Exponential backoff with a hard ceiling. When the game server isn't
+ // reachable at all (e.g. not deployed), every attempt costs an 8s+ XHR
+ // timeout — retrying forever at a fixed 3s floods the console and the
+ // network tab. After MAX_RECONNECT_ATTEMPTS we stop and stay 'offline';
+ // the UI can offer manual reconnect via retry().
_scheduleReconnect() {
if (this._reconnectTimer || this._destroyed) return;
- const delay = 3000 + Math.random() * 1500;
+ if (this._reconnectAttempts >= MAX_RECONNECT_ATTEMPTS) {
+ this._setStatus('offline', 'multiplayer unreachable — single-player only');
+ return;
+ }
+ const attempt = this._reconnectAttempts++;
+ const backoff = Math.min(RECONNECT_BASE_MS * 2 ** attempt, RECONNECT_MAX_MS);
+ const delay = backoff + Math.random() * 1000;
this._reconnectTimer = setTimeout(() => {
this._reconnectTimer = null;
if (!this._destroyed) this.connect();
@@ -165,6 +181,7 @@ export class CommunityNet {
retry() {
if (this._reconnectTimer) { clearTimeout(this._reconnectTimer); this._reconnectTimer = null; }
+ this._reconnectAttempts = 0;
this.connect();
}
destroy() {
diff --git a/src/ipfs.js b/src/ipfs.js
index 42187a228..4d0dce3d8 100644
--- a/src/ipfs.js
+++ b/src/ipfs.js
@@ -9,14 +9,22 @@
* ar://txId → https://arweave.net/txId
*/
+// Cloudflare retired both cf-ipfs.com and cloudflare-ipfs.com (Aug 2024);
+// requests to either now fail DNS (ERR_NAME_NOT_RESOLVED). pump.fun metadata
+// still hands out cf-ipfs.com image URLs, so we keep this list dead-host-free
+// and rewrite any lingering dead-gateway URL via normalizeGatewayURL().
const IPFS_GATEWAYS = [
- 'https://dweb.link/ipfs/',
- 'https://cloudflare-ipfs.com/ipfs/',
'https://ipfs.io/ipfs/',
+ 'https://dweb.link/ipfs/',
+ 'https://flk-ipfs.xyz/ipfs/',
];
const AR_GATEWAY = 'https://arweave.net/';
+// Hosts that no longer resolve. Any HTTPS gateway URL using one of these is
+// rewritten onto the primary working gateway (preserving the /ipfs/<cid>/path).
+const DEAD_GATEWAY_HOST_RE = /^https?:\/\/(?:cf-ipfs\.com|cloudflare-ipfs\.com)\/ipfs\/(.+)$/i;
+
/**
* Returns true when the URL uses a decentralised storage scheme.
* @param {string} url
@@ -26,9 +34,28 @@ export function isDecentralizedURI(url) {
return /^(ipfs|ar):\/\//i.test(url);
}
+/**
+ * Repair full HTTPS gateway URLs that point at a retired gateway host.
+ * Leaves every other URL (including live gateways) untouched.
+ *
+ * @param {string} url
+ * @param {number} [gatewayIndex=0] Which working gateway to route to.
+ * @returns {string}
+ */
+export function normalizeGatewayURL(url, gatewayIndex = 0) {
+ if (!url) return url;
+ const dead = url.match(DEAD_GATEWAY_HOST_RE);
+ if (dead) {
+ const gw = IPFS_GATEWAYS[gatewayIndex % IPFS_GATEWAYS.length];
+ return gw + dead[1];
+ }
+ return url;
+}
+
/**
* Resolve an ipfs:// or ar:// URI to an HTTPS gateway URL.
- * For regular URLs the input is returned unchanged.
+ * For regular URLs the input is returned unchanged, except that URLs pointing
+ * at a retired gateway host are rewritten onto a working gateway.
*
* @param {string} uri
* @param {number} [gatewayIndex=0] Which IPFS gateway to use (for fallback).
@@ -50,7 +77,7 @@ export function resolveURI(uri, gatewayIndex = 0) {
return AR_GATEWAY + arMatch[1];
}
- return uri;
+ return normalizeGatewayURL(uri, gatewayIndex);
}
/**
diff --git a/src/viewer.js b/src/viewer.js
index fcf54c135..b26a68dcc 100644
--- a/src/viewer.js
+++ b/src/viewer.js
@@ -29,7 +29,7 @@ import { GUI } from 'dat.gui';
import { environments } from './environments.js';
import { createModelInfo } from './model-info.js';
-import { isDecentralizedURI, resolveURI } from './ipfs.js';
+import { isDecentralizedURI, resolveURI, normalizeGatewayURL } from './ipfs.js';
import { canUseQuickLook, openQuickLook } from './ar/quick-look.js';
import { canUseSceneViewer, openSceneViewer } from './ar/scene-viewer.js';
import { WebXRSession } from './ar/webxr.js';
@@ -806,12 +806,9 @@ export class Viewer {
return new Promise((resolve, reject) => {
// Intercept and override relative URLs.
MANAGER.setURLModifier((url, path) => {
- let finalUrl = url;
-
- // Fix for broken IPFS gateway domain.
- if (finalUrl.includes('//cf-ipfs.com')) {
- finalUrl = finalUrl.replace('//cf-ipfs.com', '//cloudflare-ipfs.com');
- }
+ // Repair retired IPFS gateway hosts (cf-ipfs.com /
+ // cloudflare-ipfs.com) and resolve ipfs://, ar:// schemes.
+ let finalUrl = normalizeGatewayURL(url);
if (isDecentralizedURI(finalUrl)) {
return resolveURI(finalUrl);
diff --git a/tests/src/ipfs.test.js b/tests/src/ipfs.test.js
index a221c20c1..94d4bc4fe 100644
--- a/tests/src/ipfs.test.js
+++ b/tests/src/ipfs.test.js
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
-import { isDecentralizedURI, resolveURI } from '../../src/ipfs.js';
+import { isDecentralizedURI, resolveURI, normalizeGatewayURL } from '../../src/ipfs.js';
describe('isDecentralizedURI', () => {
it('matches ipfs:// URIs', () => {
@@ -75,4 +75,34 @@ describe('resolveURI', () => {
expect(resolveURI('IPFS://QmCID')).toMatch(/\/ipfs\/QmCID$/);
expect(resolveURI('AR://tx')).toBe('https://arweave.net/tx');
});
+
+ it('repairs retired cf-ipfs.com gateway URLs', () => {
+ const out = resolveURI('https://cf-ipfs.com/ipfs/QmTestCID');
+ expect(out).not.toContain('cf-ipfs.com');
+ expect(out).toMatch(/^https:\/\/.+\/ipfs\/QmTestCID$/);
+ });
+});
+
+describe('normalizeGatewayURL', () => {
+ it('rewrites cf-ipfs.com onto a working gateway, preserving the path', () => {
+ const out = normalizeGatewayURL('https://cf-ipfs.com/ipfs/QmCID/img.png');
+ expect(out).not.toContain('cf-ipfs.com');
+ expect(out).toMatch(/\/ipfs\/QmCID\/img\.png$/);
+ });
+
+ it('rewrites cloudflare-ipfs.com too', () => {
+ const out = normalizeGatewayURL('https://cloudflare-ipfs.com/ipfs/QmCID');
+ expect(out).not.toContain('cloudflare-ipfs.com');
+ expect(out).toMatch(/\/ipfs\/QmCID$/);
+ });
+
+ it('leaves live gateways and arbitrary URLs untouched', () => {
+ expect(normalizeGatewayURL('https://ipfs.io/ipfs/QmCID')).toBe('https://ipfs.io/ipfs/QmCID');
+ expect(normalizeGatewayURL('https://example.com/x.png')).toBe('https://example.com/x.png');
+ });
+
+ it('returns falsy input unchanged', () => {
+ expect(normalizeGatewayURL('')).toBe('');
+ expect(normalizeGatewayURL(null)).toBe(null);
+ });
});