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

Add support for Write-Progress cmdlet #140

Open
HairyCream opened this Issue Apr 14, 2016 · 23 comments

Comments

Projects
None yet
@HairyCream

HairyCream commented Apr 14, 2016

The following code, when executed using the debugger, will show the Write-Host output, but not the Write-Progress output.
for ($i = 1; $i -le 10; $i++ ) {write-progress -activity "Search in Progress" -status "$i% Complete:" -percentcomplete $i; Write-Host "Seconds Passed: " $i; Start-Sleep 1}

@daviwil daviwil added this to the Backlog milestone Apr 14, 2016

@daviwil

This comment has been minimized.

Show comment
Hide comment
@daviwil

daviwil Apr 14, 2016

Collaborator

Thanks for filing this. I'll have to see if there's a reasonable way to show progress in VS Code other than just writing progress lines to the console text.

Collaborator

daviwil commented Apr 14, 2016

Thanks for filing this. I'll have to see if there's a reasonable way to show progress in VS Code other than just writing progress lines to the console text.

@thoughtentity

This comment has been minimized.

Show comment
Hide comment
@thoughtentity

thoughtentity Apr 16, 2016

One possible thought for showing progress for long running PowerShell operations would be to pipe Write-Progress message as status bar messages in VS Code. I believe the API was designed to show ephemeral messages as it supports automatically expiring messages based on a timeout or Disposable. VS Code also uses the status bar area to show long running git operations (spinning icon during git push and pull).

thoughtentity commented Apr 16, 2016

One possible thought for showing progress for long running PowerShell operations would be to pipe Write-Progress message as status bar messages in VS Code. I believe the API was designed to show ephemeral messages as it supports automatically expiring messages based on a timeout or Disposable. VS Code also uses the status bar area to show long running git operations (spinning icon during git push and pull).

@rkeithhill

This comment has been minimized.

Show comment
Hide comment
@rkeithhill

rkeithhill Apr 16, 2016

Collaborator

That thought occurred to me as well. One issue is that Write-Progress can support up to three separate strings that should all be displayed: Activity, Status and CurrentOperation in addition to a percent complete value. Another issue is that Write-Progress supports multiple active, potentially nested progress bars.

Maybe the extension needs to create a UI for progress records kind of like ISE does where the UI is display at the top of the console pane. Not sure if that is possible with VSCode.

Collaborator

rkeithhill commented Apr 16, 2016

That thought occurred to me as well. One issue is that Write-Progress can support up to three separate strings that should all be displayed: Activity, Status and CurrentOperation in addition to a percent complete value. Another issue is that Write-Progress supports multiple active, potentially nested progress bars.

Maybe the extension needs to create a UI for progress records kind of like ISE does where the UI is display at the top of the console pane. Not sure if that is possible with VSCode.

@daviwil

This comment has been minimized.

Show comment
Hide comment
@daviwil

daviwil Apr 16, 2016

Collaborator

Yeah, we currently don't have the ability to create custom UI in VS Code. @thoughtentity's idea is a good one, but like Keith says, PowerShell progress bars can get pretty complex so the status bar might not be the best place to represent that. We'll have to look for a creative solution for showing progress in more complex scenarios.

Collaborator

daviwil commented Apr 16, 2016

Yeah, we currently don't have the ability to create custom UI in VS Code. @thoughtentity's idea is a good one, but like Keith says, PowerShell progress bars can get pretty complex so the status bar might not be the best place to represent that. We'll have to look for a creative solution for showing progress in more complex scenarios.

@ChrisLynchHPE

This comment has been minimized.

Show comment
Hide comment
@ChrisLynchHPE

ChrisLynchHPE Mar 17, 2017

Looking forward to this feature. I have a number of build scripts that I use Write-Progress and currently with 0.10.0 am unable to see the output from. If I use the integrated console (powershell.exe) separately from the vscode-powershell plugin 'Integrated PowerShell Console', Write-Progress does output, and very well I might add.

ChrisLynchHPE commented Mar 17, 2017

Looking forward to this feature. I have a number of build scripts that I use Write-Progress and currently with 0.10.0 am unable to see the output from. If I use the integrated console (powershell.exe) separately from the vscode-powershell plugin 'Integrated PowerShell Console', Write-Progress does output, and very well I might add.

