Skip to content

Conversation

@anthonykim1
Copy link
Contributor

Just doing it for build

@anthonykim1 anthonykim1 self-assigned this Jan 8, 2026
Copilot AI review requested due to automatic review settings January 8, 2026 22:16
Copy link
Contributor

Copilot AI left a 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

Comment on lines +1015 to +1017
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'}`);
Copy link

Copilot AI Jan 8, 2026

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.

Suggested change
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'
});

Copilot uses AI. Check for mistakes.
Comment on lines +998 to +999
timeout(timeoutMs).then(() => {
this._logService.trace(`runCommand: Timed out waiting for command detection prompt input after ${timeoutMs}ms, proceeding to run command`);
Copy link

Copilot AI Jan 8, 2026

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().

Suggested change
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);

Copilot uses AI. Check for mistakes.
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'}`);
Copy link

Copilot AI Jan 8, 2026

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.

Suggested change
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}`);

Copilot uses AI. Check for mistakes.
// 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}`);
Copy link

Copilot AI Jan 8, 2026

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.

Suggested change
this._logService.trace(`runCommand: Sending ^C before running command: ${commandLine}`);
this._logService.trace('runCommand: Sending ^C before running command');

Copilot uses AI. Check for mistakes.
// 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}`);
Copy link

Copilot AI Jan 8, 2026

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.

Suggested change
this._logService.trace(`runCommand: The value of shouldExecute is: ${shouldExecute}`);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants