Repository navigation
feat: add the exec approval prompt dialog - #3
AlexAlves87 wants to merge 4 commits into
Conversation
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]>
|
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. |
|
Closing this draft. Its base fix landed on The approval-dialog work will be reopened as a fresh PR against |
What
Adds the real approval dialog for the new exec-approvals path, behind the same opt-in gate:
WindowExdialog 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.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-gatewaysystem.runMXC proofs pass.Real behavior proof
Pipeline behavior is covered end to end: the real-gateway
system.runMXC 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]