Repository navigation
Fix stale approval prompts in Control UI - #86270
Conversation
|
Codex review: needs maintainer review before merge. Reviewed May 26, 2026, 11:35 PM ET / 03:35 UTC. Summary PR surface: Source +179, Tests +483. Total +662 across 9 files. Reproducibility: yes. Source inspection and the attached recording give a high-confidence path: make the Control UI hold a stale approval id after external resolution, then click Deny; current main catches the backend error and keeps the modal open. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land after maintainer approval of the stale-error-as-cleanup behavior, keeping the focused regression tests and real behavior proof; if maintainers want stale backend errors to remain visible, ask for a narrower follow-up design. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection and the attached recording give a high-confidence path: make the Control UI hold a stale approval id after external resolution, then click Deny; current main catches the backend error and keeps the modal open. Is this the best way to solve the issue? Yes, with maintainer sign-off. The diff handles stale responses at the Control UI state boundary, keeps unrelated errors visible, refreshes pending exec/plugin lists, and adds focused race/expiry coverage. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against acbb06e2660b. Label changesLabel justifications:
Evidence reviewedPR surface: Source +179, Tests +483. Total +662 across 9 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a Control UI issue where exec/plugin approval modals could remain open (and show errors) after the same approval was resolved from another client (e.g., Discord). It centralizes “resolve” cleanup behavior so stale-resolution responses are treated as terminal cleanup signals (dismiss + refresh), and resolved events clear active prompt errors while preserving any in-flight local resolve state.
Changes:
- Added exec-approval controller utilities to detect stale resolve errors, dismiss prompts, refresh pending approvals, and prune approvals after expiry.
- Updated Control UI app + gateway event handling to use the new controller cleanup functions and preserve local busy state on external resolves.
- Expanded unit test coverage for stale-error detection, resolve cleanup behavior, and refreshed-approval expiry pruning.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ui/src/ui/views/exec-approval.test.ts | Minor import formatting change for modal dialog helpers. |
| ui/src/ui/controllers/exec-approval.ts | Adds stale-resolution detection, queue refresh, prompt dismissal/cleanup helpers, and centralized resolve logic. |
| ui/src/ui/controllers/exec-approval.test.ts | Adds tests for stale error detection, resolve behavior (dismiss vs error), and refresh expiry pruning. |
| ui/src/ui/app.ts | Routes approval decisions through the controller’s centralized resolve handler. |
| ui/src/ui/app-gateway.ts | Clears active modal error on resolved events via clearResolvedExecApprovalPrompt. |
| ui/src/ui/app-gateway.sessions.node.test.ts | Updates exec-approval module mocks for new imports/behavior. |
| ui/src/ui/app-gateway.node.test.ts | Adds host state for execApprovalBusy and regression test ensuring external resolves clear errors without touching busy. |
| ui/src/ui/app-gateway-chat-load.node.test.ts | Updates exec-approval mocks to include clearResolvedExecApprovalPrompt. |
| const refreshed = sortApprovalsNewestFirst([...execApprovals, ...pluginApprovals]); | ||
| state.execApprovalQueue = refreshed; | ||
| for (const entry of refreshed) { | ||
| scheduleApprovalExpiryPrune(state, entry); | ||
| } |
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Cosmic Patch Peep Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
4c85031 to
cae7692
Compare
36af196 to
fe6e9e1
Compare
82ff44e to
65daff6
Compare
65daff6 to
3f6ba99
Compare
534483a to
b886ab1
Compare
b886ab1 to
1b5e8f1
Compare
1b5e8f1 to
73949ba
Compare
310eb9b to
5a848d4
Compare
Summary:
APPROVAL_ALREADY_RESOLVED,APPROVAL_NOT_FOUND, andunknown or expired approval idnow remove the prompt and refresh pending approvals.Bug summary:
An exec approval can be shown in Discord and in the OpenClaw Control UI at the same time. If Discord resolves it first and the web UI misses or delays the resolved event, the web modal can keep a stale approval id. On main, clicking Deny on that stale modal reports a backend error and leaves the modal open.
A_B.testing.approval.not.closing.mp4
Root cause:
Current main removes a prompt when the web client receives
exec.approval.resolvedorplugin.approval.resolved, so normal event delivery is fine. The broken path is stale local UI state:handleExecApprovalDecisioncatches every resolve error asexecApprovalErrorand does not treat stale backend responses as terminal cleanup. Main also maps modal cancel to Deny, so Escape/backdrop can hit the same stale backend error path.Fix summary:
OpenClawAppnow treats known stale approval resolve errors as terminal UI cleanup. Success removes the active prompt. Stale backend errors remove it, refreshexec.approval.listandplugin.approval.list, and keep only still-pending approvals.exec.approval.resolvedandplugin.approval.resolvedremove matching queue entries and clear the active prompt error. The exec approval view keeps Escape/backdrop wired to Deny; stale Deny is now safe because stale resolve errors dismiss and refresh.Main behavior checked:
Approval failed: GatewayRequestError: unknown or expired approval id, and the modal stayed open.exec.approval.resolvedand the connected Control UI modal disappeared.Verification:
origin/mainate96cde7e14.node scripts/run-vitest.mjs ui/src/ui/controllers/exec-approval.test.ts ui/src/ui/app-gateway.node.test.ts ui/src/ui/views/exec-approval.test.ts ui/src/ui/app.exec-approval.test.ts ui/src/ui/app-gateway-chat-load.node.test.ts ui/src/ui/app-gateway.sessions.node.test.ts --runpassed, 6 files / 114 tests.node_modules/.bin/oxfmt --check --threads=1 ui/src/ui/app-gateway-chat-load.node.test.ts ui/src/ui/app-gateway.node.test.ts ui/src/ui/app-gateway.sessions.node.test.ts ui/src/ui/app-gateway.ts ui/src/ui/app.ts ui/src/ui/app.exec-approval.test.ts ui/src/ui/controllers/exec-approval.test.ts ui/src/ui/controllers/exec-approval.ts ui/src/ui/views/exec-approval.test.ts ui/src/ui/views/exec-approval.tspassed.git diff --checkpassed.Behavior addressed: stale Control UI exec/plugin approval modals when local UI state outlives backend approval state.
Real environment tested: local Control UI against two local Gateway instances, Discord-triggered approvals, focused Vitest coverage, oxfmt, and UI typecheck.
Exact steps or command run after this patch: opened PR UI at
localhost:19010, opened main/control UI atlocalhost:19170, resolved approvals externally through Discord or forced a stale id, then clicked Deny in the web modal.Evidence after fix: PR UI removed the stale modal after stale Deny; main UI kept the modal open with
unknown or expired approval id; focused tests cover resolved events, stale resolve errors, success cleanup, unrelated-error behavior, and refresh behavior.Observed result after fix: stale externally-resolved approvals no longer leave the modal stuck, stale Deny removes the prompt, resolved events clear active prompt errors, and Escape/backdrop continue to submit Deny.
What was not tested: a fresh Slack-specific stale approval flow after the final rebase.
Agent Transcript
Redacted, condensed transcript from about 10 local agent sessions for PR #86270