Skip to content

[jules] enhance: Add global Toast notification system for mobile#320

Open
Devasy wants to merge 1 commit intomainfrom
enhancement/mobile-toast-notifications-9659098714573135941
Open

[jules] enhance: Add global Toast notification system for mobile#320
Devasy wants to merge 1 commit intomainfrom
enhancement/mobile-toast-notifications-9659098714573135941

Conversation

@Devasy
Copy link
Copy Markdown
Owner

@Devasy Devasy commented Apr 15, 2026

This PR implements a comprehensive global Toast notification system for the Mobile application using React Native Paper's Snackbar. It replaces intrusive Alert.alert calls during form validation and network feedback, significantly improving the UX.

The ToastProvider is seamlessly integrated at the root level within App.js inside the PaperProvider, allowing all screens (e.g. LoginScreen, SignupScreen, and HomeScreen) to present themed, non-blocking feedback messages to users.

This task aligns with the project's 'Error Handling & UX Polish' initiatives.


PR created automatically by Jules for task 9659098714573135941 started by @Devasy23

Summary by CodeRabbit

  • New Features
    • Toast notifications now provide feedback across the mobile app during authentication and group management, replacing blocking alert dialogs for form validation, errors, and success confirmations.
    • Notifications are automatically themed by message type (success, error, info) and dismiss after 3 seconds, creating a smoother user experience.

- Created ToastContext using react-native-paper Snackbar
- Replaced intrusive Alert.alert calls with non-blocking showToast in Auth and Home screens
- Updated .Jules tracking files

Co-authored-by: Devasy23 <110348311+Devasy23@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@Devasy Devasy requested a review from vrajpatelll as a code owner April 15, 2026 20:14
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 15, 2026

Deploy Preview for split-but-wiser canceled.

Name Link
🔨 Latest commit 982963c
🔍 Latest deploy log https://app.netlify.com/projects/split-but-wiser/deploys/69dff1af96c394000843fc7c

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@9404621). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #320   +/-   ##
=======================================
  Coverage        ?   63.55%           
=======================================
  Files           ?       21           
  Lines           ?     2456           
  Branches        ?      254           
=======================================
  Hits            ?     1561           
  Misses          ?      831           
  Partials        ?       64           
Components Coverage Δ
Authentication System 71.35% <ø> (?)
Expense Management 70.15% <ø> (?)
Group Management 73.78% <ø> (?)
User Management 97.16% <ø> (?)
Backend Core 70.78% <ø> (?)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

Walkthrough

Added a global toast notification system using React Context and react-native-paper's Snackbar component to replace blocking Alert.alert() calls. Created ToastContext module, wrapped the app navigator with ToastProvider, and updated authentication and home screens to use toast notifications for user feedback.

Changes

Cohort / File(s) Summary
Documentation
.Jules/changelog.md, .Jules/todo.md
Added changelog and todo entries documenting the new mobile global toast notification system implementation and its replacement of blocking Alert calls.
Toast Context Implementation
mobile/context/ToastContext.js
New module implementing a global toast context with ToastProvider component and useToast hook. Provides showToast() and hideToast() callbacks. Snackbar styled by toast type (success, error, info).
App Configuration
mobile/App.js
Integrated ToastProvider wrapper around AppNavigator within the component tree hierarchy.
Screen Updates
mobile/screens/LoginScreen.js, mobile/screens/SignupScreen.js, mobile/screens/HomeScreen.js
Replaced Alert.alert() calls with useToast() hook for validation errors, success messages, and failure feedback. Removed unused Alert imports.

