diff --git a/apps/mobile/src/features/usage/UsageLimitsPooled.tsx b/apps/mobile/src/features/usage/UsageLimitsPooled.tsx index 96d8f922340f7..86662d22de827 100644 --- a/apps/mobile/src/features/usage/UsageLimitsPooled.tsx +++ b/apps/mobile/src/features/usage/UsageLimitsPooled.tsx @@ -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"; @@ -31,7 +32,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 = { @@ -194,7 +195,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[0]; const openAccount = (account: LimitAccount) => navigation.navigate("SettingsUsageAccount", { accountKey: account.key, @@ -212,23 +213,37 @@ function PoolWindowCard({ ) : null} - - - {pool.remainingPercent}% - {" "} - left - + {pool.members.length > 1 ? ( + + + {pool.remainingPercent}% + {" "} + average left + + ) : ( + + + {pool.remainingPercent}% + {" "} + left + + )} + {pool.members.length > 1 ? ( + + {gt("Across {count} accounts", { count: pool.members.length })} + + ) : null} {pool.pace ? ( {m(PACE_LABEL[pool.pace])} ) : null} {description ? {description} : null} - {nextRefill ? ( + {nextReset ? ( - {refillLabel(nextRefill.member.window, now, nextRefill.restoresPercent, m)} + {formatResetsIn(nextReset.member.window, now, m, "account")} ) : null} @@ -682,11 +697,13 @@ export function UsageLimitAccountScreen({ route }: AccountScreenProps) { ) : null} - {reset && reset.restoresPercent > 0 ? ( + {reset && reset.member.refillPercent > 0 ? ( - - Restores {reset.restoresPercent}% of the pool - + {gt("After reset: {percent}% left on this account", { + percent: Math.round( + Math.min(100, remainingPercent(window) + reset.member.refillPercent), + ), + })} ) : null} diff --git a/apps/mobile/src/features/usage/UsageLimitsSection.tsx b/apps/mobile/src/features/usage/UsageLimitsSection.tsx index 043ceb7f4ec26..99739f1a6cec8 100644 --- a/apps/mobile/src/features/usage/UsageLimitsSection.tsx +++ b/apps/mobile/src/features/usage/UsageLimitsSection.tsx @@ -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", - }), - ); -} diff --git a/apps/mobile/src/i18n/translations/de.json b/apps/mobile/src/i18n/translations/de.json index f538b87920412..23f1b9d7e85a4 100644 --- a/apps/mobile/src/i18n/translations/de.json +++ b/apps/mobile/src/i18n/translations/de.json @@ -5063,15 +5063,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", @@ -5084,9 +5075,6 @@ "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}", "f8a9ced202b79202": "Kontobezeichnung ausblenden", "e4b6c8eab1e48ee2": "Kontobezeichnung anzeigen", "1f76510e608a9292": "Wird verwendet…", @@ -5464,5 +5452,26 @@ "ad208e3e32c85029": "Alle ausblenden", "3328503592789bed": "Zen", "856812e7e1fc445e": "Tool-Aufrufe im Chat", - "8d545d54c0a9e950": "Die Befehle, Bearbeitungen und Suchen ausblenden, die Agenten ausführen. „Erfolgreiche ausblenden“ behält Fehler. „Zen“ zeigt nur endgültige Antworten. Genehmigungen, Fragen und Fehler werden immer angezeigt." + "8d545d54c0a9e950": "Die Befehle, Bearbeitungen und Suchen ausblenden, die Agenten ausführen. „Erfolgreiche ausblenden“ behält Fehler. „Zen“ zeigt nur endgültige Antworten. Genehmigungen, Fragen und Fehler werden immer angezeigt.", + "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" + ] } diff --git a/apps/mobile/src/i18n/translations/en.json b/apps/mobile/src/i18n/translations/en.json index 745201ad99094..cf6a061afe1b3 100644 --- a/apps/mobile/src/i18n/translations/en.json +++ b/apps/mobile/src/i18n/translations/en.json @@ -5065,15 +5065,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", @@ -5086,9 +5077,6 @@ "8864ac914d8205e8": "Use a reset credit?", "e32c2c7e61a16f4b": "Use credit", "b58a90dc5356f80a": "resets now", - "1d8c701d90e48e07": "↻ +{percent}% now", - "949db5acc5a82add": "↻ +{percent}% Resets momentarily", - "96f9e0677375a802": "↻ +{percent}% in {duration}", "f8a9ced202b79202": "Hide account label", "e4b6c8eab1e48ee2": "Reveal account label", "1f76510e608a9292": "Using…", @@ -5466,5 +5454,26 @@ "ad208e3e32c85029": "Hide all", "3328503592789bed": "Zen", "856812e7e1fc445e": "Tool calls in chat", - "8d545d54c0a9e950": "Hide the commands, edits, and searches agents run. Hide successful keeps failures. Zen shows only final answers. Approvals, questions, and errors always show." + "8d545d54c0a9e950": "Hide the commands, edits, and searches agents run. Hide successful keeps failures. Zen shows only final answers. Approvals, questions, and errors always show.", + "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" + ] } diff --git a/apps/mobile/src/i18n/translations/es.json b/apps/mobile/src/i18n/translations/es.json index fb134339cd3c4..7178c26f9d835 100644 --- a/apps/mobile/src/i18n/translations/es.json +++ b/apps/mobile/src/i18n/translations/es.json @@ -5057,15 +5057,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", @@ -5078,9 +5069,6 @@ "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}", "f8a9ced202b79202": "Ocultar la etiqueta de la cuenta", "e4b6c8eab1e48ee2": "Mostrar la etiqueta de la cuenta", "1f76510e608a9292": "Usando…", @@ -5458,5 +5446,26 @@ "ad208e3e32c85029": "Ocultar todo", "3328503592789bed": "Zen", "856812e7e1fc445e": "Llamadas a herramientas en el chat", - "8d545d54c0a9e950": "Oculta los comandos, ediciones y búsquedas que ejecutan los agentes. Ocultar las correctas mantiene los fallos. Zen solo muestra las respuestas finales. Las aprobaciones, preguntas y errores siempre se muestran." + "8d545d54c0a9e950": "Oculta los comandos, ediciones y búsquedas que ejecutan los agentes. Ocultar las correctas mantiene los fallos. Zen solo muestra las respuestas finales. Las aprobaciones, preguntas y errores siempre se muestran.", + "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" + ] } diff --git a/apps/mobile/src/i18n/translations/fr.json b/apps/mobile/src/i18n/translations/fr.json index d6aef220df3a2..882baec5592d3 100644 --- a/apps/mobile/src/i18n/translations/fr.json +++ b/apps/mobile/src/i18n/translations/fr.json @@ -5057,15 +5057,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", @@ -5078,9 +5069,6 @@ "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}", "f8a9ced202b79202": "Masquer le libellé du compte", "e4b6c8eab1e48ee2": "Afficher le libellé du compte", "1f76510e608a9292": "Utilisation…", @@ -5458,5 +5446,26 @@ "ad208e3e32c85029": "Tout masquer", "3328503592789bed": "Zen", "856812e7e1fc445e": "Appels d’outils dans la discussion", - "8d545d54c0a9e950": "Masque les commandes, modifications et recherches lancées par les agents. Masquer les réussis garde les échecs. Zen n’affiche que les réponses finales. Les approbations, questions et erreurs s’affichent toujours." + "8d545d54c0a9e950": "Masque les commandes, modifications et recherches lancées par les agents. Masquer les réussis garde les échecs. Zen n’affiche que les réponses finales. Les approbations, questions et erreurs s’affichent toujours.", + "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" + ] } diff --git a/apps/mobile/src/i18n/translations/ja.json b/apps/mobile/src/i18n/translations/ja.json index 8cd9fba5c8332..cd081b82ec968 100644 --- a/apps/mobile/src/i18n/translations/ja.json +++ b/apps/mobile/src/i18n/translations/ja.json @@ -5038,15 +5038,6 @@ }, "%" ], - "a6ae2f414eb6349a": [ - "プールの ", - { - "i": 1, - "k": "_gt_value_1", - "v": "v" - }, - "% を回復" - ], "427c46cf712e8cb6": "リセットクレジット", "fb7be23247bbe5ec": "ペース超過", "05c53f9e062392da": "適正なペース", @@ -5059,9 +5050,6 @@ "8864ac914d8205e8": "リセットクレジットを使用しますか?", "e32c2c7e61a16f4b": "クレジットを使用", "b58a90dc5356f80a": "今すぐリセット", - "1d8c701d90e48e07": "↻ 今すぐ +{percent}%", - "949db5acc5a82add": "↻ +{percent}% まもなくリセット", - "96f9e0677375a802": "↻ {duration}後に +{percent}%", "f8a9ced202b79202": "アカウントのラベルを非表示", "e4b6c8eab1e48ee2": "アカウントのラベルを表示", "1f76510e608a9292": "使用中…", @@ -5439,5 +5427,26 @@ "ad208e3e32c85029": "すべて非表示", "3328503592789bed": "Zen", "856812e7e1fc445e": "チャット内のツール呼び出し", - "8d545d54c0a9e950": "エージェントが実行するコマンド、編集、検索を非表示にします。「成功したものを非表示」では失敗は表示されます。Zen では最終的な回答だけを表示します。承認、質問、エラーは常に表示されます。" + "8d545d54c0a9e950": "エージェントが実行するコマンド、編集、検索を非表示にします。「成功したものを非表示」では失敗は表示されます。Zen では最終的な回答だけを表示します。承認、質問、エラーは常に表示されます。", + "0823a39756bb74a0": "次のアカウントリセット:今", + "49012e2676b17322": "次のアカウントリセット:まもなく", + "a43d270db904770e": "次のアカウントリセットまで {duration}", + "d343b39fa4fc62f3": "{count} 個のアカウント", + "34def2fecab9556a": "リセット後、このアカウントの残りは {percent}%", + "2c1bdecdcb724828": [ + { + "t": "Text", + "i": 1, + "c": [ + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "%" + ] + }, + " ", + "が平均で残っています" + ] } diff --git a/apps/mobile/src/i18n/translations/ko.json b/apps/mobile/src/i18n/translations/ko.json index 731eaeecaec22..853f6d159c584 100644 --- a/apps/mobile/src/i18n/translations/ko.json +++ b/apps/mobile/src/i18n/translations/ko.json @@ -5042,15 +5042,6 @@ }, "% 남음" ], - "a6ae2f414eb6349a": [ - "풀의 ", - { - "i": 1, - "k": "_gt_value_1", - "v": "v" - }, - "% 복원" - ], "427c46cf712e8cb6": "초기화 크레딧", "fb7be23247bbe5ec": "속도 초과", "05c53f9e062392da": "속도 적정", @@ -5063,9 +5054,6 @@ "8864ac914d8205e8": "초기화 크레딧을 사용할까요?", "e32c2c7e61a16f4b": "크레딧 사용", "b58a90dc5356f80a": "지금 초기화됨", - "1d8c701d90e48e07": "↻ 지금 +{percent}%", - "949db5acc5a82add": "↻ +{percent}% 곧 초기화됨", - "96f9e0677375a802": "↻ {duration} 후 +{percent}%", "f8a9ced202b79202": "계정 레이블 숨기기", "e4b6c8eab1e48ee2": "계정 레이블 표시", "1f76510e608a9292": "사용 중…", @@ -5443,5 +5431,26 @@ "ad208e3e32c85029": "모두 숨기기", "3328503592789bed": "Zen", "856812e7e1fc445e": "채팅의 도구 호출", - "8d545d54c0a9e950": "에이전트가 실행하는 명령, 편집, 검색을 숨깁니다. 성공한 항목 숨기기는 실패를 남겨 둡니다. Zen은 최종 답변만 표시합니다. 승인, 질문, 오류는 항상 표시됩니다." + "8d545d54c0a9e950": "에이전트가 실행하는 명령, 편집, 검색을 숨깁니다. 성공한 항목 숨기기는 실패를 남겨 둡니다. Zen은 최종 답변만 표시합니다. 승인, 질문, 오류는 항상 표시됩니다.", + "0823a39756bb74a0": "다음 계정 초기화: 지금", + "49012e2676b17322": "다음 계정 초기화: 잠시 후", + "a43d270db904770e": "다음 계정 초기화까지 {duration}", + "d343b39fa4fc62f3": "계정 {count}개 기준", + "34def2fecab9556a": "초기화 후 이 계정에 {percent}% 남음", + "2c1bdecdcb724828": [ + { + "t": "Text", + "i": 1, + "c": [ + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "%" + ] + }, + " ", + "평균 남은 비율" + ] } diff --git a/apps/mobile/src/i18n/translations/pt-BR.json b/apps/mobile/src/i18n/translations/pt-BR.json index 2c4ee1bc64fc4..938738c06999b 100644 --- a/apps/mobile/src/i18n/translations/pt-BR.json +++ b/apps/mobile/src/i18n/translations/pt-BR.json @@ -5057,15 +5057,6 @@ }, "% restante até agora" ], - "a6ae2f414eb6349a": [ - "Restaura ", - { - "i": 1, - "k": "_gt_value_1", - "v": "v" - }, - "% do total" - ], "427c46cf712e8cb6": "Créditos de redefinição", "fb7be23247bbe5ec": "acima do ritmo", "05c53f9e062392da": "no ritmo", @@ -5078,9 +5069,6 @@ "8864ac914d8205e8": "Usar um crédito de redefinição?", "e32c2c7e61a16f4b": "Usar crédito", "b58a90dc5356f80a": "renova agora", - "1d8c701d90e48e07": "↻ +{percent}% agora", - "949db5acc5a82add": "↻ +{percent}% Renova em instantes", - "96f9e0677375a802": "↻ +{percent}% em {duration}", "f8a9ced202b79202": "Ocultar rótulo da conta", "e4b6c8eab1e48ee2": "Mostrar rótulo da conta", "1f76510e608a9292": "Usando…", @@ -5458,5 +5446,26 @@ "ad208e3e32c85029": "Ocultar todas", "3328503592789bed": "Zen", "856812e7e1fc445e": "Chamadas de ferramentas no chat", - "8d545d54c0a9e950": "Oculta os comandos, edições e pesquisas que os agentes executam. \"Ocultar bem-sucedidas\" mantém as falhas. Zen mostra só as respostas finais. Aprovações, perguntas e erros sempre aparecem." + "8d545d54c0a9e950": "Oculta os comandos, edições e pesquisas que os agentes executam. \"Ocultar bem-sucedidas\" mantém as falhas. Zen mostra só as respostas finais. Aprovações, perguntas e erros sempre aparecem.", + "0823a39756bb74a0": "Próxima redefinição da conta agora", + "49012e2676b17322": "Próxima redefinição da conta em instantes", + "a43d270db904770e": "Próxima redefinição da conta em {duration}", + "d343b39fa4fc62f3": "Em {count} contas", + "34def2fecab9556a": "Após a redefinição: restam {percent}% nesta conta", + "2c1bdecdcb724828": [ + { + "t": "Text", + "i": 1, + "c": [ + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "%" + ] + }, + " ", + "restantes em média" + ] } diff --git a/apps/mobile/src/i18n/translations/ru.json b/apps/mobile/src/i18n/translations/ru.json index c4f78e560083b..b5ba53caf2817 100644 --- a/apps/mobile/src/i18n/translations/ru.json +++ b/apps/mobile/src/i18n/translations/ru.json @@ -5136,15 +5136,6 @@ }, "%" ], - "a6ae2f414eb6349a": [ - "Восстанавливает ", - { - "i": 1, - "k": "_gt_value_1", - "v": "v" - }, - "% пула" - ], "427c46cf712e8cb6": "Кредиты на сброс", "fb7be23247bbe5ec": "опережение темпа", "05c53f9e062392da": "в темпе", @@ -5157,9 +5148,6 @@ "8864ac914d8205e8": "Использовать кредит на сброс?", "e32c2c7e61a16f4b": "Использовать кредит", "b58a90dc5356f80a": "сбрасывается сейчас", - "1d8c701d90e48e07": "↻ +{percent}% сейчас", - "949db5acc5a82add": "↻ +{percent}% Сброс через мгновение", - "96f9e0677375a802": "↻ +{percent}% через {duration}", "f8a9ced202b79202": "Скрыть название аккаунта", "e4b6c8eab1e48ee2": "Показать название аккаунта", "1f76510e608a9292": "Использование…", @@ -5538,5 +5526,26 @@ "ad208e3e32c85029": "Скрывать все", "3328503592789bed": "Дзен", "856812e7e1fc445e": "Вызовы инструментов в чате", - "8d545d54c0a9e950": "Скрывать команды, правки и поиски, которые выполняют агенты. «Скрывать успешные» оставляет ошибки. «Дзен» показывает только итоговые ответы. Запросы подтверждения, вопросы и ошибки показываются всегда." + "8d545d54c0a9e950": "Скрывать команды, правки и поиски, которые выполняют агенты. «Скрывать успешные» оставляет ошибки. «Дзен» показывает только итоговые ответы. Запросы подтверждения, вопросы и ошибки показываются всегда.", + "0823a39756bb74a0": "Следующий сброс лимита аккаунта сейчас", + "49012e2676b17322": "Следующий сброс лимита аккаунта скоро", + "a43d270db904770e": "Следующий сброс лимита аккаунта через {duration}", + "d343b39fa4fc62f3": "По {count} аккаунтам", + "34def2fecab9556a": "После сброса на этом аккаунте осталось {percent}%", + "2c1bdecdcb724828": [ + { + "t": "Text", + "i": 1, + "c": [ + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "%" + ] + }, + " ", + "осталось в среднем" + ] } diff --git a/apps/mobile/src/i18n/translations/sv.json b/apps/mobile/src/i18n/translations/sv.json index fa3a3dd6d039f..1499d754a082c 100644 --- a/apps/mobile/src/i18n/translations/sv.json +++ b/apps/mobile/src/i18n/translations/sv.json @@ -5063,15 +5063,6 @@ }, " % kvar vid det här laget" ], - "a6ae2f414eb6349a": [ - "Återställer ", - { - "i": 1, - "k": "_gt_value_1", - "v": "v" - }, - " % av poolen" - ], "427c46cf712e8cb6": "Återställningskrediter", "fb7be23247bbe5ec": "före takten", "05c53f9e062392da": "i takt", @@ -5084,9 +5075,6 @@ "8864ac914d8205e8": "Använda en återställningskredit?", "e32c2c7e61a16f4b": "Använd kredit", "b58a90dc5356f80a": "återställs nu", - "1d8c701d90e48e07": "↻ +{percent} % nu", - "949db5acc5a82add": "↻ +{percent} % Återställs strax", - "96f9e0677375a802": "↻ +{percent} % om {duration}", "f8a9ced202b79202": "Dölj kontoetikett", "e4b6c8eab1e48ee2": "Visa kontoetikett", "1f76510e608a9292": "Använder…", @@ -5464,5 +5452,26 @@ "ad208e3e32c85029": "Dölj alla", "3328503592789bed": "Zen", "856812e7e1fc445e": "Verktygsanrop i chatten", - "8d545d54c0a9e950": "Dölj kommandon, redigeringar och sökningar som agenter kör. Dölj lyckade behåller misslyckanden. Zen visar bara slutliga svar. Godkännanden, frågor och fel visas alltid." + "8d545d54c0a9e950": "Dölj kommandon, redigeringar och sökningar som agenter kör. Dölj lyckade behåller misslyckanden. Zen visar bara slutliga svar. Godkännanden, frågor och fel visas alltid.", + "0823a39756bb74a0": "Nästa kontoåterställning sker nu", + "49012e2676b17322": "Nästa kontoåterställning sker strax", + "a43d270db904770e": "Nästa kontoåterställning om {duration}", + "d343b39fa4fc62f3": "För {count} konton", + "34def2fecab9556a": "Efter återställning finns {percent}% kvar på det här kontot", + "2c1bdecdcb724828": [ + { + "t": "Text", + "i": 1, + "c": [ + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "%" + ] + }, + " ", + "kvar i genomsnitt" + ] } diff --git a/apps/mobile/src/i18n/translations/zh.json b/apps/mobile/src/i18n/translations/zh.json index f36e76805c298..3a23fc91e1ece 100644 --- a/apps/mobile/src/i18n/translations/zh.json +++ b/apps/mobile/src/i18n/translations/zh.json @@ -5047,15 +5047,6 @@ }, "%" ], - "a6ae2f414eb6349a": [ - "恢复池的 ", - { - "i": 1, - "k": "_gt_value_1", - "v": "v" - }, - "%" - ], "427c46cf712e8cb6": "重置额度", "fb7be23247bbe5ec": "超前", "05c53f9e062392da": "持平", @@ -5068,9 +5059,6 @@ "8864ac914d8205e8": "使用一次重置额度?", "e32c2c7e61a16f4b": "使用额度", "b58a90dc5356f80a": "已到重置时间", - "1d8c701d90e48e07": "↻ 现在 +{percent}%", - "949db5acc5a82add": "↻ +{percent}% 即将重置", - "96f9e0677375a802": "↻ {duration} 后 +{percent}%", "f8a9ced202b79202": "隐藏账户标签", "e4b6c8eab1e48ee2": "显示账户标签", "1f76510e608a9292": "正在使用…", @@ -5449,5 +5437,26 @@ "ad208e3e32c85029": "全部隐藏", "3328503592789bed": "专注模式", "856812e7e1fc445e": "聊天中的工具调用", - "8d545d54c0a9e950": "隐藏智能体执行的命令、编辑和搜索。“隐藏成功的调用”仍保留失败项;“专注模式”仅显示最终回答。审批、提问和错误始终显示。" + "8d545d54c0a9e950": "隐藏智能体执行的命令、编辑和搜索。“隐藏成功的调用”仍保留失败项;“专注模式”仅显示最终回答。审批、提问和错误始终显示。", + "0823a39756bb74a0": "下一个账户现在重置", + "49012e2676b17322": "下一个账户即将重置", + "a43d270db904770e": "下一个账户将在 {duration} 后重置", + "d343b39fa4fc62f3": "涵盖 {count} 个账户", + "34def2fecab9556a": "重置后,此账户剩余 {percent}%", + "2c1bdecdcb724828": [ + { + "t": "Text", + "i": 1, + "c": [ + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "%" + ] + }, + " ", + "平均剩余" + ] } diff --git a/apps/mobile/src/widgets/subscriptionUsageSnapshot.ts b/apps/mobile/src/widgets/subscriptionUsageSnapshot.ts index bd65da8beec6c..a694db12d0877 100644 --- a/apps/mobile/src/widgets/subscriptionUsageSnapshot.ts +++ b/apps/mobile/src/widgets/subscriptionUsageSnapshot.ts @@ -112,31 +112,37 @@ function clockLabel(at: number, from: number) { ); } -function widgetAccounts(window: LimitPoolWindow, resolve: MessageResolver): WidgetLimitAccount[] { +function widgetAccounts( + window: LimitPoolWindow, + accounts: readonly LimitAccount[], + resolve: MessageResolver, +): WidgetLimitAccount[] { const seen = new Map(); - return window.columns.map((column) => { + const memberByAccount = new Map(window.members.map((member) => [member.account.key, member])); + return accounts.map((source) => { // Redacted initials can collide, and the widget keys segments by name. - const base = accountName(column.account, resolve); + const base = accountName(source, resolve); const count = (seen.get(base) ?? 0) + 1; seen.set(base, count); - const color = normalizeProviderAccentColor(column.account.accentColor); + const color = normalizeProviderAccentColor(source.accentColor); // expo-widgets cannot convert an explicit undefined into a Kotlin value. const account = { name: count > 1 ? `${base}${count}` : base, ...(color && { color }) }; - if (column.window === null) return account; - const checkedAt = Date.parse(column.account.limits.checkedAt); - const resetsAt = column.window.resetsAt ? Date.parse(column.window.resetsAt) : NaN; + const member = memberByAccount.get(source.key); + if (!member) return account; + const checkedAt = Date.parse(source.limits.checkedAt); + const resetsAt = member.window.resetsAt ? Date.parse(member.window.resetsAt) : NaN; // A reset at or before the observation already happened. const reset = resetsAt > checkedAt; return { ...account, - remaining: remainingPercent(column.window), - refill: reset ? column.refillPercent : 0, + remaining: remainingPercent(member.window), + refill: reset ? member.refillPercent : 0, ...(reset && { resetsAt, reset: clockLabel(resetsAt, checkedAt), }), - ...(column.window.windowDurationMins && { - durationMs: column.window.windowDurationMins * 60_000, + ...(member.window.windowDurationMins && { + durationMs: member.window.windowDurationMins * 60_000, }), }; }); @@ -281,7 +287,7 @@ function subscriptionUsageProps( ? resolve(msg("Next reset {time}", { time: resetTime(window.resets[0].at) })) : resolve(msg("Reset {time}", { time: resetTime(window.resets[0].at) })) : resolve(msg("Reset time unavailable")), - accounts: widgetAccounts(window, resolve), + accounts: widgetAccounts(window, pool.accounts, resolve), })) : [], }; diff --git a/apps/web/src/components/usage/UsageLimitsPooled.browser.test.tsx b/apps/web/src/components/usage/UsageLimitsPooled.browser.test.tsx index ab114fbbd6f21..8cca10b9e70c6 100644 --- a/apps/web/src/components/usage/UsageLimitsPooled.browser.test.tsx +++ b/apps/web/src/components/usage/UsageLimitsPooled.browser.test.tsx @@ -2,12 +2,16 @@ import { EnvironmentId, ProviderDriverKind, ProviderInstanceId, + UsageLimitSourceId, type ServerProvider, } from "@t3tools/contracts"; -import { CHATGPT_USAGE_URL } from "@t3tools/shared/usageLimits"; +import { type LimitPresentations, CHATGPT_USAGE_URL } from "@t3tools/shared/usageLimits"; import { describe, expect, it } from "vite-plus/test"; +import { page } from "vite-plus/test/browser"; import { render } from "../../../test/render"; +import { AppAtomRegistryProvider } from "../../rpc/atomRegistry"; +import "../../index.css"; import { UsageLimitsPooled } from "./UsageLimitsPooled"; const checkedAt = "2026-10-25T16:00:00.000Z"; @@ -63,3 +67,93 @@ describe("UsageLimitsPooled ChatGPT usage card", () => { .toBeVisible(); }); }); + +it("keeps the account label and reset summary on a one-account row of a multi-account provider", async () => { + const now = Date.parse("2026-10-28T01:00:00.000Z"); + const checkedAt = new Date(now).toISOString(); + const driver = ProviderDriverKind.make("codex"); + const presentations: LimitPresentations = new Map([ + [ + EnvironmentId.make("demo"), + { + entry: { target: { label: "Demo" } }, + serverConfig: { + providers: [], + usageLimitSources: [ + { + id: UsageLimitSourceId.make("demo"), + kind: "cliproxy", + label: "Demo", + checkedAt, + accounts: [ + { + id: "session-only", + driver, + usageLimits: { + checkedAt, + windows: [ + { + id: "primary", + kind: "session", + label: "Session", + usedPercent: 0, + resetsAt: "2026-10-28T03:55:00.000Z", + }, + ], + }, + }, + { + id: "later-session", + driver, + usageLimits: { + checkedAt, + windows: [ + { + id: "primary", + kind: "session", + label: "Session", + usedPercent: 0.6, + resetsAt: "2026-10-28T05:00:00.000Z", + }, + ], + }, + }, + { + id: "monthly-only", + driver, + usageLimits: { + checkedAt, + windows: [ + { + id: "primary", + kind: "monthly", + label: "Monthly", + usedPercent: 2, + resetsAt: "2026-11-26T18:00:00.000Z", + }, + ], + }, + }, + ], + }, + ], + }, + }, + ], + ]); + const container = document.createElement("div"); + container.style.width = "1000px"; + await using screen = await render( + + + , + { container }, + ); + await expect.element(screen.getByText("monthly-only", { exact: true }).first()).toBeVisible(); + await expect.element(screen.getByText("Next account reset in 29d 17h")).toBeVisible(); + await expect.element(screen.getByText("Next account reset in 2h 55m")).toBeVisible(); + await expect.element(screen.getByText("average left", { exact: true })).toBeVisible(); + await expect.element(screen.getByText("Across 2 accounts", { exact: true })).toBeVisible(); + await screen.getByRole("button", { name: /^later-session: 99% left/ }).click(); + await expect.element(page.getByText("100% left on this account")).toBeVisible(); +}); diff --git a/apps/web/src/components/usage/UsageLimitsPooled.tsx b/apps/web/src/components/usage/UsageLimitsPooled.tsx index c3932252691e5..a2a9670d18e1e 100644 --- a/apps/web/src/components/usage/UsageLimitsPooled.tsx +++ b/apps/web/src/components/usage/UsageLimitsPooled.tsx @@ -207,9 +207,11 @@ function SegmentPopover({ {timeLeft !== null ? ( {gt("{timeLeft}% left by now", { timeLeft })} ) : null} - {reset && reset.restoresPercent > 0 ? ( - - {gt("+{percent}% of pool", { percent: reset.restoresPercent })} + {reset && reset.member.refillPercent > 0 ? ( + + {gt("{percent}% left on this account", { + percent: Math.round(Math.min(100, remaining + reset.member.refillPercent)), + })} ) : null} @@ -546,10 +548,12 @@ function PoolBar({ pool, color, now, + providerAccountCount, }: { readonly pool: LimitPoolWindow; readonly color: string; readonly now: number; + readonly providerAccountCount: number; }) { const restores = new Map(pool.resets.map((reset) => [reset.member.account.key, reset])); const gt = useGT(); @@ -570,7 +574,7 @@ function PoolBar({ color={normalizeProviderAccentColor(member.account.accentColor) ?? color} now={now} index={position + 1} - showAccountName={pool.columns.length > 1} + showAccountName={providerAccountCount > 1} /> ) : pool.kind === "monthly" && member.account.limits.zeroSpendCap ? (
reset.restoresPercent > 0); + const m = useMessages(); + const gt = useGT(); + const nextReset = pool.resets[0]; return (
@@ -617,18 +625,27 @@ function PoolWindowCard({ - left + {pool.members.length > 1 ? ( + average left + ) : ( + left + )} {pool.pace ? : null} - {nextRefill && pool.columns.length > 1 ? ( + {pool.members.length > 1 ? ( + + {gt("Across {count} accounts", { count: pool.members.length })} + + ) : null} + {nextReset && providerAccountCount > 1 ? ( - ↻ +{nextRefill.restoresPercent}% + {formatResetsIn(nextReset.member.window, now, m, "account")} ) : null}
- + {description ? (

{description}

) : null} @@ -660,6 +677,7 @@ function PoolSection({ pool, now }: { readonly pool: LimitPool; readonly now: nu { }); }); - it("preserves gaps without counting missing windows toward pooled quota", () => { + it("fills each row with only accounts reporting that window", () => { const [pool] = collectLimitPools( [ account("a", [window]), @@ -1353,18 +1353,49 @@ describe("pooled account columns", () => { { ...weekly, usedPercent: 80 }, ]), account("c", [weekly]), + { + ...account("capped", []), + limits: { checkedAt: "2026-09-03T11:00:00.000Z", windows: [], zeroSpendCap: true }, + }, + account("monthly", [{ ...window, kind: "monthly" }]), ], now, ); expect(keys(pool!)).toEqual([ - ["a", "b", null], - [null, "b", "c"], + ["a", "b"], + ["b", "c"], + [null, "monthly"], + ]); + expect(pool!.windows[2]!.columns.map(({ account }) => account.key)).toEqual([ + "capped", + "monthly", ]); expect(pool!.windows[1]!.members.map((member) => member.account.key)).toEqual(["b", "c"]); expect(pool!.windows[1]!.remainingPercent).toBe(40); expect(pool!.windows[1]!.resets.map((reset) => reset.restoresPercent)).toEqual([40, 20]); }); + it("gives two Codex session accounts equal slots and a monthly-only account its own full row", () => { + const codex = (key: string, windows: LimitAccount["limits"]["windows"]) => ({ + ...account(key, windows), + driver: ProviderDriverKind.make("codex"), + }); + const [pool] = collectLimitPools( + [ + codex("a", [window, { ...weekly, usedPercent: 90 }]), + codex("b", [window, { ...weekly, usedPercent: 100 }]), + codex("monthly", [{ ...window, kind: "monthly", usedPercent: 2 }]), + ], + now, + ); + expect(keys(pool!)).toEqual([["a", "b"], ["a", "b"], ["monthly"]]); + expect(pool!.windows[1]!.remainingPercent).toBe(5); + expect(pool!.windows[1]!.members.map((member) => 100 - member.window.usedPercent)).toEqual([ + 10, 0, + ]); + expect(pool!.windows[2]!.remainingPercent).toBe(98); + }); + it("falls back to weekly resets when no account reports a session", () => { const [pool] = collectLimitPools( [ diff --git a/packages/shared/src/usageLimits.ts b/packages/shared/src/usageLimits.ts index 711f3637d0a9f..f2e8867f94104 100644 --- a/packages/shared/src/usageLimits.ts +++ b/packages/shared/src/usageLimits.ts @@ -728,9 +728,14 @@ function poolWindows(accounts: readonly LimitAccount[], now: number): readonly L kind: first.kind, label: first.label, members, - columns: accounts.map( - (account) => memberByAccount.get(account.key) ?? { account, window: null }, - ), + columns: accounts.flatMap((account) => { + const member = memberByAccount.get(account.key); + return member + ? [member] + : first.kind === "monthly" && account.limits.zeroSpendCap + ? [{ account, window: null }] + : []; + }), usedPercent: Math.round(usedPercent), remainingPercent: Math.round(100 - usedPercent), pace: meanElapsed === null ? null : paceOfShares(timedUsed, meanElapsed), diff --git a/packages/shared/src/usageLimitsCopy.ts b/packages/shared/src/usageLimitsCopy.ts index 85f78e0f11f28..abe3f530d1ab7 100644 --- a/packages/shared/src/usageLimitsCopy.ts +++ b/packages/shared/src/usageLimitsCopy.ts @@ -214,10 +214,17 @@ export function formatResetsIn( window: ServerProviderUsageWindow, now: number, resolve: MFunctionType = mFallback, - style: "full" | "in" | "refill" = "full", + style: "full" | "in" | "refill" | "account" = "full", ): string | null { const countdown = resetCountdown(window, now); if (countdown === null) return null; + if (style === "account") { + if (countdown.kind === "now") return resolve(msg("Next account reset now")); + if (countdown.kind === "momentarily") return resolve(msg("Next account reset momentarily")); + return resolve( + msg("Next account reset in {duration}", { duration: formatDuration(countdown.ms, resolve) }), + ); + } if (countdown.kind === "now") return resolve(msg("resets now")); if (countdown.kind === "momentarily") return resolve(msg("Resets momentarily")); const duration = formatDuration(countdown.ms, resolve);