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
Balance menu: a service's line can carry a bar, a note and a picture
Adarshf477c0cb1011
diff --git a/docs/billing-hook.md b/docs/billing-hook.mdindex c8a47cb8..a563c81d 100644--- a/docs/billing-hook.md+++ b/docs/billing-hook.md@@ -250,10 +250,14 @@ answers again.| `POST /v1/release` | `{ holdId, reason: "not-created" }` or `{ requestId, reason: "not-created" }` | `{ ok: true }` || `POST /v1/settle` | `{ holdId, generationId, rows, status: "succeeded", final: { outputs, megapixels, seconds }, providerUsd, gpuMs, device, reachedProvider }` | `{ ok: true, charged }` || `POST /v1/refund` | `{ holdId, generationId, rows, status: "failed" \| "canceled" \| "hidden" \| "unchecked", reason, reachedProvider, gpuMs, device }` | `{ ok: true, text }` |-| `GET /v1/balance` | | `{ amount, chip, text, sub?, refillAt?, detail: { label, text }[], action?, offer? }` |+| `GET /v1/balance` | | `{ amount, chip, text, sub?, refillAt?, detail: { label, text, bar?, tone?, note?, image? }[], action?, offer? }` || `POST /v1/account-event` | `{ event: "created" \| "verified" \| "signed-in" \| "deleted", account: AccountFacts }` | `{ ok: true }` || `POST /v1/interest` | `{ account, key }` | `{ ok: true, text }` |+The balance menu shows each `detail` line as its `label` and `text`. A line can also carry `bar` (0 to 100, drawn as a+bar), `tone` (`normal`, `warn`, `full` or `calm`: the bar's and the words' colour), `note` (a smaller line under it) and+`image` (a picture, only a path on this site, such as `/_fuobe/...`). A line with none of these is one row, as before.+The price check before Run shows the quote's `text` (and `sub`) as they are. Under the toolbar (and in the price'stooltip) it shows where a new run would stand in line and the wait, about: the quote's `etaS`, else the line's ownestimate. A quote with `allowed: false` turns Run off and puts its `text` in the price slot, with its `action` link ordiff --git a/src/components/nav/status-chips.tsx b/src/components/nav/status-chips.tsxindex 7fdbde46..e97b2fc2 100644--- a/src/components/nav/status-chips.tsx+++ b/src/components/nav/status-chips.tsx@@ -16,7 +16,7 @@ import { ownGpuOf, signInHref, useEngineMode, useHydrated, useStatus, useViewer,import { placeholdersOn } from "@/lib/demo-mode";import { deviceLabel } from "@/lib/gpu/readiness";import { shortState } from "@/lib/diagnose";-import { safeLink, useInterest } from "@/lib/hosted";+import { safeLink, useInterest, type BalanceRow } from "@/lib/hosted";import type { ViewerKind } from "@/lib/nav-model";import { barRuns, type BarRuns, type RunOnPick } from "@/lib/run-place";import { useSetRunOn } from "@/lib/run-on";@@ -143,6 +143,43 @@ export function refillWords(at: number, now = Date.now()): string {return h >= 1 ? `refills in ${h} h` : `refills in ${Math.max(1, Math.round(ms / 60_000))} min`;}+const TONE_BAR: Record<NonNullable<BalanceRow["tone"]>, string> = { normal: "bg-primary", warn: "bg-warning", full: "bg-destructive", calm: "bg-primary/50" };+const TONE_TEXT: Record<NonNullable<BalanceRow["tone"]>, string> = { normal: "text-muted-foreground", warn: "font-medium text-warning", full: "font-medium text-destructive", calm: "font-medium text-primary" };++/**+ * A line of the balance menu: the label and its words; with a bar, a note or a picture, a small block (the bar in its+ * tone, the note under it, the picture only from this site).+ */+function BalanceLine({ row }: { row: BalanceRow }) {+ const bar = typeof row.bar === "number" && Number.isFinite(row.bar) ? Math.min(100, Math.max(0, row.bar)) : null;+ const image = row.image && row.image.startsWith("/") && !row.image.startsWith("//") ? row.image : null;+ const tone = row.tone && row.tone in TONE_BAR ? row.tone : "normal";+ if (bar === null && !image && !row.note) {+ return (+ <div className="flex justify-between gap-3 px-2.5 py-1 text-[12px]">+ <span className="text-muted-foreground">{row.label}</span>+ <span className="text-right">{row.text}</span>+ </div>+ );+ }+ return (+ <div className="flex flex-col gap-1.5 px-2.5 py-1.5 text-[12px]">+ <div className="flex items-baseline justify-between gap-3">+ <span className="font-medium text-foreground">{row.label}</span>+ <span className={cn("text-right tabular-nums", TONE_TEXT[tone])}>{row.text}</span>+ </div>+ {bar !== null && (+ <div role="meter" aria-valuemin={0} aria-valuemax={100} aria-valuenow={bar} aria-label={`${row.label}: ${row.text}`} className="h-1.5 overflow-hidden rounded-full bg-muted">+ <div className={cn("h-full rounded-full motion-safe:transition-[width] motion-safe:duration-500", TONE_BAR[tone])} style={{ width: `${bar > 0 ? Math.max(3, bar) : 0}%` }} />+ </div>+ )}+ {/* eslint-disable-next-line @next/next/no-img-element -- a small picture the service sends, a path on this site */}+ {image && <img src={image} alt="" width={240} height={150} decoding="async" draggable={false} className="h-auto w-full rounded-lg" />}+ {row.note && <span className="text-[11.5px] leading-snug text-muted-foreground">{row.note}</span>}+ </div>+ );+}+/*** The balance's menu items (a studio with a billing service, src/server/billing.ts): the service's own words for what* the account has left, its detail lines, its links, its offer, and the way to run for free on one's own GPU or keys.@@ -156,10 +193,7 @@ function BalanceItems({ viewer, runs }: { viewer: Viewer; runs?: BarRuns }) {{runs && <RunsChoice viewer={viewer} runs={runs} />}<DropdownMenuLabel className="px-2.5 text-[12px] font-normal text-muted-foreground">{b.text}</DropdownMenuLabel>{b.detail.map((d, i) => (- <div key={i} className="flex justify-between gap-3 px-2.5 py-1 text-[12px]">- <span className="text-muted-foreground">{d.label}</span>- <span className="text-right">{d.text}</span>- </div>+ <BalanceLine key={i} row={d} />))}<DropdownMenuSeparator className="mx-2.5 my-1.5" />{action && b.action && (diff --git a/src/lib/hosted.ts b/src/lib/hosted.tsindex e53fa4d6..6c46b4cd 100644--- a/src/lib/hosted.ts+++ b/src/lib/hosted.ts@@ -43,6 +43,19 @@ export interface HostedQuote {withoutLoras?: true;}+/**+ * A line of the balance (the service's words): a label and its words, and when the service sends them, a bar (0-100) in a+ * tone, a note under it and a picture (a path on this site).+ */+export interface BalanceRow {+ label: string;+ text: string;+ bar?: number;+ tone?: "normal" | "warn" | "full" | "calm";+ note?: string;+ image?: string;+}+/** The billing service's words for an account's balance (the top bar's chip and the account menu). */export interface HostedBalance {amount: number;@@ -50,7 +63,7 @@ export interface HostedBalance {text: string;sub?: string;refillAt?: number | null;- detail: { label: string; text: string }[];+ detail: BalanceRow[];action?: BillingAction;offer?: BillingOffer;}diff --git a/src/server/billing.ts b/src/server/billing.tsindex 2bd85214..28532734 100644--- a/src/server/billing.ts+++ b/src/server/billing.ts@@ -249,13 +249,26 @@ export interface ReadyCard extends CardLook {action?: Action;}+/**+ * A line of the balance (the service's words): a label and its words, and when the service sends them, a bar (0-100) in a+ * tone, a note under it and a picture (a path on this site).+ */+export interface BalanceRow {+ label: string;+ text: string;+ bar?: number;+ tone?: "normal" | "warn" | "full" | "calm";+ note?: string;+ image?: string;+}+export interface Balance {amount: number;chip: string;text: string;sub?: string;refillAt?: number | null;- detail: { label: string; text: string }[];+ detail: BalanceRow[];action?: Action;offer?: Offer;}