fix: skip shell-integration wait for shells without SI support (fixes #1391)#1501
Merged
anthonykim1 merged 1 commit intomicrosoft:mainfrom May 2, 2026
Merged
fix: skip shell-integration wait for shells without SI support (fixes #1391)#1501anthonykim1 merged 1 commit intomicrosoft:mainfrom
anthonykim1 merged 1 commit intomicrosoft:mainfrom
Conversation
…soft#1391) waitForShellIntegration() blocks for up to 5s waiting for an onDidChangeTerminalShellIntegration event that never fires for shells VS Code does not provide shell integration for (nu, cmd, csh, tcsh, ksh, xonsh). The wait is followed by a fallback terminal.sendText() activation that doesn't depend on shell integration anyway, so the delay is pure overhead. After the existing terminal.shellIntegration early-return, identify the shell via identifyTerminalShell() and return false immediately when the type is known and not in shellIntegrationSupportedShells. The check is wrapped in try/catch so any detection failure (or an 'unknown' result) falls through to the existing race, preserving prior behavior. For nu users this turns a ~5s freeze before activation into an imperceptible delay. Tests: - 8 new unit tests covering: nu/cmd/csh/tcsh/ksh/xonsh skip immediately, supported shells fall through to the race, unknown falls through, detection throwing falls through, undefined terminal and pre-existing shellIntegration early-returns. Fixes microsoft#1391
Contributor
Author
|
@anthonykim1 I made some changes around shell integration, would you mind taking a look as well? Thanks! |
eleanorjboyd
approved these changes
May 1, 2026
bpasero
approved these changes
May 1, 2026
Contributor
|
@StellaHuang95 This looks good, thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1391 — terminal activation is slow on nushell (and any other shell VS Code doesn't provide shell integration for).
When a Python terminal opens in
commandactivation mode,waitForShellIntegration()is awaited before sending the activation command. For shells VS Code does not provide shell integration for —nu,cmd,csh,tcsh,ksh,xonsh— theonDidChangeTerminalShellIntegrationevent never fires, the prompt-pattern heuristic is unreliable, and the wait runs out the full 5 s default timeout (pergetShellIntegrationTimeout()whenterminal.integrated.shellIntegration.enabledis true). Once the wait completes, activation falls back toterminal.sendTextanyway — so the delay is pure overhead and visibly disrupts the user's typing in the new terminal.Root cause
waitForShellIntegration()insrc/features/terminal/utils.tsdoesn't consult the codebase's existing source of truth for SI-capable shells (shellIntegrationSupportedShellsinsrc/features/terminal/shells/common/shellUtils.ts). Fornu, that means it always times out.Fix
After the existing
terminal.shellIntegrationearly-return inwaitForShellIntegration, identify the shell viaidentifyTerminalShell()and returnfalseimmediately when the shell type is known and not inshellIntegrationSupportedShells. Wrapped intry/catchso any detection failure (or'unknown'result) falls through to the existingPromise.racebody — strictly additive: best case faster, worst case identical to today.This:
shellIntegrationSupportedShells), so adding a new SI-capable shell automatically benefits both this code andshouldUseProfileActivation.false) the function would have eventually returned — semantics unchanged for all callers, only latency differs.pwsh,bash,gitbash,fish,zsh).try/catchand explicit'unknown'check make the change non-regressing even if shell detection fails.For nu users, this turns the ~5 s freeze before
overlay use ...activate.nuruns into an imperceptible delay.Testing
Manual
On
mainwithnuconfigured as default profile andpython-envs.terminal.autoActivationType: "command":On this branch, same setup:
Python Environmentsoutput channel logs:Shell 'nu' does not support shell integration; skipping wait.Verified the fix does not alter behavior for
pwsh/bash(they still wait for SI to come up, which they do quickly).Automated
8 new unit tests in
Terminal Utils - waitForShellIntegrationcover:undefinedterminal →falseimmediatelyterminal.shellIntegrationalready set →trueimmediately, no shell detectionnu→falseimmediately, no event listeners registeredcmd→falseimmediatelycsh/tcsh/ksh/xonsh→ allfalseimmediatelybash→ falls through to event race, resolvestruewhen SI event firesunknownshell → falls through to raceidentifyTerminalShellthrows → falls through to race (defensive)Related
nu, it will fall back to command activation." This PR makes that command-activation fallback fast.Risk
Low. Fully covered by tests. The change is gated by
try/catchand an explicit allow-list, so the worst case (detection fails or returns'unknown') is identical to current behavior.