Skip to content

fix(ui): suppress duplicate pairing actions while one is in flight - #167607

Closed
SunnyShu0925 wants to merge 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/pairing-duplicate-action-127580
Closed

SunnyShu0925 wants to merge 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/pairing-duplicate-action-127580

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #127580

What Problem This Solves

Rapidly double-clicking a device/node Approve/Reject button or a token Rotate/Revoke button sends two RPCs; the first succeeds and deletes the pending record, the second returns "unknown requestId", and that error is shown to the operator despite the action succeeding. This fix tracks in-flight pairing actions and disables the button until the operation settles.

  • Problem: Approve/Reject/Rotate/Revoke buttons only checked pairing permission, not whether an action for that target was already pending. A quick double-click sent duplicate RPCs, and the second failure masked the first success.
  • Solution: Track in-flight mutations in a keyed Set on DevicesPageController, keyed by kind:requestId:action. Callbacks check the Set before dispatching and clear the key in a finally block that calls publish() to re-render. Buttons and dropdown items gain a disabled state while their action is pending.
  • What changed: devices-page.tsx (pending state + dedup for all 6 callbacks), view-pending-devices.tsx (approve/reject button disabled), view-inventory.tsx (rotate/revoke button disabled), entry-menu.tsx (dropdown approve/reject item disabled), view.types.ts + devices-fixtures.ts (prop), view.pairing-actions.test.tsx (3 renderer tests), view.devices.test.ts (1 renderer test), device-pairing-dedup.e2e.test.ts (2 served-browser E2E tests).
  • What did NOT change: operation functions in page-operations.ts, dialog confirmation flow in devices-dialogs.ts, or any backend pairing logic.

Why This Change Was Made

The page layer owns UI state, so pending-mutation tracking belongs there rather than in the operation functions that only handle RPC + reload.

  • Best fix: Yes — the keyed Set is the minimal mechanism; no new abstraction or config needed.
  • Alternative: Could pass an AbortSignal through runPageTask, but that would require changing the operation function signatures for a purely UI-level concern.
  • Risk / non-goals: The Set is in-memory and per-page-instance; a page reload clears it. This is acceptable since the backend already handles duplicate requests atomically (first wins, second gets "unknown requestId").

User Impact

Operators can rapid-click Approve/Reject/Rotate/Revoke without seeing a misleading failure message. The button visually disables during the in-flight operation, giving clear feedback that the click was registered.

Evidence

Served-browser E2E (device-pairing-dedup.e2e.test.ts) — launches real Chromium, serves Control UI via Vite, installs a mock Gateway, and drives the actual Devices page:

Device approve dedup + failure recovery:

  • Double-clicks Approve while the RPC is deferred → asserts only one device.pair.approve RPC
  • Button is disabled during in-flight
  • Rejects the deferred RPC → button re-enables (failure recovery)
  • Clicks Approve again, resolves → pending row disappears
  • Final RPC count: 2 (one failed, one succeeded; no duplicates)

Node-menu approve dedup:

  • Renders a paired node with approvalState: "pending-reapproval"
  • Opens the dropdown menu, double-clicks the Approve item → asserts only one node.pair.approve RPC
  • Menu item is disabled during in-flight
  • Resolves → node list refreshes, approve item disappears
  • Final RPC count: 1 (no duplicates)

Renderer tests (view.pairing-actions.test.tsx + view.devices.test.ts): 4 tests pass — approve disables when pending (reject stays enabled), reject disables when pending (approve stays enabled), different action pending does not disable, and rotate disables when pending (revoke stays enabled).

Pre-fix verification (dedup reverted): the renderer test fails — approve button is not disabled when pendingPairingActions contains the matching key.

Existing tests: view.devices.test.ts (26 tests), devices-page.test.tsx + view-pairing.test.tsx (46 tests) all pass, no regression.

AI Assistance

This PR is AI-assisted. Used source inspection to analyze issue #127580, locate the root cause in the Devices page controller, and implement the fix. Per review, re-implemented on the Solid architecture after main migrated from Lit to Solid (.ts → .tsx) and expanded to cover all pairing mutation paths (approve, reject, rotate, revoke). The E2E tests prove dedup through real browser dispatch covering device-button and node-menu approval plus failure recovery, with pre-fix verification confirming the tests guard the actual defect.

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

The PR tracks pending pairing actions in the Devices page to suppress repeated clicks and disable matching controls until settlement.

