diff --git a/apps/web/src/components/chat/ThreadDetailsUsage.logic.test.ts b/apps/web/src/components/chat/ThreadDetailsUsage.logic.test.ts new file mode 100644 index 000000000000..02e1fc190cbe --- /dev/null +++ b/apps/web/src/components/chat/ThreadDetailsUsage.logic.test.ts @@ -0,0 +1,283 @@ +import { + ProviderDriverKind, + ProviderInstanceId, + type ServerProvider, + type ServerProviderUsageLimits, + type UsageLimitSourceSnapshot, + UsageLimitSourceId, +} from "@t3tools/contracts"; +import { describe, expect, it } from "vite-plus/test"; + +import { nextPoolReset, poolSources, resolveThreadDetailsLimits } from "./ThreadDetailsUsage.logic"; + +const now = Date.parse("2026-10-30T12:00:00.000Z"); +const checkedAt = "2026-10-30T11:59:00.000Z"; +const claude = ProviderDriverKind.make("claudeAgent"); +const codex = ProviderDriverKind.make("codex"); +const instanceId = ProviderInstanceId.make("claudeAgent"); + +function limitsAt(usedPercent: number, at = checkedAt): ServerProviderUsageLimits { + return { + checkedAt: at, + windows: [ + { + id: "five_hour", + kind: "session", + label: "Session", + usedPercent, + windowDurationMins: 300, + resetsAt: "2026-10-30T13:17:00.000Z", + }, + ], + }; +} + +function limitsResettingAt(usedPercent: number, resetsAt: string): ServerProviderUsageLimits { + const [window] = limitsAt(usedPercent).windows; + return { checkedAt, windows: [{ ...window!, resetsAt }] }; +} + +const unsupported: ServerProviderUsageLimits = { + checkedAt, + windows: [], + unavailable: { reason: "unsupported" }, +}; + +function claudeInstance(usageLimits: ServerProviderUsageLimits): ServerProvider { + return { + instanceId, + driver: claude, + enabled: true, + installed: true, + version: null, + status: "ready", + auth: { status: "authenticated", type: "customEndpoint", label: "Custom API endpoint" }, + checkedAt, + models: [], + slashCommands: [], + skills: [], + usageLimits, + }; +} + +function signedIn(id: string, email: string, usageLimits: ServerProviderUsageLimits) { + const base = claudeInstance(usageLimits); + return { + ...base, + instanceId: ProviderInstanceId.make(id), + auth: { ...base.auth, email }, + } satisfies ServerProvider; +} + +interface HubAccountInput { + readonly id: string; + readonly email?: string; + readonly driver?: ProviderDriverKind; + readonly plan?: string; + readonly limits: ServerProviderUsageLimits; +} + +function hub( + label: string, + accounts: readonly HubAccountInput[], + error?: string, +): UsageLimitSourceSnapshot { + return { + id: UsageLimitSourceId.make(label), + kind: "cliproxy", + label, + checkedAt, + accounts: accounts.map((account) => ({ + id: account.id, + driver: account.driver ?? claude, + ...(account.plan ? { plan: account.plan } : {}), + ...(account.email ? { email: account.email } : {}), + usageLimits: account.limits, + })), + ...(error ? { error } : {}), + }; +} + +/** What the card shows, reduced to the rows a user reads. */ +function shown( + own: ServerProviderUsageLimits, + sources: readonly UsageLimitSourceSnapshot[], + natives: readonly ServerProvider[] = [], +) { + const resolved = resolveThreadDetailsLimits( + instanceId, + [claudeInstance(own), ...natives], + sources, + now, + ); + if (resolved?.kind !== "pool") return resolved; + return { + kind: resolved.kind, + rows: resolved.windows.map((window) => ({ + label: window.label, + left: window.remainingPercent, + accounts: window.members.length, + from: poolSources(window), + })), + }; +} + +describe("resolveThreadDetailsLimits", () => { + it("shows nothing without a selected, known instance, or before its first reading", () => { + expect(resolveThreadDetailsLimits(null, [claudeInstance(unsupported)], [], now)).toBeNull(); + expect( + resolveThreadDetailsLimits(ProviderInstanceId.make("gone"), [], [hub("Hub", [])], now), + ).toBeNull(); + const { usageLimits: _unread, ...unread } = claudeInstance(unsupported); + const readableHub = hub("Hub", [{ id: "a.json", limits: limitsAt(20) }]); + expect(resolveThreadDetailsLimits(instanceId, [unread], [readableHub], now)).toBeNull(); + }); + + it("keeps an instance's own readable limits over any hub", () => { + const own = limitsAt(40); + expect(shown(own, [hub("Hub", [{ id: "a.json", limits: limitsAt(90) }])])).toEqual({ + kind: "instance", + limits: own, + }); + }); + + it.each([ + { + name: "one hub account", + sources: [hub("Hub", [{ id: "a.json", email: "a@example.com", limits: limitsAt(19) }])], + rows: [{ label: "Session", left: 81, accounts: 1, from: ["Hub"] }], + }, + { + name: "several accounts, pooled like Usage → Limits", + sources: [ + hub("Hub", [ + { id: "a.json", email: "a@example.com", limits: limitsAt(20) }, + { id: "b.json", email: "b@example.com", limits: limitsAt(60) }, + ]), + ], + rows: [{ label: "Session", left: 60, accounts: 2, from: ["Hub"] }], + }, + { + name: "one login reported by two hubs, counted once at its freshest reading", + sources: [ + hub("Old", [{ id: "a.json", email: "a@example.com", limits: limitsAt(90) }]), + hub("New", [ + { + id: "a.json", + email: "a@example.com", + limits: limitsAt(30, "2026-10-30T11:59:30.000Z"), + }, + ]), + ], + rows: [{ label: "Session", left: 70, accounts: 1, from: ["Old"] }], + }, + { + name: "accounts across hubs, skipping a hub that failed to read", + sources: [ + hub("Home", [{ id: "a.json", email: "a@example.com", limits: limitsAt(20) }]), + hub("Work", [{ id: "b.json", email: "b@example.com", limits: limitsAt(40) }]), + hub("Down", [], "The hub answered with HTTP 404."), + ], + rows: [{ label: "Session", left: 70, accounts: 2, from: ["Home", "Work"] }], + }, + { + name: "only this driver's readable accounts", + sources: [ + hub("Hub", [ + { id: "a.json", email: "a@example.com", limits: limitsAt(50) }, + { id: "c.json", email: "c@example.com", driver: codex, limits: limitsAt(0) }, + { id: "d.json", email: "d@example.com", limits: unsupported }, + ]), + ], + rows: [{ label: "Session", left: 50, accounts: 1, from: ["Hub"] }], + }, + { + name: "a login signed in natively and on a hub, counted once at its freshest reading", + sources: [hub("Hub", [{ id: "a.json", email: "a@example.com", limits: limitsAt(90) }])], + natives: [signedIn("claude-a", "a@example.com", limitsAt(30, "2026-10-30T11:59:30.000Z"))], + rows: [{ label: "Session", left: 70, accounts: 1, from: ["Signed-in accounts"] }], + }, + { + name: "a signed-in account no hub holds, alongside the hub's", + sources: [hub("Hub", [{ id: "a.json", email: "a@example.com", limits: limitsAt(20) }])], + natives: [signedIn("claude-b", "b@example.com", limitsAt(60))], + rows: [{ label: "Session", left: 60, accounts: 2, from: ["Hub", "Signed-in accounts"] }], + }, + ])("pools $name when the instance reads no limits", ({ sources, natives, rows }) => { + expect(shown(unsupported, sources, natives)).toEqual({ kind: "pool", rows }); + }); + + it.each([ + { + name: "skips unused resets", + plans: undefined, + used: [0, 80], + times: ["12:10", "14:00"], + restoresPercent: 40, + }, + { + name: "combines simultaneous resets", + plans: undefined, + used: [80, 80], + times: ["14:00", "14:00"], + restoresPercent: 80, + }, + { + name: "rounds simultaneous restores once", + plans: undefined, + used: [100, 100, 100, 100, 100, 100], + times: Array(6).fill("14:00"), + restoresPercent: 100, + }, + { + name: "preserves plan capacity weights", + used: [100, 0], + times: ["14:00", "14:00"], + plans: ["Pro", "Ultra"], + restoresPercent: 5, + }, + { + name: "combines weighted simultaneous resets", + used: [80, 20], + times: ["14:00", "14:00"], + plans: ["Pro", "Ultra"], + restoresPercent: 23, + }, + ])("names the next refill: $name", ({ used, times, plans, restoresPercent }) => { + const resolved = resolveThreadDetailsLimits( + instanceId, + [claudeInstance(unsupported)], + [ + hub( + "Hub", + used.map((percent, i) => ({ + id: String(i), + email: i + "@example.com", + ...(plans ? { plan: plans[i] } : {}), + limits: limitsResettingAt(percent, "2026-10-30T" + times[i] + ":00.000Z"), + })), + ), + ], + now, + ); + if (resolved?.kind !== "pool") throw new Error("expected a pool"); + const [window] = resolved.windows; + const at = Date.parse("2026-10-30T14:00:00.000Z"); + expect(nextPoolReset(window!, now)).toMatchObject({ at, restoresPercent }); + expect(nextPoolReset(window!, at)).toBeNull(); + }); + + it("keeps the instance's notice when no hub has a readable account for its driver", () => { + const sources = [ + hub("Hub", [ + { id: "c.json", driver: codex, limits: limitsAt(10) }, + { id: "d.json", limits: unsupported }, + ]), + ]; + const natives = [signedIn("claude-b", "b@example.com", limitsAt(60))]; + expect(shown(unsupported, sources, natives)).toEqual({ + kind: "instance", + limits: unsupported, + }); + }); +}); diff --git a/apps/web/src/components/chat/ThreadDetailsUsage.logic.ts b/apps/web/src/components/chat/ThreadDetailsUsage.logic.ts new file mode 100644 index 000000000000..fca85ac2c006 --- /dev/null +++ b/apps/web/src/components/chat/ThreadDetailsUsage.logic.ts @@ -0,0 +1,106 @@ +import { + EnvironmentId, + type ProviderInstanceId, + type ServerProvider, + type ServerProviderUsageLimits, + type UsageLimitSourceSnapshots, +} from "@t3tools/contracts"; +import { + collectLimitAccounts, + collectLimitPools, + collectProviderUsageLimits, + displayLimitWindows, + type LimitPoolWindow, + planCapacity, +} from "@t3tools/shared/usageLimits"; + +import { limitsNotice } from "@t3tools/shared/usageLimitsCopy"; + +export type ThreadDetailsLimits = + | { readonly kind: "instance"; readonly limits: ServerProviderUsageLimits } + | { readonly kind: "pool"; readonly windows: readonly LimitPoolWindow[] }; + +// collectLimitAccounts keys its input by environment; the card reads one, so any id serves. +const CARD_ENVIRONMENT = EnvironmentId.make("thread-details"); + +/** + * The limits the thread details card shows for one provider instance: its own, or, when it reads + * none (as when it sends requests through a CLIProxyAPI hub), the pool of its driver's accounts. + */ +export function resolveThreadDetailsLimits( + providerInstanceId: ProviderInstanceId | null, + providers: readonly ServerProvider[], + sources: UsageLimitSourceSnapshots, + now: number, +): ThreadDetailsLimits | null { + const provider = providers.find((entry) => entry.instanceId === providerInstanceId); + if (!provider) return null; + const report = collectProviderUsageLimits(provider.instanceId, providers, sources, now); + // Only this instance's data: the report keeps one instance per login, and any other entry may be + // a different login or workspace, so fall back to the instance's own snapshot. + const own = + report?.accounts.find((entry) => entry.instanceId === provider.instanceId)?.limits ?? + provider.usageLimits; + if (!own) return null; + if (limitsNotice(own) === null) return { kind: "instance", limits: own }; + return driverPool(provider.driver, providers, sources, now) ?? { kind: "instance", limits: own }; +} + +/** The reset the card names: the soonest for one account, the soonest that refills quota for a pool. */ +export function nextPoolReset(window: LimitPoolWindow, now: number) { + const pooled = window.members.length > 1; + const next = window.resets.find( + (reset) => reset.at > now && (!pooled || reset.restoresPercent > 0), + ); + if (!next || !pooled) return next ?? null; + const capacities = window.members.map((member) => planCapacity(member.account, window.kind)); + const weights = capacities.every((capacity) => capacity !== undefined) + ? capacities + : window.members.map(() => 1); + const weightOf = new Map(window.members.map((member, index) => [member, weights[index]!])); + const totalWeight = weights.reduce((total, weight) => total + weight, 0); + const restoresPercent = window.resets.reduce( + (total, reset) => + total + (reset.at === next.at ? reset.member.refillPercent * weightOf.get(reset.member)! : 0), + 0, + ); + return { ...next, restoresPercent: Math.round(restoresPercent / totalWeight) }; +} + +function driverPool( + driver: ServerProvider["driver"], + providers: readonly ServerProvider[], + sources: UsageLimitSourceSnapshots, + now: number, +): ThreadDetailsLimits | null { + const hubReadsDriver = sources.some((source) => + source.accounts.some( + (account) => account.driver === driver && limitsNotice(account.usageLimits) === null, + ), + ); + if (!hubReadsDriver) return null; + const presentations = new Map([ + [ + CARD_ENVIRONMENT, + { + entry: { target: { label: "" } }, + serverConfig: { providers, usageLimitSources: sources }, + }, + ], + ]); + const accounts = collectLimitAccounts(presentations).filter( + (account) => account.driver === driver, + ); + const [pool] = collectLimitPools(accounts, now); + if (!pool) return null; + return { kind: "pool", windows: displayLimitWindows(pool) }; +} + +/** Where a pooled window's readings come from: the hubs holding its hub-only accounts, then signed-in accounts. */ +export function poolSources(window: LimitPoolWindow): string[] { + const hubs = window.members.flatMap(({ account }) => + account.environments.length === 0 && account.sourceLabel ? [account.sourceLabel] : [], + ); + const signedIn = window.members.some(({ account }) => account.environments.length > 0); + return [...new Set(hubs), ...(signedIn ? ["Signed-in accounts"] : [])]; +} diff --git a/apps/web/src/components/chat/ThreadDetailsUsage.tsx b/apps/web/src/components/chat/ThreadDetailsUsage.tsx index 2997f6faa21b..d265052a260e 100644 --- a/apps/web/src/components/chat/ThreadDetailsUsage.tsx +++ b/apps/web/src/components/chat/ThreadDetailsUsage.tsx @@ -1,12 +1,13 @@ import type { ProviderInstanceId, ServerProvider, + ServerProviderUsageLimits, ServerProviderUsageWindow, UsageLimitSourceSnapshots, } from "@t3tools/contracts"; import { - collectProviderUsageLimits, type LimitPace, + type LimitPoolWindow, paceOf, remainingPercent, } from "@t3tools/shared/usageLimits"; @@ -23,6 +24,9 @@ import { formatUpcomingTimestamp } from "../../timestampFormat"; import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; import { formatContextWindowCompactionMessage } from "./compaction.logic"; import { ThreadDetailsSection } from "./ThreadDetailsSection"; +import { nextPoolReset, poolSources, resolveThreadDetailsLimits } from "./ThreadDetailsUsage.logic"; + +const MINUTE_MS = 60_000; const PACE_LABEL: Record = { ahead: msg("Ahead of pace"), @@ -39,27 +43,26 @@ export interface ThreadDetailsUsageInput { type UsageTone = "error" | "warning" | null; -/** The selected provider's limit windows. Each row reads as room left. */ +function limitTone(left: number): UsageTone { + if (left <= 10) return "error"; + if (left <= 20) return "warning"; + return null; +} + +/** + * The selected provider's limit windows, or its driver's pooled accounts when it reads none. + * Each row reads as room left. + */ export function ThreadDetailsUsage({ providerInstanceId, providers, sources, }: Omit) { const gt = useGT(); - const m = useMessages(); const nowMinute = useNowMinute(); const now = Date.parse(`${nowMinute}:00Z`); - const report = - providerInstanceId !== null - ? collectProviderUsageLimits(providerInstanceId, providers, sources, now) - : null; - // Only this instance's data: the report keeps one instance per login, and any other entry may be - // a different login or workspace, so fall back to the instance's own snapshot. - const limits = - report?.accounts.find((entry) => entry.instanceId === providerInstanceId)?.limits ?? - providers.find((provider) => provider.instanceId === providerInstanceId)?.usageLimits; - if (!limits) return null; - const notice = limitsNotice(limits, m); + const resolved = resolveThreadDetailsLimits(providerInstanceId, providers, sources, now); + if (!resolved) return null; return (
- {notice ? ( - {notice}} - /> + {resolved.kind === "pool" ? ( + resolved.windows.map((window) => ) ) : ( - limits.windows.map((window) => ) + )}
); } +function InstanceRows({ + limits, + now, +}: { + readonly limits: ServerProviderUsageLimits; + readonly now: number; +}) { + const gt = useGT(); + const m = useMessages(); + const notice = limitsNotice(limits, m); + if (notice) { + return ( + {notice}} + /> + ); + } + return limits.windows.map((window) => ); +} + /** The thread's context window. The bar fills as context is used; the tick marks auto-compaction. */ export function ThreadDetailsContext({ usage }: { readonly usage: ContextWindowSnapshot }) { const maxTokens = usage.maxTokens != null && usage.maxTokens > 0 ? usage.maxTokens : null; @@ -168,7 +189,7 @@ function LimitRow({ + source === "Signed-in accounts" ? gt("Signed-in accounts") : source, + ); + const accounts = window.members.length; + return ( + + + {accounts > 1 + ? gt("{label}: {left}% left across {accounts} accounts", { + label: window.label, + left, + accounts, + }) + : gt("{label}: {left}% left", { label: window.label, left })} + + + {window.pace ? ( + {m(PACE_LABEL[window.pace])} + ) : null} + {from.length > 0 ? ( + + {gt("From {sources}", { sources: from.join(", ") })} + + ) : null} + + } + /> + ); +} + +function PoolResetLine({ + window, + now, +}: { + readonly window: LimitPoolWindow; + readonly now: number; +}) { + const timestampFormat = usePrimarySettings((settings) => settings.timestampFormat); + const gt = useGT(); + const m = useMessages(); + const next = nextPoolReset(window, now); + if (!next) return null; + const resetsAt = next.member.window.resetsAt; + if (!resetsAt) return null; + const remaining = next.at - now; + const when = + remaining < MINUTE_MS + ? gt("momentarily") + : gt("in {duration}", { duration: formatDuration(remaining, m) }); + const restores = window.members.length > 1 ? next.restoresPercent : null; + const label = + restores === null + ? gt("Resets {when}", { when }) + : gt("+{restores}% {when}", { restores, when }); + return ( + + {label} · {formatUpcomingTimestamp(resetsAt, timestampFormat, now, undefined, m)} + + ); +} + /** One label, hairline, and value row; the whole row opens the details tooltip. */ function UsageRow({ label, diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index 648fd58859db..abaaeeb9d230 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -4040,6 +4040,13 @@ "ee3ae58c8b38a425": "{left} % übrig", "ebb26f93fb83a71b": "{label}: {left} % übrig", "728c6cc1431e76c8": "Wird in {duration} zurückgesetzt · {time}", + "23622878aeee86d9": "Angemeldete Konten", + "d28c53157c8c0f5f": "{label}: {left}% übrig auf {accounts} Konten", + "78c1d280f021a28f": "Von {sources}", + "754665d19aa140ca": "gleich", + "ade42d3734d25cb8": "in {duration}", + "895524ec20150093": "Zurücksetzung {when}", + "19eb68afa1a29d38": "+{restores}% {when}", "e16b0b9b490c8bc7": "{label}: {value}", "ba67d0a9ff5dabf0": "Die Zwischenablage-API ist beim Kopieren der Admin-Anfrage nicht verfügbar.", "aef4bec20e799aab": "Die Admin-Anfrage konnte nicht in die Zwischenablage kopiert werden.", diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json index 599944358b5b..2bbe6f2b3e06 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -4039,6 +4039,13 @@ "ee3ae58c8b38a425": "{left}% left", "ebb26f93fb83a71b": "{label}: {left}% left", "728c6cc1431e76c8": "Resets in {duration} · {time}", + "23622878aeee86d9": "Signed-in accounts", + "d28c53157c8c0f5f": "{label}: {left}% left across {accounts} accounts", + "78c1d280f021a28f": "From {sources}", + "754665d19aa140ca": "momentarily", + "ade42d3734d25cb8": "in {duration}", + "895524ec20150093": "Resets {when}", + "19eb68afa1a29d38": "+{restores}% {when}", "e16b0b9b490c8bc7": "{label}: {value}", "ba67d0a9ff5dabf0": "Clipboard API is unavailable while copying admin request.", "aef4bec20e799aab": "Failed to copy admin request to the clipboard.", diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json index 956f4e17a961..c41d31db42e1 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -4037,6 +4037,13 @@ "ee3ae58c8b38a425": "{left} % restante", "ebb26f93fb83a71b": "{label}: {left} % restante", "728c6cc1431e76c8": "Se restablece en {duration} · {time}", + "23622878aeee86d9": "Cuentas con sesión iniciada", + "d28c53157c8c0f5f": "{label}: {left}% restante entre {accounts} cuentas", + "78c1d280f021a28f": "De {sources}", + "754665d19aa140ca": "en un momento", + "ade42d3734d25cb8": "en {duration}", + "895524ec20150093": "Se restablece {when}", + "19eb68afa1a29d38": "+{restores}% {when}", "e16b0b9b490c8bc7": "{label}: {value}", "ba67d0a9ff5dabf0": "La API del portapapeles no está disponible al copiar la solicitud de administrador.", "aef4bec20e799aab": "No se pudo copiar la solicitud de administrador al portapapeles.", diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json index 1c982cc6d6f5..4a8929ba2e18 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -4038,6 +4038,13 @@ "ee3ae58c8b38a425": "{left} % restant", "ebb26f93fb83a71b": "{label} : {left} % restant", "728c6cc1431e76c8": "Réinitialisation dans {duration} · {time}", + "23622878aeee86d9": "Comptes connectés", + "d28c53157c8c0f5f": "{label} : {left}% restants sur {accounts} comptes", + "78c1d280f021a28f": "Depuis {sources}", + "754665d19aa140ca": "dans un instant", + "ade42d3734d25cb8": "dans {duration}", + "895524ec20150093": "Réinitialisation {when}", + "19eb68afa1a29d38": "+{restores}% {when}", "e16b0b9b490c8bc7": "{label} : {value}", "ba67d0a9ff5dabf0": "L’API Presse-papiers n’est pas disponible pour copier la demande à l’administrateur.", "aef4bec20e799aab": "Impossible de copier la demande à l’administrateur dans le presse-papiers.", diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json index 879531a396d2..d25692bfa41f 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -4028,6 +4028,13 @@ "ee3ae58c8b38a425": "残り {left}%", "ebb26f93fb83a71b": "{label}: 残り {left}%", "728c6cc1431e76c8": "{duration} 後にリセット · {time}", + "23622878aeee86d9": "ログイン済みアカウント", + "d28c53157c8c0f5f": "{label}: {accounts} アカウント全体で残り {left}%", + "78c1d280f021a28f": "取得元: {sources}", + "754665d19aa140ca": "まもなく", + "ade42d3734d25cb8": "{duration}後", + "895524ec20150093": "リセット: {when}", + "19eb68afa1a29d38": "+{restores}% {when}", "e16b0b9b490c8bc7": "{label}: {value}", "ba67d0a9ff5dabf0": "管理者へのリクエストをコピーする際にクリップボード API を利用できませんでした。", "aef4bec20e799aab": "管理者へのリクエストをクリップボードにコピーできませんでした。", diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json index fae8ce2ec6fc..cfa6679eaff5 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -4025,6 +4025,13 @@ "ee3ae58c8b38a425": "{left}% 남음", "ebb26f93fb83a71b": "{label}: {left}% 남음", "728c6cc1431e76c8": "{duration} 후 초기화 · {time}", + "23622878aeee86d9": "로그인한 계정", + "d28c53157c8c0f5f": "{label}: 계정 {accounts}개에서 {left}% 남음", + "78c1d280f021a28f": "출처: {sources}", + "754665d19aa140ca": "곧", + "ade42d3734d25cb8": "{duration} 후", + "895524ec20150093": "초기화: {when}", + "19eb68afa1a29d38": "+{restores}% {when}", "e16b0b9b490c8bc7": "{label}: {value}", "ba67d0a9ff5dabf0": "관리자 요청을 복사하는 중 클립보드 API를 사용할 수 없습니다.", "aef4bec20e799aab": "관리자 요청을 클립보드에 복사하지 못했습니다.", diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index 7010bef288b1..142aac7ff390 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -4037,6 +4037,13 @@ "ee3ae58c8b38a425": "{left}% restante", "ebb26f93fb83a71b": "{label}: {left}% restante", "728c6cc1431e76c8": "Renova em {duration} · {time}", + "23622878aeee86d9": "Contas conectadas", + "d28c53157c8c0f5f": "{label}: {left}% restante em {accounts} contas", + "78c1d280f021a28f": "De {sources}", + "754665d19aa140ca": "em instantes", + "ade42d3734d25cb8": "em {duration}", + "895524ec20150093": "Redefinição {when}", + "19eb68afa1a29d38": "+{restores}% {when}", "e16b0b9b490c8bc7": "{label}: {value}", "ba67d0a9ff5dabf0": "A API da área de transferência não está disponível ao copiar o pedido para o administrador.", "aef4bec20e799aab": "Falha ao copiar o pedido para o administrador para a área de transferência.", diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json index 0766d953dd02..3712e0672e5f 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -4037,6 +4037,13 @@ "ee3ae58c8b38a425": "Осталось {left}%", "ebb26f93fb83a71b": "{label}: осталось {left}%", "728c6cc1431e76c8": "Сброс через {duration} · {time}", + "23622878aeee86d9": "Аккаунты с выполненным входом", + "d28c53157c8c0f5f": "{label}: осталось {left}% на {accounts} аккаунтах", + "78c1d280f021a28f": "Источник: {sources}", + "754665d19aa140ca": "через мгновение", + "ade42d3734d25cb8": "через {duration}", + "895524ec20150093": "Сброс {when}", + "19eb68afa1a29d38": "+{restores}% {when}", "e16b0b9b490c8bc7": "{label}: {value}", "ba67d0a9ff5dabf0": "API буфера обмена недоступен при копировании запроса администратору.", "aef4bec20e799aab": "Не удалось скопировать запрос администратору в буфер обмена.", diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json index 5e6d1607edf3..b9d5de7b457a 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -4038,6 +4038,13 @@ "ee3ae58c8b38a425": "{left} % kvar", "ebb26f93fb83a71b": "{label}: {left} % kvar", "728c6cc1431e76c8": "Återställs om {duration} · {time}", + "23622878aeee86d9": "Inloggade konton", + "d28c53157c8c0f5f": "{label}: {left}% kvar över {accounts} konton", + "78c1d280f021a28f": "Från {sources}", + "754665d19aa140ca": "strax", + "ade42d3734d25cb8": "om {duration}", + "895524ec20150093": "Återställs {when}", + "19eb68afa1a29d38": "+{restores}% {when}", "e16b0b9b490c8bc7": "{label}: {value}", "ba67d0a9ff5dabf0": "Urklipps-API:t är inte tillgängligt vid kopiering av administratörsbegäran.", "aef4bec20e799aab": "Kunde inte kopiera administratörsbegäran till urklipp.", diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json index c86b9e6c55e4..350bf981b263 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -4044,6 +4044,13 @@ "ee3ae58c8b38a425": "剩余 {left}%", "ebb26f93fb83a71b": "{label}:剩余 {left}%", "728c6cc1431e76c8": "{duration} 后重置 · {time}", + "23622878aeee86d9": "已登录的账户", + "d28c53157c8c0f5f": "{label}:{accounts} 个账户共剩余 {left}%", + "78c1d280f021a28f": "来自 {sources}", + "754665d19aa140ca": "即将", + "ade42d3734d25cb8": "{duration}后", + "895524ec20150093": "重置:{when}", + "19eb68afa1a29d38": "+{restores}% {when}", "e16b0b9b490c8bc7": "{label}:{value}", "ba67d0a9ff5dabf0": "复制管理员请求时剪贴板 API 不可用。", "aef4bec20e799aab": "无法将管理员请求复制到剪贴板。", diff --git a/docs/user/usage.md b/docs/user/usage.md index 5160becc2156..c003df4d0668 100644 --- a/docs/user/usage.md +++ b/docs/user/usage.md @@ -153,9 +153,12 @@ anything. The command is offered only for providers that appear under **Usage To keep them in view on web and desktop, turn on **Usage limits** in **Settings → Appearance → Thread details**, or right-click the thread details card. The bottom of the thread details card then shows how much is left in each limit window of the current provider account. Some windows, such as a weekly Opus limit, count only one model. Hover a -row to see when it resets and your pace. Turn on **Context window** to also show the thread's -context use against the model's limit. A tick on the bar marks where the provider compacts -automatically, when it reports that point. +row to see when it resets and your pace. A provider that sends requests through a CLIProxyAPI hub +reports no limits of its own, so the card shows that provider's accounts pooled, the hub's and +any signed-in ones, from this environment only. **Usage → Limits** pools every connected +environment. Turn on **Context window** to also show the thread's context use against the +model's limit. A tick on the bar marks where the provider compacts automatically, when it reports +that point. OpenCode Go reports its session, weekly, and monthly allowance when OpenCode runs locally in the environment. T3 cannot report limits for external OpenCode servers because their credentials diff --git a/packages/shared/src/usageLimits.ts b/packages/shared/src/usageLimits.ts index 693d82b95697..66c59ebaacb7 100644 --- a/packages/shared/src/usageLimits.ts +++ b/packages/shared/src/usageLimits.ts @@ -553,7 +553,7 @@ const CODEX_PLAN_CAPACITY: Record = { // Claude's published plan multipliers describe the session allowance only. const CLAUDE_SESSION_CAPACITY: Record = { Pro: 1, Max: 5, Ultra: 20 }; -function planCapacity(account: LimitAccount, kind: ServerProviderUsageWindow["kind"]) { +export function planCapacity(account: LimitAccount, kind: ServerProviderUsageWindow["kind"]) { if (!account.plan) return undefined; if (account.driver === "codex" && (kind === "session" || kind === "weekly")) { return CODEX_PLAN_CAPACITY[account.plan];