Skip to content

Conversation

@seshanthS
Copy link
Collaborator

@seshanthS seshanthS commented Jan 8, 2026

Description

  • Adds skipReselect option to DocumentNFCMethodSelection screen
  • Skip crash in some cases

Tested

Manually tested the values passed using logcat.

How to QA

  • NFC Scan should work if it was working already
  • Clicking the Help button ("?") in DocumentNFCScanScreen should not crash
  • Clicking cancel button in DocumentNFCScanScreen should not crash

Summary by CodeRabbit

  • New Features

    • Added a "Skip Re-select" NFC scanning option on Android so users can bypass the re-selection step during document scans.
  • Bug Fixes

    • Improved feedback modal and auto-hide error handling to suppress cleanup errors in runtime and log development-only debug messages, reducing crashes and improving stability.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

Adds try/catch error handling and DEV-only logging around feedback hide/show cleanup, and introduces an optional skipReselect boolean propagated through NFC scanning types, scanner, screens, and method selection for Android.

Changes

Cohort / File(s) Summary
Feedback hooks
app/src/hooks/useFeedbackAutoHide.ts, app/src/hooks/useFeedbackModal.ts
Wrapped cleanup and modal/show/hide logic in try/catch blocks; errors are logged in development and suppressed instead of propagating.
NFC scanner & types
app/src/integrations/nfc/nfcScanner.ts, app/src/integrations/nfc/passportReader.ts, app/src/types/reactNativePassportReader.d.ts
Added optional skipReselect?: boolean to Inputs/ScanOptions and pass-through to Android scan calls (defaults to false when omitted).
NFC UI & routing
app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx, app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
Added Android-specific "Skip Re-select" method option and propagated skipReselect via route params into the scan screen.

Sequence Diagram(s)

