diff --git a/agent/ShopDbEndpointAgent.Tray/FleetAlertForm.cs b/agent/ShopDbEndpointAgent.Tray/FleetAlertForm.cs
index 43a9a4d6..a838f434 100644
--- a/agent/ShopDbEndpointAgent.Tray/FleetAlertForm.cs
+++ b/agent/ShopDbEndpointAgent.Tray/FleetAlertForm.cs
@@ -12,15 +12,20 @@ namespace ShopDbEndpointAgent.Tray;
internal sealed class FleetAlertForm : Form
{
private readonly FleetAlert alert;
+ private readonly FleetAlertClient? client;
+ private readonly string? hostname;
private System.Windows.Forms.Timer? countdownTimer;
+ private System.Windows.Forms.Timer? statusCheckTimer;
private int remainingSeconds;
private Label? countdownLabel;
public event EventHandler? OnAcknowledgeClicked;
- public FleetAlertForm(FleetAlert alert)
+ public FleetAlertForm(FleetAlert alert, FleetAlertClient? client = null, string? hostname = null)
{
this.alert = alert ?? throw new ArgumentNullException(nameof(alert));
+ this.client = client;
+ this.hostname = hostname;
Text = string.Empty;
FormBorderStyle = FormBorderStyle.None;
@@ -43,11 +48,46 @@ internal sealed class FleetAlertForm : Form
private void FleetAlertForm_FormClosing(object? sender, FormClosingEventArgs e)
{
countdownTimer?.Stop();
+ statusCheckTimer?.Stop();
}
private void FleetAlertForm_Load(object? sender, EventArgs e)
{
System.Media.SystemSounds.Beep.Play();
+
+ if (client != null && hostname != null)
+ {
+ StartStatusCheck();
+ }
+ }
+
+ private void StartStatusCheck()
+ {
+ statusCheckTimer = new System.Windows.Forms.Timer { Interval = 30000 };
+ statusCheckTimer.Tick += StatusCheckTimer_Tick;
+ statusCheckTimer.Start();
+ }
+
+ private async void StatusCheckTimer_Tick(object? sender, EventArgs e)
+ {
+ if (client == null || hostname == null)
+ return;
+
+ try
+ {
+ var alerts = await client.FetchAlertsAsync(hostname, CancellationToken.None);
+ var stillActive = alerts?.Any(a => a.NotificationId == alert.NotificationId) ?? false;
+
+ if (!stillActive)
+ {
+ statusCheckTimer?.Stop();
+ Close();
+ }
+ }
+ catch
+ {
+ // Ignore errors - keep the form open if we can't check status
+ }
}
private void ApplyRoundedCorners()
@@ -280,6 +320,8 @@ internal sealed class FleetAlertForm : Form
{
countdownTimer?.Stop();
countdownTimer?.Dispose();
+ statusCheckTimer?.Stop();
+ statusCheckTimer?.Dispose();
}
base.Dispose(disposing);
}
diff --git a/agent/ShopDbEndpointAgent.Tray/FleetAlertWorker.cs b/agent/ShopDbEndpointAgent.Tray/FleetAlertWorker.cs
index 2fa0d442..d097b3fb 100644
--- a/agent/ShopDbEndpointAgent.Tray/FleetAlertWorker.cs
+++ b/agent/ShopDbEndpointAgent.Tray/FleetAlertWorker.cs
@@ -129,7 +129,7 @@ internal sealed class FleetAlertWorker : IDisposable
{
try
{
- using var form = new FleetAlertForm(alert);
+ using var form = new FleetAlertForm(alert, client, hostname);
form.OnAcknowledgeClicked += (s, e) => OnAlertAcknowledged(alert, token);
var result = form.ShowDialog();
}
diff --git a/agent/ShopDbEndpointAgent.Tray/ShopDbEndpointAgent.Tray.csproj b/agent/ShopDbEndpointAgent.Tray/ShopDbEndpointAgent.Tray.csproj
index ae79c8c7..9b788fff 100644
--- a/agent/ShopDbEndpointAgent.Tray/ShopDbEndpointAgent.Tray.csproj
+++ b/agent/ShopDbEndpointAgent.Tray/ShopDbEndpointAgent.Tray.csproj
@@ -76,7 +76,10 @@
- 1.6.2
+
+ 1.6.3
true
win-x64
true
diff --git a/agent/ShopDbEndpointAgent/ShopDbEndpointAgent.csproj b/agent/ShopDbEndpointAgent/ShopDbEndpointAgent.csproj
index 554fc04e..6e853e28 100644
--- a/agent/ShopDbEndpointAgent/ShopDbEndpointAgent.csproj
+++ b/agent/ShopDbEndpointAgent/ShopDbEndpointAgent.csproj
@@ -173,7 +173,9 @@
is the side that listens, so an older tray simply never answers. -->
- 1.13.1
+
+ 1.13.2
true
win-x64
true