fix: prevent dirty file tracker from auto-opening chat-edited files (#298700)#302036
fix: prevent dirty file tracker from auto-opening chat-edited files (#298700)#302036kangarko wants to merge 3 commits intomicrosoft:mainfrom
Conversation
…icrosoft#298700) When the chat agent creates or modifies files, the text models become dirty. The TextFileEditorTracker has a general-purpose mechanism that auto-opens all dirty files as editor tabs after an 800ms debounce. This bypasses the accessibility.openChatEditedFiles setting (default: false), causing files to open in tabs even when the user has not opted in. The fix adds a check in ensureDirtyTextFilesAreOpened() to skip files that are part of an active chat editing session. The chat editing system already manages its own editor lifecycle via the accessibility.openChatEditedFiles setting — the dirty file tracker should not interfere with that. Also fixes stale accessibility help text that still referenced the old default (true) for the setting.
There was a problem hiding this comment.
Pull request overview
Fixes an accessibility/configuration regression where chat agent streaming edits mark models dirty and trigger TextFileEditorTracker to auto-open editor tabs, bypassing accessibility.openChatEditedFiles (default false). Also updates chat accessibility help text to reflect the current default behavior.
Changes:
- Exclude chat-edit-session files from the “open dirty files automatically” tracker logic.
- Update accessibility help copy describing the default behavior for opening chat-edited files.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/files/browser/editors/textFileEditorTracker.ts | Skips resources associated with chat editing sessions when deciding which dirty models to auto-open as editors. |
| src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.ts | Updates localized accessibility help text to match the current default setting behavior. |
You can also share your feedback on Copilot code review. Take the survey.
| // The chat editing system manages its own editor lifecycle via | ||
| // the accessibility.openChatEditedFiles setting (#298700). | ||
| for (const session of this.chatEditingService?.editingSessionsObs?.get() ?? []) { | ||
| if (session.entries.get().some(e => isEqual(e.modifiedURI, resource))) { |
| // Skip files being actively modified by a chat editing session. | ||
| // The chat editing system manages its own editor lifecycle via | ||
| // the accessibility.openChatEditedFiles setting (#298700). | ||
| for (const session of this.chatEditingService?.editingSessionsObs?.get() ?? []) { | ||
| if (session.entries.get().some(e => isEqual(e.modifiedURI, resource))) { | ||
| return false; | ||
| } | ||
| } |
| // Skip files being actively modified by a chat editing session. | ||
| // The chat editing system manages its own editor lifecycle via | ||
| // the accessibility.openChatEditedFiles setting (#298700). | ||
| for (const session of this.chatEditingService?.editingSessionsObs?.get() ?? []) { | ||
| if (session.entries.get().some(e => isEqual(e.modifiedURI, resource))) { | ||
| return false; | ||
| } | ||
| } |
|
@microsoft-github-policy-service agree company="MineAcademy" |
Introduce a generic per-resource override in FilesConfigurationService that prevents TextFileEditorTracker from auto-opening dirty resources as editors. Chat editing uses that override for text document entries while chat owns the file and keeps it until the file reaches a clean state, which avoids both the layer violation and the accept/debounce race. Also add a focused TextFileEditorTracker test for the explicit suppression path.
|
Thanks — updated the PR to remove the The new version pushes the state into I also replied to the CLA bot, so that check should unblock once it processes. If you'd prefer this runtime override to live somewhere other than |
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @jriekenMatched files:
|
| if (isEqual(model.resource, this.modifiedURI)) { | ||
| updateOpenEditorWhenDirtyDisabled(); | ||
| } | ||
| })); |
There was a problem hiding this comment.
There is also src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.ts and whatever is done here for documents should also work for notebooks
Use the same generic open-when-dirty suppression for notebook chat edits as for text documents, and have NotebookEditorManager honor that override before opening dirty notebook editors.
|
Thanks — that notebook point was real. I re-traced the code paths and found there are two generic dirty-editor auto-open entry points involved here:
So the suppression needed to cover both, not just document entries. I pushed a follow-up commit that:
That keeps the fix grounded in the actual auto-open paths instead of assuming documents were the only case. |
|
Hey! I know you're busy so I tried using AI on this. If you see any feasible solution we'd really appreciate this feature bc the files keep opening and breaking the width of the chat on their own. Otherwise just wanted to say you guys are doing amazing job! |
Problem
When the chat agent edits files, those models become dirty while edits stream in. VS Code has generic dirty-model auto-open paths for both text files and notebooks:
TextFileEditorTrackerfor dirty text filesNotebookEditorManagerfor dirty notebooksWithout an explicit suppression, both can auto-open editors even when
accessibility.openChatEditedFilesisfalse.My original fix addressed the behavior directly from
TextFileEditorTracker, but that introduced afiles -> chatdependency and broke layers.Updated fix
This PR now moves the suppression to a generic lower-level seam:
IFilesConfigurationServiceexposes a per-resource runtime override to suppress opening an editor for a dirty resource.TextFileEditorTrackerconsults that generic override for text files.NotebookEditorManagerconsults the same generic override for notebooks.Why this should fit better
files -> chatdependencynotebook -> chatspecial casing beyond consuming a generic service overridedisableAutoSave(...)Files changed
src/vs/workbench/services/filesConfiguration/common/filesConfigurationService.tssrc/vs/workbench/contrib/files/browser/editors/textFileEditorTracker.tssrc/vs/workbench/contrib/notebook/browser/notebook.contribution.tssrc/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.tssrc/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.tssrc/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.tssrc/vs/workbench/contrib/files/test/browser/textFileEditorTracker.test.tssrc/vs/workbench/test/common/workbenchTestServices.tssrc/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.tsFixes #298700
cc @bpasero @roblourens @jrieken @meganrogge