Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 33 additions & 16 deletions apps/mobile/src/features/usage/UsageLimitsPooled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
collectExternalUsageLinks,
collectLimitNotices,
cursorUsageWindowDetails,
formatResetsIn,
} from "@t3tools/shared/usageLimitsCopy";
import { msg, T, useGT, useMessages, Var } from "gt-react-native";
import { Fragment, type ReactNode, useId, useState } from "react";
Expand All @@ -32,7 +33,7 @@ import { ProviderIcon } from "../../components/ProviderIcon";
import type { MessageResolver } from "../../i18n/messages";
import { SettingsScreen } from "../settings/components/SettingsScreen";
import { environmentPresentations } from "../../state/presentation";
import { refillLabel, ResetCredits, resetLabels } from "./UsageLimitsSection";
import { ResetCredits, resetLabels } from "./UsageLimitsSection";
import { usageProviderKind, useProviderColors } from "./usageProviders";

const PACE_LABEL = {
Expand Down Expand Up @@ -195,7 +196,7 @@ function PoolWindowCard({
const inlineLabels = wide && segmentWidth >= 96;
const inlineReset = wide && segmentWidth >= 150;
const inlineName = wide && segmentWidth >= 220;
const nextRefill = pool.resets.find((reset) => reset.restoresPercent > 0);
const nextReset = pool.resets.find((reset) => reset.at >= now);
const openAccount = (account: LimitAccount) =>
navigation.navigate("SettingsUsageAccount", {
accountKey: account.key,
Expand All @@ -206,29 +207,43 @@ function PoolWindowCard({
const summary = (
<>
<View className={wide ? "gap-1" : "flex-row items-start justify-between gap-3"}>
<View className="gap-1">
<View className={wide ? "gap-1" : "min-w-0 flex-1 gap-1"}>
{label !== null ? (
<Text className="text-sm font-t3-medium text-foreground">{label ?? pool.label}</Text>
) : null}
<View className="flex-row items-baseline gap-1.5">
<Text className="text-sm leading-(--text-3xl--line-height) text-foreground-muted">
<T>
<Text className="text-3xl font-t3-bold tabular-nums text-foreground">
<Var>{pool.remainingPercent}</Var>%
</Text>{" "}
left
</T>
<Text className="min-w-0 shrink text-sm leading-(--text-3xl--line-height) text-foreground-muted">
{pool.members.length > 1 ? (
<T>
<Text className="text-3xl font-t3-bold tabular-nums text-foreground">
<Var>{pool.remainingPercent}</Var>%
</Text>{" "}
average left
</T>
) : (
<T>
<Text className="text-3xl font-t3-bold tabular-nums text-foreground">
<Var>{pool.remainingPercent}</Var>%
</Text>{" "}
left
</T>
)}
</Text>
</View>
{pool.members.length > 1 ? (
<Text className="text-xs text-foreground-muted">
{gt("Across {count} accounts", { count: pool.members.length })}
</Text>
) : null}
</View>
{pool.pace ? (
<Text className="text-xs text-foreground-tertiary">{m(PACE_LABEL[pool.pace])}</Text>
) : null}
</View>
{description ? <Text className="text-xs text-foreground-muted">{description}</Text> : null}
{nextRefill ? (
{nextReset ? (
<Text className="text-xs tabular-nums text-foreground-muted">
{refillLabel(nextRefill.member.window, now, nextRefill.restoresPercent, m)}
{formatResetsIn(nextReset.member.window, now, m, "account")}
</Text>
) : null}
</>
Expand Down Expand Up @@ -682,11 +697,13 @@ export function UsageLimitAccountScreen({ route }: AccountScreenProps) {
</T>
</Text>
) : null}
{reset && reset.restoresPercent > 0 ? (
{reset && reset.member.refillPercent > 0 ? (
<Text className="text-sm text-foreground-muted">
<T>
Restores <Var>{reset.restoresPercent}</Var>% of the pool
</T>
{gt("After reset: {percent}% left on this account", {
percent: Math.round(
Math.min(100, remainingPercent(window) + reset.member.refillPercent),
),
})}
</Text>
) : null}
</View>
Expand Down
23 changes: 0 additions & 23 deletions apps/mobile/src/features/usage/UsageLimitsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,26 +396,3 @@ export function resetLabels(
const duration = formatDuration(countdown.ms, resolve);
return { full: resolve(msg("resets in {duration}", { duration })), compact: duration };
}

export function refillLabel(
window: ServerProviderUsageWindow,
now: number,
percent: number,
resolve: MessageResolver,
): string | null {
const countdown = resetCountdown(window, now);
if (countdown === null) return null;
if (countdown.kind === "now") {
return resolve(msg("↻ +{percent}% now", { percent, $context: "usage limit refill" }));
}
if (countdown.kind === "momentarily") {
return resolve(msg("↻ +{percent}% Resets momentarily", { percent }));
}
return resolve(
msg("↻ +{percent}% in {duration}", {
percent,
duration: formatDuration(countdown.ms, resolve),
$context: "usage limit refill",
}),
);
}
33 changes: 21 additions & 12 deletions apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -5108,15 +5108,6 @@
},
" % sollten jetzt übrig sein"
],
"a6ae2f414eb6349a": [
"Stellt ",
{
"i": 1,
"k": "_gt_value_1",
"v": "v"
},
" % des Kontingents wieder her"
],
"427c46cf712e8cb6": "Reset-Guthaben",
"fb7be23247bbe5ec": "über dem Tempo",
"05c53f9e062392da": "im Tempo",
Expand All @@ -5129,9 +5120,27 @@
"8864ac914d8205e8": "Ein Reset-Guthaben verwenden?",
"e32c2c7e61a16f4b": "Guthaben verwenden",
"b58a90dc5356f80a": "wird jetzt zurückgesetzt",
"1d8c701d90e48e07": "↻ +{percent} % jetzt",
"949db5acc5a82add": "↻ +{percent} % Wird gleich zurückgesetzt",
"96f9e0677375a802": "↻ +{percent} % in {duration}",
"0823a39756bb74a0": "Nächste Kontozurücksetzung jetzt",
"49012e2676b17322": "Nächste Kontozurücksetzung in Kürze",
"a43d270db904770e": "Nächste Kontozurücksetzung in {duration}",
"d343b39fa4fc62f3": "Über {count} Konten",
"34def2fecab9556a": "Nach der Zurücksetzung: {percent}% auf diesem Konto übrig",
"2c1bdecdcb724828": [
{
"t": "Text",
"i": 1,
"c": [
{
"i": 2,
"k": "_gt_value_2",
"v": "v"
},
"%"
]
},
" ",
"im Durchschnitt übrig"
],
"f8a9ced202b79202": "Kontobezeichnung ausblenden",
"e4b6c8eab1e48ee2": "Kontobezeichnung anzeigen",
"1f76510e608a9292": "Wird verwendet…",
Expand Down
33 changes: 21 additions & 12 deletions apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5110,15 +5110,6 @@
},
"% left by now"
],
"a6ae2f414eb6349a": [
"Restores ",
{
"i": 1,
"k": "_gt_value_1",
"v": "v"
},
"% of the pool"
],
"427c46cf712e8cb6": "Reset credits",
"fb7be23247bbe5ec": "ahead of pace",
"05c53f9e062392da": "on pace",
Expand All @@ -5131,9 +5122,27 @@
"8864ac914d8205e8": "Use a reset credit?",
"e32c2c7e61a16f4b": "Use credit",
"b58a90dc5356f80a": "resets now",
"1d8c701d90e48e07": "↻ +{percent}% now",
"949db5acc5a82add": "↻ +{percent}% Resets momentarily",
"96f9e0677375a802": "↻ +{percent}% in {duration}",
"0823a39756bb74a0": "Next account reset now",
"49012e2676b17322": "Next account reset momentarily",
"a43d270db904770e": "Next account reset in {duration}",
"d343b39fa4fc62f3": "Across {count} accounts",
"34def2fecab9556a": "After reset: {percent}% left on this account",
"2c1bdecdcb724828": [
{
"t": "Text",
"i": 1,
"c": [
{
"i": 2,
"k": "_gt_value_2",
"v": "v"
},
"%"
]
},
" ",
"average left"
],
"f8a9ced202b79202": "Hide account label",
"e4b6c8eab1e48ee2": "Reveal account label",
"1f76510e608a9292": "Using…",
Expand Down
33 changes: 21 additions & 12 deletions apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -5102,15 +5102,6 @@
},
"% a estas alturas"
],
"a6ae2f414eb6349a": [
"Restaura un ",
{
"i": 1,
"k": "_gt_value_1",
"v": "v"
},
"% del total"
],
"427c46cf712e8cb6": "Créditos de restablecimiento",
"fb7be23247bbe5ec": "por encima del ritmo",
"05c53f9e062392da": "al ritmo",
Expand All @@ -5123,9 +5114,27 @@
"8864ac914d8205e8": "¿Usar un crédito de restablecimiento?",
"e32c2c7e61a16f4b": "Usar crédito",
"b58a90dc5356f80a": "se restablece ahora",
"1d8c701d90e48e07": "↻ +{percent} % ahora",
"949db5acc5a82add": "↻ +{percent} % Se restablece en un momento",
"96f9e0677375a802": "↻ +{percent} % en {duration}",
"0823a39756bb74a0": "Próximo restablecimiento de cuenta ahora",
"49012e2676b17322": "Próximo restablecimiento de cuenta en breve",
"a43d270db904770e": "Próximo restablecimiento de cuenta en {duration}",
"d343b39fa4fc62f3": "Entre {count} cuentas",
"34def2fecab9556a": "Tras el restablecimiento: queda un {percent}% en esta cuenta",
"2c1bdecdcb724828": [
{
"t": "Text",
"i": 1,
"c": [
{
"i": 2,
"k": "_gt_value_2",
"v": "v"
},
"%"
]
},
" ",
"disponible de media"
],
"f8a9ced202b79202": "Ocultar la etiqueta de la cuenta",
"e4b6c8eab1e48ee2": "Mostrar la etiqueta de la cuenta",
"1f76510e608a9292": "Usando…",
Expand Down
33 changes: 21 additions & 12 deletions apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -5102,15 +5102,6 @@
},
" % restant à ce stade"
],
"a6ae2f414eb6349a": [
"Restaure ",
{
"i": 1,
"k": "_gt_value_1",
"v": "v"
},
" % du quota"
],
"427c46cf712e8cb6": "Crédits de réinitialisation",
"fb7be23247bbe5ec": "en avance",
"05c53f9e062392da": "au rythme",
Expand All @@ -5123,9 +5114,27 @@
"8864ac914d8205e8": "Utiliser un crédit de réinitialisation ?",
"e32c2c7e61a16f4b": "Utiliser le crédit",
"b58a90dc5356f80a": "réinitialisation maintenant",
"1d8c701d90e48e07": "↻ +{percent} % maintenant",
"949db5acc5a82add": "↻ +{percent} % Réinitialisation imminente",
"96f9e0677375a802": "↻ +{percent} % dans {duration}",
"0823a39756bb74a0": "Prochaine réinitialisation du compte maintenant",
"49012e2676b17322": "Prochaine réinitialisation du compte sous peu",
"a43d270db904770e": "Prochaine réinitialisation du compte dans {duration}",
"d343b39fa4fc62f3": "Sur {count} comptes",
"34def2fecab9556a": "Après la réinitialisation : il reste {percent}% sur ce compte",
"2c1bdecdcb724828": [
{
"t": "Text",
"i": 1,
"c": [
{
"i": 2,
"k": "_gt_value_2",
"v": "v"
},
"%"
]
},
" ",
"restants en moyenne"
],
"f8a9ced202b79202": "Masquer le libellé du compte",
"e4b6c8eab1e48ee2": "Afficher le libellé du compte",
"1f76510e608a9292": "Utilisation…",
Expand Down
33 changes: 21 additions & 12 deletions apps/mobile/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -5083,15 +5083,6 @@
},
"%"
],
"a6ae2f414eb6349a": [
"プールの ",
{
"i": 1,
"k": "_gt_value_1",
"v": "v"
},
"% を回復"
],
"427c46cf712e8cb6": "リセットクレジット",
"fb7be23247bbe5ec": "ペース超過",
"05c53f9e062392da": "適正なペース",
Expand All @@ -5104,9 +5095,27 @@
"8864ac914d8205e8": "リセットクレジットを使用しますか?",
"e32c2c7e61a16f4b": "クレジットを使用",
"b58a90dc5356f80a": "今すぐリセット",
"1d8c701d90e48e07": "↻ 今すぐ +{percent}%",
"949db5acc5a82add": "↻ +{percent}% まもなくリセット",
"96f9e0677375a802": "↻ {duration}後に +{percent}%",
"0823a39756bb74a0": "次のアカウントリセット:今",
"49012e2676b17322": "次のアカウントリセット:まもなく",
"a43d270db904770e": "次のアカウントリセットまで {duration}",
"d343b39fa4fc62f3": "{count} 個のアカウント",
"34def2fecab9556a": "リセット後、このアカウントの残りは {percent}%",
"2c1bdecdcb724828": [
{
"t": "Text",
"i": 1,
"c": [
{
"i": 2,
"k": "_gt_value_2",
"v": "v"
},
"%"
]
},
" ",
"が平均で残っています"
],
"f8a9ced202b79202": "アカウントのラベルを非表示",
"e4b6c8eab1e48ee2": "アカウントのラベルを表示",
"1f76510e608a9292": "使用中…",
Expand Down
Loading
Loading