@@ -22,6 +22,16 @@ import { IChatContentPart } from './chatContentParts.js';
22
22
23
23
const $ = dom . $ ;
24
24
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
+
25
35
export class ChatQuotaExceededPart extends Disposable implements IChatContentPart {
26
36
public readonly domNode : HTMLElement ;
27
37
@@ -51,30 +61,52 @@ export class ChatQuotaExceededPart extends Disposable implements IChatContentPar
51
61
button1 . label = localize ( 'upgradeToCopilotPro' , "Upgrade to Copilot Pro" ) ;
52
62
button1 . element . classList . add ( 'chat-quota-error-button' ) ;
53
63
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
+
55
101
this . _register ( button1 . onDidClick ( async ( ) => {
56
102
await commandService . executeCommand ( 'workbench.action.chat.upgradePlan' ) ;
57
103
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 ( ) ;
77
106
} ) ) ;
107
+
108
+ addRetryButtonIfNeeded ( ) ;
109
+ addWaitWarningIfNeeded ( ) ;
78
110
}
79
111
80
112
hasSameContent ( other : unknown ) : boolean {
0 commit comments