Suggested reviewers

  • vrajpatelll
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a global Toast notification system for mobile.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@mobile/context/ToastContext.js`:
- Line 47: The provider is recreating its value object every render which forces
all useToast() consumers to rerender; inside the component that renders
ToastContext.Provider, memoize the value by creating const value = useMemo(() =>
({ showToast }), [showToast]) and pass value into <ToastContext.Provider
value={value}>; also ensure showToast itself is stable (wrap its definition in
useCallback if it’s recreated each render) so the memo actually prevents
unnecessary rerenders.
- Line 67: The hook useToast currently returns the raw ToastContext value which
leads to obscure runtime errors when used outside a ToastProvider; update
useToast to call useContext(ToastContext), check if the returned value is
undefined/null, and if so throw a clear Error like "useToast must be used within
a ToastProvider" so consumers fail fast; reference the existing symbol useToast
and ToastContext (and the ToastProvider pattern used elsewhere) when making the
change.

In `@mobile/screens/SignupScreen.js`:
- Around line 30-31: The post-signup navigation uses
navigation.navigate('Login') which leaves the SignupScreen in the history and
can allow back navigation to a completed form; change the transition to use
navigation.replace('Login') where the call is made (replace the
navigation.navigate call in the success path after showToast in SignupScreen.js)
so the SignupScreen is removed from the stack and users cannot go back to the
completed signup screen.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 959cad7b-153d-4e50-a287-ba5ff60fa267

📥 Commits

Reviewing files that changed from the base of the PR and between 9404621 and 982963c.

📒 Files selected for processing (7)
  • .Jules/changelog.md
  • .Jules/todo.md
  • mobile/App.js
  • mobile/context/ToastContext.js
  • mobile/screens/HomeScreen.js
  • mobile/screens/LoginScreen.js
  • mobile/screens/SignupScreen.js

};

return (
<ToastContext.Provider value={{ showToast }}>
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.

🧹 Nitpick | 🔵 Trivial

Memoize provider value to avoid app-wide rerenders on each toast state change.

At Line 47, value={{ showToast }} creates a new object every render, forcing all useToast() consumers to rerender whenever toast UI state changes.

♻️ Proposed fix
 import React, { createContext, useState, useContext, useCallback } from 'react';
+import { useMemo } from 'react';
@@
-  return (
-    <ToastContext.Provider value={{ showToast }}>
+  const contextValue = useMemo(() => ({ showToast }), [showToast]);
+
+  return (
+    <ToastContext.Provider value={contextValue}>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mobile/context/ToastContext.js` at line 47, The provider is recreating its
value object every render which forces all useToast() consumers to rerender;
inside the component that renders ToastContext.Provider, memoize the value by
creating const value = useMemo(() => ({ showToast }), [showToast]) and pass
value into <ToastContext.Provider value={value}>; also ensure showToast itself
is stable (wrap its definition in useCallback if it’s recreated each render) so
the memo actually prevents unnecessary rerenders.

);
};

export const useToast = () => useContext(ToastContext);
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.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's explore the mobile/context directory structure
find mobile/context -type f -name "*.js" -o -name "*.ts" -o -name "*.tsx" 2>/dev/null | head -20

Repository: Devasy/splitwiser

Length of output: 121


🏁 Script executed:

# Check the exact content of ToastContext.js
cat -n mobile/context/ToastContext.js

Repository: Devasy/splitwiser

Length of output: 2427


🏁 Script executed:

# Search for ToastProvider to understand the context setup
rg "ToastProvider" -A 5 -B 2

Repository: Devasy/splitwiser

Length of output: 3168


🏁 Script executed:

# Check if other context hooks in the codebase follow the guard pattern
rg "useContext\(" mobile/context web/contexts 2>/dev/null | head -20

Repository: Devasy/splitwiser

Length of output: 445


🏁 Script executed:

# Look for other custom context hooks to see the pattern
ast-grep --pattern 'export const use$_$_ = () => useContext($_);'

Repository: Devasy/splitwiser

Length of output: 43


Guard useToast to fail fast when provider is missing.

At Line 67, returning raw context can cause runtime crashes (Cannot destructure property 'showToast') if used outside ToastProvider. Throw a clear error from the hook instead. This pattern is already implemented in the web version (web/contexts/ToastContext.tsx) and should be applied consistently here.

🛡️ Proposed fix
-export const useToast = () => useContext(ToastContext);
+export const useToast = () => {
+  const context = useContext(ToastContext);
+  if (!context) {
+    throw new Error('useToast must be used within a ToastProvider');
+  }
+  return context;
+};
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const useToast = () => useContext(ToastContext);
export const useToast = () => {
const context = useContext(ToastContext);
if (!context) {
throw new Error('useToast must be used within a ToastProvider');
}
return context;
};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mobile/context/ToastContext.js` at line 67, The hook useToast currently
returns the raw ToastContext value which leads to obscure runtime errors when
used outside a ToastProvider; update useToast to call useContext(ToastContext),
check if the returned value is undefined/null, and if so throw a clear Error
like "useToast must be used within a ToastProvider" so consumers fail fast;
reference the existing symbol useToast and ToastContext (and the ToastProvider
pattern used elsewhere) when making the change.

Comment on lines +30 to +31
showToast('Account created successfully! Please login.', 'success');
navigation.navigate('Login');
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.

🧹 Nitpick | 🔵 Trivial

Prefer replace('Login') after successful signup to avoid stale back navigation.

At Line 31, navigate('Login') can keep Signup in history; users may return to a completed form via back gesture. replace is usually a better post-signup transition.

♻️ Proposed fix
     if (success) {
       showToast('Account created successfully! Please login.', 'success');
-      navigation.navigate('Login');
+      navigation.replace('Login');
     } else {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
showToast('Account created successfully! Please login.', 'success');
navigation.navigate('Login');
showToast('Account created successfully! Please login.', 'success');
navigation.replace('Login');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mobile/screens/SignupScreen.js` around lines 30 - 31, The post-signup
navigation uses navigation.navigate('Login') which leaves the SignupScreen in
the history and can allow back navigation to a completed form; change the
transition to use navigation.replace('Login') where the call is made (replace
the navigation.navigate call in the success path after showToast in
SignupScreen.js) so the SignupScreen is removed from the stack and users cannot
go back to the completed signup screen.

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