Repository navigation
Fix Android deep links broken across all notification types - #4803
Conversation
4 bugs causing deep links to silently fail: 1. Race condition: initDeepLinks() fired before providers initialized on cold start, so getInitialLink() raced against cache loading (#4763) Fix: await _initializeProviders() before calling initDeepLinks() 2. Missing bounds check: /apps deep link crashed on malformed URL when pathSegments had only 1 element (#4762) Fix: add pathSegments.length > 1 guard 3. Missing route: /action-items and /facts not handled in home page navigation switch, so task reminder notifications went nowhere Fix: add action-items (tab 1) and facts (tab 2) cases 4. Empty string fallback: FCM navigate_to defaulted to "" instead of omitting the key, bypassing the null check in the tap handler Fix: only add navigate_to to payload when present and non-empty Fixes #4799, fixes #4763, fixes #4762 Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request effectively addresses several critical bugs related to deep linking and notifications in the Android app. The changes include fixing a race condition during app initialization, preventing a crash from malformed URLs by adding a bounds check, adding missing navigation routes for notifications, and improving the handling of notification payloads. All fixes are well-implemented and robust. The code quality is good, and I have no further suggestions for improvement.
E2E Test Results (Android Emulator)Environment: emulator-5554 (API 35, x86_64), dev flavor debug build All 8 tests PASS:
ScreenshotsCold start
Notes
|
E2E Test Results: Fix 3 & Fix 4 (Notification Tap Handler)Tested by injecting payloads directly into Fix 3:
|
| Test | Payload | Result |
|---|---|---|
| 4a: no key | {some_other_key: "value"} |
Stayed on current page — handler returned early at null check |
| 4b: empty string | {navigate_to: ""} |
Navigated to home page — empty string bypassed null check, caused disruptive pushReplacement |
Fix 4 prevents this by not adding navigate_to to the FCM payload when the value is null/empty, so the 4b scenario never occurs in production.
Full Test Matrix (all 11 tests)
| # | Fix | Test | Result |
|---|---|---|---|
| 1 | Fix 2 | Malformed /apps (no ID), warm start |
PASS |
| 2 | Fix 2 | Valid /apps/id, warm start |
PASS |
| 3 | Fix 1 | Cold start /apps (no ID) |
PASS |
| 4 | Fix 1 | Cold start /apps/id |
PASS |
| 5 | Fix 1 | Cold start /tasks/token |
PASS |
| 6 | — | /unlimited navigation |
PASS |
| 7 | — | omi:// scheme malformed |
PASS |
| 8 | — | omi:// scheme cold start |
PASS |
| 9 | Fix 3 | navigate_to: "/action-items" notification tap |
PASS |
| 10 | Fix 4 | No navigate_to key in payload |
PASS |
| 11 | Fix 4 | Empty string navigate_to (pre-fix behavior) |
Demonstrates bug |
All 4 fixes validated end-to-end on Android emulator (API 35). Test code reverted — no test scaffolding in the commit.
Real FCM Notification Test ResultsSent actual Firebase Cloud Messaging notifications to the emulator via Firebase Admin SDK (project: Fix 3:
|






Summary
initDeepLinks()now waits for_initializeProviders()to complete before firing, preventing cold-start deep link failures (fix: deep link race condition — fires before providers initialized on cold start #4763)/appsdeep link now validatespathSegments.length > 1before accessing index [1], preventing crash on malformed URLs (fix: /apps deep link crashes on malformed URL (missing path segment check) #4762)action-items(tab 1) andfacts(tab 2) cases to home page navigation switch so task reminder and fact notifications actually navigatenavigate_topayload no longer defaults to""— only added when present and non-empty, so the tap handler's null check properly short-circuitsRoot Cause Analysis
All 4 bugs contributed to #4799 ("Android deep links broken across all notification types"):
app_shell.dart/appscrashes on malformed URLapp_shell.darthome/page.dartnavigate_toroute to home instead of being ignorednotification_service_fcm.dartTest plan
/appsdeep link with malformed URL → should not crashnavigate_to→ should not navigate away from current pageFixes #4799
Fixes #4763
Fixes #4762
🤖 Generated with Claude Code