Skip to content

Real-time mobile push delivery (high priority + time-sensitive)#92

Merged
TraderSamwise merged 2 commits into
masterfrom
polish-next
Jun 6, 2026
Merged

Real-time mobile push delivery (high priority + time-sensitive)#92
TraderSamwise merged 2 commits into
masterfrom
polish-next

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Problem

Agent push notifications arrived in ~10-minute coalesced bursts instead of in real time. The Expo payload set no priority, so APNs treated them as priority 5 ("power-considerate") and held them for the next radio wake.

Fix

deliverNotificationPush now sets on each Expo message:

  • priority: "high" — APNs priority 10, immediate delivery, bypassing batching.
  • sound: "default" — audible, less deferrable.
  • interruptionLevel: "time-sensitive" — breaks through Focus/summary (the device's "Time Sensitive Notifications" toggle gates this; entitlement already present).

Relay-only change — no native build needed; ships on the next wrangler deploy.

Tests

security-delivery.test.ts asserts the new fields on the outgoing payload. Suite green.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Push notifications now include enhanced audio output, high-priority delivery, and time-sensitive interruption handling to improve reliability and user experience.
  • Tests

    • Updated notification delivery tests to verify new push notification configuration settings.

…ive)

Set priority:high (APNs priority 10, bypasses power-considerate batching), sound:default, and interruptionLevel:time-sensitive on the Expo payload so agent alerts arrive immediately instead of in ~10-minute coalesced bursts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@TraderSamwise

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@vercel

vercel Bot commented Jun 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jun 6, 2026 2:21pm

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@TraderSamwise, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 9 minutes and 59 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 94f73687-d227-4717-85d3-bc4868e13a1c

📥 Commits

Reviewing files that changed from the base of the PR and between b16f127 and e3895a4.

📒 Files selected for processing (2)
  • relay/src/security-delivery.test.ts
  • relay/src/security-delivery.ts
📝 Walkthrough

Walkthrough

The pull request adds three Expo push notification configuration parameters (sound, priority, interruptionLevel) to push message payloads in the security delivery function, with matching test assertions to verify the fields are included in the Expo API request.

Changes

Expo Push Notification Enhancement

Layer / File(s) Summary
Add sound, priority, and interruptionLevel to push notifications
relay/src/security-delivery.ts, relay/src/security-delivery.test.ts
deliverNotificationPush now attaches sound: "default", priority: "high", and interruptionLevel: "time-sensitive" to each message object. The test assertion is extended to verify these fields appear in the Expo push API request payload.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • TraderSamwise/aimux#84: The main PR extends the Expo message construction logic in deliverNotificationPush by adding payload fields that were introduced or covered by that PR.
  • TraderSamwise/aimux#17: Both PRs modify the security push-notification delivery flow in relay/src/security-delivery.ts, with this PR extending the Expo push payload message fields defined in the earlier PR.

Poem

🐰 Three whispers on the digital breeze,
Sound, priority, time-sensitive pleas,
The push now speaks with clarity clear,
Notifications arrive with some flair,
A rabbit approves of this gentle affair! 🔔

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding high-priority and time-sensitive fields to Expo push notifications for real-time delivery.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch polish-next

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
relay/src/security-delivery.ts (2)

109-128: Consider high-priority delivery for security push notifications.

