File tree Expand file tree Collapse file tree 6 files changed +28
-18
lines changed Expand file tree Collapse file tree 6 files changed +28
-18
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,18 @@ import * as vscode from 'vscode'
6
6
import { CommandDeclarations , Commands } from '../../shared/vscode/commands2'
7
7
import { showCodeWhispererWebview , CodeWhispererSource } from '../vue/backend'
8
8
import { telemetry } from '../../shared/telemetry/telemetry'
9
+ import { PromptSettings } from '../../shared/settings'
9
10
/**
10
11
* The methods with backend logic for the Codewhisperer Getting Started Page commands.
11
12
*/
12
13
export class CodeWhispererCommandBackend {
13
14
constructor ( private readonly extContext : vscode . ExtensionContext ) { }
14
- public showGettingStartedPage ( source : CodeWhispererSource ) {
15
- telemetry . ui_click . emit ( { elementId : 'codewhisperer_Learn_ButtonClick' , passive : true } )
15
+ public async showGettingStartedPage ( source : CodeWhispererSource ) {
16
+ const prompts = PromptSettings . instance
17
+ //To check the condition If the user has already seen the welcome message
18
+ if ( ! ( await prompts . isPromptEnabled ( 'codeWhispererNewWelcomeMessage' ) ) ) {
19
+ telemetry . ui_click . emit ( { elementId : 'codewhisperer_Learn_ButtonClick' , passive : true } )
20
+ }
16
21
return showCodeWhispererWebview ( this . extContext , source )
17
22
}
18
23
}
Original file line number Diff line number Diff line change @@ -135,17 +135,19 @@ export class RecommendationHandler {
135
135
}
136
136
}
137
137
138
- async getTaskTypeFromEditorFileName ( fileName : string ) : Promise < CodewhispererGettingStartedTask > {
139
- if ( fileName . startsWith ( 'CodeWhisperer_generate_suggestion' ) ) {
138
+ async getTaskTypeFromEditorFileName ( filePath : string ) : Promise < CodewhispererGettingStartedTask | undefined > {
139
+ if ( filePath . includes ( 'CodeWhisperer_generate_suggestion' ) ) {
140
140
return 'autoTrigger'
141
- } else if ( fileName . startsWith ( 'CodeWhisperer_manual_invoke' ) ) {
141
+ } else if ( filePath . includes ( 'CodeWhisperer_manual_invoke' ) ) {
142
142
return 'manualTrigger'
143
- } else if ( fileName . startsWith ( 'CodeWhisperer_use_comments' ) ) {
143
+ } else if ( filePath . includes ( 'CodeWhisperer_use_comments' ) ) {
144
144
return 'commentAsPrompt'
145
- } else if ( fileName . startsWith ( 'CodeWhisperer_navigate_suggestions' ) ) {
145
+ } else if ( filePath . includes ( 'CodeWhisperer_navigate_suggestions' ) ) {
146
146
return 'navigation'
147
- } else {
147
+ } else if ( filePath . includes ( 'Generate_unit_tests' ) ) {
148
148
return 'unitTest'
149
+ } else {
150
+ return undefined
149
151
}
150
152
}
151
153
Original file line number Diff line number Diff line change @@ -72,7 +72,10 @@ export class AuthUtil {
72
72
vscode . commands . executeCommand ( 'aws.codeWhisperer.refreshStatusBar' ) ,
73
73
vscode . commands . executeCommand ( 'aws.codeWhisperer.updateReferenceLog' ) ,
74
74
] )
75
- await vscode . commands . executeCommand ( 'aws.codeWhisperer.enableCodeSuggestions' )
75
+ // To check valid connection
76
+ if ( this . isValidEnterpriseSsoInUse ( ) || ( this . isBuilderIdInUse ( ) && ! this . isConnectionExpired ( ) ) ) {
77
+ await vscode . commands . executeCommand ( 'aws.codeWhisperer.enableCodeSuggestions' )
78
+ }
76
79
await vscode . commands . executeCommand ( 'setContext' , 'CODEWHISPERER_ENABLED' , this . isConnected ( ) )
77
80
} )
78
81
}
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class CodeWhispererSession {
26
26
supplementalMetadata : Omit < CodeWhispererSupplementalContext , 'supplementalContextItems' > | undefined
27
27
} = { request : { } as any , supplementalMetadata : { } as any }
28
28
language : CodewhispererLanguage = 'java'
29
- taskType : CodewhispererGettingStartedTask = 'autoTrigger'
29
+ taskType : CodewhispererGettingStartedTask | undefined
30
30
// Various states of recommendations
31
31
recommendations : Recommendation [ ] = [ ]
32
32
suggestionStates = new Map < number , string > ( )
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import globals from '../../shared/extensionGlobals'
13
13
import { telemetry , CodewhispererLanguage , CodewhispererGettingStartedTask } from '../../shared/telemetry/telemetry'
14
14
import { FileSystemCommon } from '../../srcShared/fs'
15
15
import { getLogger } from '../../shared/logger'
16
+ import { PromptSettings } from '../../shared/settings'
16
17
export type OSType = 'Mac' | 'RestOfOS'
17
18
export class CodeWhispererWebview extends VueWebview {
18
19
public readonly id = 'CodeWhispererWebview'
@@ -156,5 +157,12 @@ export async function showCodeWhispererWebview(
156
157
subscriptions = undefined
157
158
} ) ,
158
159
]
160
+ const prompts = PromptSettings . instance
161
+ //To check the condition If the user has already seen the welcome message
162
+ if ( await prompts . isPromptEnabled ( 'codeWhispererNewWelcomeMessage' ) ) {
163
+ telemetry . ui_click . emit ( { elementId : 'codewhisperer_Learn_PageOpen' , passive : true } )
164
+ } else {
165
+ telemetry . ui_click . emit ( { elementId : 'codewhisperer_Learn_PageOpen' , passive : false } )
166
+ }
159
167
}
160
168
}
Original file line number Diff line number Diff line change @@ -81,10 +81,6 @@ import Shortcuts from './shortcuts.vue'
81
81
import ScanCode from ' ./scanCode.vue'
82
82
import GenerateSuggestionTab from ' ./genSuggestionTab.vue'
83
83
import Workshop from ' ./workshop.vue'
84
- import { CodeWhispererWebview } from ' ./backend'
85
- import { WebviewClientFactory } from ' ../../webviews/client'
86
-
87
- const client = WebviewClientFactory .create <CodeWhispererWebview >()
88
84
89
85
export default defineComponent ({
90
86
name: ' Getting_Started' ,
@@ -101,10 +97,6 @@ export default defineComponent({
101
97
active: parseInt (sessionStorage .getItem (' active' ) || ' 0' ),
102
98
}
103
99
},
104
- // The created hook runs before the templates and Virtual DOM have been mounted or rendered
105
- created() {
106
- client .emitUiClick (' codewhisperer_Learn_PageOpen' )
107
- },
108
100
mounted() {
109
101
/*
110
102
We use Session Storage here because we need to store the the first time signin user and Existing first time signin state globally. According to this we need to display the banner.
You can’t perform that action at this time.
0 commit comments