The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Chat: warm, plain words for waits, limits and stops
Adarshed1bc54295fa
diff --git a/src/app/api/chat/key/route.ts b/src/app/api/chat/key/route.tsindex 4bdf8692..8e0f904d 100644--- a/src/app/api/chat/key/route.ts+++ b/src/app/api/chat/key/route.ts@@ -29,7 +29,7 @@ export async function PUT(request: Request) {if (!p.success) return Response.json({ error: "That doesn't look like an OpenRouter key. It starts with sk-or-." }, { status: 400 });const check = await checkOpenRouterKey(p.data.key);if (check === "refused") return Response.json({ error: "OpenRouter didn't accept that key. Copy it again from openrouter.ai/settings/keys." }, { status: 422 });- if (check === "unreachable") return Response.json({ error: "Couldn't reach OpenRouter to check the key. Try again in a moment." }, { status: 503 });+ if (check === "unreachable") return Response.json({ error: "OpenRouter didn't pick up to check the key. Save it again in a moment." }, { status: 503 });const prefs = saveChatKey(v.who, p.data.key, p.data.model ?? null);return Response.json({ key: prefs.key, engine: prefs.engine });}diff --git a/src/components/chat/hooks.ts b/src/components/chat/hooks.tsindex bff02e58..32cb4110 100644--- a/src/components/chat/hooks.ts+++ b/src/components/chat/hooks.ts@@ -8,7 +8,7 @@ import { responseError } from "@/lib/refusals";async function json<T>(res: Response): Promise<T> {const body = (await res.json().catch(() => ({}))) as T & { error?: string; code?: string };- if (!res.ok) throw responseError(res, Object.assign(new Error(body.error ?? "Something went wrong. Try again."), { status: res.status }, body.code && { code: body.code }));+ if (!res.ok) throw responseError(res, Object.assign(new Error(body.error ?? "That didn't go through. Tap it once more."), { status: res.status }, body.code && { code: body.code }));return body;}@@ -73,7 +73,7 @@ export type ReplyState =/** Kept: the reply comes here as soon as the free model is ready (the page looks for it meanwhile). */| { phase: "pending" }| { phase: "writing"; text: string }- | { phase: "failed"; message: string; code: string; retryAfterS?: number };+ | { phase: "failed"; message: string; code: string; retryAfterS?: number; /** When a limit opens again (ms). */ retryAt?: number };/*** Ask for a reply and follow its stream. The thread's cached view gets the person's message and the saved reply as@@ -117,14 +117,15 @@ export function useReply(threadId: string) {});} catch {if (ac.signal.aborted) return setState({ phase: "idle" });- return setState({ phase: "failed", code: "failed", message: "Couldn't reach Fuobe. Check your connection and try again." });+ return setState({ phase: "failed", code: "failed", message: "You look offline. Your message is ready to send when you're back — tap Write it again." });}if (!res.ok || !res.body) {const e = (await res.json().catch(() => ({}))) as { error?: string; code?: string };// The guest card opens by itself (watchGuestRefusals); the message stays for Try again.responseError(res, new Error(e.error ?? ""));void qc.invalidateQueries({ queryKey: ["chat", "thread", threadId] });- return setState({ phase: "failed", code: e.code ?? "failed", message: e.error ?? "The reply didn't start. Try again." });+ const wait = Number(res.headers.get("Retry-After")) || undefined;+ return setState({ phase: "failed", code: e.code ?? "failed", message: e.error ?? "The reply didn't start. Tap Write it again.", ...(wait && { retryAfterS: wait, retryAt: Date.now() + wait * 1000 }) });}const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();let buf = "";@@ -167,7 +168,7 @@ export function useReply(threadId: string) {void qc.invalidateQueries({ queryKey: ["chat", "threads"] });} else if (e.type === "error") {ended = true;- setState({ phase: "failed", code: e.code, message: e.message, retryAfterS: e.retryAfterS });+ setState({ phase: "failed", code: e.code, message: e.message, retryAfterS: e.retryAfterS, ...(e.retryAfterS && { retryAt: Date.now() + e.retryAfterS * 1000 }) });}}}@@ -177,7 +178,7 @@ export function useReply(threadId: string) {setState({ phase: "idle" });}}- if (!ended) setState({ phase: "failed", code: "failed", message: "The reply was cut off. Try again." });+ if (!ended) setState({ phase: "failed", code: "failed", message: "The reply stopped part way. Tap Write it again for a fresh one." });},[patch, qc, threadId],);diff --git a/src/components/chat/thread-view.tsx b/src/components/chat/thread-view.tsxindex 3cf63c08..ee58b3b5 100644--- a/src/components/chat/thread-view.tsx+++ b/src/components/chat/thread-view.tsx@@ -251,7 +251,11 @@ export function ThreadView({ id }: { id: string }) {</Row>{state.phase === "waiting" && (state.starting || (state.position ?? 0) > 0) && (<p className={cn("mt-1.5 text-[12px] text-muted-foreground", c && "ml-9")}>- {state.starting && !state.position ? "Starting up…" : state.position === 1 ? "Up next" : `${(state.position ?? 1) - 1} ahead of you`}+ {state.starting && !state.position+ ? "Warming up · just a moment"+ : state.position === 1+ ? "Lots of people are chatting right now · you're next"+ : `Lots of people are chatting right now · ${(state.position ?? 1) - 1} ahead of you`}</p>)}</li>@@ -261,7 +265,7 @@ export function ThreadView({ id }: { id: string }) {<div className={cn("flex flex-wrap items-center gap-x-3 gap-y-2 text-[13px] text-muted-foreground", c && "ml-9")} role="status"><span className="inline-flex items-center gap-2"><span className="size-1.5 animate-pulse rounded-full bg-primary motion-reduce:animate-none" aria-hidden />- We'll answer here as soon as it's ready.+ Your message is saved — we'll answer here as soon as it's ready.</span>{me.data?.key && me.data.engine === "site" && (<Button@@ -286,7 +290,11 @@ export function ThreadView({ id }: { id: string }) {{state.phase === "failed" && (<li className="mt-5 animate-in duration-200 fade-in-0"><div className="flex flex-wrap items-center gap-3 rounded-2xl border bg-muted/40 p-3.5 text-[14px]">- <p className="min-w-0 flex-1">{state.message}</p>+ <p className="min-w-0 flex-1">+ {state.code === "limit" && state.retryAt+ ? `You've chatted a lot in a short while — more free replies at ${new Date(state.retryAt).toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" })}.`+ : state.message}+ </p>{state.code === "key-refused" || state.code === "no-model" ? (<Button size="sm" variant="secondary" onClick={() => setSettings(true)}>Chat settings@@ -296,10 +304,10 @@ export function ThreadView({ id }: { id: string }) {Turn on Mango Chilli</Button>) : null}- {t.messages.at(-1)?.role === "user" && (+ {t.messages.at(-1)?.role === "user" && state.code !== "limit" && (<Button size="sm" onClick={() => void ask({})}><RotateCcw />- Try again+ Write it again</Button>)}</div>@@ -483,7 +491,7 @@ function AssistantTurn({<div className={cn("mt-1 flex gap-0.5 text-muted-foreground", character && "ml-9")}>{copy}{canRetry && (- <button type="button" onClick={onRetry} className="grid size-8 place-items-center rounded-full hover:bg-accent hover:text-foreground" aria-label="Try again" title="Try again">+ <button type="button" onClick={onRetry} className="grid size-8 place-items-center rounded-full hover:bg-accent hover:text-foreground" aria-label="Write it again" title="Write it again"><RotateCcw className="size-3.5" /></button>)}diff --git a/src/server/chat/backend.ts b/src/server/chat/backend.tsindex 053d493a..326b94de 100644--- a/src/server/chat/backend.ts+++ b/src/server/chat/backend.ts@@ -41,14 +41,14 @@ export type ReplyAnswer =| { error: ChatErrorCode; message: string; retryAfterS?: number };export const CHAT_WORDS: Record<ChatErrorCode, string> = {- busy: "We'll answer here as soon as it's ready.",- limit: "That's a lot of messages in a short time. Take a breather and try again soon.",- blocked: "This message can't be answered here.",- failed: "The reply didn't finish. Try again.",+ busy: "Your message is saved — we'll answer here as soon as it's ready.",+ limit: "You've chatted a lot in a short while — more free replies in a minute or two.",+ blocked: "This one can't be answered here. Say it another way and it'll go through.",+ failed: "The reply stopped part way. Tap Write it again for a fresh one.","sign-in": "Create a free account to chat.",- "no-model": "We'll answer here as soon as it's ready.",- "key-refused": "OpenRouter didn't accept your key. Check it in chat settings.",- "too-long": "This chat is as long as a chat can be. Start a new one to keep going.",+ "no-model": "Your message is saved — we'll answer here as soon as it's ready.",+ "key-refused": "OpenRouter didn't accept your key. Update it in chat settings.",+ "too-long": "This chat is full. Start a new one to keep going.",};const asTenant = <T,>(who: string, fn: () => T): T => (who === "owner" ? fn() : runAsTenant({ kind: "account", id: who }, fn));@@ -67,7 +67,7 @@ const KEY_BUDGET = 24_000;function fromHelper(a: Exclude<HelperAnswer, { text: string }>): ReplyAnswer {const code: ChatErrorCode = a.error === "sign-in" ? "sign-in" : a.error === "limit" ? "limit" : a.error === "blocked" ? "blocked" : a.error === "busy" ? "busy" : "failed";- const message = code === "limit" && a.retryAfterS ? `That's a lot of messages in a short time. Try again in ${a.retryAfterS < 90 ? `${a.retryAfterS} s` : `${Math.ceil(a.retryAfterS / 60)} min`}.` : a.error === "blocked" && a.message ? a.message : CHAT_WORDS[code];+ const message = code === "limit" ? CHAT_WORDS.limit : a.error === "blocked" && a.message ? a.message : CHAT_WORDS[code];return { error: code, message, ...(a.retryAfterS ? { retryAfterS: a.retryAfterS } : {}) };}@@ -180,14 +180,14 @@ async function keyReply(ask: ReplyAsk, key: { key: string; model: string }): Prosignal: ask.signal,});} catch {- return { error: "failed", message: "Couldn't reach OpenRouter. Try again in a moment." };+ return { error: "failed", message: "OpenRouter didn't pick up. Tap Write it again, or switch to Fuobe's free model in chat settings." };}if (!res.ok || !res.body) {if (res.status === 401 || res.status === 403) return { error: "key-refused", message: CHAT_WORDS["key-refused"] };if (res.status === 402) return { error: "failed", message: "Your OpenRouter account is out of credits for this model. Top it up, or pick a free model in chat settings." };- if (res.status === 429) return { error: "limit", message: "OpenRouter says this model is busy or your limit is reached. Try again soon, or pick another model in chat settings." };+ if (res.status === 429) return { error: "limit", message: "This OpenRouter model has reached its limit for now. Pick another model in chat settings, or switch to Fuobe's free model." };if (res.status === 404 || res.status === 400) return { error: "failed", message: `OpenRouter couldn't run "${key.model}". Pick another model in chat settings.` };- return { error: "failed", message: "OpenRouter couldn't answer. Try again in a moment." };+ return { error: "failed", message: "OpenRouter didn't answer this time. Tap Write it again, or switch to Fuobe's free model in chat settings." };}let text = "";let problem: string | null = null;diff --git a/src/server/chat/http.ts b/src/server/chat/http.tsindex c7cfa4be..1985ca55 100644--- a/src/server/chat/http.ts+++ b/src/server/chat/http.ts@@ -20,7 +20,7 @@ export const signUp = () => Response.json({ error: GUEST_RUN_MESSAGE, code: "sigexport function tooOften(who: string, what = "changes", limit = 60): Response | null {if (who === "owner") return null;const r = hit(`chat-${what}:${who}`, limit, 60_000);- return r.ok ? null : Response.json({ error: "That's a lot at once. Wait a moment, then try again.", code: "limit" }, { status: 429, headers: { "Retry-After": String(r.retryAfterS) } });+ return r.ok ? null : Response.json({ error: "That's a lot at once — it'll work again in a few seconds.", code: "limit" }, { status: 429, headers: { "Retry-After": String(r.retryAfterS) } });}export function refused(e: unknown): Response {