Skip to content

Commit

Permalink
chat - make quota indicator top level (#237428) (#238820)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored Jan 27, 2025
1 parent 28927e2 commit 0d9cdc3
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions src/vs/workbench/contrib/chat/browser/chatQuotasService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class ChatQuotasService extends Disposable implements IChatQuotasService
private readonly chatQuotaExceededContextKey = ChatContextKeys.chatQuotaExceeded.bindTo(this.contextKeyService);
private readonly completionsQuotaExceededContextKey = ChatContextKeys.completionsQuotaExceeded.bindTo(this.contextKeyService);

private ExtensionQuotaContextKeys = { // TODO@bpasero move into product.json or turn into core keys
private ExtensionQuotaContextKeys = {
chatQuotaExceeded: 'github.copilot.chat.quotaExceeded',
completionsQuotaExceeded: 'github.copilot.completions.quotaExceeded',
};
Expand Down Expand Up @@ -176,8 +176,6 @@ export class ChatQuotasStatusBarEntry extends Disposable implements IWorkbenchCo

static readonly ID = 'chat.quotasStatusBarEntry';

private static readonly COPILOT_STATUS_ID = 'GitHub.copilot.status'; // TODO@bpasero unify into 1 core indicator

private readonly entry = this._register(new DisposableStore());

constructor(
Expand All @@ -187,11 +185,6 @@ export class ChatQuotasStatusBarEntry extends Disposable implements IWorkbenchCo
super();

this._register(Event.runAndSubscribe(this.chatQuotasService.onDidChangeQuotas, () => this.updateStatusbarEntry()));
this._register(this.statusbarService.onDidChangeEntryVisibility(e => {
if (e.id === ChatQuotasStatusBarEntry.COPILOT_STATUS_ID) {
this.updateStatusbarEntry();
}
}));
}

private updateStatusbarEntry(): void {
Expand All @@ -208,30 +201,15 @@ export class ChatQuotasStatusBarEntry extends Disposable implements IWorkbenchCo
text = localize('chatAndCompletionsQuotaExceededStatus', "Copilot limit reached");
}

const isCopilotStatusVisible = this.statusbarService.isEntryVisible(ChatQuotasStatusBarEntry.COPILOT_STATUS_ID);
if (!isCopilotStatusVisible) {
text = `$(copilot-warning) ${text}`;
}

this.entry.add(this.statusbarService.addEntry({
name: localize('indicator', "Copilot Limit Indicator"),
text,
text: `$(copilot-warning) ${text}`,
ariaLabel: text,
command: OPEN_CHAT_QUOTA_EXCEEDED_DIALOG,
showInAllWindows: true,
kind: 'prominent',
tooltip: quotaToButtonMessage({ chatQuotaExceeded, completionsQuotaExceeded })
}, ChatQuotasStatusBarEntry.ID, StatusbarAlignment.RIGHT, {
id: ChatQuotasStatusBarEntry.COPILOT_STATUS_ID,
alignment: StatusbarAlignment.RIGHT,
compact: isCopilotStatusVisible
}));

this.entry.add(this.statusbarService.overrideEntry(ChatQuotasStatusBarEntry.COPILOT_STATUS_ID, {
text: '$(copilot-warning)',
ariaLabel: text,
kind: 'prominent'
}));
}, ChatQuotasStatusBarEntry.ID, StatusbarAlignment.RIGHT, 1));
}
}
}
Expand Down

0 comments on commit 0d9cdc3

Please sign in to comment.