Skip to content

Commit 06ed71f

Browse files
RBridCopilot
andauthored
Add app notifications surface (#748)
* Permission UI & fixes. * Fix exec policy rule snapshot concurrency Co-authored-by: Copilot <[email protected]> * Retry exec policy atomic saves Co-authored-by: Copilot <[email protected]> * Add app notifications surface Add the Notifications page and InfoBar banner behavior for local command denial notifications. Fix chat turn finalization for late assistant frames and keep composer button tooltips stable during streaming. Localize new notification strings and cover notification state transitions with tests. Co-authored-by: Copilot <[email protected]> * Trigger CI rebuild Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent ea36b12 commit 06ed71f

28 files changed

Lines changed: 2234 additions & 56 deletions

‎src/OpenClaw.Shared/Capabilities/SystemCapability.cs‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ public class SystemCapability : NodeCapabilityBase
6262

6363
// Event to let UI handle the actual notification display
6464
public event EventHandler<SystemNotifyArgs>? NotifyRequested;
65+
66+
/// <summary>
67+
/// Fired when policy denies an exec request non-interactively (no native
68+
/// prompt is shown — e.g. default action is Deny, or matched rule action
69+
/// is Deny). Lets UI surfaces (chat) render a denial card that would
70+
/// otherwise be invisible to the user. Not raised when the user clicks
71+
/// Deny in the native prompt — that path already raises
72+
/// <see cref="ExecApprovalPromptService.Decided"/>.
73+
/// </summary>
74+
public event EventHandler<ExecApprovalPromptDecidedEventArgs>? PolicyAutoDecided;
6575

6676
// Command runner for system.run (swappable: local, docker, wsl)
6777
private ICommandRunner? _commandRunner;
@@ -474,7 +484,10 @@ private async Task<ExecApprovalCheckResult> EnsureApprovedAsync(
474484
return new ExecApprovalCheckResult(true, null);
475485

476486
if (approval.Action != ExecApprovalAction.Prompt || _promptHandler == null || _approvalPolicy == null)
487+
{
488+
RaisePolicyAutoDenied(command, shell, approval);
477489
return new ExecApprovalCheckResult(false, null);
490+
}
478491

479492
var decision = await _promptHandler.RequestAsync(new ExecApprovalPromptRequest
480493
{
@@ -532,6 +545,31 @@ private static bool IsExplicitDeny(ExecApprovalResult approval) =>
532545
private readonly record struct ExecApprovalCheckResult(
533546
bool Allowed,
534547
ExecApprovalPromptDecisionKind? PromptDecisionKind);
548+
549+
private void RaisePolicyAutoDenied(string command, string? shell, ExecApprovalResult approval)
550+
{
551+
var handler = PolicyAutoDecided;
552+
if (handler == null) return;
553+
try
554+
{
555+
var request = new ExecApprovalPromptRequest
556+
{
557+
Command = command,
558+
Shell = shell,
559+
MatchedPattern = approval.MatchedPattern,
560+
Reason = approval.Reason ?? "Command denied by policy"
561+
};
562+
var decision = ExecApprovalPromptDecision.Deny(approval.Reason ?? "Command denied by policy");
563+
handler(this, new ExecApprovalPromptDecidedEventArgs(
564+
request,
565+
decision,
566+
ExecApprovalPromptDecisionSource.PolicyAutoDeny));
567+
}
568+
catch (Exception ex)
569+
{
570+
Logger.Warn($"PolicyAutoDecided handler threw: {ex.Message}");
571+
}
572+
}
535573

536574
private NodeInvokeResponse HandleExecApprovalsGet()
537575
{
@@ -616,7 +654,7 @@ private NodeInvokeResponse HandleExecApprovalsSet(NodeInvokeRequest request)
616654
rule.Action = actStr.ToLowerInvariant() switch
617655
{
618656
"allow" => ExecApprovalAction.Allow,
619-
"prompt" => ExecApprovalAction.Prompt,
657+
"prompt" or "ask" => ExecApprovalAction.Prompt,
620658
_ => ExecApprovalAction.Deny
621659
};
622660
}
@@ -650,7 +688,7 @@ private NodeInvokeResponse HandleExecApprovalsSet(NodeInvokeRequest request)
650688
defaultAction = defStr.ToLowerInvariant() switch
651689
{
652690
"allow" => ExecApprovalAction.Allow,
653-
"prompt" => ExecApprovalAction.Prompt,
691+
"prompt" or "ask" => ExecApprovalAction.Prompt,
654692
_ => ExecApprovalAction.Deny
655693
};
656694
}

0 commit comments

Comments
 (0)