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(chat): make the rate-limit wait readable and pin the chat dev port

nirholas3b502c4c0a23
diff --git a/chat/README.md b/chat/README.md
index 64c34dd87..4aa681aa1 100644
--- a/chat/README.md
+++ b/chat/README.md
@@ -35,9 +35,15 @@ This directory is covered by [LICENSE](LICENSE) (proprietary, copyright 2026 nir
```sh
cd chat
npm ci # or: node scripts/ensure-deps.mjs
-npm run dev # http://localhost:5173
+npm run dev # http://localhost:5174
```
+The port is pinned to 5174 (`strictPort`) because the repo-root dev server proxies
+`/chat` there. You do not have to run this app at all to see `/chat` locally: the root
+`npm run dev` serves the last `npm run build:chat` output out of `public/chat` whenever
+5174 is down, which is the same artifact production serves. Run this app when you want
+hot reload while editing `chat/src`.
+
The dev server ([vite.config.js](vite.config.js)) does three things for you:
- Proxies `/api/*` to `https://three.ws` (override with `DEV_API_PROXY`, see below), so
diff --git a/chat/src/App.svelte b/chat/src/App.svelte
index 626b67414..4959f644c 100644
--- a/chat/src/App.svelte
+++ b/chat/src/App.svelte
@@ -954,14 +954,27 @@
}
};
+ // Retry-After is a raw second count that ranges from a few seconds to the
+ // free tier's whole daily window (~22h). Printing it as "79445s" told the
+ // reader nothing, so say it in units people use, and once waiting stops
+ // being a plan, name the way out instead.
+ const retryAdvice = (retryAfter) => {
+ const seconds = Number(retryAfter);
+ if (!Number.isFinite(seconds) || seconds <= 0) return 'Please wait a moment and try again.';
+ if (seconds < 90) return `Try again in ${Math.ceil(seconds)}s.`;
+ const minutes = Math.round(seconds / 60);
+ if (minutes < 60) return `Try again in about ${minutes} minutes.`;
+ const hours = Math.round(seconds / 3600);
+ return `The free allowance resets in about ${hours} ${hours === 1 ? 'hour' : 'hours'}. To keep going now, open Settings and add your own provider key, or pick a model you hold a key for.`;
+ };
+
const onabort = (err) => {
if (err && typeof err === 'object') {
if (err.code === 'payment_required') {
const url = err.upgradeUrl || '/pricing';
convo.messages[i].error = `Out of credits. [Upgrade your plan](${url}) to keep chatting.`;
} else if (err.code === 'rate_limited') {
- const hint = err.retryAfter ? ` Try again in ${err.retryAfter}s.` : ' Please wait a moment and try again.';
- convo.messages[i].error = `The built-in model is rate-limited.${hint}`;
+ convo.messages[i].error = `The built-in model is rate-limited. ${retryAdvice(err.retryAfter)}`;
} else if (err.code === 'network') {
convo.messages[i].error =
'Could not reach the model. The request never left this device, so nothing was sent. Check your connection, then hover this reply and press the refresh button to try again.';
diff --git a/chat/vite.config.js b/chat/vite.config.js
index f9c07ad7a..83dff877a 100644
--- a/chat/vite.config.js
+++ b/chat/vite.config.js
@@ -55,6 +55,11 @@ export default defineConfig(function () {
emptyOutDir: true,
},
server: {
+ // Pinned, because the root dev server proxies /chat to exactly this
+ // port. On Vite's default (5173) the proxy could never reach this app,
+ // and a second Vite instance would silently take the next free port.
+ port: 5174,
+ strictPort: true,
fs: {
// The chat app reuses shared wallet modules that live in the main
// repo's src/ (one repo, one wallet truth) — allow Vite to serve them.