Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(suite-native): onboarding unitialized device landing screen #16616

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

PeKne
Copy link
Contributor

@PeKne PeKne commented Jan 27, 2025

Description

  • when is an uninitialized device connected, app redirects to a device onboarding landing screen
  • the UI differs depending if the firmware is already installed on the device

Related Issue

Resolve #16278

Screenshots:

Firmware-less device

Screenshot 2025-01-27 at 11:27:19 AM Screenshot 2025-01-27 at 11:26:57 AM

Device with firmware installed

Screenshot 2025-01-27 at 11:27:29 AM Screenshot 2025-01-27 at 11:26:12 AM

@PeKne PeKne added the mobile Suite Lite issues and PRs label Jan 27, 2025
@PeKne PeKne requested a review from a team as a code owner January 27, 2025 12:19
Copy link

github-actions bot commented Jan 27, 2025

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 24
  • More info

Learn more about 𝝠 Expo Github Action

@matejkriz
Copy link
Member

Beware, the "seedless" term can be confusing. Check https://trezor.io/learn/a/seedless-setup and try to search for "seedless" in our codebase... I believe it would be better to rename it to "uninitialized".

@PeKne
Copy link
Contributor Author

PeKne commented Jan 28, 2025

@matejkriz Good point 👀, I will rename it

@PeKne PeKne changed the title feat(suite-native): onboarding seedless device landing screen feat(suite-native): onboarding unitialized device landing screen Jan 28, 2025
@PeKne
Copy link
Contributor Author

PeKne commented Jan 28, 2025

Seedlessnaming substitued with Unitialized in 76c6f6b.

@PeKne PeKne force-pushed the feat/native/seedless-device-landing-screen branch 2 times, most recently from 94fe6b8 to c2a76de Compare February 3, 2025 08:59
Copy link

coderabbitai bot commented Feb 3, 2025

Walkthrough

The pull request introduces changes across navigation, state hooks, utilities, internationalization, and the onboarding module. The onboarding route in the root navigator is renamed to "OnboardingStack" across multiple files, and a new route for the Uninitialized Device Landing screen is added. Several hooks, including those for detecting device errors and handling device connections, now incorporate new selectors (e.g., selectIsDeviceSetupSupported, selectIsDeviceInitialized) to refine control flow based on device setup support and initialization. Additionally, utility functions and type definitions have been extended, a new SVG component (HeaderUnderlineSvg) is introduced for UI embellishments, and the internationalization files now include content for the uninitialized device experience. The updates also include dependency modifications and TS configuration enhancements to support new functionality.

Assessment against linked issues

