Skip to content

feat: add secure PWA approval notifications and preferences - #129348

Merged
roboclaw-bot merged 25 commits into
mainfrom
openclaw/push-notifications-for-permission-requests
Aug 30, 2026
Merged

roboclaw-bot merged 25 commits into
mainfrom
openclaw/push-notifications-for-permission-requests

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #129347
Related: #93724

AI-assisted.

What Problem This Solves

Installed Control UI PWAs can test Web Push, but operators were not notified when time-sensitive approvals or configured agent/task events needed attention. The subscription store also lacked enough durable ownership information to target notifications safely after a browser disconnect or Gateway restart.

This PR adds authenticated, device/profile-bound PWA notifications, account and device preferences, restart-safe approval lifecycle handling, and a clear multi-Gateway browser contract.

How It Works

Each Web Push subscription is bound server-side to the paired browser device and canonical user profile that registered it. Request, terminal/restart, and configured event delivery share one authorization owner.

Immediately before network I/O, delivery checks current runtime policy, paired-device token and scopes, profile role, subscription binding, preferences, and approval/session visibility. Missing roles fail closed. Sender invocation remains in the same synchronous continuation as the final authority read.

Approval payloads are intentionally generic: no command, working directory, prompt, plugin detail, or session metadata appears on the lock screen. Resolution, expiry, abort, and authority closure always replace an actionable approval with a generic same-tag terminal notification, regardless of optional alert preferences or quiet hours. Durable delivery targets preserve that cleanup across Gateway restart.

One service-worker registration owns one browser subscription and VAPID identity. Separate PWA scopes remain independent. Switching between equally trusted Gateways requires a shared VAPID keypair; mismatches fail visibly without destroying the existing browser subscription. Operators can explicitly reset a mismatched local subscription even when the current Gateway no longer owns its server row. Reconciliation and in-flight actions are fenced across Gateway switches and preference invalidation.

Preferences and Defaults

Fresh preferences enable only the essential Approval requested alert. Optional alerts default off:

  • agent finished
  • agent question
  • scheduled task failed
  • background task failed

Operators can also configure lock-screen detail, quiet hours and time zone, agent filters, account defaults, per-device overrides, device labels, test notifications, and unsubscribe controls. Existing stored preferences are preserved.

Preference updates use a scope-discriminated protocol union so account and device payloads cannot be mixed. Rapid edits are serialized from the latest acknowledged state, and invalid IANA time zones are rejected rather than silently disabling quiet hours.

Persistent Surface

  • Additive nullable device_id, user_profile_id, and preferences_json columns on web_push_subscriptions.
  • Additive web_push_approval_deliveries table/index with cascading approval and subscription foreign keys.
  • VAPID key material remains in config_machine_state; the retired web_push_vapid_keys table is not restored.
  • Current main uses native SQLite schema version 15; this PR does not bump it. Previous-schema and older-reader reopen behavior is covered.

Screenshots

Complete notification settings and defaults

Subscribed notification settings showing only Approval requested enabled by default, optional alerts disabled, privacy, quiet hours, agent filters, device label, per-device overrides, test, and unsubscribe controls

iPhone and iPad installation guidance

iPhone-sized notification settings instructing the operator to use Share, Add to Home Screen, and open OpenClaw

Mobile approval actions

Mobile approval page with readable command context and Allow once and Deny actions

Terminal approval state

Mobile approval page after resolution showing Approved and no decision controls

Remote Gateway confirmation

Remote Gateway URL confirmation shown before approval content loads

Validation