@daviwil

This comment has been minimized.

Show comment
Hide comment
@daviwil

daviwil Mar 17, 2017

Collaborator

Yep, I've basically written my own ConsoleHost so I have to implement my own version of Write-Progress in this case. I'll probably try to borrow the implementation from PowerShell Core which isn't as pretty but gets the job done.

Collaborator

daviwil commented Mar 17, 2017

Yep, I've basically written my own ConsoleHost so I have to implement my own version of Write-Progress in this case. I'll probably try to borrow the implementation from PowerShell Core which isn't as pretty but gets the job done.

@andysimmons

This comment has been minimized.

Show comment
Hide comment
@andysimmons

andysimmons May 9, 2017

I don't know if it'll handle the complexity of PS progress bars yet, but there are some new APIs in the latest (1.12.1) VS Code release that might be interesting.

https://code.visualstudio.com/updates/v1_12#_extension-authoring

Awesome extension, by the way.

andysimmons commented May 9, 2017

I don't know if it'll handle the complexity of PS progress bars yet, but there are some new APIs in the latest (1.12.1) VS Code release that might be interesting.

https://code.visualstudio.com/updates/v1_12#_extension-authoring

Awesome extension, by the way.

@daviwil

This comment has been minimized.

Show comment
Hide comment
@daviwil

daviwil May 9, 2017

Collaborator

Thanks Andy! Yep, I've considered using that but not sure if it will be a good UX. I'll experiment with it pretty soon :)

Collaborator

daviwil commented May 9, 2017

Thanks Andy! Yep, I've considered using that but not sure if it will be a good UX. I'll experiment with it pretty soon :)

@daviwil daviwil modified the milestones: June 2017, Backlog May 9, 2017

@stephenbonar

This comment has been minimized.

Show comment
Hide comment
@stephenbonar

stephenbonar May 12, 2017

Version 1.0 seems much more stable than the pre-release versions, I find myself using the PowerShell ISE less and less! I'm definitely looking forward to Write-Progress functioning in the integrated console, but until then, I at least have the workaround of adding a powershell.exe console in the integrated terminal, which still shows progress.

stephenbonar commented May 12, 2017

Version 1.0 seems much more stable than the pre-release versions, I find myself using the PowerShell ISE less and less! I'm definitely looking forward to Write-Progress functioning in the integrated console, but until then, I at least have the workaround of adding a powershell.exe console in the integrated terminal, which still shows progress.

@crshnbrn66

This comment has been minimized.

Show comment
Hide comment
@crshnbrn66

crshnbrn66 May 30, 2017

I too have been using VScode more and more and less and less ISE.

crshnbrn66 commented May 30, 2017

I too have been using VScode more and more and less and less ISE.

@daviwil

This comment has been minimized.

Show comment
Hide comment
@daviwil

daviwil May 31, 2017

Collaborator

I've got an idea on how I might be able to reuse PowerShell's existing progress display, will experiment with this a bit and hopefully get it working in 1.3 or 1.4.

Collaborator

daviwil commented May 31, 2017

I've got an idea on how I might be able to reuse PowerShell's existing progress display, will experiment with this a bit and hopefully get it working in 1.3 or 1.4.

@daviwil daviwil modified the milestones: 1.3.0, June 2017 May 31, 2017

@daviwil daviwil modified the milestones: June 2017, July 2017 Jul 11, 2017

@tmknight

This comment has been minimized.

Show comment
Hide comment
@tmknight

tmknight Jul 21, 2017

HI, any update to this highly anticipated enhancement?

tmknight commented Jul 21, 2017

HI, any update to this highly anticipated enhancement?

@jmiller76

This comment has been minimized.

Show comment
Hide comment
@jmiller76

jmiller76 Jul 31, 2017

https://github.com/gravejester/psInlineProgress
or
Install-Module -Name psInlineProgress -Scope "CurrentUser"

This works if you tweak line 110 in the PSM1 to bypass the detection of the ISE. Also a tweak in the psd1. (I just copied the functions over and ran)
CC: @gravejester

jmiller76 commented Jul 31, 2017

