Skip to content

Commit cb68abf

Browse files
feat: surface node reapproval in Command Center
Show pending approval and reapproval state in Command Center, keep command-trust requests manual, and provide request-bound approval and reconnect guidance. Depends on core diagnostics from openclaw/openclaw#92547.
1 parent ff38d84 commit cb68abf

39 files changed

Lines changed: 3242 additions & 624 deletions

‎docs/CONNECTION_ARCHITECTURE.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Setup codes (from QR scan or paste) decode to `{ url, bootstrapToken }` via `Set
166166
5. Gateway returns `hello-ok.auth.deviceToken` after pairing
167167
6. Connection manager persists the device token to the identity file
168168

169-
**Auto-approval**: When the node requires pairing and the operator has `operator.admin` or `operator.pairing` scope, `GatewayConnectionManager` automatically approves the node pairing request, waits 1 second, then reconnects the node.
169+
**Approval boundaries**: `GatewayConnectionManager` leaves node-pair command-trust requests and reapproval pending for explicit operator approval. It may automatically approve and reconnect only an explicitly typed device-pair request used for a device role upgrade.
170170

171171
## SSH tunnel integration
172172

@@ -224,12 +224,11 @@ Connection tests live in `tests/OpenClaw.Connection.Tests/`:
224224
- `GatewayRegistryTests` / `GatewayRegistryMigrationTests` — persistence, migration
225225
- `InteractiveGatewayCredentialResolverTests` — HTTP credential resolution
226226
- `NodeConnectorTests` — node client lifecycle
227-
- `PairingFlowTests` / `NodePairAutoApproveTests` — pairing lifecycle, auto-approve
227+
- `PairingFlowTests` / `NodePairAutoApproveTests` — pairing lifecycle, device role-upgrade auto-approval, and manual node command-trust boundary
228228
- `SetupCodeFlowTests` / `SetupCodeDecoderTests` — QR code → connect flow
229229
- `StaleEventGuardTests` — generation-guarded event handling
230230
- `SettingsChangeImpactTests` — settings change classification
231231
- `RetryPolicyTests` — backoff policy
232232
- `ConnectionDiagnosticsTests` — ring buffer diagnostics
233233

234234
The heaviest remaining gap is Windows shell UI behavior (tray clicks, tooltip visibility, WinUI menu routing). Cover pure decision logic in unit tests; use manual or integration smoke tests for shell behavior.
235-

‎docs/CONNECTION_PROTOCOL_RESEARCH.md‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,11 @@ Windows implications:
403403
when system capability is enabled. Those requests require admin to approve.
404404
- A bounded QR/bootstrap operator token should not auto-approve node command
405405
trust.
406-
- Auto-approval diagnostics must report missing `operator.admin` vs missing
407-
`operator.pairing` instead of a generic failure.
408-
- `_lastAutoApprovedRequestId` must not permanently suppress recovery if the
409-
approve RPC succeeded but the post-approval reconnect failed or the gateway
410-
reuses the same request id.
406+
- `GatewayConnectionManager` only auto-approves explicitly typed device-pair
407+
role upgrades. Node-pair command trust, including reapproval, remains pending
408+
for an explicit operator decision.
409+
- Device role-upgrade auto-approval diagnostics must report missing
410+
`operator.admin` instead of a generic failure.
411411

412412
## Flow 7: local WSL setup-engine flow
413413

@@ -454,7 +454,7 @@ Reliability risks:
454454
| QR bootstrap immediate credential | `ApplySetupCodeAsync`, `CredentialResolver` | Preserved shared token can win over fresh bootstrap token. | Fixed | Force the fresh bootstrap token for the immediate setup-code connect. |
455455
| QR post-bootstrap operator reconnect | `GatewayConnectionManager` | LKG gateway may return only node token on bootstrap; operator must reconnect via preserved shared token. | Fixed | Schedule post-bootstrap operator reconnect using durable operator token or preserved shared token. |
456456
| Node token parsing | `WindowsNodeClient` | Parses direct `auth.deviceToken` for node. | Aligned for direct node connect | Validate post-approval reconnect. |
457-
| Node command trust | `GatewayConnectionManager.OnNodePairingStatusChangedAsync` | Auto-approves when request id and approval scope helper allow it. | Likely surgical fix | Separate node-pair authority and missing-scope handling. |
457+
| Node command trust | `GatewayConnectionManager.OnNodePairingStatusChangedAsync` | Explicit node-pair and unknown requests remain pending; only explicitly typed device-pair role upgrades may auto-approve. | Fixed | Preserve explicit operator approval for command trust and reapproval. |
458458
| Approval scope helper | `OperatorScopeHelper.CanApproveDevices` | Checks only admin/pairing. | Needs protocol-specific split | Do not add `operator.approvals` for `node.pair.*`; add clearer helpers. |
459459
| Capability registration | `NodeConnector`, `App.xaml.cs`, `NodeService` | Event-before-connect pattern exists; app warns if binding unavailable. | Likely surgical fix | Fail/hold/reconnect on binding miss instead of silently connecting with no commands. |
460460
| Stale node events | `GatewayConnectionManager` node handlers | Operator events are generation-guarded; node handlers are not equivalently guarded. | Likely surgical fix | Add generation or client-instance stale-event guard. |
@@ -502,8 +502,10 @@ Existing coverage:
502502
HTML for token/auth error markers, not just HTTP status.
503503
- `app.status` validation includes negotiated operator scopes and asserts the
504504
operator has `operator.admin` and `operator.pairing` on the normal local
505-
setup/shared-token path so Windows node command-trust auto-approval can
506-
complete without a leftover approval banner.
505+
setup/shared-token path. Explicitly configured SetupEngine onboarding may
506+
use those scopes to approve command trust without a leftover approval
507+
banner; `GatewayConnectionManager` runtime leaves command-trust approval
508+
pending for the operator.
507509
- Test coverage docs explicitly call out that full live gateway/node pairing
508510
against a remote gateway and long-running reconnect soak behavior are not
509511
fully covered by automated tests.

‎docs/MISSION_CONTROL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ Deliverables:
438438
- broad file system access if relevant
439439
- screen capture/graphics capture guidance
440440
- First read-only Command Center slice is implemented. It surfaces these settings pages and explanatory rows, but intentionally does not query, request, or exercise device permissions.
441-
- Capability diagnostics copy is implemented for declared commands, gateway allowlist status, and privacy-sensitive opt-ins.
441+
- Capability diagnostics distinguish approved/effective commands from pending declarations, surface pending approval/reapproval, and keep privacy-sensitive opt-ins explicit.
442442
- Mac-style onboarding security warning: **implemented in Setup Wizard Node Mode step, warning users that approved agents can run local commands and access enabled screen/camera/location/browser/canvas surfaces**
443443
- Topology choice onboarding: **first Settings guide implemented with local, WSL, SSH tunnel, and remote/Tailscale presets**
444444
- Exec approval dialog with sanitizer and three-button flow: **implemented for local `Prompt` policy decisions with Allow once / Always allow / Deny**

‎docs/WINDOWS_NODE_TESTING.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ The Windows Node feature allows the tray app to receive commands from the OpenCl
3737
### 4. Command Center
3838
- Open the tray status detail or launch `openclaw://commandcenter`
3939
- In Node Mode, verify the window shows gateway channel health from node `health` events plus a synthesized local Windows node when operator `node.list` is not connected
40-
- Check diagnostics for pairing approval, stale health, all-stopped channels, allowlist filtering, browser control host availability for `browser.proxy`, and usage-cost gaps
40+
- Check diagnostics for pairing approval, pending reapproval, stale health, all-stopped channels, allowlist filtering, browser control host availability for `browser.proxy`, and usage-cost gaps
41+
- When only the synthesized local Windows node is available, verify its locally declared capabilities/commands are labeled unverified and are not counted as approved/effective
42+
- For `pending-reapproval`, verify effective capabilities/commands remain unchanged, pending declarations are listed separately, and the copy action emits `openclaw nodes approve <pendingRequestId>`
43+
- During a changed-command handshake, verify authoritative `pending-reapproval` replaces the generic node-pair approval card and exposes only the node-list trust command; explicitly typed device role-upgrade, Node mode off/hidden, and failure cards remain higher priority
44+
- If the gateway omits a safe pending request ID, verify the copy action emits `openclaw nodes pending`, labels it as discovery only, and does not offer reconnect-after-approval yet
45+
- Approve the request explicitly, reconnect the node, and verify the effective capability/command counts update and the pending reapproval warning clears
4146
- Use "Copy fix" only for safe repair commands; privacy-sensitive commands remain informational unless you explicitly opt in on the gateway
4247

