Skip to content

feat(ios): add exec approval notification flow - #60239

Merged
ngutman merged 4 commits into
mainfrom
ios/exec-approval-notifications
Apr 5, 2026
Merged

ngutman merged 4 commits into
mainfrom
ios/exec-approval-notifications

Conversation

@ngutman

@ngutman ngutman commented Apr 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Problem: iOS had no native exec approval notification flow after onboarding, so approval requests still required another operator surface.
  • Why it matters: iPhone users could receive generic pushes, but there was no secure, well-scoped notification-to-approval UX for exec requests.
  • What changed: added lock-screen-safe exec approval APNs delivery, a scoped exec.approval.get fetch-on-open RPC, and an in-app iOS modal that resolves through the existing approval backend flow.
  • What did NOT change (scope boundary): no approval inbox/history UI, no reconnect-time reconciliation/list flow, no notification action buttons, and no QR bootstrap auth redesign in this PR.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause / Regression History (if applicable)

  • Root cause: iOS never had a native exec approval push + modal path; approval semantics existed, but not an iOS delivery/fetch/resolve UX.
  • Missing detection / guardrail: there was no mobile-specific delivery bridge, and no scoped RPC for authenticated fetch-on-open approval details.
  • Prior context (git blame, prior PR, issue, or refactor if known): split out from the broader iOS exec approval work previously carried on ios/exec-approval-push / PR feat(ios): add exec approval push flow #59732.
  • Why this regressed now: N/A; this is a new iOS capability split out from the combined branch.
  • If unknown, what was ruled out: the branch intentionally excludes QR bootstrap/auth handoff changes, which live in the stacked base PR.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
    • src/gateway/exec-approval-ios-push.test.ts
    • src/gateway/server-methods/server-methods.test.ts
    • src/infra/push-apns.test.ts
    • src/gateway/method-scopes.test.ts
    • apps/ios/Tests/ExecApprovalNotificationBridgeTests.swift
    • apps/ios/Tests/NodeAppModelInvokeTests.swift
  • Scenario the test should lock in: a generic exec approval push opens the app, the app fetches details via exec.approval.get, and the modal resolves via the existing approval decision flow while resolved pushes dismiss stale notification state.
  • Why this is the smallest reliable guardrail: the behavior crosses APNs payloads, gateway delivery targeting, a new RPC, and iOS modal state.
  • Existing test that already covers this (if any): none covered the new mobile notification flow before this PR.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

  • iOS receives a generic "Exec approval required" push for exec approval requests.
  • Tapping that push opens the app and presents a modal after authenticated detail fetch.
  • The modal supports Allow Once, Allow Always (when permitted), Deny, and Cancel.
  • Resolved/expired cleanup pushes dismiss stale approval notification state.

Diagram (if applicable)

Before:
[exec approval requested] -> [other operator surface needed]

After:
[exec approval requested] -> [generic iOS push] -> [tap notification] -> [exec.approval.get] -> [modal] -> [exec.approval.resolve]

Security Impact (required)

  • New permissions/capabilities? (Yes/No) Yes
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) Yes
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) Yes
  • If any Yes, explain risk + mitigation:
    • Risk: mobile approval delivery fetches command details and grants an operator-approval UX on iOS.
    • Mitigation: push payloads remain lock-screen-safe and generic; command text is fetched only after authenticated operator connection via exec.approval.get; the method is gated by operator.approvals; push delivery targets active operator tokens with effective approval scope; cleanup pushes are skipped when original target sets are unknown.

Repro + Verification

Environment

  • OS: macOS 26.3.1 and iOS device/simulator validation paths
  • Runtime/container: Node 24.x, local gateway
  • Model/provider: N/A
  • Integration/channel (if any): iOS app / APNs / gateway exec approvals
  • Relevant config (redacted): stacked on top of ios/qr-bootstrap-fixes

Steps

  1. Trigger an exec approval request on a gateway paired with iOS.
  2. Confirm the iOS device receives a generic approval push.
  3. Tap the notification, fetch details with exec.approval.get, and resolve from the modal.