https://github.com/gravejester/psInlineProgress
or
Install-Module -Name psInlineProgress -Scope "CurrentUser"

This works if you tweak line 110 in the PSM1 to bypass the detection of the ISE. Also a tweak in the psd1. (I just copied the functions over and ran)
CC: @gravejester

@FireInWinter

This comment has been minimized.

Show comment
Hide comment
@FireInWinter

FireInWinter Sep 5, 2017

This is a big issue for me. I have a lot of scripts that can take hours to run, but show the progress through Write-Progress. Without it, I have no way of seeing what it is doing without modifying a lot of code. Could we please get something even if it isn't a perfectly good UX? Having something that sort of works and is ugly is better than nothing.

I also don't understand why the default console (powershell.exe) handles it just fine. Why not implement that for now until a better looking solution is available?

FireInWinter commented Sep 5, 2017

This is a big issue for me. I have a lot of scripts that can take hours to run, but show the progress through Write-Progress. Without it, I have no way of seeing what it is doing without modifying a lot of code. Could we please get something even if it isn't a perfectly good UX? Having something that sort of works and is ugly is better than nothing.

I also don't understand why the default console (powershell.exe) handles it just fine. Why not implement that for now until a better looking solution is available?

@thoughtentity

This comment has been minimized.

Show comment
Hide comment
@thoughtentity

thoughtentity Sep 5, 2017

The current VS Code release v1.15.1 has built in support for the Write-Progress cmdlet in the regular integrated shell however the progress UI will not show up if you're using the integrated shell provided by VS Code PowerShell extension.

image

thoughtentity commented Sep 5, 2017

The current VS Code release v1.15.1 has built in support for the Write-Progress cmdlet in the regular integrated shell however the progress UI will not show up if you're using the integrated shell provided by VS Code PowerShell extension.

image

@tmknight

This comment has been minimized.

Show comment
Hide comment
@tmknight

tmknight Sep 6, 2017

Confirmed! Either execute your dotted script in 'powershell' host (not powershell integrated) or copy and paste code into 'powershell'.

Else use https://github.com/gravejester/psInlineProgress. Be sure to REM Line 36 of the psd1 - the psm1 already does a check for $Host.Name -notlike '*ISE*':
# Name of the Windows PowerShell host required by this module
#PowerShellHostName = 'ConsoleHost'

tmknight commented Sep 6, 2017

Confirmed! Either execute your dotted script in 'powershell' host (not powershell integrated) or copy and paste code into 'powershell'.

Else use https://github.com/gravejester/psInlineProgress. Be sure to REM Line 36 of the psd1 - the psm1 already does a check for $Host.Name -notlike '*ISE*':
# Name of the Windows PowerShell host required by this module
#PowerShellHostName = 'ConsoleHost'

@dragonwolf83

This comment has been minimized.

Show comment
Hide comment
@dragonwolf83

dragonwolf83 Feb 22, 2018

VS Code team has a new ticket for a better Progress API Microsoft/vscode#44090. At quick glance, I think it would give us a GUI that could handle PowerShell's Write-Progress complexities. Please track the API and provide feedback as they develop it.

@tylerl0706 I voted in PowerShell/PowerShellEditorServices#384 to go ahead and get the terminal progress working as a first step. That is a big feature missing. The GUI version can always be exposed later as an added enhancement.

dragonwolf83 commented Feb 22, 2018

VS Code team has a new ticket for a better Progress API Microsoft/vscode#44090. At quick glance, I think it would give us a GUI that could handle PowerShell's Write-Progress complexities. Please track the API and provide feedback as they develop it.

@tylerl0706 I voted in PowerShell/PowerShellEditorServices#384 to go ahead and get the terminal progress working as a first step. That is a big feature missing. The GUI version can always be exposed later as an added enhancement.

@rkeithhill

This comment has been minimized.

Show comment
Hide comment
@rkeithhill

rkeithhill Mar 2, 2018

Collaborator

I dunno on this. PS Core has perf issues with write-progress and that is all handled within the same process. For this, we're talking about sending json messages from one process (PS debug adapter) to another (VSCode extension). And given Electron's architecture there might even be a third process involved. Hopefully we can get the integrated console up-to-snuff in terms of displaying progress.

Collaborator

rkeithhill commented Mar 2, 2018

