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

17301 welcome screen improvements #17573

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

vojtatranta
Copy link
Contributor

@vojtatranta vojtatranta commented Mar 11, 2025

Description

Related Issue

Addresses: #17301

I addressed issues outlined in the ticket except these: I didn't address (1) and (2) and (5) in this PR: #17573

Screenshots:

Copy link

github-actions bot commented Mar 11, 2025

🚀 Expo preview is ready!

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

Learn more about 𝝠 Expo Github Action

@vojtatranta
Copy link
Contributor Author

/rebase

Copy link

@trezor-ci trezor-ci force-pushed the 17301-welcome-screen-improvements branch from 246fac1 to 7612068 Compare March 11, 2025 15:05
@vojtatranta vojtatranta marked this pull request as ready for review March 11, 2025 15:10
Copy link

coderabbitai bot commented Mar 11, 2025

Walkthrough

The changes introduce a new utility function, isDevicePerceivedAsNew, which evaluates if a device is in a "new" state by checking its status. This function is added to the shared utilities and then imported into various UI components where device status impacts interaction. In the messages module, two new message entries are added to provide tooltip text indicating that functionalities are unavailable during device setup. Both the "EnableViewOnly" and "Labeling" components are updated to use the new device state check, affecting the disabled state and dynamic tooltip content on relevant UI elements. The modifications extend existing logic without altering previous behaviors, ensuring that tooltips and action states properly reflect the device’s setup status.

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7612068 and 0dde8fd.

📒 Files selected for processing (4)
  • packages/suite/src/support/messages.ts (2 hunks)
  • packages/suite/src/views/settings/SettingsGeneral/EnableViewOnly.tsx (3 hunks)
  • packages/suite/src/views/settings/SettingsGeneral/Labeling.tsx (3 hunks)
  • suite-common/suite-utils/src/device.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/suite/src/support/messages.ts
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: run-e2e-suite-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-e2e-suite-desktop-tests (@group=other, trezor-user-env-unix)
  • GitHub Check: run-e2e-suite-desktop-tests (@group=passphrase, trezor-user-env-unix)
  • GitHub Check: run-e2e-suite-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-e2e-suite-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: run-e2e-suite-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: EAS Update
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: prepare_android_test_app
  • GitHub Check: build-web
  • GitHub Check: Analyze with CodeQL (javascript)
🔇 Additional comments (6)
suite-common/suite-utils/src/device.ts (1)

73-81: Well implemented utility function for device state detection.

The new isDevicePerceivedAsNew function provides a clear way to detect if a device is in setup/initialization state by checking for 'bootloader' or 'initialize' status. The implementation correctly handles null/undefined devices and uses the existing getStatus function appropriately.

packages/suite/src/views/settings/SettingsGeneral/EnableViewOnly.tsx (2)

1-1: LGTM - Good import and variable naming.

The import and variable naming clearly express the intent of the new functionality.

Also applies to: 27-27


39-45:

❓ Verification inconclusive

Verify tooltip message rendering.

The functionality of disabling the button when a device is newly connected looks correct. However, the tooltip content is using string IDs rather than Translation components. Make sure the ActionButton component properly handles these string IDs and renders them as expected.


🏁 Script executed:

#!/bin/bash
# Check if ActionButton processes string IDs for tooltipContent
rg -A 10 "tooltipContent" --glob "*.tsx" | grep -A 5 -B 5 "TR_"

Length of output: 24363


ActionButton Tooltip Translation Verification

Please double-check that the tooltip texts in EnableViewOnly.tsx render as intended. In this file, the tooltipContent is provided as a string ID (either 'TR_SETTINGS_DEVICE_VIEW_ONLY_DISABLED_TOOLTIP' or 'TR_SETTINGS_DEVICE_BANNER_TITLE_REMEMBERED') rather than being wrapped in a <Translation> component. Notably, other parts of the codebase (e.g., in WipeDevice.tsx and similar files) pass the translation element instead. Confirm that the ActionButton component correctly interprets and translates string IDs for its tooltip content. If it doesn’t, consider aligning this file’s implementation with the pattern used elsewhere (i.e., wrapping the ID with <Translation>).

packages/suite/src/views/settings/SettingsGeneral/Labeling.tsx (3)

1-1: LGTM - Device state integration for disabling functionality.

The import and newly connected device check are well integrated into the existing disabled conditions.

Also applies to: 45-50


52-62: Good separation of concerns for tooltip content.

The getTooltipContent function nicely handles different states and returns appropriate content based on the device state.


77-82: Verify tooltip visibility during discovery process.

The current implementation hides the tooltip during discovery process even if the component is disabled for other reasons (locked device, abnormal mode, etc.). Make sure this is the intended behavior.