Example: An operator clicks Approve twice for device request pending-req-1.

  • Before: Two approval RPCs can leave an unknown requestId error after approval succeeds.
  • After: The matching pending key suppresses the second approval dispatch and disables Approve until settlement.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The repair has clear value, but conflicting-action protection is incomplete, the node browser scenario cannot reach its target, and current real-behavior proof is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Operators can see a failure after their pairing approval succeeded.
Reason: The canonical report establishes a useful, bounded repair, but its requested conflicting-action protection is still missing.

Merge readiness

⛔ Blocked before merge - 3 items remain

This PR addresses a verified current-main bug and merits retention, but conflicting pairing actions remain possible and the node browser test still targets a removed menu component.

Priority: P2
Reviewed head: 225be04c9a17a79d088d3d29fe3b1734f3a40252

Before merge

  • Add real behavior proof - The body supplies mocked-Gateway browser-test claims, while the inspected screenshots belong to the earlier native-menu migration; provide current served-UI recording or RPC logs showing deduplication, pending disabled controls, and failure recovery, with IPs, API keys, phone numbers, and non-public endpoints redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Share the pending guard between conflicting pairing decisions (P2) - For request pending-req-1, approving adds device:pending-req-1:approve, but Reject remains enabled and checks device:pending-req-1:reject. While the approval response is pending, the operator can open and confirm Reject, dispatching a second mutation for the same request. If approval consumes the request first, rejection returns unknown requestId and runDeviceMutation can again display a failure after successful approval. This leaves the canonical issue's demonstrated conflicting-action case unresolved. Use one request-level pending owner for Approve/Reject, disable both controls, and cover that sequence through the page controller; apply the same policy to node decisions.
  • Exercise the native node menu in the browser test (P2) - The Devices row now uses the shared native Menu, which renders button[role="menuitem"][data-value="approve"]. No wa-dropdown-item exists, so this locator waits until timeout before exercising node approval. The previous review raised this same blocker and it remains unresolved. Select the actual native item and account for the menu closing after activation by reopening it before checking the pending disabled state or attempting another activation.

Findings

  • [P2] Share the pending guard between conflicting pairing decisions — ui/src/pages/devices/devices-page.tsx:592-596
  • [P2] Exercise the native node menu in the browser test — ui/src/e2e/device-pairing-dedup.e2e.test.ts:172

Tests

  • Missing end-to-end proof: Supply current served-UI recording or RPC logs covering duplicate device/node approval, conflicting actions, disabled controls, and retry after failure; the stated pre-fix renderer failure does not establish a controller-level regression.
Agent review details

How this fits together

The Devices page translates operator actions into Gateway pairing RPCs, then renders authoritative inventory and operation errors.

flowchart TD
  A[Operator clicks pairing control] --> B[Devices page controller]
  B --> C[Pending action set]
  B --> D[Confirmation dialog]
  B --> E[Gateway pairing RPC]
  D --> E
  E --> F[Inventory refresh]
  F --> G[Devices view]
Loading

Technical review

Best possible solution:

Use one pending owner for conflicting actions on each pairing request, preserve the existing confirmation and Gateway authority checks, and repair the native-menu regression test.

Do we have a high-confidence way to reproduce the issue?

Current-main dispatch, mutation error handling, backend unknown-request responses, and the canonical report establish the failure path from source; this read-only review executed no target code.

Is this the best way to solve the issue?

Page-owned pending state fits the existing architecture, but action-specific keys only prevent identical repeats and leave conflicting mutations able to reproduce the reported failure.

Full review comments:

  • [P2] Share the pending guard between conflicting pairing decisions — ui/src/pages/devices/devices-page.tsx:592-596
    For request pending-req-1, approving adds device:pending-req-1:approve, but Reject remains enabled and checks device:pending-req-1:reject. While the approval response is pending, the operator can open and confirm Reject, dispatching a second mutation for the same request. If approval consumes the request first, rejection returns unknown requestId and runDeviceMutation can again display a failure after successful approval. This leaves the canonical issue's demonstrated conflicting-action case unresolved. Use one request-level pending owner for Approve/Reject, disable both controls, and cover that sequence through the page controller; apply the same policy to node decisions.
    Confidence: 0.96
  • [P2] Exercise the native node menu in the browser test — ui/src/e2e/device-pairing-dedup.e2e.test.ts:172
    The Devices row now uses the shared native Menu, which renders button[role="menuitem"][data-value="approve"]. No wa-dropdown-item exists, so this locator waits until timeout before exercising node approval. The previous review raised this same blocker and it remains unresolved. Select the actual native item and account for the menu closing after activation by reopening it before checking the pending disabled state or attempting another activation.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 21b0c8b04255.