4348
## What Requires Gateway Support

‎docs/gateway-node-integration.md‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,25 @@ After changing config:
7878
openclaw gateway restart
7979
```
8080

81-
After changing the node's command list (code change), you must **re-pair**:
81+
After changing the node's command list, approve the pending reapproval request:
8282
```bash
83-
openclaw devices list # find old device
84-
openclaw devices reject <id> # reject the old pairing
85-
# Node will auto-reconnect and create a new pairing request
86-
openclaw devices list # find new request
87-
openclaw devices approve <id> # approve with updated commands
83+
openclaw nodes pending
84+
openclaw nodes approve <pendingRequestId>
8885
```
8986

90-
### 1.4 Why Re-Pairing is Needed
87+
`openclaw nodes pending` only discovers request IDs; it does not approve declarations.
9188

92-
The gateway snapshots the node's declared `commands` array at **pairing approval time**. If you change the node's code to add new commands and restart it, the gateway still uses the old snapshot. You must reject the old pairing and approve a new one.
89+
Older gateways without pending reapproval support may still require rejecting and re-pairing the node.
90+
91+
### 1.4 Why Reapproval is Needed
92+
93+
The gateway snapshots the node's declared `commands` array at **pairing approval time**. When a newer gateway detects changed declarations, `node.list` and `node.describe` keep the existing `caps`, `commands`, and `permissions` as the approved/effective snapshot and report the proposed replacement under `pendingDeclaredCaps`, `pendingDeclaredCommands`, and `pendingDeclaredPermissions`. Approve the reported request explicitly:
94+
95+
```powershell
96+
openclaw nodes approve <pendingRequestId>
97+
```
98+
99+
Then reconnect the node and verify the effective command and capability counts update. Pending declarations are never effective before approval. Older gateways that do not report pending reapproval fields may still require rejecting and re-pairing the node.
93100

94101
### 1.5 `denyCommands`
95102

@@ -313,7 +320,7 @@ For the first-party Windows companion node, the practical local solution is:
313320
1. Keep declaring the correct command names from the Windows node.
314321
2. Send canonical connect metadata: `platform: "windows"` and
315322
`deviceFamily: "Windows"`.
316-
3. Re-pair after command-list changes because the gateway snapshots commands at approval time.
323+
3. Reapprove command-list changes because the gateway snapshots commands at approval time; older gateways may require re-pairing.
317324

318325
### 5.1 Gateway Node Allowlist Configuration
319326

@@ -333,7 +340,7 @@ camera.clip
333340
screen.record
334341
```
335342

336-
After changing either `gateway.nodes.allowCommands` or `gateway.nodes.denyCommands`, re-approve or re-pair the Windows node. Approved device records may keep a snapshot of the commands that were visible at approval time, so a gateway restart alone may not refresh existing approvals.
343+
After changing either `gateway.nodes.allowCommands` or `gateway.nodes.denyCommands`, check Command Center for `pending-reapproval`. Copy and run its exact `openclaw nodes approve <pendingRequestId>` command, reconnect the Windows node, and verify the effective command and capability counts update. A gateway restart alone does not approve pending declarations. Older gateways without pending reapproval diagnostics may still require re-pairing.
337344

338345
### 5.2 Immediate Code Fixes (This Branch)
339346

0 commit comments

Comments
 (0)