Skip to content
Draft
Show file tree
Hide file tree
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
15 changes: 13 additions & 2 deletions src/OpenClaw.Shared/OpenClawGatewayClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class OpenClawGatewayClient : WebSocketClientBase
private bool _usageCostUnsupported;
private bool _sessionPreviewUnsupported;
private bool _nodeListUnsupported;
private IReadOnlyList<UserNotificationRule>? _userRules;

private void ResetUnsupportedMethodFlags()
{
Expand All @@ -31,6 +32,16 @@ private void ResetUnsupportedMethodFlags()
_nodeListUnsupported = false;
}

/// <summary>
/// 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.
/// </summary>
public void SetUserRules(IReadOnlyList<UserNotificationRule>? rules)
{
_userRules = rules;
}

protected override int ReceiveBufferSize => 16384;
protected override string ClientRole => "gateway";

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/OpenClaw.Tray.WinUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down