Expected

  • Push payload is generic and does not expose command text on the lock screen.
  • The app fetches approval details after authenticated open.
  • Modal resolution uses existing approval semantics and cleanup dismisses stale state.

Actual

  • Matches expected with the changes in this PR.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios:
    • reviewed the branch scope against the intended exec-notification-only split
    • validated targeted gateway/APNs tests
    • validated targeted iOS simulator tests for notification bridge parsing and modal prompt state
  • Edge cases checked:
    • stale/expired approval fetch handling
    • cleanup push dismissal
    • approval-id ambiguity hardening
    • generic payload without command-text exposure
  • What you did not verify:
    • a fresh real-phone rerun after splitting this branch from the original combined branch

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: approval details could leak through push payloads.
    • Mitigation: requested APNs payload is generic and only includes the opaque approval id.
  • Risk: stale cleanup pushes could over-broadcast to devices that did not receive the original request.
    • Mitigation: cleanup delivery is limited to remembered original targets and skipped when that target set is unknown.
  • Risk: mobile clients without active approval scope could still be targeted.
    • Mitigation: iOS push targeting follows active operator token scopes rather than historical paired-device metadata.

@openclaw-barnacle openclaw-barnacle Bot added app: ios App: ios app: web-ui App: web-ui gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Apr 3, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ac5b07c6c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/gateway/exec-approval-ios-push.ts Resolved
@greptile-apps

greptile-apps Bot commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a complete iOS exec-approval notification flow: a generic APNs alert push (no command text on the lock screen), a scoped exec.approval.get RPC gated by operator.approvals, an in-app modal with Allow Once / Allow Always / Deny / Cancel actions, and a background cleanup push that dismisses stale notification state after resolution or expiry.

Key design decisions are sound:

  • Push payloads carry only an opaque approvalId; command text is fetched post-authentication via exec.approval.get.
  • Cleanup pushes target the remembered original delivery set and are skipped when that set is unknown.
  • The iOS generation-counter pattern in presentExecApprovalNotificationPrompt correctly guards against stale fetch results when multiple notifications arrive in quick succession.
  • presentFetchedExecApprovalPrompt resets pendingExecApprovalPromptResolving when a new prompt replaces an in-flight one, preventing a permanently-frozen modal.
  • Relay and direct APNs transports are correctly handled end-to-end.

One minor observation:

  • In createExecApprovalAlertPayload and createExecApprovalResolvedPayload, nodeId is accepted in the parameter type but intentionally not included in the openclaw payload object. Unlike toPushMetadata (which includes nodeId), there is no comment explaining the deliberate exclusion. A future contributor could mistake this for an oversight and re-add nodeId, leaking device identity on the lock screen.

Confidence Score: 5/5

Safe to merge; the security model is sound, state handling is correct, and no P0/P1 issues were found.

All findings are P2 style observations. The security design (generic push payloads, scope-gated detail fetch, cleanup push targeting) is well-thought-out. iOS state management handles concurrency edge cases correctly. Tests are provided for the new gateway methods, APNs helpers, method scope, and iOS notification bridge.

src/infra/push-apns.ts lines 903–931 — the unused nodeId parameter in the exec-approval payload builders could confuse future maintainers.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/infra/push-apns.ts
Line: 903-931

Comment:
**Unused `nodeId` parameter in exec-approval payload builders**

Both `createExecApprovalAlertPayload` (line 903) and `createExecApprovalResolvedPayload` (line 920) accept `nodeId` in their parameter types but never reference `params.nodeId` in the returned `openclaw` object. This is intentional — exposing the device's node ID in a lock-screen-visible or background push would leak internal device identity — but the silent omission is not explained anywhere.

Contrast this with `toPushMetadata`, which deliberately includes `nodeId`. A future reader seeing `nodeId` in the signature of these functions may assume it was accidentally forgotten and add it back, inadvertently exposing device identity on the lock screen.

Consider either dropping `nodeId` from the local payload-builder signatures (the callers already have `params.registration.nodeId` available if needed later), or adding a brief comment:

