Skip to content

Conversation

@wabicai
Copy link
Member

@wabicai wabicai commented Nov 26, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Refined Web USB connection and retry behavior; updated device discovery failure handling and permission prompting.
  • Chores

    • Bumped package versions to 1.1.19-alpha.3 across core, transports, SDKs, examples, and shared modules.

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

@revan-zhang
Copy link
Contributor

revan-zhang commented Nov 26, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 26, 2025

Walkthrough

Release version bumps from 1.1.19-alpha.2 → 1.1.19-alpha.3 across many packages. Core WebUSB handling changed: initDevice no longer prompts and now throws on missing WebUSB device; ensureConnected removes WebUSB error from generic retries and prompts only after max retries, then rejects with WebDeviceNotFoundOrNeedsPermission or DeviceNotFound.

Changes

Cohort / File(s) Change Summary
Connect Examples
packages/connect-examples/electron-example/package.json, packages/connect-examples/expo-example/package.json, packages/connect-examples/expo-playground/package.json
Updated package version and bumped @onekeyfe/* dependency versions from 1.1.19-alpha.21.1.19-alpha.3.
Core & Shared
packages/core/package.json, packages/shared/package.json
Bumped package version to 1.1.19-alpha.3; updated hd-shared and hd-transport dependency pins in core.
Core logic
packages/core/src/core/index.ts
WebUSB behavior refactor: initDevice no longer posts prompt and throws when no device; ensureConnected stops treating WebUSB error as retryable, tracks WebUSB retry state, and only posts prompt and rejects with WebDeviceNotFoundOrNeedsPermission after max retries (otherwise rejects DeviceNotFound).
Transport Packages
packages/hd-transport/package.json, packages/hd-transport-emulator/package.json, packages/hd-transport-electron/package.json, packages/hd-transport-http/package.json, packages/hd-transport-lowlevel/package.json, packages/hd-transport-react-native/package.json, packages/hd-transport-web-device/package.json
Bumped package version and updated transport-related @onekeyfe/* dependencies from 1.1.19-alpha.21.1.19-alpha.3.
SDK Packages
packages/hd-ble-sdk/package.json, packages/hd-common-connect-sdk/package.json, packages/hd-web-sdk/package.json
Bumped package version and updated upstream @onekeyfe/* dependencies to 1.1.19-alpha.3.

Sequence Diagram

sequenceDiagram
    participant App
    participant ensureConnected
    participant initDevice
    participant Device
    participant PermissionPrompt
    participant ErrorHandler

    rect rgb(245,250,255)
    note right of ensureConnected: WebUSB-specific retry state tracked\n(prompt only after max retries)
    end

    App->>ensureConnected: start connection
    ensureConnected->>initDevice: init device (no immediate prompt for WebUSB)
    initDevice->>ensureConnected: throw if WebUSB device missing

    loop retry attempts
        ensureConnected->>Device: attempt connect
        alt Device returns WebUSB-not-found
            Device-->>ensureConnected: WebDeviceNotFoundOrNeedsPermission
            ensureConnected->>ensureConnected: mark WebUSB retry state
        else Other error
            Device-->>ensureConnected: other error
        end
    end

    alt WebUSB retry state at max attempts
        ensureConnected->>PermissionPrompt: optionally post WEB_DEVICE_PROMPT_ACCESS_PERMISSION
        PermissionPrompt-->>ensureConnected: response
        ensureConnected->>ErrorHandler: reject WebDeviceNotFoundOrNeedsPermission
    else other error at max attempts
        ensureConnected->>ErrorHandler: reject DeviceNotFound
    end

    ErrorHandler-->>App: final error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review focus:
    • packages/core/src/core/index.ts — verify initDevice changes, retry logic, WebUSB state transitions, and prompt emission timing.
    • A sample of updated package.json files across transport and SDK packages to confirm consistent version/dependency bumps.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The PR title mentions web-usb retry but doesn't accurately reflect the main changes—version bumps from alpha.2 to alpha.3 across 14 packages dominate the changeset, with only minor code logic updates in core/src/core/index.ts. Clarify the title to emphasize the release version bump (e.g., 'release: v1.1.19-alpha.3' or 'chore: bump version to 1.1.19-alpha.3'). If web-usb retry is the key feature, restructure the title to prioritize that intent.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/web-usb-retry

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 66a9be7 and 3d0c117.

📒 Files selected for processing (1)
  • packages/core/src/core/index.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build (22)
  • GitHub Check: lint (22)

Comment @coderabbitai help to get the list of available commands and usage tips.

@wabicai wabicai requested a review from originalix November 26, 2025 12:43
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: 1

♻️ Duplicate comments (1)
packages/core/src/core/index.ts (1)

814-817: Remove the assignment to unused variable.

Line 816 sets isWebUsbRetrying = true, but this variable is never read. The retry logic works correctly without it—you check DataManager.isWebUsbConnect(env) at line 849 instead.

Remove the assignment:

         if (error.errorCode === HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission) {
-          // WebUSB device not found or needs permission, mark and continue retrying (consistent with Bridge behavior)
-          isWebUsbRetrying = true;
+          // WebUSB device not found or needs permission, continue retrying (consistent with Bridge behavior)
         } else if (
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9170294 and 100af92.

📒 Files selected for processing (1)
  • packages/core/src/core/index.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint (22)
  • GitHub Check: build (22)
🔇 Additional comments (1)
packages/core/src/core/index.ts (1)

848-856: Logic looks good.

The WebUSB retry flow is correct: retry up to 5 times, then show the permission prompt only for WebUSB connections. This aligns with the PR objective.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 100af92 and 66a9be7.

📒 Files selected for processing (1)
  • packages/core/src/core/index.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/core/src/core/index.ts (5)
packages/core/src/utils/logger.ts (1)
  • error (50-57)
packages/shared/src/HardwareError.ts (1)
  • HardwareErrorCode (77-476)
packages/core/src/data-manager/DataManager.ts (1)
  • DataManager (60-459)
packages/core/src/events/ui-request.ts (2)
  • createUiMessage (200-205)
  • UI_REQUEST (8-48)
packages/core/src/constants/ui-request.ts (1)
  • UI_REQUEST (3-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: lint (22)
  • GitHub Check: build (22)
  • GitHub Check: Analyze (javascript-typescript)

@wabicai wabicai enabled auto-merge (squash) November 27, 2025 01:58
@wabicai wabicai merged commit f0e4826 into onekey Nov 27, 2025
7 of 9 checks passed
@wabicai wabicai deleted the feat/web-usb-retry branch November 27, 2025 01:58
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.

4 participants