Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Comment on lines +31 to +33
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This PR is described as a backport of #27095, which (per the linked PR summary) also increases the update-check backoff from 7 to 14 days. In this backport, UpdateCheckBackoffDays is still set to 7, so either the backport is incomplete or the PR description/linkage should be updated to reflect that only the notification delay is being backported.

Copilot uses AI. Check for mistakes.
/// <summary>
/// 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',
Expand Down Expand Up @@ -89,9 +92,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 < NotificationDelayDays)
Comment on lines +98 to +99
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

lastUpdateDate is parsed from the update file name using DateTimeStyles.AssumeLocal (see TryParseUpdateFile), but this logic compares it against DateTime.UtcNow. That UTC/local mismatch can skew the effective delay by up to ~1 day depending on timezone/DST. Consider normalizing both to the same basis (e.g., compare DateTime.UtcNow.Date to lastUpdateDate.ToUniversalTime().Date, or parse the date as UTC) so the 7-day notification delay is consistent across locales.

Suggested change
DateTime today = DateTime.UtcNow;
if ((today - lastUpdateDate).TotalDays < NotificationDelayDays)
DateTime today = DateTime.UtcNow.Date;
DateTime lastUpdateUtcDate = lastUpdateDate.ToUniversalTime().Date;
if ((today - lastUpdateUtcDate).TotalDays < NotificationDelayDays)

Copilot uses AI. Check for mistakes.
{
// 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;
}

string releaseTag = lastUpdateVersion.ToString();
string notificationMsgTemplate = s_notificationType == NotificationType.LTS
? ManagedEntranceStrings.LTSUpdateNotificationMessage
Expand Down Expand Up @@ -169,7 +181,7 @@ 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 < UpdateCheckBackoffDays)
{
// 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.
Expand Down
Loading