@@ -36,9 +36,9 @@ export interface IChatQuotasService {
36
36
}
37
37
38
38
export interface IChatQuotas {
39
- readonly chatQuotaExceeded : boolean ;
40
- readonly completionsQuotaExceeded : boolean ;
41
- readonly quotaResetDate : Date ;
39
+ chatQuotaExceeded : boolean ;
40
+ completionsQuotaExceeded : boolean ;
41
+ quotaResetDate : Date | undefined ;
42
42
}
43
43
44
44
export const OPEN_CHAT_QUOTA_EXCEEDED_DIALOG = 'workbench.action.chat.openQuotaExceededDialog' ;
@@ -50,7 +50,7 @@ export class ChatQuotasService extends Disposable implements IChatQuotasService
50
50
private readonly _onDidChangeQuotas = this . _register ( new Emitter < void > ( ) ) ;
51
51
readonly onDidChangeQuotas : Event < void > = this . _onDidChangeQuotas . event ;
52
52
53
- private _quotas = { chatQuotaExceeded : false , completionsQuotaExceeded : false , quotaResetDate : new Date ( 0 ) } ;
53
+ private _quotas : IChatQuotas = { chatQuotaExceeded : false , completionsQuotaExceeded : false , quotaResetDate : undefined } ;
54
54
get quotas ( ) : IChatQuotas { return this . _quotas ; }
55
55
56
56
private readonly chatQuotaExceededContextKey = ChatContextKeys . chatQuotaExceeded . bindTo ( this . contextKeyService ) ;
@@ -227,7 +227,7 @@ export class ChatQuotasService extends Disposable implements IChatQuotasService
227
227
228
228
clearQuotas ( ) : void {
229
229
if ( this . quotas . chatQuotaExceeded || this . quotas . completionsQuotaExceeded ) {
230
- this . acceptQuotas ( { chatQuotaExceeded : false , completionsQuotaExceeded : false , quotaResetDate : new Date ( 0 ) } ) ;
230
+ this . acceptQuotas ( { chatQuotaExceeded : false , completionsQuotaExceeded : false , quotaResetDate : undefined } ) ;
231
231
}
232
232
}
233
233
@@ -241,6 +241,8 @@ export class ChatQuotasStatusBarEntry extends Disposable implements IWorkbenchCo
241
241
242
242
static readonly ID = 'chat.quotasStatusBarEntry' ;
243
243
244
+ private static readonly COPILOT_STATUS_ID = 'GitHub.copilot.status' ; // TODO@bpasero unify into 1 core indicator
245
+
244
246
private readonly _entry = this . _register ( new MutableDisposable < IStatusbarEntryAccessor > ( ) ) ;
245
247
246
248
constructor (
@@ -254,19 +256,39 @@ export class ChatQuotasStatusBarEntry extends Disposable implements IWorkbenchCo
254
256
255
257
private updateStatusbarEntry ( ) : void {
256
258
const { chatQuotaExceeded, completionsQuotaExceeded } = this . chatQuotasService . quotas ;
259
+
260
+ // Some quota exceeded, show indicator
257
261
if ( chatQuotaExceeded || completionsQuotaExceeded ) {
258
- // Some quota exceeded, show indicator
262
+ let text : string ;
263
+ if ( chatQuotaExceeded && ! completionsQuotaExceeded ) {
264
+ text = localize ( 'chatQuotaExceededStatus' , "Chat limit reached" ) ;
265
+ } else if ( completionsQuotaExceeded && ! chatQuotaExceeded ) {
266
+ text = localize ( 'completionsQuotaExceededStatus' , "Completions limit reached" ) ;
267
+ } else {
268
+ text = localize ( 'chatAndCompletionsQuotaExceededStatus' , "Copilot limit reached" ) ;
269
+ }
270
+
271
+ const isCopilotStatusVisible = this . statusbarService . isEntryVisible ( ChatQuotasStatusBarEntry . COPILOT_STATUS_ID ) ;
272
+ if ( ! isCopilotStatusVisible ) {
273
+ text = `$(copilot-warning) ${ text } ` ;
274
+ }
275
+
259
276
this . _entry . value = this . statusbarService . addEntry ( {
260
- name : localize ( 'indicator' , "Copilot Quota Indicator" ) ,
261
- text : localize ( 'limitReached' , "Copilot Limit Reached" ) ,
262
- ariaLabel : localize ( 'copilotQuotaExceeded' , "Copilot Limit Reached" ) ,
277
+ name : localize ( 'indicator' , "Copilot Limit Indicator" ) ,
278
+ text,
279
+ ariaLabel : text ,
263
280
command : OPEN_CHAT_QUOTA_EXCEEDED_DIALOG ,
264
- kind : 'prominent' ,
265
281
showInAllWindows : true ,
266
- tooltip : quotaToButtonMessage ( { chatQuotaExceeded, completionsQuotaExceeded } ) ,
267
- } , ChatQuotasStatusBarEntry . ID , StatusbarAlignment . RIGHT , { id : 'GitHub.copilot.status' , alignment : StatusbarAlignment . RIGHT } ) ; // TODO@bpasero unify into 1 core indicator
268
- } else {
269
- // No quota exceeded, remove indicator
282
+ tooltip : quotaToButtonMessage ( { chatQuotaExceeded, completionsQuotaExceeded } )
283
+ } , ChatQuotasStatusBarEntry . ID , StatusbarAlignment . RIGHT , {
284
+ id : ChatQuotasStatusBarEntry . COPILOT_STATUS_ID ,
285
+ alignment : StatusbarAlignment . RIGHT ,
286
+ compact : isCopilotStatusVisible
287
+ } ) ;
288
+ }
289
+
290
+ // No quota exceeded, remove indicator
291
+ else {
270
292
this . _entry . clear ( ) ;
271
293
}
272
294
}
0 commit comments