diff --git a/src/OpenClaw.Shared/OpenClawGatewayClient.cs b/src/OpenClaw.Shared/OpenClawGatewayClient.cs index 0e21836..c4987b6 100644 --- a/src/OpenClaw.Shared/OpenClawGatewayClient.cs +++ b/src/OpenClaw.Shared/OpenClawGatewayClient.cs @@ -22,6 +22,7 @@ public class OpenClawGatewayClient : WebSocketClientBase private bool _usageCostUnsupported; private bool _sessionPreviewUnsupported; private bool _nodeListUnsupported; + private IReadOnlyList? _userRules; private void ResetUnsupportedMethodFlags() { @@ -31,6 +32,16 @@ private void ResetUnsupportedMethodFlags() _nodeListUnsupported = false; } + /// + /// Provides user-defined notification rules to the categorizer so custom rules + /// are applied when classifying incoming gateway notifications. + /// Call after construction and whenever settings change. + /// + public void SetUserRules(IReadOnlyList? rules) + { + _userRules = rules; + } + protected override int ReceiveBufferSize => 16384; protected override string ClientRole => "gateway"; @@ -851,7 +862,7 @@ private void EmitChatNotification(string text) Message = displayText, IsChat = true }; - var (title, type) = _categorizer.Classify(notification); + var (title, type) = _categorizer.Classify(notification, _userRules); notification.Title = title; notification.Type = type; NotificationReceived?.Invoke(this, notification); @@ -1556,7 +1567,7 @@ private void EmitNotification(string text) { Message = text.Length > 200 ? text[..200] + "…" : text }; - var (title, type) = _categorizer.Classify(notification); + var (title, type) = _categorizer.Classify(notification, _userRules); notification.Title = title; notification.Type = type; NotificationReceived?.Invoke(this, notification); diff --git a/src/OpenClaw.Tray.WinUI/App.xaml.cs b/src/OpenClaw.Tray.WinUI/App.xaml.cs index de0780f..f22e2ad 100644 --- a/src/OpenClaw.Tray.WinUI/App.xaml.cs +++ b/src/OpenClaw.Tray.WinUI/App.xaml.cs @@ -1085,6 +1085,7 @@ private void InitializeGatewayClient() UnsubscribeGatewayEvents(); _gatewayClient = new OpenClawGatewayClient(_settings.GatewayUrl, _settings.Token, new AppLogger()); + _gatewayClient.SetUserRules(_settings.UserRules.Count > 0 ? _settings.UserRules : null); _gatewayClient.StatusChanged += OnConnectionStatusChanged; _gatewayClient.ActivityChanged += OnActivityChanged; _gatewayClient.NotificationReceived += OnNotificationReceived;