Fix: Do not activate on pseudoterminals#1509
Conversation
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.
7bb767c to
064ed26
Compare
| const pseudoTerminal = createMockTerminal('pseudo', { | ||
| name: 'pseudo', | ||
| pty: { open: () => {}, close: () => {} }, | ||
| } as unknown as ExtensionTerminalOptions); |
There was a problem hiding this comment.
Would be great if we can avoid using unknown or any as much as possible
|
Thanks for the PR!
@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. |
Repro (from Q# Extension)
IssueQDK terminal keeps closing by itself, it should remain open |
Tested, now working
|
|
Thanks @edvilme |

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:
shouldSkipTerminalActivationinsrc/features/terminal/utils.tsto centralize the logic for skipping activation for terminals that are hidden from the user or are PTY-based extension terminals.TerminalManagerImplinsrc/features/terminal/terminalManager.tsto useshouldSkipTerminalActivationinstead of directly checking terminal options in multiple places, ensuring consistent behavior when opening or activating terminals. [1] [2] [3] [4]TerminalActivationImplinsrc/features/terminal/terminalActivationState.tsto use the new skip logic, preventing activation for terminals that meet the skip criteria. [1] [2]Other changes:
src/features/terminal/terminalManager.tsandsrc/features/terminal/utils.tsto remove unusedTerminalOptionsand addExtensionTerminalOptionswhere needed. [1] [2]Fixes #1482