fix: prevent conda auto-activation from hijacking terminal command output#11149
fix: prevent conda auto-activation from hijacking terminal command output#11149roomote[bot] wants to merge 2 commits intomainfrom
Conversation
…tput When a terminal is created with conda auto-activation (or any shell initialization that runs commands), a race condition could occur where VSCode fires onDidStartTerminalShellExecution events for BOTH the conda activation AND Roo's command. The previous implementation blindly set the stream when the event fired, causing Roo to pick up the wrong stream and miss its own command's output. This fix: 1. Adds an optional eventCommand parameter to setActiveStream() 2. Passes the command from the shell execution event for verification 3. Only emits stream_available if the event command matches Roo's command 4. Uses flexible prefix matching to handle PowerShell workarounds Fixes #11148
Review complete. No issues found. The log level change from Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
|
@roomote the warn for an expected ignore happening in every terminal is a bit strong. Make it lower / less chatty. Does this also work if conda activation takes 4-5 seconds? |
Changed Regarding timing: Yes, this works regardless of how long conda activation takes. The implementation uses command-string matching (not timing-based), so it will correctly identify and ignore any shell initialization command that doesn't match Roo's expected command. |
This PR attempts to address Issue #11148.
Problem
When a terminal is created with conda auto-activation (or any shell initialization that runs commands), a race condition could occur where VSCode fires
onDidStartTerminalShellExecutionevents for BOTH the conda activation AND Roo's command. The previous implementation blindly set the stream when the event fired, causing Roo to pick up the wrong stream and miss its own command's output.Solution
eventCommandparameter tosetActiveStream()inBaseTerminal.tsTerminalRegistry.onDidStartTerminalShellExecutionto pass the command from the eventeventCommandis provided,stream_availableis only emitted if it matches Roo's expected commandChanges
src/integrations/terminal/types.ts: UpdatedRooTerminal.setActiveStreamsignaturesrc/integrations/terminal/BaseTerminal.ts: AddedcommandsMatch()static method and command verificationsrc/integrations/terminal/TerminalRegistry.ts: Pass eventCommand to setActiveStreamsrc/integrations/terminal/__tests__/BaseTerminal.spec.ts: Added comprehensive testsTesting
Feedback and guidance are welcome.
Important
Fixes race condition in terminal command execution by verifying command matches before setting stream, preventing interference from auto-activation commands.
eventCommandparameter tosetActiveStream()inBaseTerminal.tsto verify command matches before setting stream.TerminalRegistry.onDidStartTerminalShellExecutionto passeventCommandfor verification.commandsMatch()to prevent interference from auto-activation commands.BaseTerminal.spec.tsfor command matching and stream handling.RooTerminal.setActiveStreamsignature intypes.ts.This description was created by
for 75501ab. You can customize this summary. It will automatically update as commits are pushed.