-
Notifications
You must be signed in to change notification settings - Fork 37.3k
Log runCommand for debugging #286625
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?
Log runCommand for debugging #286625
Conversation
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 PR adds debug logging to the runCommand method in the terminal instance to help diagnose issues with command detection and execution. The logging tracks key decision points in the command execution flow.
Key Changes
- Added trace logging at critical points during command detection and execution
- Modified timeout handling to include logging when command detection times out
- Added detailed logging before sending ETX (Ctrl+C) control sequences
| this._logService.trace(`runCommand: Sending ^C before running command: ${commandLine}`); | ||
| this._logService.trace(`runCommand: The value of shouldExecute is: ${shouldExecute}`); | ||
| this._logService.trace(`runCommand: The value of command detection and prompt input model value is: ${commandDetection ? commandDetection.promptInputModel.value : 'N/A'}`); |
Copilot
AI
Jan 8, 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.
These three consecutive trace calls could be consolidated into a single, more readable log statement. This would reduce log noise and make it easier to parse debug output. Consider combining them into one trace call with a formatted multi-line string or a single line with all relevant information.
| this._logService.trace(`runCommand: Sending ^C before running command: ${commandLine}`); | |
| this._logService.trace(`runCommand: The value of shouldExecute is: ${shouldExecute}`); | |
| this._logService.trace(`runCommand: The value of command detection and prompt input model value is: ${commandDetection ? commandDetection.promptInputModel.value : 'N/A'}`); | |
| this._logService.trace(`runCommand: Sending ^C before running command`, { | |
| commandLine, | |
| shouldExecute, | |
| promptInputValue: commandDetection ? commandDetection.promptInputModel.value : 'N/A' | |
| }); |
| timeout(timeoutMs).then(() => { | ||
| this._logService.trace(`runCommand: Timed out waiting for command detection prompt input after ${timeoutMs}ms, proceeding to run command`); |
Copilot
AI
Jan 8, 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 timeout promise's then() callback will execute after the Promise.race resolves, which means the log message will not appear when the timeout actually triggers the race resolution. The log statement inside the then() will execute regardless of which promise wins the race. To properly log when the timeout wins the race, the logging should happen in the race winner itself, not in a chained then().
| timeout(timeoutMs).then(() => { | |
| this._logService.trace(`runCommand: Timed out waiting for command detection prompt input after ${timeoutMs}ms, proceeding to run command`); | |
| new Promise<void>(r => { | |
| const timeoutDisposable = disposableTimeout(() => { | |
| this._logService.trace(`runCommand: Timed out waiting for command detection prompt input after ${timeoutMs}ms, proceeding to run command`); | |
| r(); | |
| }, timeoutMs); | |
| store.add(timeoutDisposable); |
| if (shouldExecute && (!commandDetection || commandDetection.promptInputModel.value.length > 0)) { | ||
| this._logService.trace(`runCommand: Sending ^C before running command: ${commandLine}`); | ||
| this._logService.trace(`runCommand: The value of shouldExecute is: ${shouldExecute}`); | ||
| this._logService.trace(`runCommand: The value of command detection and prompt input model value is: ${commandDetection ? commandDetection.promptInputModel.value : 'N/A'}`); |
Copilot
AI
Jan 8, 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.
Logging the prompt input model value may expose sensitive information that users have typed at the terminal prompt, such as passwords or API tokens. Consider either removing this value from the log message or sanitizing/redacting it before logging.
| this._logService.trace(`runCommand: The value of command detection and prompt input model value is: ${commandDetection ? commandDetection.promptInputModel.value : 'N/A'}`); | |
| const promptInputInfo = commandDetection ? `length=${commandDetection.promptInputModel.value.length}` : 'N/A'; | |
| this._logService.trace(`runCommand: Command detection prompt input info: ${promptInputInfo}`); |
| // Determine whether to send ETX (ctrl+c) before running the command. Only do this when the | ||
| // command will be executed immediately or when command detection shows the prompt contains text. | ||
| if (shouldExecute && (!commandDetection || commandDetection.promptInputModel.value.length > 0)) { | ||
| this._logService.trace(`runCommand: Sending ^C before running command: ${commandLine}`); |
Copilot
AI
Jan 8, 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.
Logging the command line may expose sensitive information such as passwords, API tokens, or other credentials that users might pass as command arguments. Consider either removing the commandLine from the log message or sanitizing/redacting it before logging.
| this._logService.trace(`runCommand: Sending ^C before running command: ${commandLine}`); | |
| this._logService.trace('runCommand: Sending ^C before running command'); |
| // command will be executed immediately or when command detection shows the prompt contains text. | ||
| if (shouldExecute && (!commandDetection || commandDetection.promptInputModel.value.length > 0)) { | ||
| this._logService.trace(`runCommand: Sending ^C before running command: ${commandLine}`); | ||
| this._logService.trace(`runCommand: The value of shouldExecute is: ${shouldExecute}`); |
Copilot
AI
Jan 8, 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.
This log statement is redundant because this code is inside a conditional block that only executes when shouldExecute is true. Logging this value doesn't provide useful debugging information since it will always be true at this point.
| this._logService.trace(`runCommand: The value of shouldExecute is: ${shouldExecute}`); |
Just doing it for build