-
Notifications
You must be signed in to change notification settings - Fork 37.5k
chat: support representing file deletions in edit sessions #289270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add support for file deletion operations in chat editing sessions through new ChatResponseWorkspaceEditPart. This allows agents to represent file-level operations (deletions, creations, renames) alongside text and notebook edits. - Adds ChatEditingDeletedFileEntry class to represent deleted files with proper diff display and restoration functionality - Introduces ChatResponseWorkspaceEditPart and IChatWorkspaceEdit interfaces for file-level operations at the workspace level - Implements workspace edit streaming through chat editing sessions with proper undo/redo support - Adds ChatWorkspaceEditContentPart for UI rendering of file operations - Extends chat session storage to serialize deleted file entries - Supports both acceptance and rejection of file deletions with proper state management and snapshotting Ref #275705 (Commit message generated by Copilot)
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @jriekenMatched files:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds support for file deletion operations in chat editing sessions. The implementation introduces a new ChatResponseWorkspaceEditPart API and supporting infrastructure to enable chat agents to delete files alongside text and notebook edits.
Changes:
- Adds new API surface (
ChatResponseWorkspaceEditPart,ChatWorkspaceFileEdit) for workspace-level file operations - Implements
ChatEditingDeletedFileEntryclass to represent deleted files with proper diff display and undo/redo functionality - Extends storage, UI rendering, and session management to handle file deletions
Reviewed changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
vscode.proposed.chatParticipantAdditions.d.ts |
Adds API definitions for workspace edit parts and file edit operations |
extHostTypes.ts |
Implements ChatResponseWorkspaceEditPart class for extension host |
extHostTypeConverters.ts |
Adds type conversion logic for workspace edits |
extHostChatAgents2.ts |
Integrates workspace edit method into chat response stream |
extHost.api.impl.ts |
Exports new API class for extensions |
chatService.ts |
Defines IChatWorkspaceEdit and IChatWorkspaceFileEdit interfaces |
chatEditingService.ts |
Adds applyWorkspaceEdit method and deletion support to session interface |
chatModel.ts |
Extends progress content types to include workspace edits |
chatSessionOperationLog.ts |
Adds workspace edit to operation log schema |
chatEditingSession.ts |
Implements deletion logic including file operations, timeline recording, and snapshot restoration |
chatEditingServiceImpl.ts |
Integrates workspace edit processing into response streaming |
chatEditingDeletedFileEntry.ts |
New file implementing deleted file entry with diff display and restoration |
chatEditingSessionStorage.ts |
Adds serialization support for deleted file entries |
chatListRenderer.ts |
Registers workspace edit content part renderer |
chatWorkspaceEditContentPart.ts |
New file implementing UI rendering for file operations |
chatInputPart.ts |
Adds special handling for opening deleted files in the working set |
chatProgressContentPart.ts |
Expands constructor parameter type to support workspace edit rendering |
chatEditingModifiedFileEntry.ts |
Removes hasModificationAt method (no longer needed) |
chatEditingModifiedDocumentEntry.ts |
Removes hasModificationAt method and cleans up imports |
chatEditingModifiedNotebookEntry.ts |
Removes hasModificationAt method and reorders imports |
chatEditingNotebookCellEntry.ts |
Removes hasModificationAt method |
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingDeletedFileEntry.ts:219
- The undo and redo operations in the undo/redo element lack error handling. File operations (writeFile and del) can fail due to permissions, disk space, or file system issues. If these operations fail, the undo/redo system will be in an inconsistent state. Consider adding error handling and potentially notifying the user of failures.
undo: async () => {
// Restore the file
await this._fileService.writeFile(this.modifiedURI, VSBuffer.fromString(this._originalContent));
},
redo: async () => {
// Delete the file again
await this._fileService.del(this.modifiedURI, { useTrash: false });
}
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatWorkspaceEditContentPart.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingDeletedFileEntry.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingDeletedFileEntry.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingDeletedFileEntry.ts
Show resolved
Hide resolved
| snapshotEntry.telemetryInfo, | ||
| snapshotEntry.languageId | ||
| ); | ||
| await entry.restoreFromSnapshot(snapshotEntry, false); |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The snapshot restoration logic at line 888 always passes false for restoreToDisk when restoring deleted file entries. This means deleted files are never restored to disk during snapshot restoration, which may be inconsistent with the behavior for non-deleted entries (lines 890-894) where restoreToDisk is conditionally set based on whether the state is Modified. Consider whether deleted file entries should also have conditional restoration based on their state, or if this asymmetry is intentional.
| await entry.restoreFromSnapshot(snapshotEntry, false); | |
| const restoreToDisk = snapshotEntry.state === ModifiedFileEntryState.Modified; | |
| await entry.restoreFromSnapshot(snapshotEntry, restoreToDisk); |
Add support for file deletion operations in chat editing sessions through
new ChatResponseWorkspaceEditPart. This allows agents to represent file-level
operations (deletions, creations, renames) alongside text and notebook edits.
proper diff display and restoration functionality
for file-level operations at the workspace level
proper undo/redo support
management and snapshotting
Ref #275705
(Commit message generated by Copilot)