```ts
// nodeId is intentionally omitted from the openclaw payload to keep
// the push lock-screen-safe and avoid leaking device identity.
function createExecApprovalAlertPayload(params: { nodeId: string; approvalId: string }): object {
```

How can I resolve this? If you propose a fix, please make it concise.

Greploops — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.
Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

Reviews (2): Last reviewed commit: "fix(gateway): harden approval notificati..." | Re-trigger Greptile

@ngutman
ngutman force-pushed the ios/qr-bootstrap-fixes branch from 1e3af8a to 25897b9 Compare April 3, 2026 11:42
@ngutman
ngutman requested a review from a team as a code owner April 3, 2026 11:42
@ngutman
ngutman force-pushed the ios/qr-bootstrap-fixes branch from 25897b9 to b35d417 Compare April 3, 2026 20:25
@steipete
steipete force-pushed the ios/qr-bootstrap-fixes branch from 512b9c0 to f6223e6 Compare April 4, 2026 06:57
Base automatically changed from ios/qr-bootstrap-fixes to main April 4, 2026 06:57
@ngutman
ngutman force-pushed the ios/exec-approval-notifications branch from 3ac5b07 to 04f04de Compare April 5, 2026 10:02

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04f04de513

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ngutman

ngutman commented Apr 5, 2026

Copy link
Copy Markdown
Member Author

Addressed the current review feedback and pushed follow-up commit 1e3b1d096f.

What changed:

  • hardened iOS approval routing so APNs only counts as a live approval route after an initial push succeeds
  • serialized request/cleanup APNs delivery to avoid stale cleanup races
  • guarded iOS approval prompt fetches so stale completions no longer overwrite the latest tap
  • limited stale prompt dismissal to the matching approval id
  • moved bootstrap-token redemption/revocation until after hello-ok is successfully written
  • switched the iOS approval error classifiers to structured details.reason handling and cleaned up immutable request structs
  • re-exported the new exec.approval.get protocol schema/type from the main protocol entrypoint
  • audited current in-tree approval clients for the terse ambiguous-prefix response and kept the non-leaking behavior intentionally

Validation run:

  • pnpm test src/gateway/exec-approval-ios-push.test.ts
  • pnpm test src/gateway/server-methods/server-methods.test.ts
  • pnpm test src/infra/device-bootstrap.test.ts
  • pnpm check
  • pnpm build
  • xcodebuild ... -only-testing:OpenClawTests/NodeAppModelInvokeTests test (my added approval-notification tests passed; the suite still has pre-existing unrelated failures in other NodeAppModelInvokeTests cases)

