@@ -31,7 +31,12 @@ import {
3131 LSPErrorCodes ,
3232 updateConfigurationRequestType ,
3333} from '@aws/language-server-runtimes/protocol'
34- import { AuthUtil , CodeWhispererSettings , getSelectedCustomization } from 'aws-core-vscode/codewhisperer'
34+ import {
35+ AuthUtil ,
36+ CodeWhispererSettings ,
37+ getSelectedCustomization ,
38+ TelemetryHelper ,
39+ } from 'aws-core-vscode/codewhisperer'
3540import {
3641 Settings ,
3742 createServerOptions ,
@@ -46,13 +51,20 @@ import {
4651 openUrl ,
4752 getClientId ,
4853 extensionVersion ,
54+ Commands ,
4955} from 'aws-core-vscode/shared'
5056import { processUtils } from 'aws-core-vscode/shared'
5157import { activate as activateChat } from './chat/activation'
58+ import { activate as activeInlineChat } from '../inlineChat/activation'
5259import { AmazonQResourcePaths } from './lspInstaller'
5360import { auth2 } from 'aws-core-vscode/auth'
5461import { ConfigSection , isValidConfigSection , pushConfigUpdate , toAmazonQLSPLogLevel } from './config'
5562import { telemetry } from 'aws-core-vscode/telemetry'
63+ import { SessionManager } from '../app/inline/sessionManager'
64+ import { LineTracker } from '../app/inline/stateTracker/lineTracker'
65+ import { InlineChatTutorialAnnotation } from '../app/inline/tutorials/inlineChatTutorialAnnotation'
66+ import { InlineTutorialAnnotation } from '../app/inline/tutorials/inlineTutorialAnnotation'
67+ import { InlineCompletionManager } from '../app/inline/completion'
5668
5769const localize = nls . loadMessageBundle ( )
5870const logger = getLogger ( 'amazonqLsp.lspClient' )
@@ -181,7 +193,7 @@ export async function startLanguageServer(
181193 */
182194 await initializeAuth ( client )
183195
184- await postStartLanguageServer ( client , resourcePaths , toDispose )
196+ await postStartLanguageServer ( extensionContext , client , resourcePaths , toDispose )
185197
186198 return client
187199
@@ -210,7 +222,60 @@ export async function startLanguageServer(
210222 }
211223}
212224
225+ async function setupInline (
226+ extensionContext : vscode . ExtensionContext ,
227+ client : LanguageClient ,
228+ toDispose : vscode . Disposable [ ]
229+ ) {
230+ const sessionManager = new SessionManager ( )
231+ const lineTracker = new LineTracker ( )
232+ const inlineTutorialAnnotation = new InlineTutorialAnnotation ( lineTracker , sessionManager )
233+ const inlineChatTutorialAnnotation = new InlineChatTutorialAnnotation ( inlineTutorialAnnotation )
234+
235+ const inlineManager = new InlineCompletionManager ( client , sessionManager , lineTracker , inlineTutorialAnnotation )
236+
237+ inlineManager . registerInlineCompletion ( )
238+
239+ activeInlineChat ( extensionContext , client , encryptionKey , inlineChatTutorialAnnotation )
240+
241+ toDispose . push (
242+ inlineManager ,
243+ Commands . register ( { id : 'aws.amazonq.invokeInlineCompletion' , autoconnect : true } , async ( ) => {
244+ await vscode . commands . executeCommand ( 'editor.action.inlineSuggest.trigger' )
245+ } ) ,
246+ Commands . register ( 'aws.amazonq.refreshAnnotation' , async ( forceProceed : boolean ) => {
247+ telemetry . record ( {
248+ traceId : TelemetryHelper . instance . traceId ,
249+ } )
250+
251+ const editor = vscode . window . activeTextEditor
252+ if ( editor ) {
253+ if ( forceProceed ) {
254+ await inlineTutorialAnnotation . refresh ( editor , 'codewhisperer' , true )
255+ } else {
256+ await inlineTutorialAnnotation . refresh ( editor , 'codewhisperer' )
257+ }
258+ }
259+ } ) ,
260+ Commands . register ( 'aws.amazonq.dismissTutorial' , async ( ) => {
261+ const editor = vscode . window . activeTextEditor
262+ if ( editor ) {
263+ inlineTutorialAnnotation . clear ( )
264+ try {
265+ telemetry . ui_click . emit ( { elementId : `dismiss_${ inlineTutorialAnnotation . currentState . id } ` } )
266+ } catch ( _ ) { }
267+ await inlineTutorialAnnotation . dismissTutorial ( )
268+ getLogger ( ) . debug ( `codewhisperer: user dismiss tutorial.` )
269+ }
270+ } ) ,
271+ vscode . workspace . onDidCloseTextDocument ( async ( ) => {
272+ await vscode . commands . executeCommand ( 'aws.amazonq.rejectCodeSuggestion' )
273+ } )
274+ )
275+ }
276+
213277async function postStartLanguageServer (
278+ extensionContext : vscode . ExtensionContext ,
214279 client : LanguageClient ,
215280 resourcePaths : AmazonQResourcePaths ,
216281 toDispose : vscode . Disposable [ ]
@@ -308,23 +373,12 @@ async function postStartLanguageServer(
308373 )
309374 } )
310375
311- // if (Experiments.instance.get('amazonqLSPInline', false)) {
312- // const inlineManager = new InlineCompletionManager(client)
313- // inlineManager.registerInlineCompletion()
314- // toDispose.push(
315- // inlineManager,
316- // Commands.register({ id: 'aws.amazonq.invokeInlineCompletion', autoconnect: true }, async () => {
317- // await vscode.commands.executeCommand('editor.action.inlineSuggest.trigger')
318- // }),
319- // vscode.workspace.onDidCloseTextDocument(async () => {
320- // await vscode.commands.executeCommand('aws.amazonq.rejectCodeSuggestion')
321- // })
322- // )
323- // }
324376 if ( Experiments . instance . get ( 'amazonqChatLSP' , true ) ) {
325377 await activateChat ( client , encryptionKey , resourcePaths . ui )
326378 }
327379
380+ await setupInline ( extensionContext , client , toDispose )
381+
328382 toDispose . push (
329383 AuthUtil . instance . regionProfileManager . onDidChangeRegionProfile ( sendProfileToLsp ) ,
330384 vscode . commands . registerCommand ( 'aws.amazonq.getWorkspaceId' , async ( ) => {
0 commit comments