Skip to content

Commit

Permalink
Tweaks to sign up and 'retry' buttons (#235849)
Browse files Browse the repository at this point in the history
* Tweaks to sign up and 'retry' buttons

* Update label

* Add a period
  • Loading branch information
roblourens authored Dec 11, 2024
1 parent 2eae084 commit aba7db2
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ import { IChatContentPart } from './chatContentParts.js';

const $ = dom.$;

/**
* Once the sign up button is clicked, and the retry button has been shown, it should be shown every time.
*/
let shouldShowRetryButton = false;

/**
* Once the 'retry' button is clicked, the wait warning should be shown every time.
*/
let shouldShowWaitWarning = false;

export class ChatQuotaExceededPart extends Disposable implements IChatContentPart {
public readonly domNode: HTMLElement;

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

let didAddSecondary = false;
let hasAddedWaitWarning = false;
const addWaitWarningIfNeeded = () => {
if (!shouldShowWaitWarning || hasAddedWaitWarning) {
return;
}

hasAddedWaitWarning = true;
dom.append(messageContainer, $('.chat-quota-wait-warning', undefined, localize('waitWarning', "Signing up may take a few minutes to take effect.")));
};

let hasAddedRetryButton = false;
const addRetryButtonIfNeeded = () => {
if (!shouldShowRetryButton || hasAddedRetryButton) {
return;
}

hasAddedRetryButton = true;
const button2 = this._register(new Button(messageContainer, {
buttonBackground: undefined,
buttonForeground: asCssVariable(textLinkForeground)
}));
button2.element.classList.add('chat-quota-error-secondary-button');
button2.label = localize('signedUpClickToContinue', "Signed up? Click to retry.");
this._onDidChangeHeight.fire();
this._register(button2.onDidClick(() => {
const widget = chatWidgetService.getWidgetBySessionId(element.sessionId);
if (!widget) {
return;
}

widget.rerunLastRequest();

shouldShowWaitWarning = true;
addWaitWarningIfNeeded();
}));
};

this._register(button1.onDidClick(async () => {
await commandService.executeCommand('workbench.action.chat.upgradePlan');

if (!didAddSecondary) {
didAddSecondary = true;

const button2 = this._register(new Button(messageContainer, {
buttonBackground: undefined,
buttonForeground: asCssVariable(textLinkForeground)
}));
button2.element.classList.add('chat-quota-error-secondary-button');
button2.label = localize('signedUpClickToContinue', "Signed up? Click to continue!");
this._onDidChangeHeight.fire();
this._register(button2.onDidClick(() => {
const widget = chatWidgetService.getWidgetBySessionId(element.sessionId);
if (!widget) {
return;
}

widget.rerunLastRequest();
}));
}
shouldShowRetryButton = true;
addRetryButtonIfNeeded();
}));

addRetryButtonIfNeeded();
addWaitWarningIfNeeded();
}

hasSameContent(other: unknown): boolean {
Expand Down
10 changes: 9 additions & 1 deletion src/vs/workbench/contrib/chat/browser/media/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -1473,11 +1473,19 @@ have to be updated for changes to the rules above, or to support more deeply nes

.chat-quota-error-secondary-button {
margin-top: 6px;
font-size: 12px;
padding: 0px;
border: none;
}

.chat-quota-error-secondary-button,
.chat-quota-wait-warning {
font-size: 12px;
}

.chat-quota-wait-warning {
margin-top: 2px;
}

.chat-quota-error-message {
.rendered-markdown p {
margin: 0px;
Expand Down

0 comments on commit aba7db2

Please sign in to comment.