@@ -46,6 +46,16 @@ export class StreamingDiffController implements vscode.Disposable {
4646 vscode . workspace . registerTextDocumentContentProvider ( diffViewUriScheme , this . contentProvider )
4747 }
4848
49+ private disposeSession ( session : StreamingSession ) : void {
50+ session . disposed = true
51+ session . fadedOverlayController . clear ( )
52+ session . activeLineController . clear ( )
53+ }
54+
55+ private logError ( context : string , toolUseId : string , error : any ) : void {
56+ getLogger ( ) . error ( `[StreamingDiffController] ❌ ${ context } for ${ toolUseId } : ${ error } ` )
57+ }
58+
4959 updateFsWriteParams ( toolUseId : string , fsWriteParams : FsWriteParams ) : void {
5060 const session = this . activeStreamingSessions . get ( toolUseId )
5161 if ( session ) {
@@ -246,7 +256,7 @@ export class StreamingDiffController implements vscode.Disposable {
246256 setTimeout ( async ( ) => {
247257 try {
248258 await this . cleanupTempFile ( session . tempFilePath )
249- session . disposed = true
259+ this . disposeSession ( session )
250260 this . activeStreamingSessions . delete ( toolUseId )
251261 } catch ( error ) {
252262 getLogger ( ) . warn ( `Failed to auto-cleanup temp file ${ session . tempFilePath } : ${ error } ` )
@@ -279,7 +289,7 @@ export class StreamingDiffController implements vscode.Disposable {
279289 return
280290 }
281291 const currentContent = document . getText ( )
282- if ( document . uri . fsPath = == session . tempFilePath ) {
292+ if ( document . uri . fsPath ! == session . tempFilePath ) {
283293 return
284294 }
285295 try {
@@ -417,9 +427,7 @@ export class StreamingDiffController implements vscode.Disposable {
417427 }
418428
419429 try {
420- session . disposed = true
421- session . fadedOverlayController . clear ( )
422- session . activeLineController . clear ( )
430+ this . disposeSession ( session )
423431
424432 // Clean up temp file immediately when session is closed
425433 if ( session . tempFilePath ) {
@@ -428,9 +436,7 @@ export class StreamingDiffController implements vscode.Disposable {
428436
429437 this . activeStreamingSessions . delete ( toolUseId )
430438 } catch ( error ) {
431- getLogger ( ) . error (
432- `[StreamingDiffController] ❌ Failed to close streaming session for ${ toolUseId } : ${ error } `
433- )
439+ this . logError ( 'Failed to close streaming session' , toolUseId , error )
434440 }
435441 }
436442
@@ -569,11 +575,9 @@ export class StreamingDiffController implements vscode.Disposable {
569575
570576 for ( const [ toolUseId , session ] of this . activeStreamingSessions . entries ( ) ) {
571577 try {
572- session . disposed = true
573- session . fadedOverlayController . clear ( )
574- session . activeLineController . clear ( )
578+ this . disposeSession ( session )
575579 } catch ( error ) {
576- getLogger ( ) . error ( `[StreamingDiffController] ❌ Error disposing session ${ toolUseId } : ${ error } ` )
580+ this . logError ( ' Error disposing session' , toolUseId , error )
577581 }
578582 }
579583
0 commit comments