From f7ccf9b40ee66d5c1fa5b7b1c49810a1b9a74db4 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 00:38:09 +0000 Subject: [PATCH 1/3] fix(plugin-chatbot): gate the AI quota notice's title and action on upgrade / topUp Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01JQwxbXJvjbLQ6k5N7EjZqb --- ui/packages/i18n/src/locales/ar.ts | 1 + ui/packages/i18n/src/locales/de.ts | 1 + ui/packages/i18n/src/locales/en.ts | 1 + ui/packages/i18n/src/locales/es.ts | 1 + ui/packages/i18n/src/locales/fr.ts | 1 + ui/packages/i18n/src/locales/ja.ts | 1 + ui/packages/i18n/src/locales/ko.ts | 1 + ui/packages/i18n/src/locales/pt-BR.ts | 1 + ui/packages/i18n/src/locales/ru.ts | 1 + ui/packages/i18n/src/locales/zh-Hans.ts | 1 + ui/packages/i18n/src/locales/zh-Hant.ts | 1 + .../plugin-chatbot/src/ChatbotEnhanced.tsx | 33 ++++++--- ...atbotEnhanced.quotaBlockedConfirm.test.tsx | 49 +++++++++++++ ...otEnhanced.quotaResetPromise-7587.test.tsx | 72 +++++++++++++++++++ 14 files changed, 156 insertions(+), 9 deletions(-) diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index c973810411c..040ffe0ca80 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -5303,6 +5303,7 @@ const ar = { }, chatbotQuota: { title: "الترقية مطلوبة", + limitTitle: "تم بلوغ حد الذكاء الاصطناعي", fallbackMessage: "لقد بلغت حصتك من الذكاء الاصطناعي.", buyCredits: "شراء باقة أرصدة", upgradePlan: "ترقية الخطة", diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index a320b24c533..b581fe53706 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -4869,6 +4869,7 @@ const de = { }, chatbotQuota: { title: "Upgrade erforderlich", + limitTitle: "KI-Limit erreicht", fallbackMessage: "Sie haben Ihr KI-Kontingent erreicht.", buyCredits: "Credit-Paket kaufen", upgradePlan: "Tarif upgraden", diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index f4a855f7919..e4a76084830 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -5841,6 +5841,7 @@ const en = { }, chatbotQuota: { title: 'Upgrade needed', + limitTitle: 'AI limit reached', fallbackMessage: 'You have reached your AI quota.', buyCredits: 'Buy a credit pack', upgradePlan: 'Upgrade plan', diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts index 59526248614..c879e9508ec 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -4978,6 +4978,7 @@ const es = { }, chatbotQuota: { title: "Se requiere actualizar", + limitTitle: "Límite de IA alcanzado", fallbackMessage: "Ha alcanzado su cuota de IA.", buyCredits: "Comprar un paquete de créditos", upgradePlan: "Mejorar el plan", diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts index ec43ca6a53c..5bf4039eab7 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -4974,6 +4974,7 @@ const fr = { }, chatbotQuota: { title: "Mise à niveau requise", + limitTitle: "Limite d'IA atteinte", fallbackMessage: "Vous avez atteint votre quota d'IA.", buyCredits: "Acheter un pack de crédits", upgradePlan: "Changer d'offre", diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts index 46dd0bc148e..5b689d2ef4e 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -4871,6 +4871,7 @@ const ja = { }, chatbotQuota: { title: "アップグレードが必要です", + limitTitle: "AI の利用上限に達しました", fallbackMessage: "AI の利用上限に達しました。", buyCredits: "クレジットパックを購入", upgradePlan: "プランをアップグレード", diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index ba348a5feb5..6d159da8f17 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -4868,6 +4868,7 @@ const ko = { }, chatbotQuota: { title: "업그레이드 필요", + limitTitle: "AI 사용 한도 도달", fallbackMessage: "AI 사용 한도에 도달했습니다.", buyCredits: "크레딧 팩 구매", upgradePlan: "요금제 업그레이드", diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index 9c7252b9f10..09c1cc0730a 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -4973,6 +4973,7 @@ const pt = { }, chatbotQuota: { title: "Upgrade necessário", + limitTitle: "Limite de IA atingido", fallbackMessage: "Você atingiu sua cota de IA.", buyCredits: "Comprar um pacote de créditos", upgradePlan: "Fazer upgrade do plano", diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts index 0a489487cb7..c1281b7a05c 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -5096,6 +5096,7 @@ const ru = { }, chatbotQuota: { title: "Требуется обновление тарифа", + limitTitle: "Лимит ИИ исчерпан", fallbackMessage: "Вы исчерпали квоту ИИ.", buyCredits: "Купить пакет кредитов", upgradePlan: "Повысить тариф", diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index c77a5fc0c11..832015de466 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -5130,6 +5130,7 @@ const zh = { }, chatbotQuota: { title: '需要升级', + limitTitle: 'AI 额度已用尽', fallbackMessage: 'AI 额度已用完。', buyCredits: '购买额度包', upgradePlan: '升级方案', diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index a5bb6a6b512..d397fc1bf28 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -5130,6 +5130,7 @@ const zhHant = { }, chatbotQuota: { title: '需要升級', + limitTitle: 'AI 額度已用盡', fallbackMessage: 'AI 額度已用完。', buyCredits: '購買額度包', upgradePlan: '升級方案', diff --git a/ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx b/ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx index c286fdcc013..9b5524547c7 100644 --- a/ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx +++ b/ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx @@ -7405,8 +7405,16 @@ function formatSizeLimit(bytes: number, locale: string): string { * `messageEn`; that pair is server-owned, so we still choose between them — by * the in-app locale, not `navigator.language`, which ignored the locale * switcher entirely (objectui#2871). + * + * The title and the action follow the refusal's own next-step flags, never a + * default: `topUp` offers a credit pack, `upgrade` offers the plan upgrade, and + * a refusal with neither (a paid plan's five-hour pace, a developer + * organization) gets a neutral title and NO action — waiting is the only exit, + * and the server's sentence already says when it frees up. */ -function useAiQuotaCopy(error: unknown): { text: string; cta: string } | null { +function useAiQuotaCopy( + error: unknown, +): { title: string; text: string; cta: string | null } | null { const { language } = useObjectTranslation(); const tt = useSafeTranslate(); const quota = React.useMemo(() => parseAiQuotaError(error), [error]); @@ -7416,9 +7424,15 @@ function useAiQuotaCopy(error: unknown): { text: string; cta: string } | null { text: (isZh ? quota.message : quota.messageEn ?? quota.message) || tt('chatbotQuota.fallbackMessage', 'You have reached your AI quota.'), + title: + quota.upgrade && !quota.topUp + ? tt('chatbotQuota.title', 'Upgrade needed') + : tt('chatbotQuota.limitTitle', 'AI limit reached'), cta: quota.topUp ? tt('chatbotQuota.buyCredits', 'Buy a credit pack') - : tt('chatbotQuota.upgradePlan', 'Upgrade plan'), + : quota.upgrade + ? tt('chatbotQuota.upgradePlan', 'Upgrade plan') + : null, }; } @@ -7426,7 +7440,8 @@ function useAiQuotaCopy(error: unknown): { text: string; cta: string } | null { * The next step under a confirm card that a quota refusal blocked * (objectui#7253): what happened (the server's own sentence — it names both * exits, "resets tomorrow" and "upgrade to keep designing") and, when the host - * wired one, the upgrade action. Renders nothing when the blocking error is not + * wired one, the upgrade or top-up action the refusal names (none when it + * names neither). Renders nothing when the blocking error is not * a quota refusal, so the badge above it degrades to a bare "not applied" * rather than to an invented explanation. */ @@ -7447,7 +7462,7 @@ function QuotaBlockedNextStep({ > {copy.text} - {onUpgrade ? ( + {onUpgrade && copy.cta ? (