Skip to content

Commit 258e40f

Browse files
authored
Merge pull request #249521 from microsoft/ben/flexible-rhinoceros
Copilot `1.100` recovery fixes
2 parents c0e10c7 + 308259a commit 258e40f

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

src/vs/platform/actionWidget/browser/actionWidgetDropdown.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class ActionWidgetDropdown extends BaseDropdown {
4848
}
4949

5050
override show(): void {
51-
const actionBarActions = this._options.actionBarActions ?? this._options.actionBarActionProvider?.getActions() ?? [];
51+
let actionBarActions = this._options.actionBarActions ?? this._options.actionBarActionProvider?.getActions() ?? [];
5252
const actions = this._options.actions ?? this._options.actionProvider?.getActions() ?? [];
5353
const actionWidgetItems: IActionListItem<IActionWidgetDropdownAction>[] = [];
5454

@@ -105,10 +105,11 @@ export class ActionWidgetDropdown extends BaseDropdown {
105105

106106
const previouslyFocusedElement = getActiveElement();
107107

108+
108109
const actionWidgetDelegate: IActionListDelegate<IActionWidgetDropdownAction> = {
109110
onSelect: (action, preview) => {
110-
action.run();
111111
this.actionWidgetService.hide();
112+
action.run();
112113
},
113114
onHide: () => {
114115
if (isHTMLElement(previouslyFocusedElement)) {
@@ -117,6 +118,14 @@ export class ActionWidgetDropdown extends BaseDropdown {
117118
}
118119
};
119120

121+
actionBarActions = actionBarActions.map(action => ({
122+
...action,
123+
run: async (...args: any[]) => {
124+
this.actionWidgetService.hide();
125+
return action.run(...args);
126+
}
127+
}));
128+
120129
this.actionWidgetService.show<IActionWidgetDropdownAction>(
121130
this._options.label ?? '',
122131
false,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ class ChatStatusDashboard extends Disposable {
324324
run: () => this.runCommandAndClose(() => this.openerService.open(URI.parse(defaultChat.manageSettingsUrl))),
325325
}));
326326

327-
const completionsQuotaIndicator = completionsQuota ? this.createQuotaIndicator(this.element, disposables, completionsQuota, localize('completionsLabel', "Code completions"), false) : undefined;
328-
const chatQuotaIndicator = chatQuota ? this.createQuotaIndicator(this.element, disposables, chatQuota, localize('chatsLabel', "Chat messages"), false) : undefined;
329-
const premiumChatQuotaIndicator = premiumChatQuota ? this.createQuotaIndicator(this.element, disposables, premiumChatQuota, localize('premiumChatsLabel', "Premium requests"), true) : undefined;
327+
const completionsQuotaIndicator = completionsQuota && (completionsQuota.total > 0 || completionsQuota.unlimited) ? this.createQuotaIndicator(this.element, disposables, completionsQuota, localize('completionsLabel', "Code completions"), false) : undefined;
328+
const chatQuotaIndicator = chatQuota && (chatQuota.total > 0 || chatQuota.unlimited) ? this.createQuotaIndicator(this.element, disposables, chatQuota, localize('chatsLabel', "Chat messages"), false) : undefined;
329+
const premiumChatQuotaIndicator = premiumChatQuota && (premiumChatQuota.total > 0 || premiumChatQuota.unlimited) ? this.createQuotaIndicator(this.element, disposables, premiumChatQuota, localize('premiumChatsLabel', "Premium requests"), true) : undefined;
330330

331331
if (resetDate) {
332332
this.element.appendChild($('div.description', undefined, localize('limitQuota', "Allowance resets {0}.", this.dateFormatter.value.format(new Date(resetDate)))));

src/vs/workbench/contrib/chat/browser/modelPicker/modePickerActionItem.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ export class ModePickerActionItem extends ActionWidgetDropdownActionViewItem {
7272
}
7373

7474
protected override renderLabel(element: HTMLElement): IDisposable | null {
75+
if (!this.element) {
76+
return null;
77+
}
7578
this.setAriaLabelAttributes(element);
7679
const state = modeToString(this.delegate.getMode());
7780
dom.reset(element, dom.$('span.chat-model-label', undefined, state), ...renderLabelWithIcons(`$(chevron-down)`));

src/vs/workbench/contrib/chat/common/chatEntitlementService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ export class ChatEntitlementRequests extends Disposable {
627627
if (response.monthly_quotas?.chat && typeof response.limited_user_quotas?.chat === 'number') {
628628
quotas.chat = {
629629
total: response.monthly_quotas.chat,
630-
percentRemaining: (response.limited_user_quotas.chat / response.monthly_quotas.chat) * 100,
630+
percentRemaining: Math.min(100, Math.max(0, (response.limited_user_quotas.chat / response.monthly_quotas.chat) * 100)),
631631
overageEnabled: false,
632632
overageCount: 0,
633633
unlimited: false
@@ -637,7 +637,7 @@ export class ChatEntitlementRequests extends Disposable {
637637
if (response.monthly_quotas?.completions && typeof response.limited_user_quotas?.completions === 'number') {
638638
quotas.completions = {
639639
total: response.monthly_quotas.completions,
640-
percentRemaining: (response.limited_user_quotas.completions / response.monthly_quotas.completions) * 100,
640+
percentRemaining: Math.min(100, Math.max(0, (response.limited_user_quotas.completions / response.monthly_quotas.completions) * 100)),
641641
overageEnabled: false,
642642
overageCount: 0,
643643
unlimited: false
@@ -653,7 +653,7 @@ export class ChatEntitlementRequests extends Disposable {
653653
}
654654
const quotaSnapshot: IQuotaSnapshot = {
655655
total: rawQuotaSnapshot.entitlement,
656-
percentRemaining: rawQuotaSnapshot.percent_remaining,
656+
percentRemaining: Math.min(100, Math.max(0, rawQuotaSnapshot.percent_remaining)),
657657
overageEnabled: rawQuotaSnapshot.overage_permitted,
658658
overageCount: rawQuotaSnapshot.overage_count,
659659
unlimited: rawQuotaSnapshot.unlimited

0 commit comments

Comments
 (0)