Objective Addressed Explanation
Uninitialized Device Welcome Screen UI with correct CTA navigation actions [#16278] CTA handlers currently trigger toast notifications and do not navigate to the Update Firmware or Not Sure screens.

Suggested labels

+Invity

Suggested reviewers

  • marekrjpolak
  • Nodonisko
  • vytick
  • jbazant
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@PeKne
Copy link
Contributor Author

PeKne commented Feb 3, 2025

@vytick FYI I had to squash the commits to be able to rename it (seedless ---> unitialized).

Copy link

@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: 1

🧹 Nitpick comments (4)
suite-native/module-onboarding/redux.d.ts (1)

1-7: LGTM! Consider improving type safety.

The module augmentation correctly extends Redux's Dispatch interface to support async thunk actions. However, consider making the type parameters more specific instead of using 'any'.

Here's a suggested improvement with stricter typing:

-<TThunk extends AsyncThunkAction<any, any, any>>(thunk: TThunk): ReturnType<TThunk>;
+<ReturnType = unknown, State = unknown, ExtraThunkArg = unknown>(
+  thunk: AsyncThunkAction<ReturnType, State, { rejectValue: Error; extra: ExtraThunkArg }>
+): Promise<ReturnType>;

Also consider adding JSDoc comments to document the purpose of this extension:

/**
 * Extends Redux Dispatch to support async thunk actions in the onboarding module.
 * This enables proper typing for async operations during device initialization.
 */
suite-native/module-onboarding/src/components/HeaderUnderlineSvg.tsx (1)

6-17: LGTM! Well-structured SVG component.

The component follows React best practices with proper TypeScript integration and custom hook usage.

Consider memoizing the component with React.memo() since it only depends on props and the lineColor from the hook:

-export const HeaderUnderlineSvg = (props: SvgProps) => {
+export const HeaderUnderlineSvg = React.memo((props: SvgProps) => {
     const { lineColor } = useIllustrationColors();
 
     return (
         <Svg width={222} height={10} fill="none" {...props}>
             <Path
                 fill={lineColor}
                 d="M1.995 2.525C53.744-.098 107.902.93 160.472 1.268c18.682.175 37.417 1.564 56.049 3.262l2.801.247.682.06.324.02.126.006c-.111.06.3-.144-.415.159.184 3.4.258 1.022.216 1.75-39.372-4.117-79.695-.91-118.773 2.284-8.64-2.438 79.033-8.419 118.414-4.347.25.043.453.065.775.137.005.744.163-1.63.364 1.815-.77.32-.425.107-.59.171-.138-.005-.462-.019-.599-.037-4.596-.445-10.069-1.018-14.659-1.306-33.506-2.283-67.268-3.043-100.873-2.636-40.776.651-116.234 2.03-102.32-.328Z"
             />
         </Svg>
     );
-};
+});
suite-native/device/src/hooks/useHandleDeviceConnection.ts (1)

48-48: Consider combining related selectors.

The new selectors isDeviceInitialized and isDeviceSetupSupported are closely related. Consider combining them into a single selector to reduce re-renders and improve performance.

-const isDeviceInitialized = useSelector(selectIsDeviceInitialized);
-const isDeviceSetupSupported = useSelector(selectIsDeviceSetupSupported);
+const { isDeviceInitialized, isDeviceSetupSupported } = useSelector(state => ({
+  isDeviceInitialized: selectIsDeviceInitialized(state),
+  isDeviceSetupSupported: selectIsDeviceSetupSupported(state),
+}));

Also applies to: 51-51

suite-native/intl/src/en.ts (1)

828-842: LGTM! The strings align well with the PR objectives.

The internationalization strings for the uninitialized device landing screen are well-structured and clear. The terminology change from "seedless" to "uninitialized" has been correctly implemented as discussed in the PR comments.

Consider adding a period at the end of the subtitle for consistency with other similar messages in the file:

-                    'Firmware is already installed on this Trezor. Continue only if you have used this Trezor before.',
+                    'Firmware is already installed on this Trezor. Continue only if you have used this Trezor before.',
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbb7cf9 and c2a76de.

⛔ Files ignored due to path filters (3)
  • suite-native/module-onboarding/src/assets/trezorSafe3.png is excluded by !**/*.png
  • suite-native/module-onboarding/src/assets/trezorSafe5.png is excluded by !**/*.png
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (16)
  • suite-native/app/src/navigation/RootStackNavigator.tsx (2 hunks)
  • suite-native/device/src/hooks/useDetectDeviceError.tsx (5 hunks)
  • suite-native/device/src/hooks/useHandleDeviceConnection.ts (6 hunks)
  • suite-native/device/src/index.ts (1 hunks)
  • suite-native/device/src/selectors.ts (2 hunks)
  • suite-native/device/src/types.ts (1 hunks)
  • suite-native/device/src/utils.ts (2 hunks)
  • suite-native/intl/src/en.ts (1 hunks)
  • suite-native/module-onboarding/package.json (1 hunks)
  • suite-native/module-onboarding/redux.d.ts (1 hunks)
  • suite-native/module-onboarding/src/components/HeaderUnderlineSvg.tsx (1 hunks)
  • suite-native/module-onboarding/src/navigation/OnboardingStackNavigator.tsx (2 hunks)
  • suite-native/module-onboarding/src/screens/UninitializedDeviceLandingScreen.tsx (1 hunks)
  • suite-native/module-onboarding/tsconfig.json (1 hunks)
  • suite-native/navigation/src/navigators.ts (2 hunks)
  • suite-native/navigation/src/routes.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (17)
  • GitHub Check: build-deploy
  • GitHub Check: build-deploy
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=other, trezor-user-env-unix)
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: EAS Update
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: transport-e2e-test
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: prepare_android_test_app
  • GitHub Check: build-web
  • GitHub Check: build
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: build-web
  • GitHub Check: test
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (18)
suite-native/module-onboarding/package.json (3)

16-16: New Dependency: @reduxjs/toolkit Added
The addition of @reduxjs/toolkit at version 1.9.5 supports the enhanced Redux-based state management required for the new onboarding functionality. Please ensure any newly created Redux slices or middleware conform to Toolkit best practices.


21-21: New Dependency: @trezor/connect Added
The inclusion of @trezor/connect (using the workspace version) aligns with the monorepo strategy and is expected to facilitate device connectivity features. Verify that its integration with the onboarding module works seamlessly with the rest of the system.


