Skip to content

Commit a12b46d

Browse files
authored
chat - status tweaks (microsoft#241720)
1 parent b7bdece commit a12b46d

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

src/vs/workbench/contrib/chat/browser/chatStatus.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IKeybindingService } from '../../../../platform/keybinding/common/keybi
1313
import { IProductService } from '../../../../platform/product/common/productService.js';
1414
import { IWorkbenchContribution } from '../../../common/contributions.js';
1515
import { IWorkbenchAssignmentService } from '../../../services/assignment/common/assignmentService.js';
16-
import { IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarService, StatusbarAlignment, TooltipContent } from '../../../services/statusbar/browser/statusbar.js';
16+
import { IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarService, ShowTooltipCommand, StatusbarAlignment, TooltipContent } from '../../../services/statusbar/browser/statusbar.js';
1717
import { ChatContextKeys } from '../common/chatContextKeys.js';
1818
import { IChatQuotasService } from '../common/chatQuotasService.js';
1919
import { quotaToButtonMessage, OPEN_CHAT_QUOTA_EXCEEDED_DIALOG, CHAT_SETUP_ACTION_LABEL, TOGGLE_CHAT_ACTION_ID, CHAT_OPEN_ACTION_ID } from './actions/chatActions.js';
@@ -24,6 +24,8 @@ import { KeybindingLabel } from '../../../../base/browser/ui/keybindingLabel/key
2424
import { defaultCheckboxStyles, defaultKeybindingLabelStyles } from '../../../../platform/theme/browser/defaultStyles.js';
2525
import { Checkbox } from '../../../../base/browser/ui/toggle/toggle.js';
2626
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
27+
import { Command } from '../../../../editor/common/languages.js';
28+
import { ICommandService } from '../../../../platform/commands/common/commands.js';
2729

2830
export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribution {
2931

@@ -44,7 +46,8 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
4446
@IWorkbenchAssignmentService private readonly assignmentService: IWorkbenchAssignmentService,
4547
@IProductService private readonly productService: IProductService,
4648
@IKeybindingService private readonly keybindingService: IKeybindingService,
47-
@IConfigurationService private readonly configurationService: IConfigurationService
49+
@IConfigurationService private readonly configurationService: IConfigurationService,
50+
@ICommandService private readonly commandService: ICommandService
4851
) {
4952
super();
5053

@@ -93,7 +96,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
9396

9497
let text = '$(copilot)';
9598
let ariaLabel = localize('chatStatus', "Copilot Status");
96-
let command = TOGGLE_CHAT_ACTION_ID;
99+
let command: string | Command = TOGGLE_CHAT_ACTION_ID;
97100
let tooltip: TooltipContent = localize('openChat', "Open Chat ({0})", this.keybindingService.lookupKeybinding(command)?.getLabel() ?? '');
98101

99102
// Quota Exceeded
@@ -105,7 +108,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
105108
} else if (completionsQuotaExceeded && !chatQuotaExceeded) {
106109
quotaWarning = localize('completionsQuotaExceededStatus', "Completions limit reached");
107110
} else {
108-
quotaWarning = localize('chatAndCompletionsQuotaExceededStatus', "Copilot limit reached");
111+
quotaWarning = localize('chatAndCompletionsQuotaExceededStatus', "Limit reached");
109112
}
110113

111114
text = `$(copilot-warning) ${quotaWarning}`;
@@ -139,8 +142,8 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
139142

140143
container.appendChild($('div', undefined, localize('limitTitle', "You are currently using Copilot Free:")));
141144

142-
const chatQuotaIndicator = this.createQuotaIndicator(container, chatTotal, chatRemaining, localize('chatsLabel', "Chat Messages"));
143-
const completionsQuotaIndicator = this.createQuotaIndicator(container, completionsTotal, completionsRemaining, localize('completionsLabel', "Code Completions"));
145+
const chatQuotaIndicator = this.createQuotaIndicator(container, chatTotal, chatRemaining, localize('chatsLabel', "Chats Used"));
146+
const completionsQuotaIndicator = this.createQuotaIndicator(container, completionsTotal, completionsRemaining, localize('completionsLabel', "Completions Used"));
144147

145148
this.chatEntitlementsService.resolve(CancellationToken.None).then(() => {
146149
const { chatTotal, chatRemaining, completionsTotal, completionsRemaining } = this.chatQuotasService.quotas;
@@ -149,7 +152,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
149152
completionsQuotaIndicator(completionsTotal, completionsRemaining);
150153
});
151154

152-
container.appendChild($('div', undefined, localize('limitQuota', "Limits will reset on {0}.", this.dateFormatter.format(quotaResetDate))));
155+
container.appendChild($('div', undefined, localize('limitQuota', "Usage will reset on {0}.", this.dateFormatter.format(quotaResetDate))));
153156

154157
// Settings
155158
container.appendChild(document.createElement('hr'));
@@ -161,6 +164,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
161164

162165
return container;
163166
};
167+
command = ShowTooltipCommand;
164168
}
165169

166170
// Any other User
@@ -177,6 +181,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
177181

178182
return container;
179183
};
184+
command = ShowTooltipCommand;
180185
}
181186

182187
return {
@@ -206,8 +211,8 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
206211

207212
const update = (total: number | undefined, remaining: number | undefined) => {
208213
if (typeof total === 'number' && typeof remaining === 'number') {
209-
quotaText.textContent = localize('quotaDisplay', "{0} / {1}", remaining, total);
210-
quotaBit.style.width = `${(remaining / total) * 100}%`;
214+
quotaText.textContent = localize('quotaDisplay', "{0} / {1}", total - remaining, total);
215+
quotaBit.style.width = `${((total - remaining) / total) * 100}%`;
211216
}
212217
};
213218

@@ -231,10 +236,16 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
231236

232237
const shortcut = append(shortcuts, $('div.shortcut'));
233238

234-
append(shortcut, $('span.shortcut-label', undefined, entry.text));
239+
const shortcutLabel = append(shortcut, $('span.shortcut-label', undefined, entry.text));
235240

236241
const shortcutKey = disposables.add(new KeybindingLabel(shortcut, OS, { ...defaultKeybindingLabelStyles }));
237242
shortcutKey.set(keys);
243+
244+
for (const element of [shortcutLabel, shortcutKey.element]) {
245+
disposables.add(addDisposableListener(element, EventType.CLICK, e => {
246+
this.commandService.executeCommand(entry.id);
247+
}));
248+
}
238249
}
239250

240251
return shortcuts;

src/vs/workbench/contrib/chat/browser/media/chatStatus.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141

4242
.chat-status-bar-entry-tooltip .shortcuts .shortcut .shortcut-label {
4343
flex: 1;
44+
cursor: pointer;
45+
}
46+
47+
.chat-status-bar-entry-tooltip .shortcuts .shortcut .monaco-keybinding {
48+
cursor: pointer;
4449
}
4550

4651
/* Quota Indicator */

0 commit comments

Comments
 (0)