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
Wait and limit lines: neutral by default, wording from the service
Adarsh070aff43a95a
diff --git a/docs/billing-hook.md b/docs/billing-hook.mdindex 1e269166..67b3b00a 100644--- a/docs/billing-hook.md+++ b/docs/billing-hook.md@@ -72,6 +72,7 @@ type Policy = {kinds?: { image?: boolean; video?: boolean; audio?: boolean; text?: boolean; model3d?: boolean }; // absent: allcardText?: string; // preset cards' words for a run there (absent: none)placeName?: string; // what visitors call these GPUs (absent: the install's name)+ copy?: Record<string, string>; // display copy by key (absent, or a key left out: Fuobe's own words)links?: Action[]; notice?: { id: string; text: string; url?: string }; ttlS: number;};```@@ -94,8 +95,8 @@ runs may wait like that behind the account's runs at once (`0`: no cap); a press"You have 10 runs on the way. Add more when one is done." Absent (an older service), every limit refuses as before.`startAt` (epoch ms, only with `allowed: true` or `ok: true`) says the run may be made now and waits until then before-it enters the line: the day's GPU time is used up (a `startAt` at a UTC midnight: the line before Run says "Lots of-runs today · starts in about 7 h", and at that time the runs enter at their press-time places, in press order), or an+it enters the line: the day's GPU time is used up (a `startAt` at a UTC midnight: the line before Run says "Free runs+refresh at 05:30." on the viewer's clock, and at that time the runs enter at their press-time places, in press order), or anhourly limit (at the back of the line). With credits on, a reserve refused with `top-up` whose quote is allowed with a`startAt` (free generations that renew then) waits too, and reserves at that time. `timing.heldMs` is about how longthe run is expected to wait before it enters the line at all (behind the account's runs, or until a time it was@@ -114,6 +115,25 @@ pause on its PC that has one), when every such GPU is away and one says; otherwiGPUs"), at most 40 characters. Absent: the install's own name for them (Settings → Workers → Name for your GPUs, else`FUOBE_PLACE_NAME`), else "Our GPUs". Fuobe writes every sentence so that no verb has to agree with the name.+`copy` is optional display copy: the service's own sentences for a few wait and limit lines, by key, each at most 300+characters. Fuobe fills the placeholders `{when}` ("at 14:20", "in about 40 min", "in a moment"), `{n}` (a count) and+`{line}` (a run's place and wait, "6 ahead of you · about 9 min"). A key left out, an unknown key, or a sentence that+names a placeholder the key doesn't get shows Fuobe's own words instead. The latest policy answer's copy is used for+every visitor (`src/lib/service-copy.ts`).++| Key | Shown | Placeholders | Fuobe's own words |+| --- | --- | --- | --- |+| `limitDaily` | a daily limit on free runs here | `{when}` | Free runs refresh {when}. |+| `limitHour` | an hourly limit on free runs here | `{when}` | Free runs refresh {when}. |+| `limitNetwork` | a limit on free runs from one network | `{when}` | Free runs on your network refresh {when}. |+| `limitReplies` | a limit on free text helper replies | `{when}` | More free replies {when}. |+| `queueBusy` | a run's tile with 5 or more runs ahead | `{line}`, `{n}` | {line} |+| `queueLong` | a run's tile after 10 min in line | none | Your run is saved and starts automatically; it'll appear here when it's ready. |+| `chatNext` | Chat, the next reply to be written | none | You're next |+| `chatAhead` | Chat, replies ahead of this one | `{n}` | {n} ahead of you |+| `lyricsBusy` | the lyrics helper can't take a request now | none | Try again in a moment, or type your own lyrics. |+| `writeBusy` | the text helper can't take a run's text step now | none | Press Retry in a moment. |+`megapixels` is the size of each picture or frame the run makes, about, as its workflow makes it: the canvas theworkflow binds (a canvas the request names counts only there; else the aspect ratio and resolution, the model'sdefaults where the request names none), or for a workflow sized by its input (an edit, an upscale, a face swap) thediff --git a/docs/public-signup.md b/docs/public-signup.mdindex 8dc5e881..006d9d88 100644--- a/docs/public-signup.md+++ b/docs/public-signup.md@@ -930,9 +930,9 @@ With it on:- past the account's runs at once (`limits.activeRuns`): "Starts after your other runs" before Run, "In line · afteryour other runs" on the tile; it enters at the back of the line when one of them ends, so ten fast presses neverpass another account, and its presses enter in the order they were made;- - the day's GPU time used up (the service's `startAt` at the next UTC day): "Lots of runs today · starts in about- 7 h" before Run, "In line · starts in about 7 h" on the tile; at the renewal the runs enter at their press-time- places, in press order;+ - the day's GPU time used up (the service's `startAt` at the next UTC day): "Free runs refresh at 14:20." (or the+ service's display copy, `limitDaily`) before Run, "Free runs refresh at 14:20 · this one starts then" on the+ tile; at the renewal the runs enter at their press-time places, in press order;- the billing service doesn't answer within 5 s of the press (or the moderation service doesn't, at a studio'spress): its tile shows its place as if in line, it reserves (and is checked) under its press's own request id oncethe service answers, and enters at its press-time place. While the service says runs here are paused, the linediff --git a/src/app/api/enhance/route.ts b/src/app/api/enhance/route.tsindex 06c52e55..94034886 100644--- a/src/app/api/enhance/route.ts+++ b/src/app/api/enhance/route.ts@@ -8,6 +8,7 @@ import { hostedRunsOn } from "@/server/hosted-switch";import { runAsTenant, type Tenant } from "@/server/tenant";import type { HelperAnswer } from "@/server/text-helper";import { limitFields, limitWords } from "@/lib/limit-words";+import { copyLine } from "@/lib/service-copy";type HelperTrouble = Exclude<HelperAnswer, { text: string }>;@@ -26,7 +27,7 @@ function noLyrics(owner: boolean, why: HelperTrouble | null): Response {if (owner && !why) {return Response.json({ error: "Writing lyrics needs an AI helper. Set up Claude or a local model in Settings → AI helper, or type your own.", code: "no-llm" }, { status: 503, headers });}- return Response.json({ error: "Lots of people are writing lyrics right now — try again in a moment, or type your own.", code: owner ? "no-llm" : "helper-busy" }, { status: 503, headers });+ return Response.json({ error: copyLine("lyricsBusy", {}, "Try again in a moment, or type your own lyrics."), code: owner ? "no-llm" : "helper-busy" }, { status: 503, headers });}export async function POST(request: Request) {diff --git a/src/components/chat/thread-view.tsx b/src/components/chat/thread-view.tsxindex 149a553d..76e2c2cb 100644--- a/src/components/chat/thread-view.tsx+++ b/src/components/chat/thread-view.tsx@@ -22,6 +22,7 @@ import { CHAT_KINDS, playFormat, writeTool, type CharacterCard } from "@/lib/chaimport type { Generation } from "@/lib/catalog/types";import type { ChatMessage, ChatThreadView } from "@/lib/chat/types";import { toastError } from "@/lib/refusals";+import { copyLine } from "@/lib/service-copy";import { cn } from "@/lib/utils";import { EngineLine, KindIcon, TypingDots, useReveal } from "./bits";import { CharacterFace } from "./character-face";@@ -264,8 +265,8 @@ export function ThreadView({ id }: { id: string }) {{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`}+ ? copyLine("chatNext", {}, "You're next")+ : copyLine("chatAhead", { n: (state.position ?? 1) - 1 }, "{n} ahead of you")}</p>)}</li>diff --git a/src/components/studio/pool-note.tsx b/src/components/studio/pool-note.tsxindex b9913936..6b35fe3d 100644--- a/src/components/studio/pool-note.tsx+++ b/src/components/studio/pool-note.tsx@@ -8,8 +8,8 @@ type PoolState = NonNullable<ReturnType<typeof poolRunState>>;/*** The line under a composer's toolbar for a run on this studio's GPUs: when it would be ready, before Run is pressed- * ("Ready in about 2 min", "Starts when a GPU is free", "Ready in seconds", "Starts after your other runs", "Lots of- * runs today · starts in about 7 h"), with `offer` after a long wait (the account's own GPU or key for this run, once:+ * ("Ready in about 2 min", "Starts when a GPU is free", "Ready in seconds", "Starts after your other runs", "Free+ * runs refresh at 14:20."), with `offer` after a long wait (the account's own GPU or key for this run, once:* "Run it now on your GPU"); or, when the price check refused it, the words (the* toolbar's price slot has no room for them on a phone), with the link or offer the answer carries, and `alt`: the same* run another way that does run there ("Run without LoRAs").diff --git a/src/lib/api.ts b/src/lib/api.tsindex a50d5711..f7ee5bd5 100644--- a/src/lib/api.ts+++ b/src/lib/api.ts@@ -40,6 +40,7 @@ import type { Diagnosis } from "./diagnose";import type { OwnSetup } from "./own-setup";import { BILLING_EVENT, BILLING_HEADER, refreshPriceChecks, type BillingAction, type BillingRefusalDetail, type HostedBalance } from "./hosted";import { knownPlace, notePlaceName, placeOf, type Place } from "./place-name";+import { noteServiceCopy, type ServiceCopy } from "./service-copy";import { ENGINE_KEY, ENGINE_SLOT_KEY, engineSlot, SHARED_SLOT, slotToCache, storedEngine, type EngineSlot, type SlotFacts } from "./engine-pref";/** What the status strip says of a GPU that didn't answer (src/server/account-gpu.ts VisitorTrouble). */@@ -1027,6 +1028,8 @@ export interface StatusInfo {balance?: HostedBalance;links?: BillingAction[];notice?: { id: string; text: string; url?: string };+ /** The billing service's display copy (src/lib/service-copy.ts): kept by useStatus for the wait and limit lines. */+ copy?: ServiceCopy;};/*** The owner's ComfyUI runs on the owner's computer (Settings): what the owner's Fuobe tab there last said. Never@@ -1078,6 +1081,7 @@ export function useStatus() {const s = await json<StatusInfo>(await fetchWithin("/api/status", READ_LIMIT_MS.status));// Kept for words made outside React (the toast that offers a run on this install's GPUs).notePlaceName(s.viewer?.hosted ? s.viewer.placeName : null);+ noteServiceCopy(s.viewer?.hosted ? s.viewer.copy : null);return s;},staleTime: 15_000,diff --git a/src/lib/hosted.ts b/src/lib/hosted.tsindex 8e2506ef..98d85506 100644--- a/src/lib/hosted.ts+++ b/src/lib/hosted.ts@@ -179,8 +179,8 @@ export function refreshPriceChecks(qc: QueryClient): void {* - otherwise the price (`text`: the service's words, empty when there is none) and, under it, when the run would be* ready (`wait`, inside a sentence: "ready in about 2 min", "starts when a GPU is free", "ready in seconds"; none when* nothing is known), and whether the wait is long (`long`: an account's own GPU or key may be offered for this run).- * `note`: the line under the toolbar as a sentence of its own ("Starts after your other runs", "Lots of runs today ·- * starts in about 7 h"); `held`: a run pressed now waits to enter the line, and why.+ * `note`: the line under the toolbar as a sentence of its own ("Starts after your other runs", "Free runs refresh at+ * 14:20."); `held`: a run pressed now waits to enter the line, and why.* Null while there is no answer yet.*/export function poolRunState(check: HostedCheck | null | undefined): {diff --git a/src/lib/limit-words.ts b/src/lib/limit-words.tsindex 3d8d9d9f..ec3a5af9 100644--- a/src/lib/limit-words.ts+++ b/src/lib/limit-words.ts@@ -1,10 +1,11 @@-import { aboutWords, clockWords } from "./pool-line";+import { aboutWords, clockWords, freeLimitSentence } from "./pool-line";/*** What a person reads when a limit stops a press: friendly, never "try again later", and when it refreshes, from the* limit itself. The server says the wait ("in about 40 min", the same on every clock) and sends when it ends- * (`refreshAt`); the page says it on the viewer's own clock ("at 14:20", limitWordsAt). With the free runs here shared- * out, the next step is one press away: run it self-hosted (an account), or a free account for more free runs (a guest).+ * (`refreshAt`); the page says it on the viewer's own clock ("at 14:20", limitWordsAt). Past a limit on free runs here,+ * the next step is one press away: run it self-hosted (an account), or a free account for more free runs (a guest).+ * The sentences for free runs and free replies are the service's display copy when it sends some (src/lib/service-copy.ts).*/export type LimitKind = "free-today" | "free-hour" | "network" | "runs" | "pictures" | "files" | "reports" | "steps" | "replies";@@ -16,11 +17,10 @@ export const isLimitKind = (v: unknown): v is LimitKind => typeof v === "string"function sentence(kind: LimitKind, when: string): string {switch (kind) {case "free-today":- return `Lots of people are creating on Fuobe today, so free runs are shared out — yours refresh ${when}.`;case "free-hour":- return `Lots of people are creating on Fuobe right now, so free runs are shared out — yours refresh ${when}.`;case "network":- return `Lots of people on your network are creating right now, so free runs are shared out — yours refresh ${when}.`;+ case "replies":+ return freeLimitSentence(kind, when);case "runs":return `You've made a lot this hour — you can run again ${when}.`;case "pictures":@@ -31,8 +31,6 @@ function sentence(kind: LimitKind, when: string): string {return `Thanks — we have your reports. You can send more ${when}.`;case "steps":return `You've kept a lot of steps this hour — download them now, and you can keep more ${when}.`;- case "replies":- return `Lots of people are writing on Fuobe right now, so free replies are shared out — yours refresh ${when}.`;}}diff --git a/src/lib/pending-words.ts b/src/lib/pending-words.tsindex 22989f9d..63736fec 100644--- a/src/lib/pending-words.ts+++ b/src/lib/pending-words.ts@@ -1,6 +1,7 @@import type { Generation } from "./catalog/types";import { lineWords } from "./pool-line";import { POOL_WORDS } from "./relay";+import { copyLine } from "./service-copy";/** Words that already say a run's place ("Waiting for a GPU · 1 ahead", "Next for a GPU", "In ComfyUI's queue"). */const SAYS_PLACE = /\bahead\b|\bnext\b|\bin line\b|queue/i;@@ -8,8 +9,11 @@ const SAYS_PLACE = /\bahead\b|\bnext\b|\bin line\b|queue/i;/** How long a run on this studio's GPUs waits before its tile says it is saved and starts by itself. */export const LONG_WAIT_MS = 10 * 60_000;-/** A run on this studio's GPUs that has waited long: it is kept, and starts by itself (never ended for a wait). */-export const LONG_WAIT_WORDS = "High demand right now — your run is saved and starts automatically; it'll appear here when it's ready.";+/**+ * A run on this studio's GPUs that has waited long: it is kept, and starts by itself (never ended for a wait). The+ * service's display copy (`queueLong`, src/lib/service-copy.ts) when it sends some.+ */+export const longWaitWords = (): string => copyLine("queueLong", {}, "Your run is saved and starts automatically; it'll appear here when it's ready.");/*** What a run on its way says on its tile or cover: its words (never empty: a blank or missing message reads "Queued" or@@ -24,7 +28,7 @@ export function pendingWords(g: Pick<Generation, "status" | "message" | "place"if (g.status === "queued") {const line = g.queue ? lineWords(g.queue, now) : POOL_WORDS.inLine;const long = !g.queue?.held && g.createdAt !== undefined && now - g.createdAt >= LONG_WAIT_MS;- return long ? { label: LONG_WAIT_WORDS, place: line } : { label: line, place: null };+ return long ? { label: longWaitWords(), place: line } : { label: line, place: null };}return { label: message ?? POOL_WORDS.working, place: null };}diff --git a/src/lib/pool-line.ts b/src/lib/pool-line.tsindex 880b1c39..e4ade74c 100644--- a/src/lib/pool-line.ts+++ b/src/lib/pool-line.ts@@ -5,13 +5,16 @@* only its place, "Working", then its result: it is taken whatever the line, and never ends for a wait.** A run can also be made and wait to enter the line (`held`): behind the account's other runs ("After your other runs"),- * until a time ("Lots of people are creating on Fuobe today, so free runs are shared out — yours refresh at 14:20." before- * Run, "Free runs refresh at 14:20 · this one starts then" on its tile), or while runs there are paused ("Warming up · starts automatically").+ * until a time ("Free runs refresh at 14:20." before Run, "Free runs refresh at 14:20 · this one starts then" on its+ * tile), or while runs there are paused ("Warming up · starts automatically").** The words are friendly and say what happens next: never the machinery (a GPU, a worker, a queue), never "busy", never* "try again later" (tests/hosted-words.test.ts). They are made in the browser, so a time is the viewer's own clock.+ * A few of them are the service's display copy when it sends some (src/lib/service-copy.ts), else the plain ones here.*/+import { copyLine } from "./service-copy";+/** Why a run made now waits to enter the line (server: pool-holds.ts). */export type HeldReason = "mine" | "today" | "service" | "hour" | "list" | "credits";@@ -47,6 +50,25 @@ export function clockWords(at: number, now = Date.now()): string {return new Date(at).toDateString() === new Date(now).toDateString() ? time : `tomorrow at ${time}`;}+/** The display copy key for each limit on free runs and free replies (src/lib/service-copy.ts). */+const FREE_COPY = { "free-today": "limitDaily", "free-hour": "limitHour", network: "limitNetwork", replies: "limitReplies" } as const;++/** The plain sentences for those limits, when no display copy is sent. */+const FREE_FALLBACK: Record<keyof typeof FREE_COPY, string> = {+ "free-today": "Free runs refresh {when}.",+ "free-hour": "Free runs refresh {when}.",+ network: "Free runs on your network refresh {when}.",+ replies: "More free replies {when}.",+};++/**+ * The sentence for a limit on free runs or free replies (src/lib/limit-words.ts), `when` it refreshes ("at 14:20", "in+ * about 40 min", "in a moment").+ */+export function freeLimitSentence(kind: keyof typeof FREE_COPY, when: string): string {+ return copyLine(FREE_COPY[kind], { when }, FREE_FALLBACK[kind]);+}+/** When a run waiting for a time starts: "at 14:20" (or "in a moment" when that time has come). */const atWords = (startAt: number | undefined, now: number): string => (startAt && startAt - now > 60_000 ? `at ${clockWords(startAt, now)}` : "in a moment");@@ -78,15 +100,15 @@ export const capitalFirst = (s: string): string => (s ? s[0].toUpperCase() + s.s/*** The line under the toolbar before Run, as a sentence of its own: "Ready in about 2 min", "Starts after your other- * runs", "Lots of people are creating on Fuobe today, so free runs are shared out — yours refresh at 14:20.", "Starts- * at 14:20, when your free generations renew", the service's own words while runs there are paused. Null when nothing is known.+ * runs", "Free runs refresh at 14:20.", "Starts at 14:20, when your free generations renew", the service's own words+ * while runs there are paused. Null when nothing is known.*/export function noteWords(q: LineFacts, now = Date.now()): string | null {if (q.held === "service" && q.paused && q.note) return q.note;if (q.held === "list") return "You're on the waiting list. Your runs start as soon as you're in.";// (The same sentences as a limit's refusal, src/lib/limit-words.ts.)- if (q.held === "today") return `Lots of people are creating on Fuobe today, so free runs are shared out — yours refresh ${atWords(q.startAt, now)}.`;- if (q.held === "hour") return `Lots of people are creating on Fuobe right now, so free runs are shared out — yours refresh ${atWords(q.startAt, now)}.`;+ if (q.held === "today") return freeLimitSentence("free-today", atWords(q.startAt, now));+ if (q.held === "hour") return freeLimitSentence("free-hour", atWords(q.startAt, now));const wait = waitWords(q, now);if (!wait) return null;if (q.held === "credits") return `${capitalFirst(wait)}, when your free generations renew`;@@ -94,14 +116,15 @@ export function noteWords(q: LineFacts, now = Date.now()): string | null {return capitalFirst(wait);}-/** How many ahead of a place in line make "lots of people" worth saying (only when people really are waiting). */+/** How many ahead of a place in line make the display copy's longer line worth showing (`queueBusy`). */const MANY_AHEAD = 5;/*** A run's place on this install's GPUs (1: next) and its wait: "You're next · ready in about 40 s", "2 ahead of you ·- * about 3 min", "6 ahead of you · about 9 min · lots of people are creating right now". A run waiting for a GPU to come- * on: "Warming up · starting in a moment". A run waiting to enter the line: "After your other runs · ready in about 2- * min", "Free runs refresh at 14:20 · this one starts then", "You're on the waiting list"; one waiting for the service, as warming up.+ * about 3 min" (with many ahead, the display copy's `queueBusy` line around it when the service sends one). A run+ * waiting for a GPU to come on: "Warming up · starting in a moment". A run waiting to enter the line: "After your+ * other runs · ready in about 2 min", "Free runs refresh at 14:20 · this one starts then", "You're on the waiting+ * list"; one waiting for the service, as warming up.*/export function lineWords(q: LineFacts, now = Date.now()): string {if (q.held === "mine") {@@ -119,5 +142,5 @@ export function lineWords(q: LineFacts, now = Date.now()): string {const head = `${ahead} ahead of you`;const line = eta ? `${head} · ${q.light ? "ready in seconds" : eta}` : head;// (The place and the wait first: a tile shows two lines.)- return ahead >= MANY_AHEAD ? `${line} · lots of people are creating right now` : line;+ return ahead >= MANY_AHEAD ? copyLine("queueBusy", { line, n: ahead }, "{line}") : line;}diff --git a/src/lib/service-copy.ts b/src/lib/service-copy.tsnew file mode 100644index 00000000..9ada42c5--- /dev/null+++ b/src/lib/service-copy.ts@@ -0,0 +1,86 @@+/**+ * Display copy: optional sentences an install's billing service may send with its policy answer (`Policy.copy`,+ * docs/billing-hook.md), keyed by where they show. Each one may hold placeholders that the code fills in: `{when}`+ * ("at 14:20", "in about 40 min", "in a moment"), `{n}` (a count) and `{line}` (a run's place in line, "6 ahead of you ·+ * about 9 min"). A key the service doesn't send, or one whose sentence names a placeholder the code doesn't fill there,+ * shows the code's own plain sentence (the fallback at each call site), so an install with no service reads those.+ *+ * The browser gets the copy as `viewer.copy` in GET /api/status (only while hosted runs are on); the server keeps the+ * latest policy answer's copy for the sentences it writes itself (billing.ts). Both note it here (noteServiceCopy).+ */++export const COPY_KEYS = [+ /** A daily limit on free runs here: "{when}" it refreshes. */+ "limitDaily",+ /** An hourly limit on free runs here: "{when}" it refreshes. */+ "limitHour",+ /** A limit on free runs from one network: "{when}" it refreshes. */+ "limitNetwork",+ /** A limit on free text helper replies: "{when}" it refreshes. */+ "limitReplies",+ /** A run's place in line with many runs ahead of it: "{line}" (its place and wait), "{n}" ahead. */+ "queueBusy",+ /** A run that has waited long in line: it is saved and starts by itself. */+ "queueLong",+ /** Chat: the next reply to be written is this one. */+ "chatNext",+ /** Chat: "{n}" replies ahead of this one. */+ "chatAhead",+ /** The lyrics helper can't take this request now. */+ "lyricsBusy",+ /** The free text helper can't take a run's text step now. */+ "writeBusy",+] as const;++export type CopyKey = (typeof COPY_KEYS)[number];++export type ServiceCopy = Partial<Record<CopyKey, string>>;++/** The longest sentence kept (characters); a longer one is left out. */+export const COPY_MAX = 300;++const KEYS: ReadonlySet<string> = new Set(COPY_KEYS);++/** A service's copy as kept: known keys only, text only, control characters out, spaces folded. Null when none is left. */+export function cleanCopy(raw: unknown): ServiceCopy | null {+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;+ const out: ServiceCopy = {};+ for (const [key, value] of Object.entries(raw as Record<string, unknown>)) {+ if (!KEYS.has(key) || typeof value !== "string") continue;+ const s = value.replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").replace(/\s+/g, " ").trim();+ if (s && s.length <= COPY_MAX) out[key as CopyKey] = s;+ }+ return Object.keys(out).length ? out : null;+}++declare global {+ var __fuobeServiceCopy: ServiceCopy | null | undefined;+}++/** Note the copy the service last gave (the status in the browser, a policy answer on the server). */+export function noteServiceCopy(raw: unknown): void {+ globalThis.__fuobeServiceCopy = cleanCopy(raw);+}++/** The copy as last noted (null: none). */+export const knownCopy = (): ServiceCopy | null => globalThis.__fuobeServiceCopy ?? null;++/** A sentence with its placeholders filled; null when it names one that isn't given. */+function fill(template: string, vars: Record<string, string | number>): string | null {+ let missing = false;+ const s = template.replace(/\{(\w+)\}/g, (_, k: string) => {+ const v = vars[k];+ if (v === undefined) missing = true;+ return v === undefined ? "" : String(v);+ });+ return missing ? null : s;+}++/**+ * The sentence for `key`: the service's when it sent one (filled in), else `fallback` filled in the same way.+ * `copy`: the copy to read (default: the copy last noted).+ */+export function copyLine(key: CopyKey, vars: Record<string, string | number>, fallback: string, copy: ServiceCopy | null = knownCopy()): string {+ const own = copy?.[key];+ return (own && fill(own, vars)) ?? fill(fallback, vars) ?? fallback;+}diff --git a/src/server/account-gpu.ts b/src/server/account-gpu.tsindex f7a4c9a5..8541ca45 100644--- a/src/server/account-gpu.ts+++ b/src/server/account-gpu.ts@@ -1,6 +1,7 @@import "server-only";import dns from "node:dns/promises";import net from "node:net";+import { cleanCopy, type ServiceCopy } from "@/lib/service-copy";import { isCloudProvider, type CloudProvider } from "@/lib/your-keys";import { accountEngineMode, accountKeyInfo, accountProviders, paidAllowed, usableProviders } from "./account-keys";import { accountGpu, type Account, type AccountGpu } from "./auth";@@ -375,6 +376,8 @@ export interface VisitorView {links?: Action[];/** A notice to show once per id (the billing service's policy). */notice?: { id: string; text: string; url?: string };+ /** The billing service's display copy (src/lib/service-copy.ts), cleaned. Only with `hosted`. */+ copy?: ServiceCopy;}declare global {@@ -478,6 +481,9 @@ export async function visitorStatus(account: Account | null) {if (rules) viewer.pool = rules;if (account && p?.links?.length) viewer.links = p.links;if (account && p?.notice) viewer.notice = p.notice;+ // The service's display copy (wait and limit lines), for guests and accounts alike.+ const copy = p?.hosted ? cleanCopy(p.copy) : null;+ if (copy) viewer.copy = copy;const b = account ? await billingBalance(account.id) : null;if (b) viewer.balance = b;}diff --git a/src/server/billing.ts b/src/server/billing.tsindex e7c51776..33f6288e 100644--- a/src/server/billing.ts+++ b/src/server/billing.ts@@ -3,6 +3,7 @@ import type { Account } from "./auth";import { db } from "./db";import { HookDown, hookCall, hookTarget, type HookTarget } from "./hook-client";import { hostedRunsOn } from "./hosted-switch";+import { noteServiceCopy } from "@/lib/service-copy";/*** The billing hook (docs/billing-hook.md): an install can connect an external billing service at FUOBE_BILLING_URL.@@ -151,6 +152,11 @@ export interface Policy {placeName?: string;links?: Action[];notice?: { id: string; text: string; url?: string };+ /**+ * Display copy: sentences by key, with placeholders the app fills in (src/lib/service-copy.ts COPY_KEYS). Absent, or a+ * key left out: the app's own plain sentence. The latest answer's copy applies to every visitor's words.+ */+ copy?: Record<string, string>;ttlS: number;}@@ -324,6 +330,7 @@ export async function policy(accountId: string | null): Promise<Policy | null> {const ttlMs = Math.max(0, Math.min(3600, Number(p.ttlS) || 0)) * 1000;keep({ at: Date.now(), ttlMs, policy: p, goodAt: Date.now(), ...(p.prefer && { prefer: p.prefer }) });savePolicy(key, p);+ noteServiceCopy(p.copy);return p;} catch (e) {logDown("policy", e);@@ -628,4 +635,5 @@ export function resetBillingCache(): void {globalThis.__fuobeBillingBalances?.clear();globalThis.__fuobeBillingQuotes?.clear();globalThis.__fuobeBillingBadUrl = undefined;+ globalThis.__fuobeServiceCopy = undefined;}diff --git a/src/server/providers/llm.ts b/src/server/providers/llm.tsindex 990a8c65..f6c5cd56 100644--- a/src/server/providers/llm.ts+++ b/src/server/providers/llm.ts@@ -5,6 +5,7 @@ import { getModel } from "@/lib/catalog";import { cueText, parseCues, toSrt, type Cue } from "@/lib/cues";import type { GenInput, ModelRoute, Operation } from "@/lib/catalog/types";import { GUEST_RUN_MESSAGE } from "@/lib/guest-access";+import { copyLine } from "@/lib/service-copy";import { HOSTED_PROVIDERS, testHosted } from "../llm/hosted";import { aiHelper, chatLocal, checkLocal, emptyReply, LOCAL_LABELS, localLabel, localProblem, localReady, localServers, localWhat, pinnedKind, probeLocal, type JsonSpec, type LocalKind, type Ready } from "../llm";import { placeName } from "../place-name";@@ -208,7 +209,7 @@ async function viaComfy(system: string, user: string, signal: AbortSignal): Promfunction helperTrouble(a: Exclude<HelperAnswer, { text: string }>): string {if (a.error === "blocked") return a.message || "This text can't be written here.";if (a.error === "sign-in") return GUEST_RUN_MESSAGE;- if (a.error === "busy") return "Lots of people are writing right now — press Retry in a moment.";+ if (a.error === "busy") return copyLine("writeBusy", {}, "Press Retry in a moment.");return "The writer couldn't finish this text. Press Retry.";}diff --git a/tests/hosted-price-check.test.ts b/tests/hosted-price-check.test.tsindex 4c55490e..43da49b3 100644--- a/tests/hosted-price-check.test.ts+++ b/tests/hosted-price-check.test.ts@@ -271,4 +271,25 @@ describe("what this install's GPUs keep off, in the status", () => {billing.resetBillingCache();expect((await visitorStatus(auth.accountById(a)!)).viewer.cardText).toBe("Free this week");});++ it("the status carries the billing service's display copy (known keys only), and the server's own sentences use it", async () => {+ const { limitWords } = await import("@/lib/limit-words");+ process.env.FUOBE_HOSTED_RUNS = "1";+ process.env.FUOBE_HOSTED_FREE = "1";+ // No service: no copy, the plain sentences.+ expect((await visitorStatus(auth.accountById(a)!)).viewer.copy).toBeUndefined();+ expect(limitWords("free-hour", 40 * 60)).toBe("Free runs refresh in about 40 min.");+ process.env.FUOBE_BILLING_URL = fake.url;+ process.env.FUOBE_BILLING_TOKEN = "test-billing-token";+ fake.policy = { ...FAKE_POLICY, copy: { limitHour: "Hourly runs come back {when}.", madeUp: "x", chatNext: "Up next" } };+ billing.resetBillingCache();+ expect((await visitorStatus(null)).viewer.copy).toEqual({ limitHour: "Hourly runs come back {when}.", chatNext: "Up next" });+ expect((await visitorStatus(auth.accountById(a)!)).viewer.copy).toEqual({ limitHour: "Hourly runs come back {when}.", chatNext: "Up next" });+ expect(limitWords("free-hour", 40 * 60)).toBe("Hourly runs come back in about 40 min.");+ // A service that stops sending copy: the plain sentences again.+ fake.policy = { ...FAKE_POLICY };+ billing.resetBillingCache();+ expect((await visitorStatus(auth.accountById(a)!)).viewer.copy).toBeUndefined();+ expect(limitWords("free-hour", 40 * 60)).toBe("Free runs refresh in about 40 min.");+ });});diff --git a/tests/hosted-run-button.test.ts b/tests/hosted-run-button.test.tsindex d0e0d668..245d743d 100644--- a/tests/hosted-run-button.test.ts+++ b/tests/hosted-run-button.test.ts@@ -29,9 +29,9 @@ describe("the words for a place in line", () => {expect(lineWords({ place: 1, etaSeconds: 38 })).toBe("You're next · ready in about 40 s");expect(lineWords({ place: 3, etaSeconds: 130 })).toBe("2 ahead of you · about 2 min");expect(lineWords({ place: 2, etaSeconds: 3 * 3600 })).toBe("1 ahead of you · about 3 h");- // Lots of people only when lots really are waiting ahead.- expect(lineWords({ place: 12, etaSeconds: null })).toBe("11 ahead of you · lots of people are creating right now");- expect(lineWords({ place: 22, etaSeconds: 3 })).toBe("21 ahead of you · about 5 s · lots of people are creating right now");+ // Many ahead: the place and the wait (with no display copy).+ expect(lineWords({ place: 12, etaSeconds: null })).toBe("11 ahead of you");+ expect(lineWords({ place: 22, etaSeconds: 3 })).toBe("21 ahead of you · about 5 s");// Never a place before the first, nor a wait that can't be.expect(lineWords({ place: 0, etaSeconds: -5 })).toBe("You're next");});diff --git a/tests/limit-words.test.ts b/tests/limit-words.test.tsindex 4ec1e009..822885e6 100644--- a/tests/limit-words.test.ts+++ b/tests/limit-words.test.ts@@ -16,10 +16,11 @@ describe("limits", () => {const now = new Date(2026, 10, 8, 12, 0).getTime();it("say when free runs refresh, on the server as a wait and on the page as the viewer's clock", () => {- expect(limitWords("free-today", 40 * 60)).toBe("Lots of people are creating on Fuobe today, so free runs are shared out — yours refresh in about 40 min.");+ expect(limitWords("free-today", 40 * 60)).toBe("Free runs refresh in about 40 min.");const at = now + (2 * 60 + 20) * 60_000;- expect(limitWordsAt("free-today", at, now)).toBe(`Lots of people are creating on Fuobe today, so free runs are shared out — yours refresh at ${clockWords(at, now)}.`);- expect(limitWordsAt("replies", at, now)).toMatch(/free replies are shared out — yours refresh at /);+ expect(limitWordsAt("free-today", at, now)).toBe(`Free runs refresh at ${clockWords(at, now)}.`);+ expect(limitWordsAt("replies", at, now)).toBe(`More free replies at ${clockWords(at, now)}.`);+ expect(limitWords("network", 40 * 60)).toBe("Free runs on your network refresh in about 40 min.");// A time that has come: in a moment, never a time in the past.expect(limitWordsAt("free-hour", now - 1000, now)).toMatch(/refresh in a moment\.$/);expect(readyInWords(20)).toBe("in a moment");@@ -66,19 +67,20 @@ describe("waits and failures", () => {for (const w of [POOL_WORDS.failed, ...Object.values(FILE_TROUBLE_WORDS), ...Object.values(ENGINE_WORDS)]) expect(w, w).toMatch(/\btry\b/i);});- it("lots of people only when lots really are waiting", () => {+ it("a place in line says the place and the wait, however many are ahead", () => {expect(lineWords({ place: 2, etaSeconds: 60 }, now)).toBe("1 ahead of you · about 1 min");- expect(lineWords({ place: 7, etaSeconds: 600 }, now)).toBe("6 ahead of you · about 10 min · lots of people are creating right now");+ expect(lineWords({ place: 7, etaSeconds: 600 }, now)).toBe("6 ahead of you · about 10 min");});});describe("a long wait in line", () => {it("keeps the run: saved, it starts by itself, with its place under it", async () => {- const { pendingWords, LONG_WAIT_MS, LONG_WAIT_WORDS } = await import("@/lib/pending-words");+ const { pendingWords, LONG_WAIT_MS, longWaitWords } = await import("@/lib/pending-words");const now = Date.now();const g = { status: "queued" as const, message: null, place: "pool" as const, queue: { place: 3, etaSeconds: 120 } };expect(pendingWords({ ...g, createdAt: now - 60_000 }, null, now)).toEqual({ label: "2 ahead of you · about 2 min", place: null });- expect(pendingWords({ ...g, createdAt: now - LONG_WAIT_MS }, null, now)).toEqual({ label: LONG_WAIT_WORDS, place: "2 ahead of you · about 2 min" });- expect(LONG_WAIT_WORDS).not.toMatch(/\bbusy\b|queue|worker|GPU|try again later|!/i);+ expect(pendingWords({ ...g, createdAt: now - LONG_WAIT_MS }, null, now)).toEqual({ label: longWaitWords(), place: "2 ahead of you · about 2 min" });+ expect(longWaitWords()).toBe("Your run is saved and starts automatically; it'll appear here when it's ready.");+ expect(longWaitWords()).not.toMatch(/\bbusy\b|queue|worker|GPU|try again later|!/i);});});diff --git a/tests/pool-holds.test.ts b/tests/pool-holds.test.tsindex 2a4e67df..d34101d2 100644--- a/tests/pool-holds.test.ts+++ b/tests/pool-holds.test.ts@@ -293,7 +293,7 @@ describe("the daily cap (H2)", () => {/** The next UTC midnight: the time the billing service says the day's GPU time renews. */const midnight = () => (Math.floor(Date.now() / 86_400_000) + 1) * 86_400_000;- it("A4: past the day's GPU time a press makes a held run; before Run 'Lots of runs today'; at the renewal they enter in press order", async () => {+ it("A4: past the day's GPU time a press makes a held run; before Run the free-runs line; at the renewal they enter in press order", async () => {const at = midnight();fake.reserveExtra = { startAt: at };fake.quoteAnswer = { allowed: true, amount: 7, priceVersion: "v7", text: "7 units", startAt: at };@@ -302,7 +302,7 @@ describe("the daily cap (H2)", () => {const p = await check(a.cookie);expect(p.body.quote).toMatchObject({ allowed: true });expect(p.body.line).toMatchObject({ held: "today", startAt: at, long: true });- expect(noteWords(p.body.line as never)).toMatch(/^Lots of people are creating on Fuobe today, so free runs are shared out — yours refresh at .+\.$/);+ expect(noteWords(p.body.line as never)).toMatch(/^Free runs refresh at .+\.$/);const first = await press(b.cookie);await new Promise((r) => setTimeout(r, 5));const second = await press(a.cookie);diff --git a/tests/pool-limits.test.ts b/tests/pool-limits.test.tsindex 6a1028a9..ad46b06d 100644--- a/tests/pool-limits.test.ts+++ b/tests/pool-limits.test.ts@@ -324,7 +324,7 @@ describe("runs at once on this install's GPUs", () => {const third = await post(IMAGE, a.cookie);expect(third.status).toBe(429);expect(third.body.code).toBe("limit");- expect(third.body.error).toMatch(/^Lots of people are creating on Fuobe right now, so free runs are shared out — yours refresh in about \d+ min\.$/);+ expect(third.body.error).toMatch(/^Free runs refresh in about \d+ min\.$/);expect(third.body).toMatchObject({ limit: "free-hour", refreshAt: expect.any(Number) });} finally {Object.assign(billing.OPEN_POLICY.limits, was);@@ -430,7 +430,7 @@ describe("runs waiting, runs an hour, runs from one address", () => {expect((await post({ ...IMAGE, ...SHOWN }, b.cookie, from)).status).toBe(201);const third = await post({ ...IMAGE, ...SHOWN }, b.cookie, from);expect(third.status).toBe(429);- expect(third.body.error).toMatch(/^Lots of people on your network are creating right now, so free runs are shared out — yours refresh in about \d+ min\.$/);+ expect(third.body.error).toMatch(/^Free runs on your network refresh in about \d+ min\.$/);expect((await post({ ...IMAGE, ...SHOWN }, b.cookie, { "x-forwarded-for": "198.51.100.4" })).status).toBe(201);const kept = db().prepare("SELECT addr FROM pool_admissions WHERE addr IS NOT NULL").all() as { addr: string }[];expect(kept.length).toBeGreaterThan(0);diff --git a/tests/service-copy.test.ts b/tests/service-copy.test.tsnew file mode 100644index 00000000..45c93d02--- /dev/null+++ b/tests/service-copy.test.ts@@ -0,0 +1,97 @@+import { execFileSync } from "node:child_process";+import path from "node:path";+import { afterEach, describe, expect, it } from "vitest";+import { limitWords, limitWordsAt } from "@/lib/limit-words";+import { longWaitWords } from "@/lib/pending-words";+import { clockWords, lineWords, noteWords } from "@/lib/pool-line";+import { cleanCopy, COPY_KEYS, COPY_MAX, copyLine, knownCopy, noteServiceCopy } from "@/lib/service-copy";++/*+ * Display copy (src/lib/service-copy.ts): an install's billing service may send its own sentences for a few wait and+ * limit lines. Without it, Fuobe's own plain sentences show.+ */++afterEach(() => noteServiceCopy(null));++describe("display copy", () => {+ const now = new Date(2026, 10, 8, 12, 0).getTime();+ const at = now + (2 * 60 + 20) * 60_000;++ it("keeps known keys with text only, cleaned, and nothing too long", () => {+ expect(cleanCopy(null)).toBeNull();+ expect(cleanCopy("limitDaily")).toBeNull();+ expect(cleanCopy(["x"])).toBeNull();+ expect(cleanCopy({ madeUp: "x", limitDaily: 3 })).toBeNull();+ expect(cleanCopy({ limitDaily: " Back\n {when}. ", chatNext: "", queueLong: "x".repeat(COPY_MAX + 1), writeBusy: "Soon." })).toEqual({ limitDaily: "Back {when}.", writeBusy: "Soon." });+ expect(new Set(COPY_KEYS).size).toBe(COPY_KEYS.length);+ });++ it("fills the placeholders; a sentence naming one that isn't given shows the plain one", () => {+ expect(copyLine("chatAhead", { n: 3 }, "{n} ahead of you", null)).toBe("3 ahead of you");+ expect(copyLine("chatAhead", { n: 3 }, "{n} ahead of you", { chatAhead: "{n} before yours" })).toBe("3 before yours");+ expect(copyLine("chatAhead", { n: 3 }, "{n} ahead of you", { chatAhead: "{who} before yours" })).toBe("3 ahead of you");+ // A value is put in as it is, never read for placeholders again.+ expect(copyLine("queueBusy", { line: "{n}", n: 2 }, "{line}", { queueBusy: "{line} · more" })).toBe("{n} · more");+ });++ it("with no copy, every line is plain", () => {+ expect(knownCopy()).toBeNull();+ expect(limitWords("free-today", 40 * 60)).toBe("Free runs refresh in about 40 min.");+ expect(limitWords("free-hour")).toBe("Free runs refresh in a moment.");+ expect(limitWords("network", 40 * 60)).toBe("Free runs on your network refresh in about 40 min.");+ expect(limitWordsAt("replies", at, now)).toBe(`More free replies at ${clockWords(at, now)}.`);+ expect(noteWords({ place: 1, etaSeconds: null, held: "today", startAt: at }, now)).toBe(`Free runs refresh at ${clockWords(at, now)}.`);+ expect(lineWords({ place: 9, etaSeconds: 600 }, now)).toBe("8 ahead of you · about 10 min");+ expect(longWaitWords()).toBe("Your run is saved and starts automatically; it'll appear here when it's ready.");+ });++ it("with copy noted, the lines read it", () => {+ noteServiceCopy({+ limitDaily: "Daily runs are back {when}.",+ limitHour: "Hourly runs are back {when}.",+ limitNetwork: "Runs on this network are back {when}.",+ limitReplies: "Replies are back {when}.",+ queueBusy: "{line} · {n} in front",+ queueLong: "Saved; it starts by itself.",+ });+ expect(limitWords("free-today", 40 * 60)).toBe("Daily runs are back in about 40 min.");+ expect(limitWords("free-hour", 40 * 60)).toBe("Hourly runs are back in about 40 min.");+ expect(limitWords("network", 40 * 60)).toBe("Runs on this network are back in about 40 min.");+ expect(limitWordsAt("replies", at, now)).toBe(`Replies are back at ${clockWords(at, now)}.`);+ expect(noteWords({ place: 1, etaSeconds: null, held: "hour", startAt: at }, now)).toBe(`Hourly runs are back at ${clockWords(at, now)}.`);+ // Only with many ahead.+ expect(lineWords({ place: 3, etaSeconds: 120 }, now)).toBe("2 ahead of you · about 2 min");+ expect(lineWords({ place: 9, etaSeconds: 600 }, now)).toBe("8 ahead of you · about 10 min · 8 in front");+ expect(longWaitWords()).toBe("Saved; it starts by itself.");+ // Other limits keep their own words.+ expect(limitWords("runs", 40 * 60)).toBe("You've made a lot this hour — you can run again in about 40 min.");+ noteServiceCopy(undefined);+ expect(limitWords("free-today", 40 * 60)).toBe("Free runs refresh in about 40 min.");+ });+});++describe("the public tree holds only plain wait and limit words", () => {+ // Built from parts, so this file never holds a phrase it looks for.+ const phrases = [+ ["lots", "of", "people"],+ ["high", "demand", "right", "now"],+ ["are", "shared", "out"],+ ["people", "are", "chatting"],+ ["people", "are", "writing"],+ ["people", "are", "creating"],+ ["creating", "on", "Fuobe"],+ ].map((w) => w.join(" "));++ it("finds none of the busy-time phrases in any tracked file", () => {+ const root = path.resolve(__dirname, "..");+ const args = ["grep", "-n", "-i", "-I", "-F", ...phrases.flatMap((p) => ["-e", p]), "--", "."];+ let out = "";+ try {+ out = execFileSync("git", args, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], maxBuffer: 64 << 20 });+ } catch (e) {+ // git grep exits 1 when nothing matches.+ if ((e as { status?: number }).status !== 1) throw e;+ }+ expect(out.split("\n").filter(Boolean)).toEqual([]);+ });+});diff --git a/tests/text-helper.test.ts b/tests/text-helper.test.tsindex 519526de..d7ba4c79 100644--- a/tests/text-helper.test.ts+++ b/tests/text-helper.test.ts@@ -364,7 +364,7 @@ describe("the AI helper's order and the lyrics route", () => {process.env.FUOBE_HOSTED_RUNS = "1";const busy = await enhanceRoute.POST(post("/api/enhance", { prompt: "a song", target: "lyrics" }, "account"));expect(busy.status).toBe(503);- expect(await busy.json()).toEqual({ error: "Lots of people are writing lyrics right now — try again in a moment, or type your own.", code: "helper-busy" });+ expect(await busy.json()).toEqual({ error: "Try again in a moment, or type your own lyrics.", code: "helper-busy" });// A rewrite always comes back: the offline one when the helper is busy.const rewrite = await enhanceRoute.POST(post("/api/enhance", { prompt: "a cat" }, "account"));expect(((await rewrite.json()) as { prompt: string }).prompt).toMatch(/^a cat\. /);