4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import { RunOnceScheduler , timeout } from '../../../../../base/common/async.js' ;
7
+ import { Emitter } from '../../../../../base/common/event.js' ;
7
8
import { Disposable , IReference , toDisposable } from '../../../../../base/common/lifecycle.js' ;
8
9
import { IObservable , ITransaction , observableValue , transaction } from '../../../../../base/common/observable.js' ;
9
10
import { themeColorFromId } from '../../../../../base/common/themables.js' ;
@@ -24,10 +25,11 @@ import { IModelService } from '../../../../../editor/common/services/model.js';
24
25
import { IResolvedTextEditorModel , ITextModelService } from '../../../../../editor/common/services/resolverService.js' ;
25
26
import { IModelContentChange , IModelContentChangedEvent } from '../../../../../editor/common/textModelEvents.js' ;
26
27
import { localize } from '../../../../../nls.js' ;
28
+ import { IFileService } from '../../../../../platform/files/common/files.js' ;
27
29
import { editorSelectionBackground } from '../../../../../platform/theme/common/colorRegistry.js' ;
28
30
import { IUndoRedoService } from '../../../../../platform/undoRedo/common/undoRedo.js' ;
29
31
import { IChatAgentResult } from '../../common/chatAgents.js' ;
30
- import { IModifiedFileEntry , WorkingSetEntryState } from '../../common/chatEditingService.js' ;
32
+ import { ChatEditKind , IModifiedFileEntry , WorkingSetEntryState } from '../../common/chatEditingService.js' ;
31
33
import { IChatService } from '../../common/chatService.js' ;
32
34
import { ChatEditingSnapshotTextModelContentProvider , ChatEditingTextModelContentProvider } from './chatEditingTextModelContentProviders.js' ;
33
35
@@ -40,6 +42,11 @@ export class ChatEditingModifiedFileEntry extends Disposable implements IModifie
40
42
public readonly docSnapshot : ITextModel ;
41
43
private readonly doc : ITextModel ;
42
44
45
+ private readonly _onDidDelete = this . _register ( new Emitter < void > ( ) ) ;
46
+ public get onDidDelete ( ) {
47
+ return this . _onDidDelete . event ;
48
+ }
49
+
43
50
get originalURI ( ) : URI {
44
51
return this . docSnapshot . uri ;
45
52
}
@@ -95,6 +102,8 @@ export class ChatEditingModifiedFileEntry extends Disposable implements IModifie
95
102
return this . _telemetryInfo ;
96
103
}
97
104
105
+ readonly createdInRequestId : string | undefined ;
106
+
98
107
get lastModifyingRequestId ( ) {
99
108
return this . _telemetryInfo . requestId ;
100
109
}
@@ -104,15 +113,20 @@ export class ChatEditingModifiedFileEntry extends Disposable implements IModifie
104
113
resourceRef : IReference < IResolvedTextEditorModel > ,
105
114
private readonly _multiDiffEntryDelegate : { collapse : ( transaction : ITransaction | undefined ) => void } ,
106
115
private _telemetryInfo : IModifiedEntryTelemetryInfo ,
116
+ kind : ChatEditKind ,
107
117
@IModelService modelService : IModelService ,
108
118
@ITextModelService textModelService : ITextModelService ,
109
119
@ILanguageService languageService : ILanguageService ,
110
120
@IBulkEditService public readonly bulkEditService : IBulkEditService ,
111
121
@IChatService private readonly _chatService : IChatService ,
112
122
@IEditorWorkerService private readonly _editorWorkerService : IEditorWorkerService ,
113
- @IUndoRedoService private readonly _undoRedoService : IUndoRedoService
123
+ @IUndoRedoService private readonly _undoRedoService : IUndoRedoService ,
124
+ @IFileService private readonly _fileService : IFileService ,
114
125
) {
115
126
super ( ) ;
127
+ if ( kind === ChatEditKind . Created ) {
128
+ this . createdInRequestId = this . _telemetryInfo . requestId ;
129
+ }
116
130
this . doc = resourceRef . object . textEditorModel ;
117
131
const docSnapshot = this . docSnapshot = this . _register (
118
132
modelService . createModel (
@@ -316,11 +330,16 @@ export class ChatEditingModifiedFileEntry extends Disposable implements IModifie
316
330
return ;
317
331
}
318
332
319
- this . _setDocValue ( this . docSnapshot . getValue ( ) ) ;
320
-
321
333
this . _stateObs . set ( WorkingSetEntryState . Rejected , transaction ) ;
322
- await this . collapse ( transaction ) ;
323
334
this . _notifyAction ( 'rejected' ) ;
335
+ if ( this . createdInRequestId === this . _telemetryInfo . requestId ) {
336
+ await this . _fileService . del ( this . resource ) ;
337
+ this . _onDidDelete . fire ( ) ;
338
+ this . dispose ( ) ;
339
+ } else {
340
+ this . _setDocValue ( this . docSnapshot . getValue ( ) ) ;
341
+ await this . collapse ( transaction ) ;
342
+ }
324
343
}
325
344
326
345
private _setDocValue ( value : string ) : void {
0 commit comments