Skip to content

fix(app): open the chat when an iOS chat-answer push is tapped - #22286

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/chat-answer-push-tap
Oct 19, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/chat-answer-push-tap

Conversation

@apoorvdarshan

Copy link
Copy Markdown
Collaborator

What changed and why

Fixes #22285

Omi's chat answers reach iOS as an APNS alert. The FCM data carries push_type=chat_answer and navigate_to=/chat/omi (send_client_displayed_notification(_async) in backend/utils/notifications.py, _chat_message_notification in backend/utils/chat.py). A tap goes through onMessageOpenedApp / getInitialMessage to NotificationUtil.handleFcmDataTap and then routeFromFcmData.

Since 618efee (#18858), routeFromFcmData returns null for every non-empty push_type except capture_recovery with repair_device. So tapping an answer opens the app on whatever screen it was on and never opens the chat, which undoes the #5126 deep link on iOS. Android is not affected because its local BigText notification rebuilds the tap payload with only navigate_to and message_id.

routeFromFcmData now recognises chat_answer and returns its navigate_to when that is a chat route (/chat/...). Unknown push types still route nowhere, a chat_answer that points anywhere else routes nowhere, and the capture-recovery rule is unchanged.

Product invariants affected

none

How it was verified

  • Traced the path on origin/main (f26307c):
    • Both backend senders set push_type='chat_answer' next to navigate_to='/chat/{app_id}'.
    • The iOS APNS alert has no content-available, so iOS shows it as a normal alert. A tap reaches handleFcmDataTap with push_type still in message.data, and routeFromFcmData returned null for it.
    • git show 618efeee6d shows that before this commit the tap used navigateToFromFcmData, which does not check push_type.
  • Checked that /chat/<id> still opens the chat (case 'chat' in home_deep_links.dart) and that the Android paths are unchanged (ChatAnswerNotificationHandler.handle leaves push_type out of the local payload).
  • dart format --line-length 120 on the changed Dart files made no changes.
  • I did not run tests locally. CI with ci:full runs the new tests and the full app suite. I wrote the new tests to fail without the fix: routeFromFcmData returns null for the chat-answer payload, and handleFcmDataTap returns false with nothing opened.

Tests

app/test/unit/notification_fcm_navigate_to_test.dart:

  • a chat_answer push opens the chat it names: the payload the backend sends routes to /chat/omi.
  • a chat_answer push without a chat route routes nowhere: a navigate_to of /settings/device, /conversation/abc, an empty string, or none at all returns null.
  • a chat_answer tap opens its chat in the mounted Home (#5126): handleFcmDataTap with the same payload returns true, and the registered Home opener receives /chat/omi.

The existing capture-recovery and unknown-push-type tests are unchanged.

UI evidence

UI-Evidence: none -- this fixes where a notification tap leads, with no layout change, and no simulator or device is available here; the unit and widget tests above cover the routing.

Failure class (fixes)

Failure-Class: new

Failure-class transition narrative

New class FC-push-tap-router-drops-sent-push-type.

🤖 Generated with Claude Code

Omi's chat answers reach iOS as an APNS alert whose data carries
push_type=chat_answer and navigate_to=/chat/omi. Since 618efee the
tap router (NotificationUtil.routeFromFcmData) returns null for every
typed push except capture_recovery, so tapping an answer opened the app
but never the chat, undoing the BasedHardware#5126 deep link. Android was not
affected because its local BigText notification drops push_type from
the tap payload.

Route a chat_answer push to its navigate_to when that names a chat
(/chat/...). Unknown push types, and a chat_answer that points anywhere
else, still route nowhere.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@apoorvdarshan apoorvdarshan added the ci:full Maintainer-granted: run full CI on this fork PR label Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The production change here is correct and nicely scoped - approved.

  • app/lib/services/notifications.dart: the new chat_answer branch restores the #5126 deep link while keeping the typed-allowlist property from #18858 - navigate_to is honored only for push_type=chat_answer and only within /chat/, so a typed push still cannot be steered to an arbitrary screen. I verified the sender contract: the only backend senders (send_client_displayed_notification[_async], called from utils/chat.py) always set navigate_to=f'/chat/{app_id}', so the prefix gate covers every real payload. The capture_recovery rule and the untyped legacy fallback are untouched, and Android's local BigText rebuild (no push_type in the tap payload) keeps routing via the fallback exactly as before.
  • app/test/unit/notification_fcm_navigate_to_test.dart: good coverage - the positive route, the spoof/mismatch cases (/settings/device, /conversation/..., empty, missing), and an end-to-end handleFcmDataTap widget test through HomeNavigation.
  • .github/failure-classes/FC-push-tap-router-drops-sent-push-type.json: validates against scripts/failure-class, and the canonical prevention matches what the tests now assert.
  • app/changelog/unreleased/20261019-chat-answer-notification-tap.json: platforms: ["ios"] matches the mobile changelog schema.

Security: this re-opens navigate_to routing only for the chat_answer type and confines it to the /chat/ prefix - the spoof-steering concern that motivated #18858 stays closed for every other route.

USER IMPACT: on iOS, tapping an Omi answer notification opens that chat again (since #18858 it only opened the app); Android behavior is unchanged.

Nothing blocking from my side. Nice failure-class write-up - the Android-masks-iOS asymmetry in violated_contract is exactly the kind of context that prevents a repeat.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added the flutter flutter work label Oct 19, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Mobile bug fix (iOS chat-answer push deep link), root cause stated, test added, CI green. Confidence 5/5.

@kodjima33
kodjima33 merged commit 8ee12de into BasedHardware:main Oct 19, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Maintainer-granted: run full CI on this fork PR flutter flutter work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS: tapping an Omi answer notification no longer opens the chat

3 participants