feat(cli): extract QuotaContext and resolve infinite render loop#24959
feat(cli): extract QuotaContext and resolve infinite render loop#24959
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
Size Change: +616 B (0%) Total Size: 34.1 MB
ℹ️ View Unchanged
|
This comment was marked as outdated.
This comment was marked as outdated.
This change isolates quota-related state into a dedicated context, preventing frequent quota updates from triggering global UI re-renders. It also removes an unstable object literal in AppContainer that was causing a 'Maximum update depth exceeded' crash during shell tool execution. Includes cleanup of useTraceUpdate and temporary debug logging.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the CLI's state management by extracting quota-related data from UIStateContext into a new, dedicated QuotaContext. The changes include the introduction of the QuotaContext and useQuotaState hook, along with updates to several components and tests to utilize this new context. A critical issue was noted in AppContainer.tsx where the quota property is still being assigned to the uiState object, resulting in a type mismatch since the property was removed from the UIState interface.
Removed duplicated QuotaState interface from UIStateContext, reverted stylistic changes in MaxSizedBox, and removed temporary fallback logic in test utilities. All tests have been migrated to use QuotaContext.
Code ReviewOverall, the extraction of I did find one issue in the test utilities that needs to be addressed: Issue in
|

Summary
Resolved the fatal 'Maximum update depth exceeded' React error (Crash #185) that occurred during high-volume terminal output or shell tool execution.
Details
The investigation revealed that high-frequency state updates (specifically quota stats and error counts) were triggering global UI re-renders because of an unstable
quotaobject literal inside the rootUIStateContext. This created a synchronous feedback loop with layout measurements.Key Changes:
QuotaContext: Created a dedicated context to isolate quota state (userTier,stats,proQuotaRequest, etc.). This ensures that post-message quota updates no longer trigger a full-app re-render.uiStateobject inAppContainer.tsxby removing unstable object literals and ensuring proper memoization.useTraceUpdatehook and all temporary investigation logging ([DEBUG_LOOP]) to clean up the codebase anddebug.log.Footer,DialogManager, anduseComposerStatusto use the newuseQuotaStatehook.Related Issues
Fixes #24917
How to Validate
! find .).npm test -w @google/gemini-cli) pass.Pre-Merge Checklist