Exact remote head: 34d02eb8774da3cd58a04475751a5caef84d42cc, rebased onto origin/main a202e76e78d370beb9bc9835fbcfb9a6414c7e49.

  • Final post-rebase owner matrix: 81 tests passed across authenticated subscription ownership, atomic stale-unsubscribe fencing, push handlers/store, passive service-worker lookup, Gateway-switch action fencing, and Codex startup retry.
  • Broader integrated feature matrix: 188 tests passed across Gateway approval/event delivery, persistence/preferences, Settings and reconciliation UI, approval E2E, Workboard E2E, and Codex startup retry. QA Lab causal-chain owners add 108 passing tests.
  • Exact CI metadata regressions for settings-search translations and Gateway method release trains pass locally (20 assertions).
  • The exact Codex persistent-startup retry case passes locally after keeping only that fixture alive long enough for process command registration; production Codex transport behavior is unchanged.
  • Android replacement-socket tests dispatch refresh on the Compose UI thread, then wait for history/readiness off-thread before asserting refreshed metadata. This host has no Java runtime, so exact-head Android CI is the authoritative proof.
  • Workboard keyboard-selection E2E now waits for the picker’s visible expanded state before sending navigation keys. Local execution was blocked by an orphaned test bridge, so exact-head UI E2E CI is the authoritative proof.
  • Full node scripts/check-changed.mjs completed formatting, policy, dependency, plugin-boundary, dead-export, i18n, core/test/UI/extension typecheck and lint, schema-v15, database-first, and import-cycle checks. The post-rebase changed gate is also green.
  • Full pnpm build passed outside the process sandbox, including native-require postbuild and package/declaration checks. The final post-rebase Control UI build passes at 346,432 B gzip against the 346,761 B enforcement limit.
  • Current-default settings capture passed through a real Chromium Control UI with a mocked Gateway and was inspected before upload.
  • Mandatory P2 autoreview found and drove fixes for ambiguous transport outcomes, reconciliation/action races, role fail-closed and implied-scope behavior, mandatory terminal cleanup, rapid preference edits, invalid time zones, iOS installation guidance, runtime-load errors, subscriber independence, and subscription ownership transfer. The final scoped review is clean.
  • Shared lock-screen display labels remove Unicode control/format characters, collapse whitespace, and truncate safely to 80 UTF-16 units; approval and event payload regressions pass, and final mandatory P2 autoreview is clean.

Detailed earlier evidence: #129348 (comment)

Review Status

All actionable findings from the latest published ClawSweeper review are addressed on this head, including stable pagination beyond 1,024 terminal approvals, current-Gateway VAPID mismatch state/reset, subscription ownership transfer, and bounded display labels. Fresh exact-head ClawSweeper review and CI are pending and must be green before squash merge.

A real installed-PWA Apple/Google OS notification banner was unavailable, so that display path is not claimed. Browser UI, service-worker behavior, encrypted outbound delivery, authorization, persistence, and restart recovery are covered deterministically.

Change Size

  • Production: +2750/-247
  • Tests: +3236/-33
  • Docs: +80/-17
  • Generated: +12/-0

Worked on by


View the OpenClaw team session

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime labels Aug 25, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review August 25, 2026 13:22
@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Aug 25, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@roboclaw-bot
roboclaw-bot force-pushed the openclaw/push-notifications-for-permission-requests branch from 26592de to 156577c Compare August 25, 2026 13:53
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 10:42 PM ET / August 30, 2026, 02:42 UTC.

ClawSweeper review

What this changes

Adds targeted Control UI PWA push notifications for approval requests, per-device and per-user notification preferences, and browser-subscription recovery handling.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/state/openclaw-state-schema.sql. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for explicit maintainer review: the implementation appears to enforce targeted delivery correctly, but it introduces material shared-SQLite retention and recovery semantics that require recorded maintainer acceptance.

Priority: P2
Reviewed head: 34d02eb8774da3cd58a04475751a5caef84d42cc
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A substantial, well-covered feature with favorable production-boundary proof, pending explicit maintainer acceptance of its durable-state contract.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): Supplied PR discussion describes after-fix production-boundary traces using real Web Push transport for allowed, revoked, and rebound subscriptions; accompanying UI artifacts could not be independently replayed in this read-only environment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): Supplied PR discussion describes after-fix production-boundary traces using real Web Push transport for allowed, revoked, and rebound subscriptions; accompanying UI artifacts could not be independently replayed in this read-only environment.
Evidence reviewed 7 items Targeted authorization: Approval delivery resolves current paired-device, token, profile, role-policy, and required-scope facts before constructing a synthetic visibility client for the target browser.
Final-delivery fencing: The request path rechecks terminal status before recording recipients and sending; terminal recovery reloads current targets and discards rebound subscription bindings before delivery.
Persistent-state contract: The branch adds nullable subscription binding and preference columns plus a lazy, cascade-cleaned approval-delivery table.
Findings None None.
Security None None.