The sendSecurityPush function does not include the new priority, sound, and interruptionLevel fields. While agent notifications benefit from immediate delivery (as addressed in this PR), security alerts (login attempts, device changes) may also warrant high-priority, time-sensitive delivery to ensure users are promptly notified of potential security events.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/src/security-delivery.ts` around lines 109 - 128, sendSecurityPush
currently crafts Expo message objects without priority/sound/interruptionLevel,
so update the message construction in sendSecurityPush to include high-priority
delivery fields (e.g., priority: "high", sound: "default" or a defined alert
sound, and interruptionLevel: "time-sensitive") inside each mapped message's
top-level properties and/or data payload as required by sendExpoPush/Expo
format; modify the mapping in sendSecurityPush (the .map callback creating
to/title/body/data) to add these fields so sendExpoPush receives messages marked
for immediate/time-sensitive delivery.

47-49: ⚡ Quick win

Consider typing the Expo message interface.

The message objects are currently typed as unknown[] (Line 62), which bypasses compile-time validation of field names and value types. Consider defining a typed interface for Expo push messages to catch typos and ensure required fields are present.

📝 Example typed interface
interface ExpoPushMessage {
  to: string;
  title: string;
  body: string;
  sound?: string;
  priority?: "default" | "normal" | "high";
  interruptionLevel?: "passive" | "active" | "time-sensitive" | "critical";
  data?: Record<string, unknown>;
}

Then update the function signature:

-async function sendExpoPush(messages: unknown[]): Promise<void> {
+async function sendExpoPush(messages: ExpoPushMessage[]): Promise<void> {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/src/security-delivery.ts` around lines 47 - 49, Define a proper
ExpoPushMessage interface (fields: to, title, body, optional sound, priority,
interruptionLevel, data) and replace the loose unknown[] type used for messages
(e.g., the messages parameter or variable named messages in
sendPushNotifications/sendExpoNotifications) with ExpoPushMessage[]; update any
construction sites to match the interface and fix any typos/missing required
fields (e.g., ensure sound, priority, interruptionLevel values match the allowed
union types) so the compiler enforces correct shape.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@relay/src/security-delivery.ts`:
- Around line 47-49: The notification payload uses interruptionLevel:
"time-sensitive" (kebab-case) and unguarded iOS-only fields; change
interruptionLevel to the Expo-expected camelCase "timeSensitive", and ensure
iOS-only fields (sound and interruptionLevel) are only applied on iOS (e.g.,
gate them with a platform/OS check or place them under an ios-specific
sub-object used for iOS notifications) while keeping priority: "high"
cross-platform; update the corresponding tests in security-delivery.test.ts to
expect "timeSensitive" and the platform gating behavior for
sound/interruptionLevel.

---

Nitpick comments:
In `@relay/src/security-delivery.ts`:
- Around line 109-128: sendSecurityPush currently crafts Expo message objects
without priority/sound/interruptionLevel, so update the message construction in
sendSecurityPush to include high-priority delivery fields (e.g., priority:
"high", sound: "default" or a defined alert sound, and interruptionLevel:
"time-sensitive") inside each mapped message's top-level properties and/or data
payload as required by sendExpoPush/Expo format; modify the mapping in
sendSecurityPush (the .map callback creating to/title/body/data) to add these
fields so sendExpoPush receives messages marked for immediate/time-sensitive
delivery.
- Around line 47-49: Define a proper ExpoPushMessage interface (fields: to,
title, body, optional sound, priority, interruptionLevel, data) and replace the
loose unknown[] type used for messages (e.g., the messages parameter or variable
named messages in sendPushNotifications/sendExpoNotifications) with
ExpoPushMessage[]; update any construction sites to match the interface and fix
any typos/missing required fields (e.g., ensure sound, priority,
interruptionLevel values match the allowed union types) so the compiler enforces
correct shape.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f33593f2-58f6-4549-ad98-65bdc2a5b882

📥 Commits

Reviewing files that changed from the base of the PR and between 2b81d05 and b16f127.

📒 Files selected for processing (2)
  • relay/src/security-delivery.test.ts
  • relay/src/security-delivery.ts

Comment thread relay/src/security-delivery.ts Outdated
Expo expects interruptionLevel "timeSensitive" (kebab-case is silently ignored). Gate sound + interruptionLevel to iOS tokens; priority stays cross-platform.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@TraderSamwise

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@TraderSamwise
TraderSamwise merged commit 1154460 into master Jun 6, 2026
3 checks passed
@TraderSamwise
TraderSamwise deleted the polish-next branch June 6, 2026 14:24
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.

1 participant