Consider this alternative that would show tooltips during discovery for other disabled states:

-isActive={isDisabled && !isDiscoveryRunning}
+isActive={isDisabled}

The tooltip content would still be null during discovery due to the getTooltipContent function's logic.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
  • @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.

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 (1)
packages/suite/src/views/settings/SettingsGeneral/EnableViewOnly.tsx (1)

1-2: Consider using the same utility function as Labeling.tsx.

You're importing getStatus here, but in Labeling.tsx you're using isDevicePerceivedAsNew. For consistency and maintainability, consider using the same utility function across both files.

-import { getStatus } from '@suite-common/suite-utils';
+import { isDevicePerceivedAsNew } from '@suite-common/suite-utils';

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5646719 and 7612068.

📒 Files selected for processing (7)
  • packages/suite-data/files/translations/cs.json (1 hunks)
  • packages/suite/src/support/messages.ts (1 hunks)
  • packages/suite/src/views/settings/SettingsGeneral/EnableViewOnly.tsx (3 hunks)
  • packages/suite/src/support/messages.ts (1 hunks)
  • packages/suite/src/views/settings/SettingsGeneral/EnableViewOnly.tsx (2 hunks)
  • packages/suite/src/views/settings/SettingsGeneral/Labeling.tsx (3 hunks)
  • suite-common/suite-utils/src/device.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: run_android_e2e_tests
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: Analyze with CodeQL (javascript)
🔇 Additional comments (9)
packages/suite-data/files/translations/cs.json (1)

1580-1580: New translation entry for view-only mode tooltip added

The new entry
"TR_SETTINGS_DEVICE_VIEW_ONLY_DISABLED_TOOLTIP": "Nedostupné, pokud se zařízení teprve nastavuje."
clearly communicates that the view-only mode is unavailable during device setup. The phrasing is concise and consistent with similar tooltip messages in the file.

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

73-81: Well-designed utility function that encapsulates device status checks

The isDevicePerceivedAsNew function is a well-structured addition that properly encapsulates the logic for determining if a device should be considered "new" based on its status. It handles null/undefined inputs appropriately and reuses the existing getStatus function, following the coding patterns established in other utility functions within this file.

This abstraction will help maintain consistency across the codebase by providing a single source of truth for this check, reducing duplication in components that need to determine if a device is in a new/setup state.

packages/suite/src/support/messages.ts (1)

5898-5901: New tooltip message for device setup state approved.

This new translation entry provides a clear message for users when certain features are disabled during device initialization. The message is concise and follows the same pattern as other tooltip messages in the file.

packages/suite/src/views/settings/SettingsGeneral/Labeling.tsx (4)

1-1: Well-organized import of utility function.

Good job adding the import for isDevicePerceivedAsNew. This separation of concerns makes the code more maintainable by centralizing device status logic in a common utility.


45-50: Clean implementation of device status check.

Good refactoring to use the utility function isDevicePerceivedAsNew instead of directly checking device status in the component. This change improves maintainability by centralizing the logic for determining if a device is new.

The isDisabled conditions are now more comprehensive and properly handle the case of a newly connected device.


52-62: Well-structured tooltip content function.

The new getTooltipContent function is a good addition that provides clear, contextual feedback to users based on the device state. The conditional logic is easy to follow and maintains good separation of concerns.


77-82: Improved tooltip behavior.

The updated tooltip configuration with conditional activation and dynamic content improves the user experience by providing relevant guidance based on the current state of the device and discovery process.

packages/suite/src/views/settings/SettingsGeneral/EnableViewOnly.tsx (2)

40-48: Improved button state handling and feedback.

The updates to the button state and tooltip content provide better user feedback based on device status. This is a good improvement to the user experience.

However, as mentioned above, consider using the isDevicePerceivedAsNew utility function for consistency with other files.


27-28: 🛠️ Refactor suggestion

Use shared utility for device status check.

Currently, you're manually checking for specific device statuses, while the Labeling.tsx file uses the isDevicePerceivedAsNew utility function. For consistency and to avoid duplication of logic, consider using the same utility across both files.

-const deviceStatus = device && getStatus(device);
-const newlyConnectedDevice = deviceStatus === 'bootloader' || deviceStatus === 'initialize';
+const newlyConnectedDevice = isDevicePerceivedAsNew(device);

Likely an incorrect or invalid review comment.

@vojtatranta vojtatranta force-pushed the 17301-welcome-screen-improvements branch from 7612068 to 0dde8fd Compare March 13, 2025 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🤝 Needs QA
Development

Successfully merging this pull request may close these issues.

2 participants