From 5fbf285924f9cc8f9f9c08fffd6b0144dad10160 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 3 Mar 2026 13:07:05 -0800 Subject: [PATCH 1/2] Delay update notification for 1 week --- .../host/msh/UpdatesNotification.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs index b7c001db710..af9e8c66a25 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs @@ -89,9 +89,18 @@ internal static void ShowUpdateNotification(PSHostUserInterface hostUI) if (TryParseUpdateFile( updateFilePath: out _, out SemanticVersion lastUpdateVersion, - lastUpdateDate: out _) + out DateTime lastUpdateDate) && lastUpdateVersion != null) { + DateTime today = DateTime.UtcNow; + if ((today - lastUpdateDate).TotalDays < 7) + { + // The update was out less than 1 weeks ago and it's possible the packages are still rolling out. + // We only show the notification when the update is at least 1 weeks old, to reduce the chance that + // users see the notification but cannot get the new update when they try to install it. + return; + } + string releaseTag = lastUpdateVersion.ToString(); string notificationMsgTemplate = s_notificationType == NotificationType.LTS ? ManagedEntranceStrings.LTSUpdateNotificationMessage @@ -169,10 +178,10 @@ internal static async Task CheckForUpdates() out DateTime lastUpdateDate); DateTime today = DateTime.UtcNow; - if (parseSuccess && updateFilePath != null && (today - lastUpdateDate).TotalDays < 7) + if (parseSuccess && updateFilePath != null && (today - lastUpdateDate).TotalDays < 14) { - // There is an existing update file, and the last update was less than 1 week ago. - // It's unlikely a new version is released within 1 week, so we can skip this check. + // There is an existing update file, and the last update was less than 2 weeks ago. + // It's unlikely a new version is released within 2 weeks, so we can skip this check. return; } From 76c33cc6fa9a6db8c2d4ea2fafa9e44624ed3c49 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 25 Mar 2026 11:40:55 -0700 Subject: [PATCH 2/2] Address Copilot comments --- .../host/msh/UpdatesNotification.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs index af9e8c66a25..eb4557c04d2 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs @@ -28,6 +28,9 @@ internal static class UpdatesNotification private const string StableBuildInfoURL = "https://aka.ms/pwsh-buildinfo-stable"; private const string PreviewBuildInfoURL = "https://aka.ms/pwsh-buildinfo-preview"; + private const int NotificationDelayDays = 7; + private const int UpdateCheckBackoffDays = 7; + /// /// The version of new update is persisted using a file, not as the file content, but instead baked in the file name in the following template: /// `update{notification-type}_{version}_{publish-date}` -- held by 's_updateFileNameTemplate', @@ -93,10 +96,10 @@ internal static void ShowUpdateNotification(PSHostUserInterface hostUI) && lastUpdateVersion != null) { DateTime today = DateTime.UtcNow; - if ((today - lastUpdateDate).TotalDays < 7) + if ((today - lastUpdateDate).TotalDays < NotificationDelayDays) { - // The update was out less than 1 weeks ago and it's possible the packages are still rolling out. - // We only show the notification when the update is at least 1 weeks old, to reduce the chance that + // The update was out less than 1 week ago and it's possible the packages are still rolling out. + // We only show the notification when the update is at least 1 week old, to reduce the chance that // users see the notification but cannot get the new update when they try to install it. return; } @@ -178,10 +181,10 @@ internal static async Task CheckForUpdates() out DateTime lastUpdateDate); DateTime today = DateTime.UtcNow; - if (parseSuccess && updateFilePath != null && (today - lastUpdateDate).TotalDays < 14) + if (parseSuccess && updateFilePath != null && (today - lastUpdateDate).TotalDays < UpdateCheckBackoffDays) { - // There is an existing update file, and the last update was less than 2 weeks ago. - // It's unlikely a new version is released within 2 weeks, so we can skip this check. + // There is an existing update file, and the last update was less than 1 week ago. + // It's unlikely a new version is released within 1 week, so we can skip this check. return; }