@@ -49,8 +49,6 @@ export class AutoDebugController implements vscode.Disposable {
4949 public readonly onSessionEnded = new vscode . EventEmitter < string > ( )
5050
5151 constructor ( config ?: Partial < AutoDebugConfig > , client ?: any , encryptionKey ?: Buffer ) {
52- this . logger . debug ( 'AutoDebugController: Initializing auto debug controller' )
53-
5452 this . config = {
5553 enabled : true ,
5654 autoReportThreshold : 1 , // Report when 1 or more errors detected
@@ -66,7 +64,6 @@ export class AutoDebugController implements vscode.Disposable {
6664 this . errorFormatter = new ErrorContextFormatter ( )
6765 this . lspClient = new AutoDebugLspClient ( client , encryptionKey )
6866
69- this . setupEventHandlers ( )
7067 this . disposables . push (
7168 this . diagnosticsMonitor ,
7269 this . onProblemsDetected ,
@@ -105,8 +102,6 @@ export class AutoDebugController implements vscode.Disposable {
105102 return
106103 }
107104 const sessionId = this . currentSession . id
108- this . logger . debug ( 'AutoDebugController: Ending session %s' , sessionId )
109-
110105 this . currentSession = undefined
111106 this . onSessionEnded . fire ( sessionId )
112107 }
@@ -123,12 +118,10 @@ export class AutoDebugController implements vscode.Disposable {
123118 */
124119 public async detectProblems ( ) : Promise < Problem [ ] > {
125120 if ( ! this . config . enabled ) {
126- this . logger . debug ( 'AutoDebugController: Auto debug is disabled' )
127121 return [ ]
128122 }
129123
130124 if ( ! this . currentSession ) {
131- this . logger . debug ( 'AutoDebugController: No active session, starting new one' )
132125 await this . startSession ( )
133126 }
134127
@@ -144,7 +137,6 @@ export class AutoDebugController implements vscode.Disposable {
144137 const filteredProblems = this . filterProblems ( newProblems )
145138
146139 if ( filteredProblems . length > 0 ) {
147- this . logger . debug ( 'AutoDebugController: Detected %d new problems' , filteredProblems . length )
148140 this . onProblemsDetected . fire ( filteredProblems )
149141 }
150142
@@ -155,8 +147,6 @@ export class AutoDebugController implements vscode.Disposable {
155147 * Creates formatted error contexts for AI debugging
156148 */
157149 public async createErrorContexts ( problems : Problem [ ] ) : Promise < ErrorContext [ ] > {
158- this . logger . debug ( 'AutoDebugController: Creating error contexts for %d problems' , problems . length )
159-
160150 const contexts : ErrorContext [ ] = [ ]
161151
162152 for ( const problem of problems ) {
@@ -167,17 +157,13 @@ export class AutoDebugController implements vscode.Disposable {
167157 this . logger . warn ( 'AutoDebugController: Failed to create context for problem: %s' , error )
168158 }
169159 }
170-
171- this . logger . debug ( 'AutoDebugController: Created %d error contexts' , contexts . length )
172160 return contexts
173161 }
174162
175163 /**
176164 * Formats problems for display or AI consumption
177165 */
178166 public formatProblemsForChat ( problems : Problem [ ] ) : string {
179- this . logger . debug ( 'AutoDebugController: Formatting %d problems for chat' , problems . length )
180-
181167 const cwd = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri . fsPath || process . cwd ( )
182168 return this . errorFormatter . formatProblemsString ( problems , cwd )
183169 }
@@ -205,23 +191,19 @@ export class AutoDebugController implements vscode.Disposable {
205191 */
206192 public updateConfig ( newConfig : Partial < AutoDebugConfig > ) : void {
207193 this . config = { ...this . config , ...newConfig }
208- this . logger . debug ( 'AutoDebugController: Configuration updated' )
209194 }
210195
211196 /**
212197 * Sets the language client for LSP communication
213198 */
214199 public setLanguageClient ( client : any ) : void {
215200 this . lspClient . setLanguageClient ( client )
216- this . logger . debug ( 'AutoDebugController: Language client set' )
217201 }
218202
219203 /**
220204 * Sends a chat message through the LSP client (public interface)
221205 */
222206 public async sendChatMessage ( message : string , source : string ) : Promise < void > {
223- this . logger . debug ( 'AutoDebugController: Public sendChatMessage called from source: %s' , source )
224-
225207 await this . sendMessageToChat ( message )
226208 }
227209
@@ -236,8 +218,6 @@ export class AutoDebugController implements vscode.Disposable {
236218 * Fix with Amazon Q - sends up to 15 error messages one time when user clicks the button
237219 */
238220 public async fixAllProblemsInFile ( maxProblems : number = 15 ) : Promise < void > {
239- this . logger . debug ( 'AutoDebugController: Starting single Fix with Amazon Q request' )
240-
241221 const editor = vscode . window . activeTextEditor
242222 if ( ! editor ) {
243223 void vscode . window . showWarningMessage ( 'No active editor found' )
@@ -261,19 +241,13 @@ export class AutoDebugController implements vscode.Disposable {
261241
262242 if ( errorDiagnostics . length === 0 ) {
263243 void vscode . window . showInformationMessage ( `✅ No errors found in ${ fileName } ` )
264- this . logger . debug ( 'AutoDebugController: No errors found in current file' )
265244 return
266245 }
267246
268247 // Take up to maxProblems errors (15 by default)
269248 const diagnosticsToFix = errorDiagnostics . slice ( 0 , maxProblems )
270249 const totalErrors = errorDiagnostics . length
271250 const errorsBeingSent = diagnosticsToFix . length
272-
273- this . logger . debug (
274- `AutoDebugController: Found ${ totalErrors } total errors, sending ${ errorsBeingSent } to Amazon Q`
275- )
276-
277251 // Convert diagnostics to problems
278252 const problems = diagnosticsToFix . map ( ( diagnostic ) => ( {
279253 uri : editor . document . uri ,
@@ -297,20 +271,9 @@ export class AutoDebugController implements vscode.Disposable {
297271 totalErrors ,
298272 errorsBeingSent
299273 )
300-
301- // Show progress message
302- void vscode . window . showInformationMessage (
303- `🔧 Sending ${ errorsBeingSent } error${ errorsBeingSent !== 1 ? 's' : '' } to Amazon Q for fixing...`
304- )
305-
306274 await this . sendChatMessage ( fixMessage , 'singleFix' )
307-
308- this . logger . debug ( 'AutoDebugController: Fix request sent successfully' )
309275 } catch ( error ) {
310276 this . logger . error ( 'AutoDebugController: Error in fix process: %s' , error )
311- void vscode . window . showErrorMessage (
312- `Error during fix process: ${ error instanceof Error ? error . message : 'Unknown error' } `
313- )
314277 }
315278 }
316279
@@ -349,7 +312,7 @@ export class AutoDebugController implements vscode.Disposable {
349312 }
350313
351314 parts . push ( '' )
352- parts . push ( 'Please fix the error in place in the file. ' )
315+ parts . push ( 'Please fix the error' )
353316
354317 if ( totalErrors > errorsBeingSent ) {
355318 parts . push (
@@ -366,17 +329,7 @@ export class AutoDebugController implements vscode.Disposable {
366329 */
367330 private async sendMessageToChat ( message : string ) : Promise < void > {
368331 const triggerID = randomUUID ( )
369- this . logger . debug (
370- 'AutoDebugController: Sending message directly to language server with triggerID: %s' ,
371- triggerID
372- )
373- this . logger . debug ( 'AutoDebugController: Message content: %s' , message . substring ( 0 , 200 ) )
374-
375332 try {
376- // **DIRECT LSP APPROACH**: Send directly to language server to avoid webview routing issues
377- // The previous approach was going through webview connectors which use the wrong format
378-
379- // Use the LSP client to send chat request directly to language server
380333 const success = await this . lspClient . sendChatMessage ( {
381334 message : message ,
382335 triggerType : 'autoDebug' ,
@@ -395,26 +348,13 @@ export class AutoDebugController implements vscode.Disposable {
395348 triggerID ,
396349 error
397350 )
398- this . logger . error (
399- 'AutoDebugController: Error stack: %s' ,
400- error instanceof Error ? error . stack : 'No stack trace'
401- )
402- throw error
403351 }
404352 }
405353
406354 /**
407355 * Automatically fixes problems using the language server
408356 */
409357 public async autoFixProblems ( problems : Problem [ ] , filePath : string , autoApply : boolean = false ) : Promise < boolean > {
410- this . logger . debug ( 'AutoDebugController: Auto-fixing %d problems for %s' , problems . length , filePath )
411- this . logger . debug (
412- 'AutoDebugController: Problems to fix: %s' ,
413- problems
414- . map ( ( p ) => `${ p . severity } : ${ p . diagnostic . message } at line ${ p . diagnostic . range . start . line } ` )
415- . join ( ', ' )
416- )
417-
418358 try {
419359 // Get file content
420360 const document = await vscode . workspace . openTextDocument ( vscode . Uri . file ( filePath ) )
@@ -446,91 +386,10 @@ export class AutoDebugController implements vscode.Disposable {
446386 return false
447387 } catch ( error ) {
448388 this . logger . error ( 'AutoDebugController: Error during auto-fix: %s' , error )
449- void vscode . window . showErrorMessage (
450- `Failed to auto-fix problems: ${ error instanceof Error ? error . message : 'Unknown error' } `
451- )
452389 return false
453390 }
454391 }
455392
456- private setupEventHandlers ( ) : void {
457- this . logger . debug ( 'AutoDebugController: Setting up event handlers' )
458-
459- // **ONLY trigger on specific file events (save/open) - NO continuous monitoring during typing**
460- // This prevents notification spam while you're actively coding
461-
462- // Listen for file saves and check for errors
463- this . disposables . push (
464- vscode . workspace . onDidSaveTextDocument ( async ( document ) => {
465- await this . handleFileEvent ( document , 'save' )
466- } )
467- )
468-
469- // Listen for file opens and check for errors
470- this . disposables . push (
471- vscode . workspace . onDidOpenTextDocument ( async ( document ) => {
472- await this . handleFileEvent ( document , 'open' )
473- } )
474- )
475- }
476-
477- /**
478- * Handles file events (save/open) and checks for errors that should trigger auto-debug
479- */
480- private async handleFileEvent ( document : vscode . TextDocument , eventType : 'save' | 'open' ) : Promise < void > {
481- if ( ! this . config . enabled ) {
482- return
483- }
484-
485- if ( ! this . currentSession ) {
486- await this . startSession ( )
487- }
488-
489- this . logger . debug ( 'AutoDebugController: Document %s, checking for errors: %s' , eventType , document . fileName )
490-
491- // **Only trigger auto-notification if there are actual errors after file event**
492- setTimeout ( async ( ) => {
493- try {
494- // Check if there are errors in the file
495- const diagnostics = vscode . languages . getDiagnostics ( document . uri )
496- const errorDiagnostics = diagnostics . filter ( ( d ) => d . severity === vscode . DiagnosticSeverity . Error )
497-
498- if ( errorDiagnostics . length > 0 ) {
499- this . logger . debug ( `AutoDebugController: Found ${ errorDiagnostics . length } errors after ${ eventType } ` )
500-
501- // **FIX #1: Always show notification when errors are found (removed Amazon Q activity requirement)**
502- this . logger . debug ( `AutoDebugController: Showing notification for errors found after ${ eventType } ` )
503-
504- // Convert diagnostics to problems
505- const problems = errorDiagnostics . map ( ( diagnostic ) => ( {
506- uri : document . uri ,
507- diagnostic,
508- severity : mapDiagnosticSeverity ( diagnostic . severity ) ,
509- source : diagnostic . source || 'unknown' ,
510- isNew : true ,
511- } ) )
512-
513- // Update session with new problems
514- if ( this . currentSession ) {
515- this . currentSession = {
516- ...this . currentSession ,
517- problems : [ ...this . currentSession . problems , ...problems ] ,
518- }
519- }
520-
521- // Fire the problems detected event - this triggers the notification in AutoDebugFeature
522- this . onProblemsDetected . fire ( problems )
523-
524- this . logger . debug ( 'AutoDebugController: Problems detected event fired for notification' )
525- } else {
526- this . logger . debug ( `AutoDebugController: No errors found after ${ eventType } ` )
527- }
528- } catch ( error ) {
529- this . logger . error ( `AutoDebugController: Error checking problems after ${ eventType } : %s` , error )
530- }
531- } , this . config . debounceMs )
532- }
533-
534393 /**
535394 * Gets the range that encompasses all problems
536395 */
0 commit comments