Skip to content

Commit aba7db2

Browse files
authored
Tweaks to sign up and 'retry' buttons (microsoft#235849)
* Tweaks to sign up and 'retry' buttons * Update label * Add a period
1 parent 2eae084 commit aba7db2

File tree

2 files changed

+61
-21
lines changed

2 files changed

+61
-21
lines changed

src/vs/workbench/contrib/chat/browser/chatContentParts/chatQuotaExceededPart.ts

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ import { IChatContentPart } from './chatContentParts.js';
2222

2323
const $ = dom.$;
2424

25+
/**
26+
* Once the sign up button is clicked, and the retry button has been shown, it should be shown every time.
27+
*/
28+
let shouldShowRetryButton = false;
29+
30+
/**
31+
* Once the 'retry' button is clicked, the wait warning should be shown every time.
32+
*/
33+
let shouldShowWaitWarning = false;
34+
2535
export class ChatQuotaExceededPart extends Disposable implements IChatContentPart {
2636
public readonly domNode: HTMLElement;
2737

@@ -51,30 +61,52 @@ export class ChatQuotaExceededPart extends Disposable implements IChatContentPar
5161
button1.label = localize('upgradeToCopilotPro', "Upgrade to Copilot Pro");
5262
button1.element.classList.add('chat-quota-error-button');
5363

54-
let didAddSecondary = false;
64+
let hasAddedWaitWarning = false;
65+
const addWaitWarningIfNeeded = () => {
66+
if (!shouldShowWaitWarning || hasAddedWaitWarning) {
67+
return;
68+
}
69+
70+
hasAddedWaitWarning = true;
71+
dom.append(messageContainer, $('.chat-quota-wait-warning', undefined, localize('waitWarning', "Signing up may take a few minutes to take effect.")));
72+
};
73+
74+
let hasAddedRetryButton = false;
75+
const addRetryButtonIfNeeded = () => {
76+
if (!shouldShowRetryButton || hasAddedRetryButton) {
77+
return;
78+
}
79+
80+
hasAddedRetryButton = true;
81+
const button2 = this._register(new Button(messageContainer, {
82+
buttonBackground: undefined,
83+
buttonForeground: asCssVariable(textLinkForeground)
84+
}));
85+
button2.element.classList.add('chat-quota-error-secondary-button');
86+
button2.label = localize('signedUpClickToContinue', "Signed up? Click to retry.");
87+
this._onDidChangeHeight.fire();
88+
this._register(button2.onDidClick(() => {
89+
const widget = chatWidgetService.getWidgetBySessionId(element.sessionId);
90+
if (!widget) {
91+
return;
92+
}
93+
94+
widget.rerunLastRequest();
95+
96+
shouldShowWaitWarning = true;
97+
addWaitWarningIfNeeded();
98+
}));
99+
};
100+
55101
this._register(button1.onDidClick(async () => {
56102
await commandService.executeCommand('workbench.action.chat.upgradePlan');
57103

58-
if (!didAddSecondary) {
59-
didAddSecondary = true;
60-
61-
const button2 = this._register(new Button(messageContainer, {
62-
buttonBackground: undefined,
63-
buttonForeground: asCssVariable(textLinkForeground)
64-
}));
65-
button2.element.classList.add('chat-quota-error-secondary-button');
66-
button2.label = localize('signedUpClickToContinue', "Signed up? Click to continue!");
67-
this._onDidChangeHeight.fire();
68-
this._register(button2.onDidClick(() => {
69-
const widget = chatWidgetService.getWidgetBySessionId(element.sessionId);
70-
if (!widget) {
71-
return;
72-
}
73-
74-
widget.rerunLastRequest();
75-
}));
76-
}
104+
shouldShowRetryButton = true;
105+
addRetryButtonIfNeeded();
77106
}));
107+
108+
addRetryButtonIfNeeded();
109+
addWaitWarningIfNeeded();
78110
}
79111

80112
hasSameContent(other: unknown): boolean {

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,11 +1473,19 @@ have to be updated for changes to the rules above, or to support more deeply nes
14731473

14741474
.chat-quota-error-secondary-button {
14751475
margin-top: 6px;
1476-
font-size: 12px;
14771476
padding: 0px;
14781477
border: none;
14791478
}
14801479

1480+
.chat-quota-error-secondary-button,
1481+
.chat-quota-wait-warning {
1482+
font-size: 12px;
1483+
}
1484+
1485+
.chat-quota-wait-warning {
1486+
margin-top: 2px;
1487+
}
1488+
14811489
.chat-quota-error-message {
14821490
.rendered-markdown p {
14831491
margin: 0px;

0 commit comments

Comments
 (0)