@@ -72,6 +72,7 @@ export default class MDBExtensionController implements vscode.Disposable {
7272 _editDocumentCodeLensProvider : EditDocumentCodeLensProvider ;
7373 _exportToLanguageCodeLensProvider : ExportToLanguageCodeLensProvider ;
7474 _participantController : ParticipantController ;
75+ _startupNotificationShown = false ;
7576
7677 constructor (
7778 context : vscode . ExtensionContext ,
@@ -166,6 +167,7 @@ export default class MDBExtensionController implements vscode.Disposable {
166167 this . registerCommands ( ) ;
167168 this . showOverviewPageIfRecentlyInstalled ( ) ;
168169 void this . showSurveyForEstablishedUsers ( ) ;
170+ void this . showCopilotIntroductionForEstablishedUsers ( ) ;
169171 }
170172
171173 registerCommands = ( ) : void => {
@@ -909,23 +911,82 @@ export default class MDBExtensionController implements vscode.Disposable {
909911 }
910912 }
911913
914+ async showCopilotIntroductionForEstablishedUsers ( ) : Promise < void > {
915+ const copilotIntroductionShown =
916+ this . _storageController . get (
917+ StorageVariables . GLOBAL_COPILOT_INTRODUCTION_SHOWN
918+ ) === true ;
919+
920+ // Show the toast when startup notifications have not been shown
921+ // to the user yet and they have saved connections
922+ // -> they haven't just started using this extension.
923+ if (
924+ this . _startupNotificationShown ||
925+ copilotIntroductionShown ||
926+ ! this . _connectionStorage . hasSavedConnections ( )
927+ ) {
928+ return ;
929+ }
930+
931+ this . _startupNotificationShown = true ;
932+
933+ const action = 'Chat with @MongoDB' ;
934+ const text =
935+ 'Generate queries, interact with documentation, and explore your database schema using the MongoDB Copilot extension. Give it a try!' ;
936+ const result = await vscode . window . showInformationMessage (
937+ text ,
938+ { } ,
939+ {
940+ title : action ,
941+ }
942+ ) ;
943+
944+ const copilot = vscode . extensions . getExtension ( 'github.copilot-chat' ) ;
945+ if ( result ?. title === action ) {
946+ await vscode . commands . executeCommand ( 'workbench.action.chat.newChat' ) ;
947+ await vscode . commands . executeCommand (
948+ 'workbench.action.chat.clearHistory'
949+ ) ;
950+ await vscode . commands . executeCommand ( 'workbench.action.chat.open' , {
951+ query : '@MongoDB' ,
952+ isPartialQuery : true ,
953+ } ) ;
954+ this . _telemetryService . trackCopilotIntroductionClicked ( {
955+ is_copilot_active : ! ! copilot ?. isActive ,
956+ } ) ;
957+ } else {
958+ this . _telemetryService . trackCopilotIntroductionDismissed ( {
959+ is_copilot_active : ! ! copilot ?. isActive ,
960+ } ) ;
961+ }
962+
963+ // Whether action was taken or the prompt dismissed, we won't show this again.
964+ void this . _storageController . update (
965+ StorageVariables . GLOBAL_COPILOT_INTRODUCTION_SHOWN ,
966+ true
967+ ) ;
968+ }
969+
912970 async showSurveyForEstablishedUsers ( ) : Promise < void > {
913971 const surveyId = '9viN9wcbsC3zvHyg7' ;
914972
915973 const hasBeenShownSurveyAlready =
916974 this . _storageController . get ( StorageVariables . GLOBAL_SURVEY_SHOWN ) ===
917975 surveyId ;
918976
919- // Show the survey when it hasn't been show to the
920- // user yet, and they have saved connections
977+ // Show the toast when startup notifications have not been shown
978+ // to the user yet and they have saved connections
921979 // -> they haven't just started using this extension
922980 if (
981+ this . _startupNotificationShown ||
923982 hasBeenShownSurveyAlready ||
924983 ! this . _connectionStorage . hasSavedConnections ( )
925984 ) {
926985 return ;
927986 }
928987
988+ this . _startupNotificationShown = true ;
989+
929990 const action = 'Share your thoughts' ;
930991 const text = 'How can we make the MongoDB extension better for you?' ;
931992 const link = 'https://forms.gle/9viN9wcbsC3zvHyg7' ;
0 commit comments