Skip to content

Start-Transcript + Write-Progress + yarn + MacOS: ^[[23;1R #5159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
6 tasks done
dkattan opened this issue Mar 21, 2025 · 4 comments
Open
6 tasks done

Start-Transcript + Write-Progress + yarn + MacOS: ^[[23;1R #5159

dkattan opened this issue Mar 21, 2025 · 4 comments
Labels
Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!

Comments

@dkattan
Copy link

dkattan commented Mar 21, 2025

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

An ANSI escape sequence is emitted and script execution is blocked until you hit Enter a bunch of times.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Darwin 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name             : ConsoleHost
Version          : 7.5.0
InstanceId       : 54662023-751e-4a90-bdac-1799cccf6dfb
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

1.98.2
ddc367ed5c8936efe395cffeec279b04ffd7db78
arm64

Extension Version

Steps to Reproduce

Run on MacOS in VS Code

# test.ps1
Start-Transcript -Path (New-TemporaryFile).FullName
Write-Progress "a"
yarn --version
Stop-Transcript
PS /Users/user/code> ./test.ps1
Transcript started, output file is /var/folders/c0/vqmgyfpx38q4bwrxrkcgwcyr0000gn/T/tmpMneggD.tmp
1.22.22                                                                                                                 
^[[6;1R

Details

  • Does not happen on VS Code in Windows
  • Does not happen from zsh Terminal outside of VS Code when run from `pwsh -File ./test.ps1

Visuals

Image

Logs

No response

@dkattan dkattan added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Mar 21, 2025
@andyleejordan
Copy link
Member

Hey, can you test in a PowerShell terminal that's in VS Code, but is not the extension terminal? Can you also test with VS Code's shell integration feature disabled?

@dkattan
Copy link
Author

dkattan commented Mar 27, 2025

Hey, can you test in a PowerShell terminal that's in VS Code, but is not the extension terminal? Can you also test with VS Code's shell integration feature disabled?

Okay this is fun. If I paste it in as multiple lines like individual commands, no issue.

However, if I put it all on one line:
Start-Transcript -Path (New-TemporaryFile).FullName;Write-Progress "a"; yarn --version; Stop-Transcript; it breaks on both pwsh and PowerShell Extension terminals.

Using F5 is likely running the whole thing as a single command.

I'm having a hard time disabling the shell integration. I set "terminal.integrated.shellIntegration.enabled": false but $env:TERM_PROGRAM still shows vscode even after relaunching. I'll hammer on it more tomorrow.

@dkattan
Copy link
Author

dkattan commented Mar 28, 2025

I'm having a hard time disabling the shell integration. I set "terminal.integrated.shellIntegration.enabled": false but $env:TERM_PROGRAM still shows vscode even after relaunching. I'll hammer on it more tomorrow.

For posterity: It appears $env:TERM_PROGRAM is an unreliable indicator of whether shellIntegration is enabled or disabled. The more obvious way to tell if the shellIntegration is disabled is to open a new pwsh and hover over it and look for the presence or absence of "Shell integration activated"

Image

Also I find it interesting that shellIntegration-bash.sh uses VSCODE_SHELL_INTEGRATION=1 to prevent installing more than once per session but shellIntegration.ps1 uses $global:__VSCodeOriginalPrompt but I digress.

Ultimately disabling the shell integration did not fix it:

Image

@dkattan
Copy link
Author

dkattan commented Mar 28, 2025

Okay here's something interesting and potentially unrelated but on Windows Write-Progress output is included in the transcript and gets clobbered by yarn --version's output:

**********************
PowerShell transcript start
Start time: 20250328063748
Username: AzureAD\DarrenKattan
RunAs User: AzureAD\DarrenKattan
Configuration Name: 
Machine: DKATTAN-PC3 (Microsoft Windows NT 10.0.26100.0)
Host Application: C:\Program Files\PowerShell\7\pwsh.dll -WorkingDirectory ~
Process ID: 26296
PSVersion: 7.5.0
PSEdition: Core
GitCommitId: 7.5.0
OS: Microsoft Windows 10.0.26100
Platform: Win32NT
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 7.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
WSManStackVersion: 3.0
**********************
Transcript started, output file is C:\Users\DKattan\AppData\Local\Temp\tmpgp3yin.tmp
1.22.19essing                                                                                                        ]
**********************
PowerShell transcript end
End time: 20250328063748
**********************

However, if I don't run yarn at all, Write-Progress output is not included:

Start-Transcript -Path (New-TemporaryFile).FullName;"Running Write-Progress";Write-Progress "a";"Stopping Transcript"; Stop-Transcript;
**********************
PowerShell transcript start
Start time: 20250328064528
Username: AzureAD\DarrenKattan
RunAs User: AzureAD\DarrenKattan
Configuration Name: 
Machine: DKATTAN-PC3 (Microsoft Windows NT 10.0.26100.0)
Host Application: C:\Program Files\PowerShell\7\pwsh.dll -WorkingDirectory ~
Process ID: 26296
PSVersion: 7.5.0
PSEdition: Core
GitCommitId: 7.5.0
OS: Microsoft Windows 10.0.26100
Platform: Win32NT
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 7.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
WSManStackVersion: 3.0
**********************
Transcript started, output file is C:\Users\DKattan\AppData\Local\Temp\tmplq1ybd.tmp
Running Write-Progress
Stopping Transcript
**********************
PowerShell transcript end
End time: 20250328064528
**********************

On MacOS if I continuously hit Enter to get through it while including yarn, Write-Progress output is not included, and Write-Progress is also not included without yarn.

So I guess the question is, should Write-Progress messages be included in the transcript? It seems like they shouldn't. But for some reason they are when NativeCommands like yarn are run.

I suppose the strangest thing is that I can't repro is in a Terminal outside of VS Code. If I open Terminal on MacOS and then type pwsh and paste this same repro line in it works just fine.

Final clue!
If I redirect stderr to stdout, everything works as expected:

$global:__VSCodeOriginalPrompt;Start-Transcript -Path (New-TemporaryFile).FullName;Write-Progress "a"; yarn --version 2>&1; Stop-Transcript;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!
Projects
None yet
Development

No branches or pull requests

2 participants