microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.08k stars 8.24k forks source link

Auto-show progress in task bar based on contents of last line of buffer #8449

Open kishanth-ithayakumar opened 3 years ago

kishanth-ithayakumar commented 3 years ago

Description of the new feature/enhancement

Display percentage loading indicator in windows taskbar. image

  1. Read the last output line in the console.
  2. If there's a string, such as "12%" or "12/100" then, display the percentage in task bar.

Proposed technical implementation details (optional)

zadjii-msft commented 3 years ago

IIRC, this is something that ConEmu does, so we could add a setting to enable this too. I'll link it up with the others at #6700, thanks!

skyline75489 commented 3 years ago

Some thoughts: if every single line needs to be read to determine whether it's an progress indicator line like 42% (42/100), would it cause measurably impact on performance? I highly suspect that it would, no matter how fast regex is. Just imagine how much output bcz produces. We definitely do not want to throw all the CPU away after all the hard work trying to save as many as CPU cycles as possible.

So here's my two cents. The progress indicator line ususally just sticks right at the bottom, right? We should detect this scenerio instead of filtering every single line that's feed to us.

zadjii-msft commented 3 years ago

I believe that's how ConEmu and mintty implemented this as well - it's only detection on the very last line.

DHowett commented 3 years ago

Backlog approved!

dannyvv commented 3 years ago

@DHowett When considering, please also consider supporting the existing api's for windows' taskbar:

There is also some existing art for AzureDevops where special markers in the text stream can show percentage completed of a task.

It would be great if these could be unified. (maybe get agreement on some metadata markers for this) I.e. if the shell could standardize on a pattern that then other systems like github actions, azure devops could consume as is.

image It would be great if these would work in the tabs (and perhaps translate the 'latest' or 'in focus' tab to the windows taskbar.

KalleOlaviNiemitalo commented 3 years ago

@dannyvv, letting ITaskbarList3::SetProgressState set progress on the window returned by GetConsoleWindow and making Windows Terminal proxy that to its own window looks difficult to me:

Perhaps Windows Terminal could instead use ITaskbarList3::RegisterTab to show all panes (not just tabs) in the task bar, and let the task bar combine the progress info… but I guess this would require the registered windows to be visible.

Anyway, it seems the implementation would be complex and almost separate from what was previously requested in this issue.

Making BuildXL output the OSC 9;4 sequence might be much easier.

DHowett commented 3 years ago

Indeed. We talked about this way back when we were first doing ConPTY stuff, and it's capital-H hard. It only works in BXL (and razzle!) because we made the mistake of allowing applications DIRECT unfettered access to the console window handle, which we just can't do any longer. Switching to OSC 9;4 makes it compatible with more terminal emulators on Windows, and even has the benefit of working over a remote connection (say you're remoting to a build machine to fix a build break.)