From d554bb0983c167beb5945528503839cdb2b0b316 Mon Sep 17 00:00:00 2001 From: Supra4E8C Date: Thu, 1 Oct 2026 21:58:20 +0800 Subject: [PATCH] feat: add Claude reset grants functionality - Implemented ClaudeResetGrants component to manage reset grants for Claude usage. - Integrated reset grant operations with session management and eligibility checks. - Added API service for reading and claiming reset grants from the Anthropic API. - Enhanced UI with localized messages for reset grant actions. - Created tests for grant parsing, claiming, and session handling to ensure reliability. --- src/features/quota/components/QuotaCard.tsx | 8 + .../providers/claude/ClaudeResetGrants.tsx | 183 ++++++++++ .../providers/claude/resetGrantOperations.ts | 101 ++++++ src/i18n/locales/en.json | 24 ++ src/i18n/locales/ru.json | 24 ++ src/i18n/locales/zh-CN.json | 24 ++ src/i18n/locales/zh-TW.json | 24 ++ src/services/api/claudeResetGrants.ts | 312 +++++++++++++++++ src/utils/quota/constants.ts | 1 + tests/claudeResetGrants.test.ts | 314 ++++++++++++++++++ 10 files changed, 1015 insertions(+) create mode 100644 src/features/quota/providers/claude/ClaudeResetGrants.tsx create mode 100644 src/features/quota/providers/claude/resetGrantOperations.ts create mode 100644 src/services/api/claudeResetGrants.ts create mode 100644 tests/claudeResetGrants.test.ts diff --git a/src/features/quota/components/QuotaCard.tsx b/src/features/quota/components/QuotaCard.tsx index 2ab6b3c2..f59210be 100644 --- a/src/features/quota/components/QuotaCard.tsx +++ b/src/features/quota/components/QuotaCard.tsx @@ -22,6 +22,7 @@ import { import { bindQuotaClasses } from '../types'; import { QUOTA_ADAPTERS, type QuotaCardState } from '../providers'; import { isQuotaRefreshDisabled, type QuotaFileEntry } from '../logic'; +import { ClaudeResetGrants } from '../providers/claude/ClaudeResetGrants'; import bodyStyles from './QuotaBody.module.scss'; import styles from './QuotaCard.module.scss'; @@ -138,6 +139,13 @@ export function QuotaCard(props: QuotaCardProps) { {status !== 'idle' && (