diff --git a/apps/web/src/components/settings/ProviderInstanceCard.tsx b/apps/web/src/components/settings/ProviderInstanceCard.tsx index 327b48c2d44a..94b144253dc5 100644 --- a/apps/web/src/components/settings/ProviderInstanceCard.tsx +++ b/apps/web/src/components/settings/ProviderInstanceCard.tsx @@ -18,6 +18,7 @@ import { useEffect, useRef, useState, type ReactNode } from "react"; import { isProviderDriverKind, resolveProviderInstanceEnabled, + type EnvironmentId, type ProviderInstanceConfig, type ProviderInstanceEnvironmentVariable, type ProviderInstanceId, @@ -31,6 +32,7 @@ import { readCustomModelEntries, toCustomModelSetting, } from "@t3tools/shared/model"; +import { limitsNotice } from "@t3tools/shared/usageLimits"; import { cn } from "../../lib/utils"; import { useCopyToClipboard } from "../../hooks/useCopyToClipboard"; import { normalizeProviderAccentColor } from "../../providerInstances"; @@ -48,6 +50,7 @@ import { ProviderInstanceIcon, providerInstanceInitials } from "../chat/Provider import { ProviderAccentColorPicker } from "./ProviderAccentColorPicker"; import { RedactedSensitiveText } from "./RedactedSensitiveText"; import { SettingsRow, SettingsSection } from "./settingsLayout"; +import { LimitWindows, ResetCredits } from "../usage/UsageLimits"; import { getProviderVersionAdvisoryPresentation, PROVIDER_STATUS_STYLES, @@ -170,6 +173,60 @@ function ProviderAuthEmail(props: { readonly email: string | undefined }) { ); } +function ProviderUsageLimits({ + environmentId, + provider, +}: { + readonly environmentId?: EnvironmentId; + readonly provider: ServerProvider | undefined; +}) { + const [now] = useState(() => Date.now()); + const usageLimits = provider?.usageLimits; + const notice = usageLimits ? limitsNotice(usageLimits) : null; + const providerName = provider?.displayName?.trim() || provider?.driver || "provider"; + + return ( + + {!provider ? ( + + ) : !usageLimits ? ( + + ) : notice ? ( + + ) : ( +
+
+
+
+

Current subscription

+

+ {provider.auth.label ?? provider.auth.type ?? "Not reported"} +

+
+
+
+ +
+ {usageLimits.resetCredits && environmentId ? ( +
+ +
+ ) : null} +
+
+ )} +
+ ); +} + function ProviderEnvironmentSection(props: { readonly environment: ReadonlyArray; readonly onChange: (environment: ReadonlyArray) => void; @@ -344,6 +401,7 @@ function ProviderEnvironmentSection(props: { interface ProviderInstanceCardProps { readonly instanceId: ProviderInstanceId; + readonly environmentId?: EnvironmentId; readonly instance: ProviderInstanceConfig; readonly driverOption: DriverOption | undefined; readonly liveProvider: ServerProvider | undefined; @@ -399,6 +457,7 @@ interface ProviderInstanceCardProps { */ export function ProviderInstanceCard({ instanceId, + environmentId, instance, driverOption, liveProvider, @@ -914,6 +973,13 @@ export function ProviderInstanceCard({ ) : null} + + {mode === "editor" ? ( + + ) : null} ); } diff --git a/apps/web/src/components/settings/ProviderSettingsPanel.tsx b/apps/web/src/components/settings/ProviderSettingsPanel.tsx index 74676e3ff167..ce71f466ae38 100644 --- a/apps/web/src/components/settings/ProviderSettingsPanel.tsx +++ b/apps/web/src/components/settings/ProviderSettingsPanel.tsx @@ -77,10 +77,10 @@ import { stackedThreadToast, toastManager } from "../ui/toast"; import { AddProviderInstanceDialog } from "./AddProviderInstanceDialog"; import { ExpandableText } from "./ExpandableText"; import { ProviderInstanceCard } from "./ProviderInstanceCard"; -import { UsageProviderSettings } from "./UsageProviderSettings"; import { ProviderSetupSection, readAntigravityAuthMethod } from "./ProviderSetupSection"; import { DRIVER_OPTIONS, getDriverOption } from "./providerDriverMeta"; import { searchableSetting } from "./settingsSearch"; +import { UsageProviderSettings } from "./UsageProviderSettings"; import { backgroundActivityOverrideSettings, buildProviderInstanceUpdatePatch, @@ -777,7 +777,6 @@ export function EnvironmentProviderSettings({ const selectedRow = rows.find((row) => row.instanceId === selectedInstanceId) ?? (targetInstanceMissing ? null : (rows[0] ?? null)); - const updateProviderInstance = ( row: InstanceRow, next: ProviderInstanceConfig, @@ -892,6 +891,7 @@ export function EnvironmentProviderSettings({ - + {window.label} {remainingPercent(window)}% left - + {pace ? : null} {resetsIn ?? ""}