How this fits together

The Gateway records browser push subscriptions, checks their current device/profile authorization when an approval needs attention, and sends an encrypted alert to the Control UI PWA. The PWA reconciles its browser subscription with the Gateway and exposes notification controls in Settings.

flowchart LR
A[Approval request] --> B[Gateway authorization]
B --> C[Current device and profile binding]
C --> D[Durable delivery record]
D --> E[Web Push sender]
E --> F[Control UI PWA]
F --> G[Authenticated approval page]
Loading

Decision needed

Question Recommendation
Should the additive shared-SQLite subscription bindings and durable approval-delivery records be accepted with their retention, cascade, downgrade, and restart-recovery semantics? Accept the state contract: Record approval of the binding, cascade, downgrade, and recovery semantics, then continue normal merge review.

Why: This is a material persistent-state and operator-policy choice that source inspection cannot make on behalf of maintainers.

Before merge

  • Resolve merge risk (P1) - The new binding, preference, and delivery records alter shared SQLite retention, cascade, downgrade, and restart-recovery behavior; that durable-state contract needs explicit maintainer acceptance before merge.
  • Complete next step (P2) - A maintainer must explicitly accept the material shared-state lifecycle before this feature can advance.
Agent review details

Security

None.

PR surface

Source +2503, Tests +3203, Docs +63, Generated +12, Other +2. Total +5783 across 72 files.

View PR surface stats
Area Files Added Removed Net
Source 40 2755 252 +2503
Tests 23 3235 32 +3203
Docs 5 80 17 +63
Config 0 0 0 0
Generated 1 12 0 +12
Other 3 4 2 +2
Total 72 6086 303 +5783

Review metrics

Metric Value Why it matters
Classified change size 72 files; production +2,757/-252, tests +3,236/-33, docs +80/-17, generated +13/-1 This is a large feature change spanning authorization, persistence, Gateway protocol, UI, and documentation.

Stored data model

Persistent data-model change detected: database schema: src/state/openclaw-state-schema.sql, persistent cache schema: src/infra/push-web.ts, unknown-data-model-change: packages/gateway-protocol/src/schema/push.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm the retained-state contract (recommended)
    Explicitly approve the subscription-binding and delivery-recovery lifecycle before merge.
  2. Narrow the persistence design
    Pause the PR if the durable binding and delivery records are not acceptable for the shared state database.

Technical review

Best possible solution:

Record explicit maintainer acceptance of the shared-state lifecycle contract, then merge only after ordinary exact-head review and checks complete.

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

Not applicable: this PR introduces a new approval-notification capability rather than repairing a demonstrated current-main failure.

Is this the best way to solve the issue?

Unclear pending an explicit durable-state decision; the targeted authorization design is source-supported, but maintainers must choose whether to retain this persistence lifecycle.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2646feaaf553.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Supplied PR discussion describes after-fix production-boundary traces using real Web Push transport for allowed, revoked, and rebound subscriptions; accompanying UI artifacts could not be independently replayed in this read-only environment.

Label justifications:

  • P2: This is a bounded operator-notification feature rather than an emergency regression.
  • merge-risk: 🚨 compatibility: Persisted subscription bindings and recovery behavior can affect existing browser subscriptions and upgrades.
  • merge-risk: 🚨 security-boundary: Approval notifications cross a device/profile authorization boundary before external push delivery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): Supplied PR discussion describes after-fix production-boundary traces using real Web Push transport for allowed, revoked, and rebound subscriptions; accompanying UI artifacts could not be independently replayed in this read-only environment.
  • proof: sufficient: Contributor real behavior proof is sufficient. Supplied PR discussion describes after-fix production-boundary traces using real Web Push transport for allowed, revoked, and rebound subscriptions; accompanying UI artifacts could not be independently replayed in this read-only environment.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record an explicit maintainer decision on the retention, cascade, downgrade, and restart-recovery semantics.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (32 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-29T22:08:42.885Z sha dae50f3 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T22:50:02.945Z sha 0d35d004322bfc03468f165629b01cfa5604d628 :: found issues before merge. :: [P1] Bind VAPID-mismatch cleanup to the subscription owner
  • reviewed 2026-08-30T00:35:47.217Z sha 171f543 :: found issues before merge. :: [P2] Surface lazy runtime failures instead of leaving push actions active
  • reviewed 2026-08-30T00:49:42.681Z sha fffaad477af4a7aadd1081de8fd1dc3e71d891a8 :: found issues before merge. :: [P2] Surface lazy runtime failures before enabling push actions | [P2] Do not treat injected transcript messages as agent completion
  • reviewed 2026-08-30T01:02:16.849Z sha aec65c388aeca8109c3af6f9ac6e64ac93050746 :: found issues before merge. :: [P2] Surface lazy runtime failures before enabling push actions | [P2] Exclude injected transcript updates from completion notifications
  • reviewed 2026-08-30T01:32:01.283Z sha 86c8e71 :: found issues before merge. :: [P2] Distinguish injected transcript updates from completed runs | [P2] Make a failed lazy push runtime unavailable
  • reviewed 2026-08-30T02:16:44.027Z sha 320dc41 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T02:31:50.259Z sha c5651df :: needs maintainer review before merge. :: none

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Production-boundary approval Web Push proof is complete on the latest local patch.

The isolated run used production device pairing/approval, profile-role persistence, shared SQLite subscription storage, VAPID signing, payload encryption, and the real web-push HTTP sender against a local HTTPS endpoint. It did not use the mocked pairing store or mocked sender from the unit tests.

{
  "allowed": { "delivered": true, "outgoingRequests": 1 },
  "revoked": { "delivered": false, "outgoingRequestsAdded": 0 },
  "reassigned": { "delivered": false, "outgoingRequestsAdded": 0 },
  "transport": {
    "status": 201,
    "contentEncoding": "aes128gcm",
    "ttl": "60",
    "urgency": "high",
    "authorizationPresent": true,
    "plaintextLeaked": false
  }
}

Sequence:

  1. A paired operator device/profile with operator.approvals + operator.read produced one encrypted HTTPS request.
  2. Revoking that device's operator token produced no additional outgoing request.
  3. Rebinding the same endpoint to another active paired device/profile produced no request for the original device-scoped approval.

This satisfies the ClawSweeper final-effect authority ask. A real Apple/Google phone notification display is still not claimed; that remaining vendor-display gap is now stated in the PR body.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 25, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/push-notifications-for-permission-requests branch from 156577c to bfc8136 Compare August 25, 2026 14:43
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Addressed the final ClawSweeper finding on bfc8136f3a26b52ea4f3a0524f4daa54d7f2ddf1.

  • approval resolvedAtMs and expiry are now reread after transport/pairing preparation, immediately before sender invocation;
  • TTL is recomputed from that same final timestamp;
  • resolve-during-preparation and expiry-during-preparation regressions failed on the prior code by reaching the sender and now prove zero sender calls;
  • a preparation-delay regression failed with TTL: 60 on the prior code and now proves TTL: 30 after 30 seconds elapsed;
  • the 10-file focused suite passes 189 tests across 4 shards;
  • the targeted changed gate and Codex Sol/high autoreview are clean.

The earlier production-boundary allowed/revoked/reassigned HTTPS proof remains valid. Exact-head hosted CI is running on a main tip with known unrelated auth/runtime failures tracked by active maintainer repair PRs; no merge-readiness claim is made for CI until that upstream gate is green.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

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

Labels

app: android App: android app: web-ui App: web-ui docs Improvements or additions to documentation extensions: codex extensions: qa-lab gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Send scoped PWA notifications for approval requests

3 participants