Implemented proper BLE cleanup mechanism on user logout: **Root Cause:** - BLE cleanup callback was being set but reference could become stale - No explicit cleanup call in profile logout handler - Callback stability issues due to re-renders **Changes:** 1. app/_layout.tsx: - Use useRef pattern to maintain stable callback reference - Set callback once with ref that always points to current cleanupBLE - Cleanup callback on unmount to prevent memory leaks 2. app/(tabs)/profile/index.tsx: - Add explicit cleanupBLE() call in logout handler - Import useBLE hook to access cleanup function - Ensure cleanup happens before logout completes 3. services/api.ts: - Update setOnLogoutBLECleanupCallback signature to accept null - Allows proper cleanup of callback on unmount 4. jest.setup.js: - Add AsyncStorage mock to prevent test failures 5. Tests: - Add comprehensive BLE cleanup tests - Test callback pattern and stability - Test logout flow with BLE cleanup - Test error handling during cleanup **Result:** BLE connections now properly disconnect when user logs out, preventing stale connections and potential resource leaks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
WellNuoLite @ a1e30939a6
WellNuo - Caregiving App
WellNuo is a React Native/Expo app for monitoring and caring for loved ones (beneficiaries).
Tech Stack
- React Native with Expo SDK 54
- Expo Router for file-based navigation
- TypeScript
Get started
-
Install dependencies
npm install -
Start the app
npx expo start
Authentication Flow
The app uses email-based OTP authentication with two distinct paths:
Existing User (Login)
login.tsx -> Enter email -> welcome-back.tsx -> verify-otp.tsx -> Main App
- User enters email on login screen
- System checks if email exists in database
- If exists: navigates to "Welcome Back" screen, sends OTP
- User enters OTP code
- After verification: navigates to main app (tabs)
New User (Registration)
login.tsx -> Enter email -> verify-email.tsx (auto-sends OTP) -> verify-otp.tsx -> enter-name.tsx -> add-loved-one.tsx -> Main App
- User enters email on login screen
- System checks if email exists in database
- If NOT exists: navigates to "Verify Email" screen
- OTP is automatically sent when screen loads
- User can optionally enter a partner/referral code (6-digit numeric)
- User proceeds to OTP verification
- After verification: enters their name
- Then adds their first beneficiary (or skips)
- Finally navigates to main app
Partner/Referral Code
Partner codes are 6-digit numeric codes for marketing/referrals:
- Only available during NEW user registration (verify-email screen)
- NOT shown for existing users logging in
- Visual: 6 separate cells with hidden TextInput for keyboard
- Only accepts digits (non-numeric characters are filtered out)
- Test code "123456" available for development
Key Files
Authentication
app/(auth)/login.tsx- Email entry screenapp/(auth)/verify-email.tsx- OTP sending for new users + partner codeapp/(auth)/welcome-back.tsx- OTP sending for existing usersapp/(auth)/verify-otp.tsx- OTP verificationapp/(auth)/enter-name.tsx- Name entry for new usersapp/(auth)/add-loved-one.tsx- Add first beneficiary
Main App
app/(tabs)/index.tsx- Beneficiary list (home)app/(tabs)/voice.tsx- Voice assistantapp/(tabs)/account.tsx- Account settings
Services
services/api.ts- API serviceservices/sherpaTTS.ts- Text-to-Speech (stub for Expo Go)contexts/AuthContext.tsx- Authentication contextcontexts/BeneficiaryContext.tsx- Beneficiary context
Development Notes
Expo Go Limitations
Some features are stubbed when running in Expo Go:
expo-speech-recognition- Uses Alert fallback instead of native speechsherpa-onnx-tts- Uses expo-speech instead of native TTS
Running on Simulators
Use specific UDID for each port:
IOS_SIMULATOR_UDID=FCED72EF-3ADE-47D5-AC67-5C9B0DE59D7E npx expo start --port 8082 --ios
See ~/Desktop/dev instructions/SIMULATORS.md for full port-to-UDID mapping.
Description
Languages
JavaScript
49.7%
HTML
39.1%
TypeScript
10.9%
Python
0.1%