(Skipped — changes are parameter propagation and localized error handling without new multi-component control flow that requires sequencing.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • transphorm
  • shazarre

Poem

Small catches in code, quiet and neat,
Errors logged in dev, crashes we beat,
A flag for Android, skip the reselect dance,
Parameters flow, giving users a chance,
Ship the change—light, secure, and fleet.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add skipReselect Option' directly corresponds to the main change: adding a new skipReselect option throughout the NFC scanning flow.
Description check ✅ Passed The description covers all required template sections with sufficient detail: what is being changed (skipReselect option), testing approach (manual logcat), and QA steps (NFC scan functionality and crash prevention).
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.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67797e4 and 12783e5.

📒 Files selected for processing (1)
  • app/src/integrations/nfc/nfcScanner.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/integrations/nfc/nfcScanner.ts
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: test
  • GitHub Check: test-common
  • GitHub Check: type-check
  • GitHub Check: android-build-test
  • GitHub Check: e2e-ios
  • GitHub Check: analyze-android

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
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
app/src/integrations/nfc/nfcScanner.ts (1)

18-30: Critical: Add missing skipReselect property to Inputs interface.

Line 94 references inputs.skipReselect, but the Inputs interface doesn't declare this property. This causes the TypeScript compilation error reported in the pipeline.

🔧 Proposed fix
 interface Inputs {
   passportNumber: string;
   dateOfBirth: string;
   dateOfExpiry: string;
   canNumber?: string;
   useCan?: boolean;
   skipPACE?: boolean;
   skipCA?: boolean;
   extendedMode?: boolean;
   usePacePolling?: boolean;
   sessionId: string;
   userId?: string;
+  skipReselect?: boolean;
 }
app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx (2)

25-32: Critical: NFCParams type missing skipReselect field.

The NFCParams type doesn't include skipReselect?: boolean, but the new NFC method at line 47 passes { skipReselect: true } in its params. This breaks type safety—the code only compiles because of the as never assertion at line 146.

🔧 Proposed fix: Add skipReselect to NFCParams
 type NFCParams = {
   skipPACE?: boolean;
   canNumber?: string;
   useCan?: boolean;
   skipCA?: boolean;
   extendedMode?: boolean;
   usePacePolling?: boolean;
+  skipReselect?: boolean;
 };

146-146: Remove type assertion after fixing NFCParams.

The as never assertion bypasses TypeScript's type checking and masks the missing skipReselect field in NFCParams. Once the type is corrected (see previous comment), this assertion should be removed or replaced with a proper type.

♻️ Proposed fix after NFCParams is updated
-    navigation.navigate('DocumentNFCScan', params as never);
+    navigation.navigate('DocumentNFCScan', params);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e01b3c and 67797e4.

📒 Files selected for processing (7)
  • app/src/hooks/useFeedbackAutoHide.ts
  • app/src/hooks/useFeedbackModal.ts
  • app/src/integrations/nfc/nfcScanner.ts
  • app/src/integrations/nfc/passportReader.ts
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/types/reactNativePassportReader.d.ts
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{js,jsx,ts,tsx}: NEVER log sensitive data including PII (names, DOB, passport numbers, addresses), credentials, tokens, API keys, private keys, or session identifiers.
ALWAYS redact/mask sensitive fields in logs using consistent patterns (e.g., ***-***-1234 for passport numbers, J*** D*** for names).

Files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
  • app/src/integrations/nfc/nfcScanner.ts
  • app/src/hooks/useFeedbackModal.ts
  • app/src/hooks/useFeedbackAutoHide.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Use React Navigation with createStaticNavigation for type-safe navigation in React Native applications.
Implement platform-specific handling with Platform.OS === 'ios' ? 'iOS' : 'Android' checks before platform-specific code in React Native.
Initialize native modules with initializeNativeModules() before any native operations in React Native.
Implement lazy loading for screens using React.lazy() in React Native applications.
Implement custom modal system with useModal hook and callback registry in React Native.
Integrate haptic feedback using useHapticNavigation hook in React Native navigation.
Use platform-specific initial routes: web uses 'Home', mobile uses 'Splash' in React Navigation.
Use Zustand for global state management in React Native applications.
Use custom hooks for complex state (useModal, useHapticNavigation) instead of inline logic.
Use AsyncStorage for simple data, SQLite for complex data, and Keychain for sensitive data in React Native.
Use @/ alias for src imports and @tests/ alias for test imports in TypeScript/JavaScript files.
Use conditional rendering with Platform.OS for platform-specific code in React Native.
Use Tamagui for UI components in React Native applications.
Do not log sensitive data in production, including identity verification and passport information.
Use Keychain for secure storage of sensitive data in React Native.
Implement proper cleanup of sensitive data after use.
Implement certificate validation for passport data verification.
Always use try-catch for async operations in React Native and TypeScript code.
Implement graceful degradation when native modules fail in React Native.
Provide user-friendly error messages in UI and error handlers.
Lazy load screens and components to optimize bundle size in React Native.
Prevent memory leaks in native modules in React Native.

Files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
  • app/src/integrations/nfc/nfcScanner.ts
  • app/src/hooks/useFeedbackModal.ts
  • app/src/hooks/useFeedbackAutoHide.ts
**/*.{tsx,jsx,ts,js}

📄 CodeRabbit inference engine (.cursorrules)

Implement proper cleanup in useEffect and component unmount hooks in React.

Files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
  • app/src/integrations/nfc/nfcScanner.ts
  • app/src/hooks/useFeedbackModal.ts
  • app/src/hooks/useFeedbackAutoHide.ts
**/{mobile,client,app,time,verification}/**/*.{ts,tsx,js,swift,kt}

📄 CodeRabbit inference engine (.cursor/rules/compliance-verification.mdc)

Use server-signed time tokens or chain block timestamps for trusted time in mobile clients, do not trust device wall-clock alone

Files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
  • app/src/integrations/nfc/nfcScanner.ts
  • app/src/hooks/useFeedbackModal.ts
  • app/src/hooks/useFeedbackAutoHide.ts
**/{mobile,client,app,proof,zk}/**/*.{ts,tsx,js,swift,kt}

📄 CodeRabbit inference engine (.cursor/rules/compliance-verification.mdc)

**/{mobile,client,app,proof,zk}/**/*.{ts,tsx,js,swift,kt}: Include trusted time anchor in proof generation and verify time anchor authenticity before proof generation in mobile implementations
Achieve proof generation in <60 seconds on mid-tier mobile devices

Files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
  • app/src/integrations/nfc/nfcScanner.ts
  • app/src/hooks/useFeedbackModal.ts
  • app/src/hooks/useFeedbackAutoHide.ts
app/**/*.{ts,tsx}

📄 CodeRabbit inference engine (app/AGENTS.md)

Ensure yarn types passes (TypeScript validation) before creating a PR

Files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
  • app/src/integrations/nfc/nfcScanner.ts
  • app/src/hooks/useFeedbackModal.ts
  • app/src/hooks/useFeedbackAutoHide.ts
app/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (app/AGENTS.md)

app/**/*.{ts,tsx,js,jsx}: Ensure web build succeeds with yarn web before creating a PR
Do not include sensitive data in logs - avoid logging PII, credentials, and tokens
Use react-native-dotenv for environment configuration via @env import
Confirm no sensitive data exposed before PR merge

Files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
  • app/src/integrations/nfc/nfcScanner.ts
  • app/src/hooks/useFeedbackModal.ts
  • app/src/hooks/useFeedbackAutoHide.ts
app/src/**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

app/src/**/*.{ts,tsx,js,jsx}: Review React Native TypeScript code for:

  • Component architecture and reusability
  • State management patterns
  • Performance optimizations
  • TypeScript type safety
  • React hooks usage and dependencies
  • Navigation patterns

Files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
  • app/src/integrations/nfc/nfcScanner.ts
  • app/src/hooks/useFeedbackModal.ts
  • app/src/hooks/useFeedbackAutoHide.ts
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (.cursorrules)

Implement comprehensive error boundaries in React components.

Files:

  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: selfxyz/self PR: 0
File: app/AGENTS.md:0-0
Timestamp: 2025-12-25T19:19:04.954Z
Learning: Explain platform-specific code paths (iOS/Android/Web) in PR descriptions
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Implement certificate validation for passport data verification.

Applied to files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
📚 Learning: 2025-12-25T19:19:35.354Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-12-25T19:19:35.354Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.test.{ts,tsx} : Test `isPassportDataValid()` with realistic, synthetic passport data (never use real user data)

Applied to files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
📚 Learning: 2025-11-18T12:17:14.819Z
Learnt from: seshanthS
Repo: selfxyz/self PR: 1337
File: packages/mobile-sdk-alpha/src/processing/mrz.ts:189-194
Timestamp: 2025-11-18T12:17:14.819Z
Learning: In packages/mobile-sdk-alpha/src/processing/mrz.ts, the checkScannedInfo function and related TD1 extraction/validation logic are only reached on Android. iOS uses native Swift parsing (LiveMRZScannerView.swift) that bypasses this TypeScript layer.

Applied to files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
  • app/src/integrations/nfc/nfcScanner.ts
📚 Learning: 2025-12-25T19:19:35.354Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-12-25T19:19:35.354Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.{ts,tsx} : Ensure no breaking changes to public API or document them properly

Applied to files:

  • app/src/types/reactNativePassportReader.d.ts
  • app/src/integrations/nfc/passportReader.ts
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
  • app/src/integrations/nfc/nfcScanner.ts
📚 Learning: 2025-10-23T12:08:55.529Z
Learnt from: shazarre
Repo: selfxyz/self PR: 1236
File: packages/mobile-sdk-alpha/src/flows/onboarding/document-nfc-screen.tsx:356-378
Timestamp: 2025-10-23T12:08:55.529Z
Learning: In packages/mobile-sdk-alpha/src/flows/onboarding/document-nfc-screen.tsx, the NFC native events emitted via NativeEventEmitter are generic status strings (e.g., "PACE succeeded", "BAC failed", "Reading DG1 succeeded") and do not contain sensitive MRZ data or passport numbers, so they do not require sanitization before logging.

Applied to files:

  • app/src/integrations/nfc/passportReader.ts
  • app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx
  • app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx
  • app/src/integrations/nfc/nfcScanner.ts
📚 Learning: 2025-12-25T19:19:35.354Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-12-25T19:19:35.354Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.test.{ts,tsx} : Ensure `parseNFCResponse()` works with representative, synthetic NFC data

Applied to files:

  • app/src/integrations/nfc/passportReader.ts
  • app/src/integrations/nfc/nfcScanner.ts
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use custom hooks for complex state (`useModal`, `useHapticNavigation`) instead of inline logic.

Applied to files:

  • app/src/hooks/useFeedbackModal.ts
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Implement custom modal system with `useModal` hook and callback registry in React Native.

Applied to files:

  • app/src/hooks/useFeedbackModal.ts
📚 Learning: 2025-11-25T14:06:55.970Z
Learnt from: CR
Repo: selfxyz/self PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T14:06:55.970Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Always use try-catch for async operations in React Native and TypeScript code.

Applied to files:

  • app/src/hooks/useFeedbackModal.ts
  • app/src/hooks/useFeedbackAutoHide.ts
🪛 GitHub Actions: Mobile CI
app/src/integrations/nfc/nfcScanner.ts

[error] 94-94: TypeScript error TS2339: Property 'skipReselect' does not exist on type 'Inputs'.

⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: test-common
  • GitHub Check: type-check
  • GitHub Check: analyze-android
  • GitHub Check: android-build-test
  • GitHub Check: e2e-ios
🔇 Additional comments (7)
app/src/hooks/useFeedbackModal.ts (1)

30-49: LGTM - Solid defensive error handling.

The try/catch blocks around Sentry feedback operations prevent crashes from native module failures, with sensible fallbacks and dev-only logging. This aligns with the guideline to always use try-catch for async/native operations in React Native.

Also applies to: 55-61, 73-79

app/src/hooks/useFeedbackAutoHide.ts (1)

20-26: LGTM - Consistent error handling in cleanup.

The try/catch wrapper in the cleanup function prevents errors during screen unfocus from crashing the app. Consistent with the pattern in useFeedbackModal.ts.

app/src/types/reactNativePassportReader.d.ts (1)

14-14: LGTM - Type definition properly extended.

The optional skipReselect property is correctly added to the ScanOptions interface, maintaining backward compatibility with existing code.

app/src/screens/documents/scanning/DocumentNFCScanScreen.tsx (1)

84-84: LGTM - skipReselect parameter properly integrated.

The skipReselect parameter is correctly added to the route params type (line 84), destructured from route params (line 336), and passed to the scan function (line 351). Implementation follows the existing pattern for optional NFC scan parameters.

Also applies to: 330-337, 351-351

app/src/integrations/nfc/passportReader.ts (2)

19-19: LGTM: Android-specific NFC option added correctly.

The optional skipReselect parameter is properly added to the ScanOptions type and will be Android-only in practice (iOS scan path doesn't use it).


87-109: No action needed—sessionId forwarding is correct and intentional.

Both platform implementations properly require sessionId: the Android module accepts it via the ScanOptions abstraction, and the iOS implementation explicitly includes it as a parameter in the scanPassport signature (line 56). This is not a separate bundled fix—it's part of the unified type-safe abstraction across both platforms.

app/src/screens/documents/scanning/DocumentNFCMethodSelectionScreen.tsx (1)

42-48: LGTM: Android-specific NFC option properly configured.

The new skipReselect method is correctly configured for Android-only with appropriate label and description. The params will be properly typed once NFCParams is updated.

@seshanthS seshanthS merged commit ab84822 into dev Jan 8, 2026
24 checks passed
@seshanthS seshanthS deleted the feat/add-nfc-option branch January 8, 2026 19:14
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.

2 participants