27-27: New Dependency: react-native-svg Added
Adding react-native-svg with version ^15.9.0 enables support for SVG rendering (e.g., the new HeaderUnderlineSvg component). Please check that this version integrates well within the existing React Native setup and that any required native linking or configuration is addressed as needed.

suite-native/device/src/types.ts (1)

3-9: LGTM! Well-defined type alias for setup-supporting devices.

The type definition is clear, explicit, and follows TypeScript best practices by using the Exclude utility type to define supported device models.

suite-native/device/src/index.ts (1)

15-15: LGTM! Export statement follows consistent pattern.

The export statement maintains consistency with other exports in the file.

suite-native/module-onboarding/src/navigation/OnboardingStackNavigator.tsx (1)

11-11: LGTM! Navigation changes follow consistent patterns.

The new screen is properly integrated into the navigation stack following React Navigation best practices.

Also applies to: 30-33

suite-native/device/src/utils.ts (1)

42-57: LGTM! Well-structured device support check.

The implementation is robust with:

  • Exhaustive pattern matching for device models
  • Clear separation between supported/unsupported models
  • Type safety using UnreachableCaseError
suite-native/navigation/src/routes.ts (1)

4-4: LGTM! Clean navigation route updates.

The changes maintain consistency in navigation structure and properly integrate the new uninitialized device flow.

Also applies to: 32-32

suite-native/app/src/navigation/RootStackNavigator.tsx (1)

44-44: LGTM! Consistent route name updates.

The changes maintain consistency with the route renaming in routes.ts.

Also applies to: 53-53

suite-native/module-onboarding/src/screens/UninitializedDeviceLandingScreen.tsx (3)

74-82: Implement navigation logic for TODO comments.

Both button handlers currently show toast messages instead of implementing navigation. Please implement the navigation logic for:

  1. Next onboarding screen based on firmware status
  2. Screen for tampered device information

85-86: Add close button handler.

The close button event handling is missing. Implement the close action to ensure proper navigation flow.


15-22: Validate image height calculation.

The image height calculation uses a fixed ratio of screen height. Consider:

  1. Testing with different screen sizes
  2. Ensuring the image remains visible with different system font sizes
  3. Validating the behavior when content overflows
suite-native/device/src/hooks/useHandleDeviceConnection.ts (1)

62-93: LGTM! Well-structured device initialization handling.

The new effect correctly handles uninitialized devices by checking multiple conditions before navigating to the onboarding screen. The conditions are comprehensive and include:

  • Device setup support check
  • Device initialization status
  • Device connection status
  • Onboarding completion status
  • Portfolio tracker check
  • Biometrics overlay visibility
suite-native/device/src/selectors.ts (1)

189-192: LGTM! Well-implemented memoized selector.

The new selector selectIsDeviceSetupSupported is correctly implemented using createMemoizedSelector for performance optimization. The null check on the model parameter is a good defensive programming practice.

suite-native/navigation/src/navigators.ts (1)

115-115: LGTM! Type-safe route addition.

The new route UninitializedDeviceLanding is correctly added to the OnboardingStackParamList with proper TypeScript type safety.

suite-native/device/src/hooks/useDetectDeviceError.tsx (2)

106-140: LGTM! Improved error handling for unsupported firmware.

The condition for showing the unsupported firmware alert now correctly considers device setup support, preventing unnecessary alerts for devices that support setup but have unsupported firmware.


142-205: LGTM! Enhanced uninitialized device handling.

The early return condition for uninitialized device alerts now includes isDeviceSetupSupported, ensuring that alerts are only shown for devices that don't support setup. This aligns with the PR's objective of improving the onboarding experience.

suite-native/module-onboarding/tsconfig.json (1)

9-9: LGTM! The dependency addition is appropriate.

Adding the reference to the connect package is necessary for the uninitialized device landing screen to interact with the device.

@PeKne PeKne force-pushed the feat/native/seedless-device-landing-screen branch from f79e01f to 6cb12b4 Compare February 3, 2025 11:02
Copy link
Contributor

@yanascz yanascz left a comment

Choose a reason for hiding this comment

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

I like! 👍

Copy link
Contributor

@vytick vytick left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments 🙏 . lgtm 🚀

@PeKne
Copy link
Contributor Author

PeKne commented Feb 3, 2025

/rebase

Copy link

github-actions bot commented Feb 3, 2025

@trezor-ci trezor-ci force-pushed the feat/native/seedless-device-landing-screen branch from 68cc994 to 4ac48a2 Compare February 3, 2025 13:35
Copy link

