feat(billing): implement G1 AI credits overage flow with billing telemetry#18590
feat(billing): implement G1 AI credits overage flow with billing telemetry#18590gsquared94 merged 3 commits intogoogle-gemini:mainfrom
Conversation
Summary of ChangesHello @gsquared94, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces comprehensive support for Google One AI Credits within the Gemini CLI. It enables users to seamlessly transition from free usage to paid credits when their quota is exhausted, enhancing the user experience by providing clear options and guidance. The changes encompass new backend logic for credit management, interactive user interface dialogs, updated statistics displays, and robust telemetry for tracking billing-related events, ensuring a smooth and configurable credit usage flow. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive integration for Google One AI Credits into the Gemini CLI. The changes are well-structured, adding a new billing module, UI dialogs for overage and empty wallets, and updating the stats display. The core logic in useQuotaAndFallback correctly handles different credit usage strategies.
I've found one critical issue related to data flow that causes the UI to display a stale credit balance after credits are used. My review includes a detailed comment and a code suggestion to address this by implementing an event-based update mechanism.
d406da0 to
b55abd9
Compare
|
Hi there! Thank you for your contribution to Gemini CLI. To improve our contribution process and better track changes, we now require all pull requests to be associated with an existing issue, as announced in our recent discussion and as detailed in our CONTRIBUTING.md. This pull request is being closed because it is not currently linked to an issue. Once you have updated the description of this PR to link an issue (e.g., by adding How to link an issue: Thank you for your understanding and for being a part of our community! |
b55abd9 to
50f672b
Compare
0c682da to
8759e36
Compare
8759e36 to
6836f0e
Compare
|
Gemini review says:
|
Fixed. |
e75c741 to
fe9d458
Compare
Adds end-to-end support for Google One AI credits in quota exhaustion flows: - New billing module (packages/core/src/billing/) with credit balance checking, overage strategy management, and G1 URL construction - OverageMenuDialog and EmptyWalletDialog UI components for quota exhaustion with credit purchase options - Credits flow handler extracted to creditsFlowHandler.ts with overage menu, empty wallet, and auto-use-credits logic - Server-side credit tracking: enabledCreditTypes on requests, consumed/remaining credits from streaming responses - Billing telemetry events (overage menu shown, option selected, credits used, credit purchase click, API key updated) - OpenTelemetry metrics for overage option and credit purchase counters - Credit balance display in /stats command with refresh support - Settings: general.overageStrategy (ask/always/never) for credit usage - Error handling: INSUFFICIENT_G1_CREDITS_BALANCE as terminal error regardless of domain field presence - Persistent info message after
- OverageMenuDialog.test.tsx: add afterEach with vi.restoreAllMocks(), remove RadioButtonSelect mock, use renderWithProviders + toMatchSnapshot for rendering tests and keyboard input for handler tests - EmptyWalletDialog.test.tsx: same treatment as OverageMenuDialog - useQuotaAndFallback.test.ts: vi.clearAllMocks() → vi.restoreAllMocks() in afterEach to prevent test pollution
fe9d458 to
1edfea8
Compare
b2d6844
Summary
Adds end-to-end support for Google One AI credits in quota exhaustion flows. When a user hits their free quota limit on an eligible model (Gemini 3 Pro Preview, 3.1 Pro Preview), they are offered the option to continue using their G1 AI credits, switch to a fallback model, or purchase more credits.
Related Issues
For https://github.com/google-gemini/maintainers-gemini-cli/issues/1227
How to Validate
Follow go/gemini-cli-x-ai-credits-integration-testing
Pre-Merge Checklist