Skip to content

feat: add the exec approval prompt dialog - #3

Closed
AlexAlves87 wants to merge 4 commits into
fix/exec-approvals-reject-shell-interpretersfrom
feat/exec-approvals-prompt-dialog
Closed

AlexAlves87 wants to merge 4 commits into
fix/exec-approvals-reject-shell-interpretersfrom
feat/exec-approvals-prompt-dialog

Conversation

@AlexAlves87

@AlexAlves87 AlexAlves87 commented Jul 21, 2026 •

Copy link
Copy Markdown
Owner

Stacked on openclaw#1039. Review after A.
This PR targets the branch of openclaw#1039, so the diff below is only the dialog. It will be retargeted to main once openclaw#1039 merges.

What

Adds the real approval dialog for the new exec-approvals path, behind the same opt-in gate:

  • A display sanitizer that escapes invisible and direction-changing code points in the command text before it is shown.
  • A UI-free prompt-handler core (the dispatcher hop and the window are injected as delegates) so its behavior is unit-testable without WinUI. It is fail-closed: it never throws, never returns a plain allow, and denies on cancellation, dispatcher-enqueue failure, window close, or any internal error.
  • The WindowEx dialog itself, built in code like the existing pairing and recording-consent dialogs. The allow buttons are never default-focused and arm only after a short delay and once the whole command has been scrolled into view. Escape, the close button, and Alt+F4 resolve to Deny.
  • A mixed-script confusable check (Unicode UTS perf: hoist shell normalisation and cache notification regex objects openclaw/openclaw-windows-node#39): the dialog warns when a command token mixes Latin with Cyrillic or Greek letters, instead of escaping them (which would mangle legitimate non-ASCII text).
  • Localized strings for all five locales.

Inert until enabled

The coordinator keeps AlwaysCannotPresentEvaluator, so the dialog is not shown in production. Combined with the opt-in flag being off by default, the new path stays inert. The only production wiring change is replacing the null prompt handler with the real one in the coordinator construction.

Validation

  • ./build.ps1: succeeds with no warnings or errors.
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj (invariant globalization): passes. One pre-existing culture-formatting test unrelated to this change requires a non-invariant culture and passes without the invariant flag.
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj (invariant globalization): passes.
  • ./scripts/validate-mxc-e2e.ps1: passes. Both real-gateway system.run MXC proofs pass.

Real behavior proof

Pipeline behavior is covered end to end: the real-gateway system.run MXC E2E passes, and the coordinator and prompt-handler integration tests exercise the approval path with the real handler. The dialog's on-screen behavior is Not verified / blocked: manual visual verification is pending and will be completed before this leaves Draft (foreground display, allow-button arming after the delay and full scroll, Escape/close/Alt+F4 resolving to Deny, escaped rendering of invisible characters, the mixed-script warning, and higher display scaling).

Co-Authored-By: Claude Sonnet 4.6 [email protected]

AlexAlves87 and others added 4 commits July 21, 2026 05:00
Command text shown in an approval prompt can carry invisible or
direction-changing code points (BiDi overrides, zero-width characters, fake
line breaks, non-ASCII spaces) that let an agent make the approved text look
like a different command. Add a rune-based sanitizer that escapes those code
points as \u{HEX} before any UI binding, leaving legitimate text untouched.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Add the UI-free core behind the approval prompt: a handler that sanitizes the
command, working directory, and resolved path, builds a display-ready view, and
resolves the outcome behind two injected delegates (dispatcher enqueue + show
dialog) so its full behavior is testable without WinUI. It is fail-closed:
never throws, never returns a plain allow, and denies on cancellation, enqueue
failure, window close, or any internal error.

Also flag mixed-script confusables (Latin intermixed with Cyrillic or Greek,
the homoglyph-spoofing signal from Unicode UTS openclaw#39) so the dialog can warn the
user. Confusables are not escaped — that would mangle legitimate non-ASCII
text — only reported.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Add the WindowEx approval window built in code like the existing pairing and
recording-consent dialogs (the tray has no reliable XamlRoot for ContentDialog).
It shows the sanitized command in a monospaced, selectable card plus optional
context rows, and offers Deny / Allow Once / Allow Always.

Security posture: the allow buttons are never default-focused and arm only once
a short delay has elapsed AND the whole command has been scrolled into view, so
a long command cannot be approved with its dangerous tail off-screen. Escape,
the close button, and Alt+F4 all resolve to Deny. A caution row appears when the
command trips the mixed-script confusable check. Strings added to all five
locales.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Replace the null prompt handler in the coordinator construction with a thin
WinUI adapter that supplies the real dispatcher hop and dialog window to the
shared handler core. The coordinator keeps the always-cannot-present evaluator,
so the dialog stays dormant until a real presentation gate lands: the new path
remains inert (opt-in flag off and presentation gated off). Update the log
message to reflect that the prompt dialog is wired.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@AlexAlves87

AlexAlves87 commented Jul 21, 2026 •

Copy link
Copy Markdown
Owner Author

Still pending before this leaves Draft: manual visual verification of the dialog. The behavior is covered by tests, but the on-screen behavior is confirmed by hand: that it comes to the foreground, that the allow buttons arm only after the delay and once the whole command has been scrolled into view, that Escape / close / Alt+F4 resolve to Deny, that command text with invisible characters renders escaped, that the mixed-script warning appears, and how it looks at higher display scaling. This will be done before the PR is marked ready for review.

@AlexAlves87

Copy link
Copy Markdown
Owner Author

Closing this draft. Its base fix landed on main via openclaw#1039 (squash-merged), which also reworked the surrounding exec-approval model. Rebasing this stack would carry redundant, now-conflicting history.

The approval-dialog work will be reopened as a fresh PR against main, containing only the dialog, prompt-handler core, display sanitizer, mixed-script warning, and their tests, adapted to the current model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant