Skip to content

Commit 180acbe

Browse files
fix: pass UserRules to NotificationCategorizer (closes #94)
UserRules from settings were never passed to Classify() — custom notification rules were silently ignored. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b511e50 commit 180acbe

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/OpenClaw.Shared/OpenClawGatewayClient.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class OpenClawGatewayClient : WebSocketClientBase
2222
private bool _usageCostUnsupported;
2323
private bool _sessionPreviewUnsupported;
2424
private bool _nodeListUnsupported;
25+
private IReadOnlyList<UserNotificationRule>? _userRules;
2526

2627
private void ResetUnsupportedMethodFlags()
2728
{
@@ -31,6 +32,16 @@ private void ResetUnsupportedMethodFlags()
3132
_nodeListUnsupported = false;
3233
}
3334

35+
/// <summary>
36+
/// Provides user-defined notification rules to the categorizer so custom rules
37+
/// are applied when classifying incoming gateway notifications.
38+
/// Call after construction and whenever settings change.
39+
/// </summary>
40+
public void SetUserRules(IReadOnlyList<UserNotificationRule>? rules)
41+
{
42+
_userRules = rules;
43+
}
44+
3445
protected override int ReceiveBufferSize => 16384;
3546
protected override string ClientRole => "gateway";
3647

@@ -851,7 +862,7 @@ private void EmitChatNotification(string text)
851862
Message = displayText,
852863
IsChat = true
853864
};
854-
var (title, type) = _categorizer.Classify(notification);
865+
var (title, type) = _categorizer.Classify(notification, _userRules);
855866
notification.Title = title;
856867
notification.Type = type;
857868
NotificationReceived?.Invoke(this, notification);
@@ -1556,7 +1567,7 @@ private void EmitNotification(string text)
15561567
{
15571568
Message = text.Length > 200 ? text[..200] + "…" : text
15581569
};
1559-
var (title, type) = _categorizer.Classify(notification);
1570+
var (title, type) = _categorizer.Classify(notification, _userRules);
15601571
notification.Title = title;
15611572
notification.Type = type;
15621573
NotificationReceived?.Invoke(this, notification);

src/OpenClaw.Tray.WinUI/App.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,7 @@ private void InitializeGatewayClient()
10811081
UnsubscribeGatewayEvents();
10821082

10831083
_gatewayClient = new OpenClawGatewayClient(_settings.GatewayUrl, _settings.Token, new AppLogger());
1084+
_gatewayClient.SetUserRules(_settings.UserRules.Count > 0 ? _settings.UserRules : null);
10841085
_gatewayClient.StatusChanged += OnConnectionStatusChanged;
10851086
_gatewayClient.ActivityChanged += OnActivityChanged;
10861087
_gatewayClient.NotificationReceived += OnNotificationReceived;

0 commit comments

Comments
 (0)