@@ -53,64 +53,11 @@ import { LineTracker } from '../app/inline/stateTracker/lineTracker'
5353import { InlineTutorialAnnotation } from '../app/inline/tutorials/inlineTutorialAnnotation'
5454import { InlineChatTutorialAnnotation } from '../app/inline/tutorials/inlineChatTutorialAnnotation'
5555import { codeReviewInChat } from '../app/amazonqScan/models/constants'
56- import { AutoDebugFeature } from '../lsp/autoDebug'
57- import { autoDebugRetryConfig } from '../lsp/autoDebug/constants'
58-
59- // Module-level registry for AutoDebug feature
60- let registeredAutoDebugFeature : AutoDebugFeature | undefined
61-
62- export function registerAutoDebugFeature ( feature : AutoDebugFeature ) {
63- registeredAutoDebugFeature = feature
64- }
65-
66- export function getRegisteredAutoDebugFeature ( ) : AutoDebugFeature | undefined {
67- return registeredAutoDebugFeature
68- }
56+ import { activateAutoDebug } from './autoDebug/activation'
6957
7058const localize = nls . loadMessageBundle ( )
7159const logger = getLogger ( 'amazonqLsp.lspClient' )
7260
73- interface RetryOptions {
74- maxAttempts : number
75- initialDelayMs : number
76- maxDelayMs : number
77- backoffMultiplier : number
78- onRetry ?: ( attempt : number , error : Error ) => void
79- onFailure ?: ( attempts : number , lastError : Error ) => void
80- }
81-
82- /**
83- * Retry a function with exponential backoff
84- */
85- async function retryWithExponentialBackoff < T > ( fn : ( ) => T | Promise < T > , options : RetryOptions ) : Promise < T > {
86- const { maxAttempts, initialDelayMs, maxDelayMs, backoffMultiplier, onRetry, onFailure } = options
87-
88- let lastError : Error
89-
90- for ( let attempt = 1 ; attempt <= maxAttempts ; attempt ++ ) {
91- try {
92- return await fn ( )
93- } catch ( error ) {
94- lastError = error instanceof Error ? error : new Error ( String ( error ) )
95-
96- if ( attempt === maxAttempts ) {
97- onFailure ?.( attempt , lastError )
98- throw lastError
99- }
100-
101- onRetry ?.( attempt , lastError )
102-
103- // Calculate delay with exponential backoff
104- const delay = Math . min ( initialDelayMs * Math . pow ( backoffMultiplier , attempt - 1 ) , maxDelayMs )
105-
106- await new Promise ( ( resolve ) => setTimeout ( resolve , delay ) )
107- }
108- }
109-
110- // This should never be reached, but TypeScript requires it
111- throw lastError !
112- }
113-
11461export function hasGlibcPatch ( ) : boolean {
11562 // Skip GLIBC patching for SageMaker environments
11663 if ( isSageMaker ( ) ) {
@@ -396,48 +343,12 @@ async function onLanguageServerReady(
396343 await activate ( client , encryptionKey , resourcePaths . ui )
397344 }
398345
399- // Connect AutoDebug feature to the language client
346+ // Activate AutoDebug feature with direct LSP client connection
400347 try {
401- getLogger ( 'amazonqLsp' ) . debug ( 'Attempting to connect AutoDebug feature to language client' )
402-
403- await retryWithExponentialBackoff (
404- ( ) => {
405- const autoDebugFeature = getRegisteredAutoDebugFeature ( )
406- if ( ! autoDebugFeature ) {
407- throw new Error ( 'AutoDebug feature not registered' )
408- }
409- const controller = autoDebugFeature . getController ( )
410- if ( ! controller ) {
411- throw new Error ( 'AutoDebug controller not available' )
412- }
413- controller . setLanguageClient ( client )
414- getLogger ( 'amazonqLsp' ) . debug ( 'AutoDebug feature connected successfully' )
415- } ,
416- {
417- maxAttempts : autoDebugRetryConfig . maxAttempts ,
418- initialDelayMs : autoDebugRetryConfig . initialDelayMs ,
419- maxDelayMs : autoDebugRetryConfig . maxDelayMs ,
420- backoffMultiplier : autoDebugRetryConfig . backoffMultiplier ,
421- onRetry : ( attempt , error ) => {
422- getLogger ( 'amazonqLsp' ) . debug (
423- 'AutoDebug connection attempt %d failed: %s. Retrying...' ,
424- attempt ,
425- error . message
426- )
427- } ,
428- onFailure : ( attempts , lastError ) => {
429- getLogger ( 'amazonqLsp' ) . error (
430- 'AutoDebug feature not found after %d attempts - integration will not work. ' +
431- 'This may indicate that the AutoDebug feature failed to activate or there is a timing issue. ' +
432- 'Last error: %s' ,
433- attempts ,
434- lastError . message
435- )
436- } ,
437- }
438- )
348+ const autoDebugFeature = await activateAutoDebug ( extensionContext , client , encryptionKey )
349+ toDispose . push ( autoDebugFeature )
439350 } catch ( error ) {
440- getLogger ( 'amazonqLsp' ) . error ( 'Failed to connect AutoDebug feature to language client : %s' , error )
351+ getLogger ( 'amazonqLsp' ) . error ( 'Failed to activate AutoDebug feature: %s' , error )
441352 }
442353
443354 const refreshInterval = auth . startTokenRefreshInterval ( 10 * oneSecond )
0 commit comments