I dunno on this. PS Core has perf issues with write-progress and that is all handled within the same process. For this, we're talking about sending json messages from one process (PS debug adapter) to another (VSCode extension). And given Electron's architecture there might even be a third process involved. Hopefully we can get the integrated console up-to-snuff in terms of displaying progress.

@tmknight

This comment has been minimized.

Show comment
Hide comment
@tmknight

tmknight Mar 12, 2018

In the interim, I've created a module to display progress (attached). Not super elegant, but may work for most purposes: https://github.com/tmknight/Write-InlineProgress

tmknight commented Mar 12, 2018

In the interim, I've created a module to display progress (attached). Not super elegant, but may work for most purposes: https://github.com/tmknight/Write-InlineProgress

@FireInWinter

This comment has been minimized.

Show comment
Hide comment
@FireInWinter

FireInWinter Sep 14, 2018

Is there a possibility of getting this addressed? It seems that people are waiting until they have a perfect solution, but don't seem to get that "Perfect is the enemy of good". Right now we have some weird hacks that don't give full Write-Progress support (you need to modify all scripts/modules to use Write-InlineProgress) and thoughts that doing it in VS Code currently won't be perfect or might have performance issues. How about we get something that isn't perfect, but does implement the full Write-Progress cmdlet? A better/more performant solution can come later as VS Code progresses.

FireInWinter commented Sep 14, 2018

Is there a possibility of getting this addressed? It seems that people are waiting until they have a perfect solution, but don't seem to get that "Perfect is the enemy of good". Right now we have some weird hacks that don't give full Write-Progress support (you need to modify all scripts/modules to use Write-InlineProgress) and thoughts that doing it in VS Code currently won't be perfect or might have performance issues. How about we get something that isn't perfect, but does implement the full Write-Progress cmdlet? A better/more performant solution can come later as VS Code progresses.

@rkeithhill

This comment has been minimized.

Show comment
Hide comment
@rkeithhill

rkeithhill Sep 14, 2018

Collaborator

Seems to me that we should just emulate what PS Core does on Linux - displays the progress inline (using Write-Progress):

image

I'd prefer that to be the default experience even in the Windows ConsoleHost. Admittedly this is just my preferred aesthetics. :-)

Collaborator

rkeithhill commented Sep 14, 2018

Seems to me that we should just emulate what PS Core does on Linux - displays the progress inline (using Write-Progress):

image

I'd prefer that to be the default experience even in the Windows ConsoleHost. Admittedly this is just my preferred aesthetics. :-)

@SeeminglyScience

This comment has been minimized.

Show comment
Hide comment
@SeeminglyScience

SeeminglyScience Sep 14, 2018

Collaborator

We could just hijack ConsoleHost.

The initial runspace that PSES is started in is the runspace created with the process. We could save the value of $Host before starting the PSES runspace and call it's WriteProgress method.

Collaborator

SeeminglyScience commented Sep 14, 2018

We could just hijack ConsoleHost.

The initial runspace that PSES is started in is the runspace created with the process. We could save the value of $Host before starting the PSES runspace and call it's WriteProgress method.

@JustinGrote

This comment has been minimized.

Show comment
Hide comment
@JustinGrote

JustinGrote Oct 10, 2018

I like @SeeminglyScience's thought, if it actually works.

Alternatively could just capture the progress stream and send it to the VSCode Progress API. Maybe have an option toggle

Here's one way to do that.
https://github.com/Microsoft/vscode-extension-samples/tree/master/progress-sample
$pscmd = [Powershell]::Create();$pscmd.AddScript({1..100 | % { Write-Progress -Activity "Test" -Status "Processing $_"}}).Invoke();$pscmd.streams.progress

JustinGrote commented Oct 10, 2018

I like @SeeminglyScience's thought, if it actually works.

Alternatively could just capture the progress stream and send it to the VSCode Progress API. Maybe have an option toggle

Here's one way to do that.
https://github.com/Microsoft/vscode-extension-samples/tree/master/progress-sample
$pscmd = [Powershell]::Create();$pscmd.AddScript({1..100 | % { Write-Progress -Activity "Test" -Status "Processing $_"}}).Invoke();$pscmd.streams.progress

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