Skip to content

Fix: Do not activate on pseudoterminals#1509

Open
edvilme wants to merge 5 commits into
mainfrom
pseudoterminal-guard
Open

Fix: Do not activate on pseudoterminals#1509
edvilme wants to merge 5 commits into
mainfrom
pseudoterminal-guard

Conversation

@edvilme
Copy link
Copy Markdown
Contributor

@edvilme edvilme commented May 7, 2026

This pull request introduces a new utility function to consistently determine when terminal activation should be skipped, and refactors related logic throughout the codebase to use this function. The main goal is to improve reliability and maintainability by centralizing the logic for skipping activation of certain terminals (such as hidden or PTY-based extension terminals).

Terminal activation skip logic improvements:

  • Added a new function shouldSkipTerminalActivation in src/features/terminal/utils.ts to centralize the logic for skipping activation for terminals that are hidden from the user or are PTY-based extension terminals.
  • Refactored TerminalManagerImpl in src/features/terminal/terminalManager.ts to use shouldSkipTerminalActivation instead of directly checking terminal options in multiple places, ensuring consistent behavior when opening or activating terminals. [1] [2] [3] [4]
  • Updated TerminalActivationImpl in src/features/terminal/terminalActivationState.ts to use the new skip logic, preventing activation for terminals that meet the skip criteria. [1] [2]

Other changes:

  • Cleaned up imports in src/features/terminal/terminalManager.ts and src/features/terminal/utils.ts to remove unused TerminalOptions and add ExtensionTerminalOptions where needed. [1] [2]

Fixes #1482

edvilme and others added 4 commits May 7, 2026 10:09
Currently the extension gets activated on pseudoterminals as the current check for not user-facing terminals does not catch this case. These terminals should be skipped during activation as to avoid unexpected commands and behavior.
@edvilme edvilme force-pushed the pseudoterminal-guard branch from 7bb767c to 064ed26 Compare May 7, 2026 18:55
@edvilme edvilme added the bug Issue identified by VS Code Team member as probable bug label May 7, 2026
const pseudoTerminal = createMockTerminal('pseudo', {
name: 'pseudo',
pty: { open: () => {}, close: () => {} },
} as unknown as ExtensionTerminalOptions);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be great if we can avoid using unknown or any as much as possible

@anthonykim1
Copy link
Copy Markdown
Contributor

Thanks for the PR!

PTY-based extension terminals

@edvilme Have you / can you please test this with a sample extension that creates a custom PTY terminal? That seems closest to the original repro path, where the terminal is opened by another extension after activation.

@edvilme
Copy link
Copy Markdown
Contributor Author

edvilme commented May 12, 2026

Repro (from Q# Extension)

  1. Install quantim.qsharp-lang-vscode (v. 1.27.0)
  2. Open a workspace with a .venv in it
  3. Confirm virtual env activation happens in PS terminal
  4. Create foo.qs file (use snippet suggestions)
  5. Run program

Issue

QDK terminal keeps closing by itself, it should remain open

@edvilme
Copy link
Copy Markdown
Contributor Author

edvilme commented May 12, 2026

Thanks for the PR!

PTY-based extension terminals

@edvilme Have you / can you please test this with a sample extension that creates a custom PTY terminal? That seems closest to the original repro path, where the terminal is opened by another extension after activation.

Tested, now working

image

@edvilme edvilme requested a review from anthonykim1 May 12, 2026 23:11
@edvilme edvilme changed the title Pseudoterminal guard Fix: Do not activate on pseudoterminals May 12, 2026
@anthonykim1
Copy link
Copy Markdown
Contributor

anthonykim1 commented May 13, 2026

Thanks @edvilme
Might need to tweak the test to opt out activation for extension contributed custom pty terminals, and remove unknowns/any from #1509 (comment) but looks good otherwise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Activation commands sent to Pseudoterminals owned by other extensions

2 participants