Skip to content

Conversation

@anthonykim1
Copy link
Contributor

Resolves: #640
I couldnt seem to repro ^C to show up on Python file run on Mac, but only on Windows.

This is happening because we have some extra polling happening before onCommandStarted event gets fired: https://github.com/microsoft/vscode/blob/86db4eb05dbfd82dc9b4ea022883494257ac3d63/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts#L727 Which is what leads to resetting the value of promptInputModel:

We need the promptInputModel's value to be empty and state to be not execute in order to not cause ^C upon executeCommand run: https://github.com/microsoft/vscode/blob/86db4eb05dbfd82dc9b4ea022883494257ac3d63/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts#L1010

So in that meantime before we clear the value of promptInput to empty string, the state will be execute and value of it will point to activation script. Which will lead to ^C.

I think we'd have better chance when we remove some Windows specific heuristics in command detection, after rolling out newer conpty as default.

@anthonykim1 anthonykim1 added this to the January 2026 milestone Jan 11, 2026
@anthonykim1 anthonykim1 self-assigned this Jan 11, 2026
@anthonykim1 anthonykim1 added bug Issue identified by VS Code Team member as probable bug area-terminal Environment extension specific terminal issues. labels Jan 11, 2026
@anthonykim1 anthonykim1 marked this pull request as ready for review January 11, 2026 03:43
@anthonykim1 anthonykim1 enabled auto-merge (squash) January 11, 2026 03:44
// Since we have extra polliing on Windows that could lead to race stale promptInputModel value,
// temporarily add small timeout to avoid ^C.
// TODO: Consider removing when we clean up polling with newer conpty: https://github.com/microsoft/vscode/issues/224488
await timeout(50);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A timeout like this will always be flaky unfortunately.

Have you considered awaiting the activate call if triggered via executeCommand, and queuing any further commands until that resolves?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tyriar We actually do await for the activate call when activating with executeCommand

const terminal = await this.terminalManager.getProjectTerminal(
options.cwd instanceof Uri ? options.cwd : Uri.file(options.cwd),
environment,
);
await runInTerminal(environment, terminal, options);

which goes to:

Maybe the better fix is to move where https://github.com/microsoft/vscode/blob/86db4eb05dbfd82dc9b4ea022883494257ac3d63/src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts#L213 happens, to after execution in core?

@anthonykim1 anthonykim1 requested a review from Tyriar January 11, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-terminal Environment extension specific terminal issues. bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CTRL-C is immediately issued upon run, execution gets cancelled by activation command

3 participants