Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(usage): Limits tab with provider quota windows and Codex banked resets #9421

ClosedStiensWout(GitHub profile, opens in a new tab)wants to merge 18 commits intomain fromrefs/pull/9421/headopened View on GitHub

Showing 38 changed files with 181 additions and 2 deletions (loading 36).

x
0 of 38 viewed, 38 left
168 additions and 0 deletionsapps/mobile/src/features/usage/UsageLimitsSection.tsxAdded
View file
@@ -0,0 +1,168 @@
+import { elapsedShare, formatDuration, paceOf, resetMillis } from "@t3tools/shared/usageLimits";
+import { View } from "react-native";
+​
+import { AppText as Text } from "../../components/AppText";
+import type { EnvironmentProviderLimits } from "../../state/usage";
+import { SettingsSection } from "../settings/components/SettingsSection";
+import { PROVIDER_LABEL, useProviderColors } from "./usageProviders";
+​
+type LimitWindow = EnvironmentProviderLimits["windows"][number];
+​
+const PACE_LABEL = { ahead: "ahead of pace", on: "on pace", under: "under pace" } as const;
+​
+function paceLabel(window: LimitWindow, now: number): string | null {
+ const pace = paceOf(window, now);
+ return pace === null ? null : PACE_LABEL[pace];
+}
+​
+/**
+ * One window as a full-width bar from the moment it opened to its reset.
+ * Usage fills from the left; the hairline sits at the elapsed fraction, which
+ * is also where even spending would have put the fill.
+ */
+function WindowBar({
+ window,
+ now,
+ color,
+}: {
+ readonly window: LimitWindow;
+ readonly now: number;
+ readonly color: string;