Skip to content

fix chat notification not deep linking to chat screen#6282

Merged
mdmohsin7 merged 2 commits into
mainfrom
fix/chat-notification-bug
Apr 3, 2026
Merged

fix chat notification not deep linking to chat screen#6282
mdmohsin7 merged 2 commits into
mainfrom
fix/chat-notification-bug

Conversation

@krushnarout
Copy link
Copy Markdown
Member

Summary

  • Tapping a chat push notification opened the app but stayed on the home screen instead of navigating to chat
  • Root cause: addPostFrameCallback fired before HomePage finished its async init work (streamDeviceRecording, refreshMessages), causing the Navigator.push to be silently dropped
  • Fix: replace addPostFrameCallback with a 300ms Future.delayed so the push happens after the widget tree has fully settled
ScreenRecording_04-02-2026.20-56-56_1.mov

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 2, 2026

Greptile Summary

This PR fixes chat push-notification deep linking by replacing an inner addPostFrameCallback with Future.delayed(const Duration(milliseconds: 300)) so that Navigator.push fires after HomePage has initialised.

  • P1 — fragile timing fix: The 300 ms delay is an arbitrary magic number applied after streamDeviceRecording and refreshMessages are already awaited, meaning the widget tree is already settled. The Future.delayed call is also not awaited, so there is no guarantee the 300 ms is sufficient on slow devices. A direct Navigator.push (or a single WidgetsBinding.instance.addPostFrameCallback) would be deterministic and correct.

Confidence Score: 3/5

Merging carries reliability risk: the 300 ms magic-number delay can silently fail to navigate on slow devices.

The change fixes a real regression but uses an unawaited, arbitrary-duration delay in place of a deterministic navigation call. All async prerequisites are already awaited before the navigation point, so the delay is both unnecessary and unreliable.

app/lib/pages/home/page.dart — the Future.delayed block at line 357

Important Files Changed

Filename Overview
app/lib/pages/home/page.dart Replaces inner addPostFrameCallback with an unawaited Future.delayed(300ms) for chat deep-link navigation; the delay is a magic number applied after async setup is already complete, which is fragile and may fail on slow devices.

Sequence Diagram

sequenceDiagram
    participant OS as OS / FCM
    participant App as App (cold start)
    participant HP as HomePage.initState
    participant Nav as Navigator

    OS->>App: Tap chat notification (deep link)
    App->>HP: addPostFrameCallback (first frame)
    HP->>HP: await streamDeviceRecording
    HP->>HP: await refreshMessages
    Note over HP: widget tree fully settled here
    HP->>HP: Future.delayed(300ms) [unawaited]
    Note over HP,Nav: after 300ms (may not be enough on slow devices)
    HP->>Nav: Navigator.push(ChatPage)
Loading

Comments Outside Diff (1)

  1. app/lib/pages/home/page.dart, line 357-364 (link)

    P1 Fragile magic-number delay instead of awaited navigation

    By the time execution reaches line 357, both streamDeviceRecording (line 315) and refreshMessages (lines 342/349) have already been awaited inside the outer addPostFrameCallback. The widget tree is fully settled — an additional 300 ms is unnecessary and unreliable: on a low-end device under load, 300 ms may still not be enough, while on fast devices it adds a perceptible jitter before the screen appears.

    The Future.delayed(...) call is also not awaited, so the surrounding function exits before navigation fires, making the timing guarantee purely accidental. A direct Navigator.push — or a single addPostFrameCallback if a frame boundary is truly needed — is the correct fix here:

    // All async setup is already done; navigate directly.
    if (mounted) {
      Navigator.push(
        context,
        MaterialPageRoute(builder: (context) => ChatPage(isPivotBottom: false, autoMessage: autoMessageToSend)),
      );
    }

Reviews (1): Last reviewed commit: "fix chat notification not deep linking t..." | Re-trigger Greptile

@krushnarout krushnarout linked an issue Apr 2, 2026 that may be closed by this pull request
3 tasks
@krushnarout krushnarout requested a review from mdmohsin7 April 2, 2026 15:49
Replace arbitrary Future.delayed(300ms) with a direct Navigator.push.
By the time the "chat" case runs, streamDeviceRecording and refreshMessages
are already awaited, so the widget tree is fully settled and no delay is needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mdmohsin7 mdmohsin7 merged commit 953e0ea into main Apr 3, 2026
2 checks passed
@mdmohsin7 mdmohsin7 deleted the fix/chat-notification-bug branch April 3, 2026 12:05
Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
…6282)

## Summary
- Tapping a chat push notification opened the app but stayed on the home
screen instead of navigating to chat
- Root cause: `addPostFrameCallback` fired before `HomePage` finished
its async init work (`streamDeviceRecording`, `refreshMessages`),
causing the `Navigator.push` to be silently dropped
- Fix: replace `addPostFrameCallback` with a 300ms `Future.delayed` so
the push happens after the widget tree has fully settled


https://github.com/user-attachments/assets/9f973b93-b68e-40cd-b2b1-bc92c8659b9d

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

Omi chat response notifications do not deep link to chat when tapped

2 participants