Provenance checked

  • Devices page mutation dispatch changes intended behavior with a stated reason (74828ac: The Solid migration preserved existing pairing actions and kept Gateway authority unchanged; it carried the dispatch behavior rather than establishing its original introduction.)
  • Native Devices menu keeps the original intent (8815aa6: The merged migration replaced Web Awesome with the shared native Menu while preserving callbacks and pairing-permission checks.)
  • Reject and revoke confirmation ownership keeps the original intent (f9eae0c: In-app confirmations replaced window.confirm because embedded webviews could silently decline without a visible outcome.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +115, Tests +324. Total +439 across 9 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 5 129 14 +115
Tests 4 324 0 +324
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 453 14 +439

Review metrics

Metric Value Why it matters
Production versus test growth Production +129/-14 lines; tests and fixtures +324/-0 lines The production growth implements pending-state handling across the existing callbacks; most added validation exercises rendering and browser dispatch, although the node browser scenario is currently broken.

Root-cause cluster

Relationship: same_root_cause
Canonical: #127580
Summary: This PR partially addresses the canonical report's missing ownership of pending pairing mutations.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The bug produces misleading failure feedback after successful pairing, with limited impact on the Devices management workflow.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-09T07:36:01.562Z sha 2e00b7b4897d7029404ff7c73cc1b3fd1cd6fe3f :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-09T08:07:04.921Z sha ec85d30066a530c4f86553a18a1d290072e292c1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-09T08:36:48.115Z sha 4b6d7a53a0a35bb15a6f54d2c1851f0215bd7b4c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-09T09:08:13.806Z sha c9a9e896f08a39ce00643e28f210128366bbe658 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T09:44:48.477Z sha 8e016ad44273bd29cabdc6ec36883693f52e8210 :: needs changes before merge. :: none
  • reviewed 2026-10-09T10:15:55.735Z sha ac75f5d610a782429d0b8b88e47be962180572c1 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T10:47:57.163Z sha ac75f5d610a782429d0b8b88e47be962180572c1 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-13T10:54:34.935Z sha 0e74945b14084bdc4c31fb9bf6feb9be33d8e6dc :: needs real behavior proof before merge. :: [P2] Publish the cleared pending state after approval settles | [P2] Exercise the native node menu in the added browser test

Reviewed October 13, 2026, 7:04 AM ET / 11:04 UTC (Revision 11).

@SunnyShu0925
SunnyShu0925 force-pushed the fix/pairing-duplicate-action-127580 branch from 4f38c8f to 2e00b7b Compare October 9, 2026 06:04
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@SunnyShu0925
SunnyShu0925 force-pushed the fix/pairing-duplicate-action-127580 branch 3 times, most recently from 4b6d7a5 to c9a9e89 Compare October 9, 2026 08:53
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 9, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/pairing-duplicate-action-127580 branch from c9a9e89 to 8e016ad Compare October 9, 2026 09:28
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/pairing-duplicate-action-127580 branch 2 times, most recently from 2613ee4 to ac75f5d Compare October 9, 2026 10:01
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review.

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@SunnyShu0925
SunnyShu0925 force-pushed the fix/pairing-duplicate-action-127580 branch 2 times, most recently from e15f21e to 0e74945 Compare October 13, 2026 10:46
@clawsweeper clawsweeper Bot added the rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. label Oct 13, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 13, 2026
Device and node approve/reject buttons and token rotate/revoke buttons in
the Devices page only checked pairing permission, not whether an action for
that target was already pending. A rapid double-click sent two RPCs; the
first succeeded and deleted the pending record, the second returned
"unknown requestId", and that error was shown to the operator despite the
approval succeeding.

Track in-flight pairing mutations in a keyed Set on DevicesPageController.
Approve, reject, rotate, and revoke callbacks check the Set before
dispatching and clear the key in a finally block with a publish to re-render.
Buttons and dropdown items gain a disabled state while their action is pending.

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

Labels

app: web-ui App: web-ui P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate pairing actions can render failure after approval succeeded

1 participant