4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import './media/chatViewSetup.css' ;
7
- import { $ , addDisposableListener , EventType , getActiveElement , setVisibility } from '../../../../base/browser/dom.js' ;
7
+ import { $ , getActiveElement , setVisibility } from '../../../../base/browser/dom.js' ;
8
8
import { Button , ButtonWithDropdown } from '../../../../base/browser/ui/button/button.js' ;
9
9
import { renderIcon } from '../../../../base/browser/ui/iconLabel/iconLabels.js' ;
10
10
import { IAction , toAction } from '../../../../base/common/actions.js' ;
@@ -37,7 +37,7 @@ import { Registry } from '../../../../platform/registry/common/platform.js';
37
37
import { asText , IRequestService } from '../../../../platform/request/common/request.js' ;
38
38
import { IStorageService , StorageScope , StorageTarget } from '../../../../platform/storage/common/storage.js' ;
39
39
import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js' ;
40
- import { defaultButtonStyles , defaultCheckboxStyles } from '../../../../platform/theme/browser/defaultStyles.js' ;
40
+ import { defaultButtonStyles } from '../../../../platform/theme/browser/defaultStyles.js' ;
41
41
import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js' ;
42
42
import { IWorkbenchContribution } from '../../../common/contributions.js' ;
43
43
import { IViewDescriptorService , ViewContainerLocation } from '../../../common/views.js' ;
@@ -55,7 +55,6 @@ import { ChatViewId, EditsViewId, ensureSideBarChatViewSize, IChatWidget, showCh
55
55
import { CHAT_EDITING_SIDEBAR_PANEL_ID , CHAT_SIDEBAR_PANEL_ID } from './chatViewPane.js' ;
56
56
import { ChatViewsWelcomeExtensions , IChatViewsWelcomeContributionRegistry } from './viewsWelcome/chatViewsWelcome.js' ;
57
57
import { IChatQuotasService } from './chatQuotasService.js' ;
58
- import { Checkbox } from '../../../../base/browser/ui/toggle/toggle.js' ;
59
58
import { mainWindow } from '../../../../base/browser/window.js' ;
60
59
61
60
const defaultChat = {
@@ -65,7 +64,6 @@ const defaultChat = {
65
64
termsStatementUrl : product . defaultChatAgent ?. termsStatementUrl ?? '' ,
66
65
privacyStatementUrl : product . defaultChatAgent ?. privacyStatementUrl ?? '' ,
67
66
skusDocumentationUrl : product . defaultChatAgent ?. skusDocumentationUrl ?? '' ,
68
- publicCodeMatchesUrl : product . defaultChatAgent ?. publicCodeMatchesUrl ?? '' ,
69
67
providerId : product . defaultChatAgent ?. providerId ?? '' ,
70
68
providerName : product . defaultChatAgent ?. providerName ?? '' ,
71
69
providerScopes : product . defaultChatAgent ?. providerScopes ?? [ [ ] ] ,
@@ -88,8 +86,6 @@ enum ChatEntitlement {
88
86
Pro
89
87
}
90
88
91
- const ASK_FOR_PUBLIC_CODE_MATCHES = false ; // TODO@bpasero revisit this
92
-
93
89
//#region Contribution
94
90
95
91
const TRIGGER_SETUP_COMMAND_ID = 'workbench.action.chat.triggerSetup' ;
@@ -158,10 +154,7 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
158
154
f1 : true ,
159
155
precondition : ContextKeyExpr . and (
160
156
ChatContextKeys . Setup . installed . negate ( ) ,
161
- ContextKeyExpr . or (
162
- ChatContextKeys . Setup . entitled ,
163
- ContextKeyExpr . has ( 'config.chat.experimental.offerSetup' )
164
- )
157
+ ContextKeyExpr . has ( 'config.chat.experimental.offerSetup' )
165
158
) ,
166
159
menu : {
167
160
id : MenuId . ChatCommandCenter ,
@@ -183,9 +176,9 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
183
176
showCopilotView ( viewsService , layoutService ) ;
184
177
ensureSideBarChatViewSize ( 400 , viewDescriptorService , layoutService ) ;
185
178
186
- if ( startSetup === true && ! ASK_FOR_PUBLIC_CODE_MATCHES ) {
179
+ if ( startSetup === true ) {
187
180
const controller = that . controller . value ;
188
- controller . setup ( { publicCodeSuggestions : true } ) ;
181
+ controller . setup ( ) ;
189
182
}
190
183
191
184
configurationService . updateValue ( 'chat.commandCenter.enabled' , true ) ;
@@ -205,10 +198,7 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
205
198
category : CHAT_CATEGORY ,
206
199
precondition : ContextKeyExpr . and (
207
200
ChatContextKeys . Setup . installed . negate ( ) ,
208
- ContextKeyExpr . or (
209
- ChatContextKeys . Setup . entitled ,
210
- ContextKeyExpr . has ( 'config.chat.experimental.offerSetup' )
211
- )
201
+ ContextKeyExpr . has ( 'config.chat.experimental.offerSetup' )
212
202
) ,
213
203
menu : {
214
204
id : MenuId . ChatCommandCenter ,
@@ -521,10 +511,10 @@ class ChatSetupRequests extends Disposable {
521
511
return this . resolveEntitlement ( session , CancellationToken . None ) ;
522
512
}
523
513
524
- async signUpLimited ( session : AuthenticationSession , options : { publicCodeSuggestions : boolean } ) : Promise < boolean > {
514
+ async signUpLimited ( session : AuthenticationSession ) : Promise < boolean > {
525
515
const body = {
526
516
restricted_telemetry : 'disabled' ,
527
- public_code_suggestions : options . publicCodeSuggestions ? 'enabled' : 'disabled '
517
+ public_code_suggestions : 'enabled'
528
518
} ;
529
519
530
520
const response = await this . request ( defaultChat . entitlementSignupLimitedUrl , 'POST' , body , session , CancellationToken . None ) ;
@@ -637,7 +627,7 @@ class ChatSetupController extends Disposable {
637
627
this . _onDidChange . fire ( ) ;
638
628
}
639
629
640
- async setup ( options : { publicCodeSuggestions : boolean } ) : Promise < void > {
630
+ async setup ( ) : Promise < void > {
641
631
const title = localize ( 'setupChatProgress' , "Getting Copilot ready..." ) ;
642
632
const badge = this . activityService . showViewContainerActivity ( isCopilotEditsViewActive ( this . viewsService ) ? CHAT_EDITING_SIDEBAR_PANEL_ID : CHAT_SIDEBAR_PANEL_ID , {
643
633
badge : new ProgressBadge ( ( ) => title ) ,
@@ -649,14 +639,16 @@ class ChatSetupController extends Disposable {
649
639
location : ProgressLocation . Window ,
650
640
command : TRIGGER_SETUP_COMMAND_ID ,
651
641
title,
652
- } , ( ) => this . doSetup ( options ) ) ;
642
+ } , ( ) => this . doSetup ( ) ) ;
653
643
} finally {
654
644
badge . dispose ( ) ;
655
645
}
656
646
}
657
647
658
- private async doSetup ( options : { publicCodeSuggestions : boolean } ) : Promise < void > {
648
+ private async doSetup ( ) : Promise < void > {
659
649
this . context . suspend ( ) ; // reduces flicker
650
+
651
+ let focusChatInput = false ;
660
652
try {
661
653
let session : AuthenticationSession | undefined ;
662
654
let entitlement : ChatEntitlement | undefined ;
@@ -680,20 +672,30 @@ class ChatSetupController extends Disposable {
680
672
}
681
673
}
682
674
675
+ const activeElement = getActiveElement ( ) ;
676
+
683
677
// Install
684
678
this . setStep ( ChatSetupStep . Installing ) ;
685
- await this . install ( session , entitlement ?? this . context . state . entitlement , options ) ;
679
+ await this . install ( session , entitlement ?? this . context . state . entitlement ) ;
680
+
681
+ const currentActiveElement = getActiveElement ( ) ;
682
+ focusChatInput = activeElement === currentActiveElement || currentActiveElement === mainWindow . document . body ;
686
683
} finally {
687
684
this . setStep ( ChatSetupStep . Initial ) ;
688
685
this . context . resume ( ) ;
689
686
}
687
+
688
+ if ( focusChatInput ) {
689
+ ( await showCopilotView ( this . viewsService , this . layoutService ) ) ?. focusInput ( ) ;
690
+ }
690
691
}
691
692
692
693
private async signIn ( ) : Promise < { session : AuthenticationSession | undefined ; entitlement : ChatEntitlement | undefined } > {
693
694
let session : AuthenticationSession | undefined ;
694
695
let entitlement : ChatEntitlement | undefined ;
695
696
try {
696
697
showCopilotView ( this . viewsService , this . layoutService ) ;
698
+
697
699
session = await this . authenticationService . createSession ( defaultChat . providerId , defaultChat . providerScopes [ 0 ] ) ;
698
700
entitlement = await this . requests . forceResolveEntitlement ( session ) ;
699
701
} catch ( error ) {
@@ -707,9 +709,8 @@ class ChatSetupController extends Disposable {
707
709
return { session, entitlement } ;
708
710
}
709
711
710
- private async install ( session : AuthenticationSession , entitlement : ChatEntitlement , options : { publicCodeSuggestions : boolean } ) : Promise < void > {
712
+ private async install ( session : AuthenticationSession , entitlement : ChatEntitlement , ) : Promise < void > {
711
713
const signedIn = ! ! session ;
712
- const activeElement = getActiveElement ( ) ;
713
714
714
715
let installResult : 'installed' | 'cancelled' | 'failedInstall' | undefined = undefined ;
715
716
const wasInstalled = this . context . state . installed ;
@@ -718,7 +719,7 @@ class ChatSetupController extends Disposable {
718
719
showCopilotView ( this . viewsService , this . layoutService ) ;
719
720
720
721
if ( entitlement !== ChatEntitlement . Limited && entitlement !== ChatEntitlement . Pro && entitlement !== ChatEntitlement . Unavailable ) {
721
- didSignUp = await this . requests . signUpLimited ( session , options ) ;
722
+ didSignUp = await this . requests . signUpLimited ( session ) ;
722
723
}
723
724
724
725
await this . extensionsWorkbenchService . install ( defaultChat . extensionId , {
@@ -747,11 +748,6 @@ class ChatSetupController extends Disposable {
747
748
}
748
749
749
750
this . telemetryService . publicLog2 < InstallChatEvent , InstallChatClassification > ( 'commandCenter.chatInstall' , { installResult, signedIn } ) ;
750
-
751
- const currentActiveElement = getActiveElement ( ) ;
752
- if ( activeElement === currentActiveElement || currentActiveElement === mainWindow . document . body ) {
753
- ( await showCopilotView ( this . viewsService , this . layoutService ) ) ?. focusInput ( ) ;
754
- }
755
751
}
756
752
}
757
753
@@ -802,18 +798,14 @@ class ChatSetupWelcomeContent extends Disposable {
802
798
}
803
799
804
800
// Limited SKU
805
- const limitedSkuHeader = localize ( { key : 'limitedSkuHeader' , comment : [ '{Locked="[]({0})"}' ] } , "$(sparkle-filled) We now offer [Copilot for free]({0})." , defaultChat . skusDocumentationUrl ) ;
801
+ const limitedSkuHeader = localize ( { key : 'limitedSkuHeader' , comment : [ '{Locked="[]({0})"}' ] } , "$(sparkle-filled) We now offer [Copilot for free]({0}) with 50 chat messages and 2000 code completions per month ." , defaultChat . skusDocumentationUrl ) ;
806
802
const limitedSkuHeaderContainer = this . element . appendChild ( $ ( 'p' ) ) ;
807
803
limitedSkuHeaderContainer . appendChild ( this . _register ( markdown . render ( new MarkdownString ( limitedSkuHeader , { isTrusted : true , supportThemeIcons : true } ) ) ) . element ) ;
808
804
809
- const publicCodeSuggestionsLabel = localize ( 'detectionLabel' , "Allow code suggestions that [match public code]({0})" , defaultChat . publicCodeMatchesUrl ) ;
810
- const { container : publicCodeSuggestionsContainer , checkbox : publicCodeSuggestionsCheckbox } = this . createCheckBox ( publicCodeSuggestionsLabel , true , markdown ) ;
811
-
812
805
// Terms
813
806
const terms = localize ( { key : 'termsLabel' , comment : [ '{Locked="["}' , '{Locked="]({0})"}' , '{Locked="]({1})"}' ] } , "By continuing, you agree to our [Terms]({0}) and [Privacy Policy]({1})." , defaultChat . termsStatementUrl , defaultChat . privacyStatementUrl ) ;
814
807
const termsContainer = this . element . appendChild ( $ ( 'p' ) ) ;
815
808
termsContainer . classList . add ( 'terms-container' ) ;
816
- termsContainer . classList . toggle ( 'is-standalone' , ! ASK_FOR_PUBLIC_CODE_MATCHES ) ;
817
809
termsContainer . appendChild ( this . _register ( markdown . render ( new MarkdownString ( terms , { isTrusted : true } ) ) ) . element ) ;
818
810
819
811
// Setup Button
@@ -833,30 +825,13 @@ class ChatSetupWelcomeContent extends Disposable {
833
825
supportIcons : true ,
834
826
...defaultButtonStyles
835
827
} ) ) ;
836
- this . _register ( button . onDidClick ( ( ) => this . controller . setup ( { publicCodeSuggestions : ASK_FOR_PUBLIC_CODE_MATCHES ? publicCodeSuggestionsCheckbox . checked : true } ) ) ) ;
828
+ this . _register ( button . onDidClick ( ( ) => this . controller . setup ( ) ) ) ;
837
829
838
830
// Update based on model state
839
- this . _register ( Event . runAndSubscribe ( this . controller . onDidChange , ( ) => this . update ( limitedSkuHeaderContainer , button , [ publicCodeSuggestionsContainer ] , [ publicCodeSuggestionsCheckbox ] ) ) ) ;
831
+ this . _register ( Event . runAndSubscribe ( this . controller . onDidChange , ( ) => this . update ( limitedSkuHeaderContainer , button ) ) ) ;
840
832
}
841
833
842
- private createCheckBox ( label : string , checked : boolean , markdown : MarkdownRenderer ) : { container : HTMLElement ; checkbox : Checkbox } {
843
- const container = this . element . appendChild ( $ ( 'p.checkbox-container' ) ) ;
844
- const checkbox = this . _register ( new Checkbox ( label , checked , defaultCheckboxStyles ) ) ;
845
- container . appendChild ( checkbox . domNode ) ;
846
-
847
- const checkboxLabel = container . appendChild ( this . _register ( markdown . render ( new MarkdownString ( label , { isTrusted : true , supportThemeIcons : true } ) , { inline : true , className : 'checkbox-label' } ) ) . element ) ;
848
- this . _register ( addDisposableListener ( checkboxLabel , EventType . CLICK , e => {
849
- if ( checkbox ?. enabled && ( e . target as HTMLElement ) . tagName !== 'A' ) {
850
- checkbox . checked = ! checkbox . checked ;
851
- checkbox . focus ( ) ;
852
- }
853
- } ) ) ;
854
-
855
- return { container, checkbox } ;
856
- }
857
-
858
- private update ( limitedSkuHeaderContainer : HTMLElement , button : Button | ButtonWithDropdown , limitedCheckboxContainers : HTMLElement [ ] , limitedCheckboxes : Checkbox [ ] ) : void {
859
- const showLimitedCheckboxes = ASK_FOR_PUBLIC_CODE_MATCHES ? this . context . state . entitlement !== ChatEntitlement . Limited && this . context . state . entitlement !== ChatEntitlement . Pro && this . context . state . entitlement !== ChatEntitlement . Unavailable : false ;
834
+ private update ( limitedSkuHeaderContainer : HTMLElement , button : Button | ButtonWithDropdown ) : void {
860
835
let showLimitedSkuHeader : boolean ;
861
836
let buttonLabel : string ;
862
837
@@ -882,27 +857,15 @@ class ChatSetupWelcomeContent extends Disposable {
882
857
}
883
858
884
859
switch ( this . controller . step ) {
885
- case ChatSetupStep . Initial :
886
- for ( const checkbox of limitedCheckboxes ) {
887
- checkbox . enable ( ) ;
888
- }
889
- break ;
890
860
case ChatSetupStep . SigningIn :
891
- for ( const checkbox of limitedCheckboxes ) {
892
- checkbox . disable ( ) ;
893
- }
894
861
buttonLabel = localize ( 'setupChatSignIn' , "$(loading~spin) Signing in to {0}..." , defaultChat . providerName ) ;
895
862
break ;
896
863
case ChatSetupStep . Installing :
897
- for ( const checkbox of limitedCheckboxes ) {
898
- checkbox . disable ( ) ;
899
- }
900
864
buttonLabel = localize ( 'setupChatInstalling' , "$(loading~spin) Getting Copilot Ready..." ) ;
901
865
break ;
902
866
}
903
867
904
868
setVisibility ( showLimitedSkuHeader , limitedSkuHeaderContainer ) ;
905
- setVisibility ( showLimitedCheckboxes , ...limitedCheckboxContainers ) ;
906
869
907
870
button . label = buttonLabel ;
908
871
button . enabled = this . controller . step === ChatSetupStep . Initial ;
@@ -926,7 +889,6 @@ class ChatSetupContext extends Disposable {
926
889
927
890
private readonly canSignUpContextKey = ChatContextKeys . Setup . canSignUp . bindTo ( this . contextKeyService ) ;
928
891
private readonly signedOutContextKey = ChatContextKeys . Setup . signedOut . bindTo ( this . contextKeyService ) ;
929
- private readonly entitledContextKey = ChatContextKeys . Setup . entitled . bindTo ( this . contextKeyService ) ;
930
892
private readonly limitedContextKey = ChatContextKeys . Setup . limited . bindTo ( this . contextKeyService ) ;
931
893
private readonly triggeredContext = ChatContextKeys . Setup . triggered . bindTo ( this . contextKeyService ) ;
932
894
private readonly installedContext = ChatContextKeys . Setup . installed . bindTo ( this . contextKeyService ) ;
@@ -1031,7 +993,6 @@ class ChatSetupContext extends Disposable {
1031
993
changed = this . updateContextKey ( this . signedOutContextKey , this . _state . entitlement === ChatEntitlement . Unknown ) || changed ;
1032
994
changed = this . updateContextKey ( this . canSignUpContextKey , this . _state . entitlement === ChatEntitlement . Available ) || changed ;
1033
995
changed = this . updateContextKey ( this . limitedContextKey , this . _state . entitlement === ChatEntitlement . Limited ) || changed ;
1034
- changed = this . updateContextKey ( this . entitledContextKey , this . _state . entitlement === ChatEntitlement . Pro ) || changed ;
1035
996
changed = this . updateContextKey ( this . triggeredContext , ! ! this . _state . triggered ) || changed ;
1036
997
changed = this . updateContextKey ( this . installedContext , ! ! this . _state . installed ) || changed ;
1037
998
0 commit comments