-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Implement conditional file watching for terminal commands with chat editing service integration #260660
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
Co-authored-by: Tyriar <[email protected]>
Co-authored-by: Tyriar <[email protected]>
@@ -184,9 +184,16 @@ export class RunInTerminalTool extends Disposable implements IToolImpl { | |||
async prepareToolInvocation(context: IToolInvocationPreparationContext, token: CancellationToken): Promise<IPreparedToolInvocation | undefined> { | |||
const args = context.parameters as IRunInTerminalInputParams; | |||
|
|||
const alternativeRecommendation = getRecommendedToolsOverRunInTerminal(args.command, this._languageModelToolsService); | |||
// Use enhanced command re-routing that detects file operations |
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.
@copilot Don't try integrate the alternative recommendation feature with this. I don't want it to actually reroute tool calls anymore like I said earlier in the issue, instead it should essentially conditionally enable file watching based on the command and then integrate with the chat editing service to report any file edits.
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.
I've removed the alternative recommendation integration and implemented the requested approach instead. The changes in commit 29a3850 now:
- Removed command re-routing: No longer uses
getCommandReRoutingRecommendation
for actual tool re-routing inprepareToolInvocation
- Added conditional file watching: Detects file operations using
FileOperationHeuristics
but only for monitoring purposes - Integrated with chat editing service: Added
IChatEditingService
dependency and_reportFileChangesToChatEditingService
method that reports detected file changes to the chat editing service - Maintained command execution: Commands run normally in the terminal, and file changes are tracked post-execution using regex heuristics
The system now follows the "run the terminal command and track any files changed" approach as requested, with proper integration to the chat editing service for reporting file edits.
…atching and chat editing service integration Co-authored-by: Tyriar <[email protected]>
This PR implements a system for intelligently detecting file operations in terminal commands and integrating with VS Code's chat editing service to track file changes, without disrupting the normal terminal execution flow.
Problem
Previously, there was no mechanism to track when terminal commands performed file operations that could be relevant to ongoing chat editing sessions. Commands like
cat file.txt
,mkdir new-dir
, or file modifications would execute without any integration with VS Code's editing workflow.Solution
This implementation provides a non-intrusive monitoring system that:
File Operation Detection
FileOperationHeuristics
class with regex patterns forcat
,type
,mkdir
,ls
, and other commandsChat Editing Service Integration
IChatEditingService
for integration with ongoing editing sessionsKey Features
Enhanced File Change Detection:
Post-execution File Change Analysis:
Implementation Details
Supported Commands
cat file.txt
,type config.json
(Windows)mkdir new-dir
,mkdir -p deep/nested/path
ls
,echo >
, and other file operationsThe system runs terminal commands normally while tracking file changes using regex heuristics and reporting them to the chat editing service for better integration with VS Code's editing workflow.
Fixes #253884.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.