Skip to content
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

Support notification on pwsh startup when a new release is available #10689

Merged
merged 9 commits into from
Oct 8, 2019

Conversation

daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Oct 3, 2019

PR Summary

RFC: PowerShell/PowerShell-RFC#162
Support notification on pwsh startup when a new release is available

  • Preview pwsh will check both new preview and stable releases. It prints notification message at startup time as long as the latest preview version or stable version is higher than the current version.
  • Stable pwsh will check new stable releases only. It prints notification message at startup time if the latest stable version is higher than the current version.
  • Update check and notification will only happen for interactive sessions, and it can be suppressed by both the -NoLogo flag and an environment variable POWERSHELL_UPDATECHECK_OPTOUT.
  • Update check is done by a task that is delayed for 3 seconds after pwsh starts, so it has minimum impact to the startup time.

For detailed implementation design, please look at the RFC.

Notification Message

For stable version pwsh:

C:\Users\user>e:\6.2.1\pwsh.exe -noprofile
PowerShell 6.2.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/powershell
Type 'help' to get help.

!! A new PowerShell stable release is available: v6.2.3 !!
Upgrade now, or check out the release page at:
https://github.com/PowerShell/PowerShell/releases/tag/v6.2.3

PS C:\Users\user>

For preview version pwsh:

C:\Users\user>e:\preview\pwsh.exe -noprofile
PowerShell 6.2.0-preview.3
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/powershell
Type 'help' to get help.

!! A new PowerShell preview release is available: v7.0.0-preview.4 !!
Upgrade now, or check out the release page at:
https://github.com/PowerShell/PowerShell/releases/tag/v7.0.0-preview.4

PS C:\Users\user>

Startup Perf Measurement on my dev machines

Windows

When no new release is available, namely on the latest preview/stable pwsh where notification will not be printed, the update notification change adds about 4ms to the startup time of an interactive session.

  • 2ms spent on starting the update-check task
  • 2ms spent on the notification printing logic

When a new release is available, namely on an old preview/stable pwsh where a notification message will be printed, the update notification change adds about 6ms to the startup time of an interactive session.

  • 2ms spent on starting the update-check task
  • 4ms spent on the notification printing logic

As a reference, Measure-Command { F:\pscore70.preview4\pwsh.exe -noprofile -c exit } takes about 400ms on average on my Windows dev machine.

Linux (Ubuntu 16.04)

When no new release is available, namely on the latest preview/stable pwsh where notification will not be printed, the update notification change adds about 6ms to the startup time of an interactive session.

  • 3ms spent on starting the update-check task
  • 3ms spent on the notification printing logic

When a new release is available, namely on an old preview/stable pwsh where a notification message will be printed, the update notification change adds about 9ms to the startup time of an interactive session.

  • 3ms spent on starting the update-check task
  • 6ms spent on the notification printing logic

As a reference, Measure-Command { pwsh-preview -noprofile -c exit } takes about 445ms on average on my Linux dev machine.

macOS (10.14.6)

When no new release is available, namely on the latest preview/stable pwsh where notification will not be printed, the update notification change adds about 4ms to the startup time of an interactive session.

  • 2ms spent on starting the update-check task
  • 2ms spent on the notification printing logic

When a new release is available, namely on an old preview/stable pwsh where a notification message will be printed, the update notification change adds about 5ms to the startup time of an interactive session.

  • 2ms spent on starting the update-check task
  • 3ms spent on the notification printing logic

As a reference, Measure-Command { pwsh-preview -noprofile -c exit } takes about 316ms on average on my macOS dev machine.

PR Checklist

Copy link
Collaborator

@rjmholt rjmholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks really nice to me. Left a couple of comments but generally looks really good

@daxian-dbw
Copy link
Member Author

daxian-dbw commented Oct 3, 2019

@rjmholt Thanks for the review and feedback! I addressed them all. Also, I decided to use using declaration in QueryNewReleaseAsync to make it less nested.
Can you please take another look?

@daxian-dbw
Copy link
Member Author

@joeyaiello Could you please take a look at the current notification message in the PR description? I decided to not print it in color as it's (1) over striking (annoying) (2) not accessibility friendly.

Copy link
Collaborator

@rjmholt rjmholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@daxian-dbw
Copy link
Member Author

Rebased to resolve a conflict in experimental feature declaration.

@adityapatwardhan adityapatwardhan merged commit a08d5ee into PowerShell:master Oct 8, 2019
@daxian-dbw daxian-dbw deleted the new-notify branch October 8, 2019 22:54
@iSazonov iSazonov added the CL-Experimental Indicates that a PR should be marked as an Experimental Feature in the Change Log label Oct 9, 2019
@iSazonov iSazonov added this to the 7.0.0-preview.5 milestone Oct 9, 2019
@iSazonov
Copy link
Collaborator

iSazonov commented Oct 9, 2019

No tests was added.

@daxian-dbw
Copy link
Member Author

@iSazonov I don't know how to add a test for it. It seems manually testable only -- only interactive session will trigger update-check and notification-printing.

@iSazonov
Copy link
Collaborator

iSazonov commented Oct 9, 2019

We could use HttpListener helper module to emulate server responses, HelpersHostCS to get host output, and test hook to force update check. Although I'm not sure it is worth the effort. Maybe after it ceases to be experimental.

@bergmeister
Copy link
Contributor

bergmeister commented Oct 11, 2019

@daxian-dbw
It does not seem to be aware of the daily build though.
image
A bit of a late feedback: All the exclamation marks make it look very non-standard and not so professional. Generally, I'd recommend to not use any exclamation marks at all as this is a purely informative message (after the first time the user might be very well aware of it). It would be great if it did some maths around the support time whether the current version is still in support or not.

@SteveL-MSFT
Copy link
Member

@bergmeister I'm going to do an update to the message. Let me look at some examples from other software.

@iSazonov
Copy link
Collaborator

@bergmeister This is an experimental feature and feedbacks is not a late. And we were more worried about the code than about the look. :-)

@iSazonov
Copy link
Collaborator

Upgrade now

Not clear how.

@daxian-dbw
Copy link
Member Author

@bergmeister Thanks for the feedback! I was expecting @joeyaiello to take a look at the message but he was busy and didn't get to it.
As @iSazonov said, this PR is more about implementation, and the message will be updated based on feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-Experimental Indicates that a PR should be marked as an Experimental Feature in the Change Log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants