Skip to content

feat(host-api): scheduled push notifications (RFC 0019)#170

Merged
johnthecat merged 10 commits into
feat/create-transaction-refinementfrom
feat/scheduled-notifications
May 14, 2026
Merged

feat(host-api): scheduled push notifications (RFC 0019)#170
johnthecat merged 10 commits into
feat/create-transaction-refinementfrom
feat/scheduled-notifications

Conversation

@cuteWarmFrog

@cuteWarmFrog cuteWarmFrog commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the JS SDK side of paritytech/truapi RFC 0019 / truapi#66: scheduled push notifications with idempotent cancellation.

Breaking change (per senior-dev review): the prior wire format is replaced rather than versioned alongside. Hosts and products must upgrade together at v0.8.

  • host_push_notification request gains scheduled_at: Option<u64> (ms UTC); response changes from Result<(), GenericErr> to Result<NotificationId, PushNotificationError> (with ScheduleLimitReached and Unknown { reason }).
  • New host_push_notification_cancel(NotificationId) -> Result<(), GenericErr> — host MUST treat unknown/already-fired ids as Ok(()) per RFC §5.
  • Both methods gated by the existing DevicePermission::Notifications (no new permission variant).
  • New host-api-wrapper surface: createNotificationManager(...).push({ text, deeplink?, scheduledAt? }) → Promise<NotificationId> and .cancel(id).

Host-side persistence, OS-scheduler integration, and the platform-wide 64-slot queue cap remain host-application concerns; the SDK only transports the typed error.

Test plan

  • npm run build
  • npm run lint
  • npm test — 449 tests across 44 files pass (11 in notification.spec.ts)
  • Tests cover: immediate delivery returns id; scheduled delivery roundtrips scheduledAt: bigint; ScheduleLimitReached; Unknown { reason } roundtrip; permission denial for both push and cancel; cancel happy path; arbitrary-id passthrough; GenericError propagation
  • Manual smoke once a host advertises v0.8

🤖 Generated with Claude Code

@cuteWarmFrog cuteWarmFrog self-assigned this May 13, 2026
@cuteWarmFrog cuteWarmFrog force-pushed the feat/scheduled-notifications branch 2 times, most recently from 4a41cf5 to 2e36d6b Compare May 13, 2026 21:17
@cuteWarmFrog cuteWarmFrog force-pushed the feat/scheduled-notifications branch 2 times, most recently from 8dc050c to 3800d91 Compare May 14, 2026 09:12
@johnthecat johnthecat changed the base branch from main to feat/create-transaction-refinement May 14, 2026 10:34
@johnthecat johnthecat force-pushed the feat/create-transaction-refinement branch from 3938ce7 to 1634946 Compare May 14, 2026 10:47
cuteWarmFrog and others added 5 commits May 14, 2026 11:51
Implements the JS SDK side of paritytech/truapi RFC 0019 (scheduled push
notifications with idempotent cancellation).

BREAKING CHANGE: `host_push_notification` wire format changes — request gains
`scheduled_at: Option<u64>` (ms UTC), response becomes
`Result<NotificationId, PushNotificationError>` with `ScheduleLimitReached`
and `Unknown { reason }` variants. The prior wire format is replaced rather
than versioned alongside; hosts and products must upgrade together.

Protocol changes (v0.8 of host-api-protocol.md):
- `host_push_notification` carries the new `PushNotification` struct
- new `host_push_notification_cancel(NotificationId) -> Result<(), GenericErr>`
- both methods gated by `DevicePermission::Notifications`

SDK changes:
- host-api: `PushNotification`, `NotificationId`, `PushNotificationError`
- host-container: new `handlePushNotificationCancel`; existing
  `handlePushNotification` returns `NotificationId` and rejects with
  `PushNotificationError`
- host-api-wrapper: `createNotificationManager()` exposing
  `.push({ text, deeplink?, scheduledAt? })` and `.cancel(id)`

Host-side persistence, OS-scheduler integration, and the platform-wide
queue cap remain host-application concerns; the SDK only transports
the typed error.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@johnthecat johnthecat force-pushed the feat/scheduled-notifications branch from fe71f2a to 1c2e9d3 Compare May 14, 2026 10:54
@johnthecat johnthecat merged commit 33ea295 into feat/create-transaction-refinement May 14, 2026
5 checks passed
johnthecat added a commit that referenced this pull request May 15, 2026
Co-authored-by: Sergey Zhuravlev <zhuravlev1337@gmail.com>
@johnthecat johnthecat deleted the feat/scheduled-notifications branch June 11, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants