Skip to content
Draft
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
83 changes: 43 additions & 40 deletions src/OpenClaw.Tray.WinUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,9 @@ private void CopyDeviceIdToClipboard()
global::Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);

// Show toast confirming copy
new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(LocalizationHelper.GetString("Toast_DeviceIdCopied"))
.AddText(string.Format(LocalizationHelper.GetString("Toast_DeviceIdCopiedDetail"), _nodeService.ShortDeviceId))
.Show();
.AddText(string.Format(LocalizationHelper.GetString("Toast_DeviceIdCopiedDetail"), _nodeService.ShortDeviceId)));
}
catch (Exception ex)
{
Expand All @@ -597,10 +596,9 @@ private void CopyNodeSummaryToClipboard()
dataPackage.SetText(summary);
global::Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);

new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(LocalizationHelper.GetString("Toast_NodeSummaryCopied"))
.AddText(string.Format(LocalizationHelper.GetString("Toast_NodeSummaryCopiedDetail"), _lastNodes.Length))
.Show();
.AddText(string.Format(LocalizationHelper.GetString("Toast_NodeSummaryCopiedDetail"), _lastNodes.Length)));
}
catch (Exception ex)
{
Expand Down Expand Up @@ -654,10 +652,9 @@ private async Task ExecuteSessionActionAsync(string action, string sessionKey, s

if (!sent)
{
new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(LocalizationHelper.GetString("Toast_SessionActionFailed"))
.AddText(LocalizationHelper.GetString("Toast_SessionActionFailedDetail"))
.Show();
.AddText(LocalizationHelper.GetString("Toast_SessionActionFailedDetail")));
return;
}

Expand All @@ -671,10 +668,9 @@ private async Task ExecuteSessionActionAsync(string action, string sessionKey, s
Logger.Warn($"Session action error ({action}): {ex.Message}");
try
{
new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(LocalizationHelper.GetString("Toast_SessionActionFailed"))
.AddText(ex.Message)
.Show();
.AddText(ex.Message));
}
catch { }
}
Expand Down Expand Up @@ -1157,10 +1153,9 @@ private void OnNodeStatusChanged(object? sender, ConnectionStatus status)
{
try
{
new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(LocalizationHelper.GetString("Toast_NodeModeActive"))
.AddText(LocalizationHelper.GetString("Toast_NodeModeActiveDetail"))
.Show();
.AddText(LocalizationHelper.GetString("Toast_NodeModeActiveDetail")));
}
catch { /* ignore */ }
}
Expand All @@ -1176,18 +1171,16 @@ private void OnPairingStatusChanged(object? sender, OpenClaw.Shared.PairingStatu
{
AddRecentActivity("Node pairing pending", category: "node", dashboardPath: "nodes", nodeId: args.DeviceId);
// Show toast with approval instructions
new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(LocalizationHelper.GetString("Toast_PairingPending"))
.AddText(string.Format(LocalizationHelper.GetString("Toast_PairingPendingDetail"), args.DeviceId.Substring(0, 16)))
.Show();
.AddText(string.Format(LocalizationHelper.GetString("Toast_PairingPendingDetail"), args.DeviceId.Substring(0, 16))));
}
else if (args.Status == OpenClaw.Shared.PairingStatus.Paired)
{
AddRecentActivity("Node paired", category: "node", dashboardPath: "nodes", nodeId: args.DeviceId);
new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(LocalizationHelper.GetString("Toast_NodePaired"))
.AddText(LocalizationHelper.GetString("Toast_NodePairedDetail"))
.Show();
.AddText(LocalizationHelper.GetString("Toast_NodePairedDetail")));
}
}
catch { /* ignore */ }
Expand All @@ -1200,10 +1193,9 @@ private void OnNodeNotificationRequested(object? sender, OpenClaw.Shared.Capabil
// Agent requested a notification via node.invoke system.notify
try
{
new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(args.Title)
.AddText(args.Body)
.Show();
.AddText(args.Body));
}
catch (Exception ex)
{
Expand Down Expand Up @@ -1376,10 +1368,9 @@ private void OnSessionCommandCompleted(object? sender, SessionCommandResult resu
dashboardPath: !string.IsNullOrWhiteSpace(result.Key) ? $"sessions/{result.Key}" : "sessions",
sessionKey: result.Key);

new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(title)
.AddText(message)
.Show();
.AddText(message));
}
catch (Exception ex)
{
Expand Down Expand Up @@ -1434,7 +1425,7 @@ private void OnNotificationReceived(object? sender, OpenClawNotification notific
.AddArgument("action", "open_chat"));
}

builder.Show();
ShowToast(builder);
}
catch (Exception ex)
{
Expand All @@ -1451,6 +1442,22 @@ private void OnNotificationReceived(object? sender, OpenClawNotification notific
return System.IO.File.Exists(iconPath) ? iconPath : null;
}

/// <summary>Applies the user's NotificationSound preference to a builder, then shows it.</summary>
private void ShowToast(ToastContentBuilder builder)
{
switch (_settings?.NotificationSound)
{
case "None":
builder.AddAudio(silent: true);
break;
case "Subtle":
builder.AddAudio(new Uri("ms-winsoundevent:Notification.IM"));
break;
// "Default" or null: no-op — let Windows use its default sound
}
builder.Show();
}

private bool ShouldShowNotification(OpenClawNotification notification)
{
if (_settings == null) return true;
Expand Down Expand Up @@ -1498,10 +1505,9 @@ private async Task RunHealthCheckAsync(bool userInitiated = false)
{
if (userInitiated)
{
new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(LocalizationHelper.GetString("Toast_HealthCheck"))
.AddText(LocalizationHelper.GetString("Toast_HealthCheckNotConnected"))
.Show();
.AddText(LocalizationHelper.GetString("Toast_HealthCheckNotConnected")));
}
return;
}
Expand All @@ -1512,21 +1518,19 @@ private async Task RunHealthCheckAsync(bool userInitiated = false)
await _gatewayClient.CheckHealthAsync();
if (userInitiated)
{
new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(LocalizationHelper.GetString("Toast_HealthCheck"))
.AddText(LocalizationHelper.GetString("Toast_HealthCheckSent"))
.Show();
.AddText(LocalizationHelper.GetString("Toast_HealthCheckSent")));
}
}
catch (Exception ex)
{
Logger.Warn($"Health check failed: {ex.Message}");
if (userInitiated)
{
new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(LocalizationHelper.GetString("Toast_HealthCheckFailed"))
.AddText(ex.Message)
.Show();
.AddText(ex.Message));
}
}
}
Expand Down Expand Up @@ -1749,13 +1753,12 @@ private void ShowSurfaceImprovementsTipIfNeeded()

try
{
new ToastContentBuilder()
ShowToast(new ToastContentBuilder()
.AddText(LocalizationHelper.GetString("Toast_ActivityStreamTip"))
.AddText(LocalizationHelper.GetString("Toast_ActivityStreamTipDetail"))
.AddButton(new ToastButton()
.SetContent(LocalizationHelper.GetString("Toast_ActivityStreamTipButton"))
.AddArgument("action", "open_activity"))
.Show();
.AddArgument("action", "open_activity")));
}
catch (Exception ex)
{
Expand Down