Improve CLI quota message#315797
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves how Copilot CLI chat sessions surface quota-exceeded errors by reusing the per-plan quota messaging that already exists for other chat flows, so users get a consistent, polished quota message.
Changes:
- Extracted per-plan quota messaging into a reusable helper (
getQuotaMessageForPlan). - Added quota detection in Copilot CLI session error handling and rethrew as a dedicated
CopilotCLIQuotaExceededError. - Updated CLI chat participants to convert that error into
errorDetailswithisQuotaExceeded: true.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/platform/chat/common/commonTypes.ts | Extracts quota message selection into getQuotaMessageForPlan for reuse. |
| extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts | Maps CLI quota errors to errorDetails.isQuotaExceeded for the sessions UI flow. |
| extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts | Maps CLI quota errors to errorDetails.isQuotaExceeded for the main CLI chat sessions flow. |
| extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotcliSession.ts | Detects quota errors from SDK events and throws a specialized quota error with the per-plan message. |
Copilot's findings
Comments suppressed due to low confidence (1)
extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotcliSession.ts:1485
- When a quota error is detected, a CopilotCLIQuotaExceededError is thrown before updating the session status. Because _status was set to InProgress at the start of the request, this path leaves the session stuck InProgress (and can block subsequent requests via the “already busy” check and keep the session item showing as active). Set _status to Failed (and fire _statusChange) before throwing the quota error, and ensure any required cleanup/telemetry still happens for this terminal state.
if (isQuotaError) {
this._chatQuotaService.clearQuota();
let plan: string | undefined;
try {
const copilotToken = await this._authenticationService.getCopilotToken();
plan = copilotToken.copilotPlan;
} catch { /* token unavailable */ }
throw new CopilotCLIQuotaExceededError(getQuotaMessageForPlan(plan));
}
- Files reviewed: 4/4 changed files
- Comments generated: 1
Comment on lines
+1419
to
+1423
| if (event.data.errorType === 'quota' || event.data.statusCode === 402) { | ||
| isQuotaError = true; | ||
| } else { | ||
| requestStream?.markdown(l10n.t('\n\nError: ({0}) {1}', event.data.errorType, event.data.message)); | ||
| } |
aeschli
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #315335
FYI @DonJayamanne