Skip to content

fix(push): preserve distinct Android alerts while offline - #20066

Merged
Jinwoo-H merged 1 commit into
mainfrom
fix/android-push-offline-delivery
Sep 11, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
fix/android-push-offline-delivery

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Android notification payloads collapse while a device is offline, so distinct agent alerts can be lost. Send non-collapsible data messages and let the existing native notification handler display them, preserving tray IDs, channels, sound preferences, routing metadata, and silent dismissal messages.

Retain the deployed gateway's optional paneKey support, which the mobile rollout revert removed from source.

Validation: 139 gateway tests and 30 contract tests passed; gateway typecheck passed. Four database integration checks skipped. On Android 36, six queued implementation payloads produced six notifications after reconnect, with OS grouping and correct normal/silent channels. The control notification payload produced only the last of six alerts. Network recovery was isolated using temporary emulator-only port translation; this change does not repair network restrictions on Google's push connection.

Deployed to the notification-only production service: https://github.com/stablyai/orca/actions/runs/34575782749. The first production test delivered all six offline alerts after approximately 79 seconds on the unmodified emulator network. Android cold-start dismissal registration is fixed separately in #20068; mobile restoration remains unmerged.

Repeated production verification with the app process confirmed absent: six of six alerts delivered; valid dismissal removed only its target and retained the other five. No network workaround; Google automatically fell back to port 443 after ~73 seconds. Temporary registration removed.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 538fef7e-7c54-4226-b546-6234b38cb354

📥 Commits

Reviewing files that changed from the base of the PR and between fab78c7 and 21a573f.

📒 Files selected for processing (8)
  • cloud/apps/push/src/fcm-client.test.ts
  • cloud/apps/push/src/fcm-client.ts
  • cloud/apps/push/src/push-delivery-message.ts
  • cloud/apps/push/src/push-dismissal-provider.test.ts
  • cloud/apps/push/src/push-notification-sound.test.ts
  • cloud/apps/push/src/push-pane-routing.test.ts
  • cloud/apps/push/src/push-server-send.test.ts
  • cloud/packages/push-contract/src/send-messages.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The push contract now accepts an optional paneKey and preserves it in delivery data. Android FCM messages now use the data payload for notification fields and no longer use collapse_key or nested notification fields. Tests were updated for the new FCM shape, silent-channel data, dismissal payloads, and pane routing.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 21a57

The Android push payload migration and pane routing changes are validated without an identified remaining merge risk.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the problem, implementation, compatibility goal, and validation results. However, it does not follow the repository template and omits the required Linked Issue, Visual Proof … Update the description to include all template sections. Add the required issue reference after "Fixes #". Add visual proof or state "N/A" with a reason. Complete the testing checklist and document platform coverage, review status, upstream…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main change: preserving distinct Android alerts while devices are offline.
Full details: Description check

Explanation

The description explains the problem, implementation, compatibility goal, and validation results. However, it does not follow the repository template and omits the required Linked Issue, Visual Proof or explicit N/A statement, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections.

Resolution

Update the description to include all template sections. Add the required issue reference after "Fixes #". Add visual proof or state "N/A" with a reason. Complete the testing checklist and document platform coverage, review status, upstream-boundary applicability, notes, and the remaining checklist items.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@pullfrog pullfrog 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.

Important

This change makes Android delivery depend on a native handler that is not in the released mobile app. There is no server-side gate preventing the data-only payload from reaching old clients, so deploying it ahead of #20068 silently drops push notifications for every Android user on the current release.

Reviewed changes

  • Data-only FCM payload: fcmMessageBody drops the notification / android.notification / collapse_key shape and moves title, message, tag, channelId, and sound into a non-collapsible data payload so distinct offline alerts survive reconnect.
  • paneKey restored: PushNotificationSchema and buildPushDelivery re-add the optional paneKey, re-syncing the source with the already-deployed gateway.
  • Test updates: fcm-client.test.ts assertions rewritten for the new shape, dismissal/sound tests extended, and a new push-pane-routing.test.ts covers the pane round-trip.

⚠️ Data-only delivery breaks the released Android app until #20068 ships

The gateway stops sending the FCM notification payload and relies on the device rendering the data payload itself. That rendering lives in the mobile push rollout that was reverted in #20040 and is only restored by the still-open #20068 (whose base is this branch). The current mobile source has no handler for data-only messages: there is no custom FirebaseMessagingService, no addNotificationReceivedListener, and setNotificationHandler in app/_layout.tsx only affects foreground presentation of notifications the OS already received. Android does not display a data-only FCM message on its own, so a backgrounded or killed app on the current release will receive the message and show nothing.

This is exactly the "changing what the publisher sends breaks old clients" hazard from docs/reference/remote-wire-compatibility.md (Rule 3), and unlike the RPC surface there is no capability handshake to soften it. The device registry (push_devices) stores only platform, not an app version or capability, so the gateway currently has no way to send the old shape to old clients and the new shape to new ones.

The PR body documents the coordination with #20068 and notes the gateway has already been deployed to a "notification-only production service" and validated against a #20068 build, so this is a sequencing concern rather than a code defect. The change is correct given the handler exists; the risk is an unguarded deploy ordering.

Technical details
# Data-only FCM payload must not reach clients without the native handler

## Affected sites
- cloud/apps/push/src/fcm-client.ts:40-51 — `notification`/`android.notification`/`collapse_key` removed; display fields moved into `data`.
- cloud/apps/push/src/device-registry-store.ts:16,88 — registration stores `platform` only; no app version/capability to gate on.
- mobile/src/notifications/local-notification-scheduling.ts — relies on local scheduling; no remote data-message rendering.
- #20068 (fix/mobile-push-recovery) — the handler this payload depends on; still unmerged.

## Required outcome
- The data-only format must only be delivered to app builds that contain the #20068 handler, or the gateway must otherwise be prevented from flipping before the mobile release is live.

## Suggested approach (optional)
- Add an app-version or capability field to device registration and gate the FCM payload shape on it, so old registrations keep the `notification` payload while new ones get data-only; or
- Hold the flip behind a deploy flag and coordinate the gateway and mobile release explicitly.

## Open questions for the human (optional)
- Is the "notification-only production service" separate from the gateway serving released app builds? If it is the same service, is the released Android app confirmed to already contain the #20068 handler?

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 08a24ef into main Sep 11, 2026
26 checks passed
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