@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

🧹 Nitpick comments (2)
suite-native/device/src/utils.ts (1)

42-57: LGTM with a minor suggestion!

The implementation is well-structured with proper type safety and exhaustive pattern matching. The function clearly separates supported and unsupported device models for setup.

Consider enhancing the comment to better explain the business logic:

-    // Exhaustive check for case that new model is introduced later it won't be forgotten.
+    // Exhaustive check ensures handling of all device models, including future additions.
+    // Only T2B1, T3B1, and T3T1 models are currently supported for device setup.
suite-native/app/src/navigation/RootStackNavigator.tsx (1)

108-111: Document why gesture navigation is disabled for AuthorizeDeviceStack.

Consider adding a comment explaining why gestureEnabled: false is necessary for this specific stack. This helps other developers understand the security or UX implications.

 options={{
     ...stackNavigationOptionsConfig,
+    // Disable gesture navigation to prevent accidental exits during device authorization
     gestureEnabled: false,
 }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68cc994 and 4ac48a2.

⛔ Files ignored due to path filters (3)
  • suite-native/module-onboarding/src/assets/t3b1.png is excluded by !**/*.png
  • suite-native/module-onboarding/src/assets/t3t1.png is excluded by !**/*.png
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (16)
  • suite-native/app/src/navigation/RootStackNavigator.tsx (2 hunks)
  • suite-native/device/src/hooks/useDetectDeviceError.tsx (5 hunks)
  • suite-native/device/src/hooks/useHandleDeviceConnection.ts (6 hunks)
  • suite-native/device/src/index.ts (1 hunks)
  • suite-native/device/src/selectors.ts (2 hunks)
  • suite-native/device/src/types.ts (1 hunks)
  • suite-native/device/src/utils.ts (2 hunks)
  • suite-native/intl/src/en.ts (1 hunks)
  • suite-native/module-onboarding/package.json (1 hunks)
  • suite-native/module-onboarding/redux.d.ts (1 hunks)
  • suite-native/module-onboarding/src/components/HeaderUnderlineSvg.tsx (1 hunks)
  • suite-native/module-onboarding/src/navigation/OnboardingStackNavigator.tsx (2 hunks)
  • suite-native/module-onboarding/src/screens/UninitializedDeviceLandingScreen.tsx (1 hunks)
  • suite-native/module-onboarding/tsconfig.json (1 hunks)
  • suite-native/navigation/src/navigators.ts (2 hunks)
  • suite-native/navigation/src/routes.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (14)
  • suite-native/device/src/index.ts
  • suite-native/module-onboarding/tsconfig.json
  • suite-native/module-onboarding/redux.d.ts
  • suite-native/device/src/selectors.ts
  • suite-native/module-onboarding/src/navigation/OnboardingStackNavigator.tsx
  • suite-native/module-onboarding/src/components/HeaderUnderlineSvg.tsx
  • suite-native/device/src/types.ts
  • suite-native/module-onboarding/package.json
  • suite-native/navigation/src/navigators.ts
  • suite-native/device/src/hooks/useDetectDeviceError.tsx
  • suite-native/intl/src/en.ts
  • suite-native/navigation/src/routes.ts
  • suite-native/module-onboarding/src/screens/UninitializedDeviceLandingScreen.tsx
  • suite-native/device/src/hooks/useHandleDeviceConnection.ts
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: build-deploy
  • GitHub Check: build-deploy
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: EAS Update
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: transport-e2e-test
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: prepare_android_test_app
  • GitHub Check: build-web
  • GitHub Check: test
  • GitHub Check: build-web
  • GitHub Check: Analyze with CodeQL (javascript)
🔇 Additional comments (3)
suite-native/device/src/utils.ts (1)

5-5: LGTM!

The import of UnreachableCaseError follows the suggestion from the past review comments.

suite-native/app/src/navigation/RootStackNavigator.tsx (2)

44-44: LGTM! Route name change is consistent with the new navigation structure.

The renaming from Onboarding to OnboardingStack aligns with the new navigation hierarchy and the implementation of the uninitialized device landing screen.


83-84: LGTM! Well-structured navigation group with clear documentation.

Good organization of related navigation flows with consistent bottom slide animation. The comment clearly explains the purpose of this grouping.

@PeKne PeKne merged commit 131942f into develop Feb 3, 2025
78 checks passed
@PeKne PeKne deleted the feat/native/seedless-device-landing-screen branch February 3, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Suite Lite issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Onboarding - Unitialized Device Welcome Screen
4 participants