Please re-review when you get a chance. @codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e3b1d096f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3089 to +3093
self.startOperatorGatewayLoop(
url: cfg.url,
stableID: effectiveStableID,
token: cfg.token,
bootstrapToken: cfg.bootstrapToken,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Respect bootstrap guard before restarting operator loop

ensureOperatorReconnectLoopIfNeeded now starts startOperatorGatewayLoop whenever operatorGatewayTask is nil, but it no longer checks shouldStartOperatorGatewayLoop. In sessions where activeGatewayConnectConfig.bootstrapToken is still set, this bypasses the existing “wait for bootstrap handoff” rule and can start the operator loop with a bootstrap token, which risks consuming/redeeming the bootstrap token before normal handoff completes and can break reconnect/onboarding behavior for those bootstrap-driven clients.

Useful? React with 👍 / 👎.

Comment on lines +196 to +200
await clearStaleApnsRegistrationIfNeeded({
nodeId: target.nodeId,
registration: target.registration,
result,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don’t fail route detection on registration-cleanup errors

The per-target request delivery path treats clearStaleApnsRegistrationIfNeeded failures as rejected push deliveries because it is awaited inside the same promise. If APNs send succeeds but stale-registration cleanup throws (for example due to pairing-state I/O failures), the target is counted as undelivered, and handleRequested can return false/no-approval-route even though the approval alert actually reached the device. Cleanup should be best-effort logging, not part of delivery success accounting.

Useful? React with 👍 / 👎.

@ngutman

ngutman commented Apr 5, 2026

Copy link
Copy Markdown
Member Author

@greptile please re-review the latest PR head.

The previously flagged iOS follow-ups have been addressed on the current commit, and we'd like an updated score/comment pass on the latest diff.

@ngutman ngutman self-assigned this Apr 5, 2026
@ngutman
ngutman force-pushed the ios/exec-approval-notifications branch from 1e3b1d0 to fdcccb5 Compare April 5, 2026 13:33
@ngutman
ngutman merged commit 28955a3 into main Apr 5, 2026
4 checks passed
@ngutman
ngutman deleted the ios/exec-approval-notifications branch April 5, 2026 13:33
@ngutman

ngutman commented Apr 5, 2026

Copy link
Copy Markdown
Member Author

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test (latest main was already red on unrelated failures, including the duplicate-key issue in src/agents/tool-display-config.ts); scoped validation run for this PR: pnpm test src/gateway/exec-approval-ios-push.test.ts src/gateway/server-methods/server-methods.test.ts src/gateway/method-scopes.test.ts src/gateway/server.auth.control-ui.suite.ts src/infra/push-apns.test.ts
  • Land commit: fdcccb5
  • Merge commit: 28955a3

Thanks @ngutman!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fdcccb5096

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +290 to +293
if (opts?.iosPushDelivery?.handleRequested) {
try {
deliveredToIosPush = await opts.iosPushDelivery.handleRequested(requestEvent);
} catch (err) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid blocking approval requests on iOS push delivery

This path awaits iosPushDelivery.handleRequested(...) before deciding whether to send the immediate accepted response, even when another approval route is already available (hasExecApprovalClients, forwarded, or hasTurnSourceRoute). Because iOS delivery now waits for APNs send completion, requests can be delayed by push network latency/timeouts and callers can hit RPC timeouts despite already having a viable non-iOS route. Consider only waiting on iOS delivery when it is the final fallback route, and otherwise dispatching it asynchronously.

Useful? React with 👍 / 👎.

Comment on lines +288 to +291
const deliveryState = await deliveryStatePromise;
if (pendingDeliveryStateById.get(request.id) === deliveryStatePromise) {
pendingDeliveryStateById.delete(request.id);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear pending iOS delivery entries on delivery-plan failure

If deliveryStatePromise rejects (for example, pairing/APNs registration reads throw), execution exits before pendingDeliveryStateById is cleaned up. That stale rejected promise is then re-awaited by handleResolved/handleExpired, which fails before their delete calls, so entries can accumulate and cleanup pushes for those approvals will keep erroring. The pending map deletion should run in a finally/rejection path as well.

Useful? React with 👍 / 👎.

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* fix(auth): hand off qr bootstrap to bounded device tokens

* feat(ios): add exec approval notification flow

* fix(gateway): harden approval notification delivery

* docs(changelog): add ios exec approval entry (openclaw#60239) (thanks @ngutman)
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* fix(auth): hand off qr bootstrap to bounded device tokens

* feat(ios): add exec approval notification flow

* fix(gateway): harden approval notification delivery

* docs(changelog): add ios exec approval entry (openclaw#60239) (thanks @ngutman)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix(auth): hand off qr bootstrap to bounded device tokens

* feat(ios): add exec approval notification flow

* fix(gateway): harden approval notification delivery

* docs(changelog): add ios exec approval entry (openclaw#60239) (thanks @ngutman)
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
* fix(auth): hand off qr bootstrap to bounded device tokens

* feat(ios): add exec approval notification flow

* fix(gateway): harden approval notification delivery

* docs(changelog): add ios exec approval entry (openclaw#60239) (thanks @ngutman)
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
* fix(auth): hand off qr bootstrap to bounded device tokens

* feat(ios): add exec approval notification flow

* fix(gateway): harden approval notification delivery

* docs(changelog): add ios exec approval entry (openclaw#60239) (thanks @ngutman)
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
* fix(auth): hand off qr bootstrap to bounded device tokens

* feat(ios): add exec approval notification flow

* fix(gateway): harden approval notification delivery

* docs(changelog): add ios exec approval entry (openclaw#60239) (thanks @ngutman)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant