Repository navigation
Conversation
Fixes BasedHardware#4375. Chat answers use a client-displayed FCM path (data-only on Android, APNS alert on iOS) so Flutter can render BigText locally with a navigate_to payload. Extends utils/notifications.py instead of a parallel module; keeps async send_chat_message_notification_async wired; patches main.dart's single background handler (no dual registration); reuses NotificationUtil for cold-start taps. Failure-Class: none Co-authored-by: Apoorv Darshan <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 10 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the clean rebase - this integrates far better than #13065: one background entrypoint in main.dart's _firebaseMessagingBackgroundHandler (no second registration), tap routing reuses NotificationUtil.navigateToFromFcmData/handleNavigateTo so cold-start taps survive the navigator race, and the client-displayed sender shares APNS topic, failure codes, and token pruning with the existing send_notification paths. I also verified the foreground path still emits ServerMessage before the early return, so in-app consumers are unaffected, and the legacy compat branch (notification_type == 'plugin' + /chat/ route) in isChatAnswerData keeps old-format pushes working.
Two issues block merge for me, both in this PR's core surface:
-
backend/utils/notifications.py - send_client_displayed_notification and its _async twin set payload['body'] = body on top of the data['text'] field that NotificationMessage.get_message_as_dict already carries, so the full answer travels twice in the data payload. FCM caps data payloads at 4KB and rejects the entire message when it's exceeded, so long answers (roughly 2k+ chars) will make the push fail silently - the notification disappears entirely instead of expanding as BigText. That's a regression versus the current single-copy path and it hits exactly the long-answer case this PR is fixing. ChatAnswerNotificationHandler._resolveBody already falls back to data['text'], so dropping (or bounding) the duplicated body keeps behavior while halving the payload.
-
app/lib/services/notifications/chat_answer_notification_handler.dart - handle() creates the notification unconditionally; isAppInForeground is only used in the debug log, unlike the sibling handlers (MergeNotificationHandler.handleMergeCompleted, ImportantConversationNotificationHandler) which only display when the app is backgrounded. Two visible consequences: (a) on Android foreground, the early branch in notification_service_fcm.dart runs before the !OmiVoicePlaybackService.instance.isSpeaking guard, so a shade notification now pops while Omi is speaking the answer aloud; (b) on iOS foreground, listenForMessages previously showed nothing (_shouldShowForegroundNotificationOnFCMMessageReceived() is Android-only) and now presents a local banner while the user is inside the app. If foreground display is intended for chat answers, please gate the foreground call site on the speaking state (mirroring the legacy branch just below it) and make the isAppInForeground semantics explicit; otherwise display only when !isAppInForeground like the merge/important handlers.
The rest checks out, verified against the diff:
- app/lib/main.dart - the new else-if branch in _firebaseMessagingBackgroundHandler matches the existing handler chain, and the comment correctly warns against re-registering a second background handler.
- app/lib/services/notifications/notification_service_fcm.dart - the legacy _showForegroundNotification path now selects NotificationLayout.BigText for /chat/ routes and threads the payload through; taps flow through the existing awesome-notifications action path (_handleAppLinkOrDeepLink polls for the navigator, so terminated-state taps work).
- backend/utils/chat.py - both send_chat_message_notification and send_chat_message_notification_async use the client-displayed sender; no stale references to the removed send_notification import; call sites unchanged.
- backend/utils/notifications.py - _build_apns_config's new alert branch sets apns-push-type: alert / priority 10 / topic correctly; _build_message(client_displayed=True) omits the top-level notification and the Android notification config while webpush keeps title/body with the HTTPS-link guard intact.
- Tests - chat_answer_notification_handler_test.dart covers the matcher including legacy-plugin and negative cases; test_chat_answer_client_displayed_notification.py asserts the message shape (no top-level notification, push_type, APNS alert) for both senders; the three stub updates (test_chat_stream_error_fallback.py, test_desktop_transcribe.py, test_sync_silent_failure.py) only mock the new symbols on the already-stubbed utils.notifications module - no production behavior masked.
Also noting the tradeoff you flagged in the description: data-only Android delivery means no system-tray fallback if the background isolate can't run (Doze / aggressive OEM killers), and wakeUpScreen stays off. Reasonable call, but it's a notification-reliability product decision that needs explicit maintainer sign-off alongside merge review.
Requesting changes on items 1 and 2; happy to re-review. Human maintainer sign-off needed for the data-only fallback tradeoff, which the PR description itself defers.
AI-generated maintainer feedback on behalf of the Omi maintainers. Leaving for human maintainer sign-off on the data-only Android delivery tradeoff noted above.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
Drop duplicated payload['body'] from client-displayed chat pushes so the answer travels once via data['text']; keep APNS/webpush display_body. Match merge-handler foreground semantics and suppress shade while speaking. Failure-Class: none Co-authored-by: Apoorv Darshan <[email protected]>
|
Addressed both CHANGES_REQUESTED items in 5789f10:
Ready for re-review. — Apoorv |
Run dart format --line-length 120 on changed Dart files so the Formatting CI job passes (notification_service_fcm.dart was the reported failure; main.dart, chat_answer_notification_handler.dart, and chat_answer_notification_handler_test.dart were also reformatted). Verification: dart format --line-length 120 --set-exit-if-changed --output=none (4 files, 0 changed) Co-authored-by: Apoorv Darshan <[email protected]>
|
Formatting fixed — ran |
CI Formatting runs flutter pub get before dart format, which resolves app/analysis_options.yaml (formatter.page_width: 120) and applies the Dart 3.7+ formatter. The prior fix ran without pub resolution and reformatted authMethod / ChangeNotifierProxyProvider4 differently than CI expects. Verification (after cd app && flutter pub get): dart format --line-length 120 --set-exit-if-changed --output=none (4 dart files, 0 changed) scripts/backend-python-format --check (6 py files, unchanged) Co-authored-by: Apoorv Darshan <[email protected]>
|
Formatting fix (take 2): CI runs Re-ran after New head: |
Both concerns from this review are resolved on the current head (5789f10 / 60633df): send_client_displayed_notification no longer duplicates the answer in payload['body'] (single copy via data['text']; APNS alert keeps display_body), and the chat-answer shade path is now gated on !OmiVoicePlaybackService.instance.isSpeaking with display only when backgrounded (merge-handler semantics).
|
Both items from the earlier changes-requested review are verified fixed on 60633df — thanks for the quick turnaround and the clean fix commit.
Everything else still checks out on this head:
Left for human maintainer sign-off (unchanged from the prior review, and deliberately outside this PR's scope): data-only Android delivery drops the system-tray fallback when the client handler can't run (Doze / aggressive OEM killers), and by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Fix confirmed real (Fixes #4375, BigText chat notifications). Prior CHANGES_REQUESTED (FCM 4KB payload duplication, missing foreground/speaking gate) addressed in follow-up commit 5789f10 and dismissed; cubic confirms all issues addressed. CI green, tests added. 4/5 confidence (only scoped-diff line count exceeds threshold).
… boundary ratchet BasedHardware#13173 added `send_client_displayed_notification` and its async twin to `utils/notifications.py`, and moved `utils/chat.py` off `send_notification` onto them. Both new functions reach `_send_to_user{,_async}` directly, so they are transport entry points like the ones already listed — but the scanner did not know the names, so after merging main `chat.py` read as 0 direct calls and the checker demanded the baseline drop it. That would have recorded a reduction that never happened and left two unguarded ways to own transport. Adding the names restores `chat.py: 2`, so the baseline is unchanged and the ratchet still holds at 20. Failure-Class: none
The boundary ratchet guarded a hand-written list of seven names — two private, five public — and
utils/notifications.py has thirteen public functions that call an FCM
primitive directly. The other eight — send_action_item_data_message, the
action-item update/deletion/batch-deletion messages,
send_apple_reminders_sync_push{,_async}, send_important_conversation_message
and send_merge_completed_message — were bypasses a new producer could use
without tripping the check, and twelve existing call sites already did.
The recorded 20 was exact only for the subset. Against the module's real
surface the tree has 32 direct calls across 18 files.
Two properties make this worth fixing before merge rather than after. The
baseline must exactly match observed counts and may never grow per file, so
once it is on main, widening the guard means migrating every newly visible
call site in the same PR or weakening the check. And the list has already
drifted once: the first entry point added after it (BasedHardware#13173) went unguarded
until a merge happened to surface it.
So the list is gone. The checker reads the transport module and treats as an
entry point every public function whose own body calls _send_to_user,
_send_to_user_async or _send_messages. A sender added tomorrow is guarded the
day it lands, with no edit here. The baseline is regenerated at the honest 32;
there is no baseline on main yet, so this is the one moment that costs nothing.
Direct callers only, and that limit is stated in the checker and pinned by a
test: a wrapper delivering through another public function
(send_credit_limit_notification -> send_notification) is not itself counted.
A missing or unparseable transport module raises rather than deriving an empty
list that would pass as zero calls.
Mutation-checked: restoring a fixed list fails the new derivation test, and
the real tree's ratchet rejects a baseline that no longer matches; a fresh
producer calling send_merge_completed_message — previously unguarded — is now
counted and rejected.
Failure-Class: none
Co-Authored-By: Claude Opus 5 <[email protected]>
What changed and why
Fixes #4375. Click-to-talk / chat-answer notifications were truncated in the Android shade and tapping them opened the app without navigating to the chat. This PR delivers chat answers as client-displayed FCM (data-only on Android + APNS alert on iOS) so Flutter can render
BigTextlocally with anavigate_topayload.Supersedes #13065 (dirty merge base + CHANGES_REQUESTED). Clean branch cut from current
BasedHardware/omimain.Integration vs #13065 review
send_chat_message_notification_async+_chat_message_notification; both sync and async chat paths use the client-displayed sender.NotificationUtil.navigateToFromFcmData/handleNavigateTo— no cold-start navigator race (bug: Tapping Omi response notifications doesn't navigate to the correct conversation #5126).main.dart's_firebaseMessagingBackgroundHandler; nofcm_background_handler.dartdual registration.backend/utils/notifications.py—send_client_displayed_notification/_asyncshare APNS topic, failure codes, and token pruning (no parallelchat_answer_notifications.py).ChatAnswerNotificationHandler; initial-message navigation stays onNotificationUtil; unit tests usetesting.import_isolationas on main.Review follow-up (CHANGES_REQUESTED → 5789f10)
payload['body']; answer travels once viadata['text']. APNS/webpush still receivedisplay_bodyfor system alerts.!OmiVoicePlaybackService.instance.isSpeaking; handler only creates a shade notification when!isAppInForeground(merge-handler pattern).Product notes left for maintainer review (same as #13065): data-only Android drops system-tray fallback when the client handler cannot run;
wakeUpScreenis not enabled (matches merge/important handlers).Product invariants affected
app/lib/main.dartonly to add the chat-answer branch in the existing FCM background handler. Preserves existing production-family routing / Firebase authority; no data-plane or API-base change.How it was verified
Device BigText / tap-to-chat could not be exercised in this Linux Cloud VM (no Android SDK / physical device). Flutter unit file
app/test/unit/chat_answer_notification_handler_test.dartis included for CI Mobile App Checks.Tests
backend/tests/unit/test_chat_answer_client_displayed_notification.py— data-only Android message, APNS alert,push_type=chat_answer, sync + async senders, no duplicatedbody, long-answer under 4KBapp/test/unit/chat_answer_notification_handler_test.dart—isChatAnswerDatapredicate casesutils.chatstill import the new notification APIsFailure class (fixes)
Failure-Class: none