Skip to content

Conversation

@wabicai
Copy link
Contributor

@wabicai wabicai commented Nov 6, 2025

Summary by CodeRabbit

  • New Features

    • Bootloader permission prompts and bootloader-ready status during firmware flows.
    • Reconnect device UI and explicit Connect Device button with loading state.
    • Auto-detect USB device connections to trigger device searches.
  • UI

    • Simplified device search/connect experience with clearer WebUSB guidance.
    • Cleaned local firmware description to use a single localized message.
  • Chores

    • Updated hardware SDK/dependency versions.

@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Walkthrough

Adds bootloader permission and reconnect UX, moves WebUSB connect orchestration into Dashboard, swaps the hardware SDK to a common connect SDK with env: 'webusb', removes bridge release mapping/state, updates runtime flags (isUpdating, needsBootloaderPermission), and treats .cjs as non-asset in webpack; bumps related packages to 1.1.16.

Changes

Cohort / File(s) Summary
Build & Dependencies
config/webpack.config.js, package.json
Treat .cjs as JS (exclude from asset/resource). Bump OneKey packages to 1.1.16 and add [email protected]. Minor resolutions formatting fixes.
Hardware SDK & Instance
src/hardware/instance.ts, src/hardware/index.ts
Replace HardwareSDK with HardwareCommonSdk, set env: 'webusb', update connectSrc to 1.1.16; add promptBootloaderDeviceAccess(); remove checkBridgeStatus() and bridge-release map logic; wire setNeedsBootloaderPermission.
Runtime State
src/store/reducers/runtime.ts
Remove bridgeVersion / bridgeReleaseMap and their reducers; add isUpdating and needsBootloaderPermission plus setIsUpdating and setNeedsBootloaderPermission; simplify pageStatus union.
Search & Dashboard UI
src/components/SearchDevice/index.tsx, src/views/Dashboard.tsx
Make SearchDevice a prop-driven FC (onConnectDevice, isConnecting); move WebUSB prompt/connect logic into Dashboard (handleConnectDevice), add USB connect listener, and narrow pageStatus conditions.
Firmware UI
src/components/Firmware/Firmware.tsx, src/components/Firmware/V3UploadLocalFirmware.tsx
Add BootloaderPermissionPrompt, BootloaderStatusAlert, and ReconnectDevice; gate device alerts on bootloader permission; remove bridge-release modal/logic; adjust local firmware description text.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Dashboard
    participant SearchDevice
    participant ServiceHardware
    participant HardwareCommonSdk

    rect rgb(230,245,255)
    Note over Dashboard,ServiceHardware: User-initiated connect (WebUSB)
    end

    User->>Dashboard: opens app / requests device
    Dashboard->>ServiceHardware: searchDevices()
    ServiceHardware->>HardwareCommonSdk: query authorized devices
    HardwareCommonSdk-->>ServiceHardware: no device
    ServiceHardware-->>Dashboard: result empty
    Dashboard->>SearchDevice: render with onConnectDevice
    User->>SearchDevice: click Connect
    SearchDevice->>Dashboard: onConnectDevice()
    Dashboard->>ServiceHardware: promptBootloaderDeviceAccess()
    ServiceHardware->>HardwareCommonSdk: request WebUSB permission
    HardwareCommonSdk->>User: browser permission prompt
    User-->>HardwareCommonSdk: grant access
    HardwareCommonSdk-->>ServiceHardware: device selected
    ServiceHardware-->>Dashboard: device available
    Dashboard->>Dashboard: set pageStatus = connected
Loading
sequenceDiagram
    participant Firmware
    participant BootloaderPrompt
    participant ServiceHardware
    participant User

    rect rgb(245,235,255)
    Note over Firmware,ServiceHardware: Bootloader permission flow
    end

    Firmware->>BootloaderPrompt: show authorize UI
    User->>BootloaderPrompt: click Authorize
    BootloaderPrompt->>ServiceHardware: promptBootloaderDeviceAccess()
    ServiceHardware->>User: browser permission prompt
    User-->>ServiceHardware: grant/deny
    alt granted
        ServiceHardware-->>BootloaderPrompt: success
        BootloaderPrompt-->>Firmware: permission granted
    else denied
        ServiceHardware-->>BootloaderPrompt: error
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Pay extra attention to:
    • src/hardware/* — SDK swap, promptBootloaderDeviceAccess() behavior, and removed bridge mapping.
    • src/store/reducers/runtime.ts — state shape changes and action exports.
    • src/views/Dashboard.tsx — WebUSB connect flow, concurrency guards, and USB event listener.
    • src/components/SearchDevice/index.tsx and src/components/Firmware/Firmware.tsx — new props, conditional rendering, and bootloader permission UI.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
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.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: migrating to Web USB and upgrading SDK packages to version 1.1.16, which aligns with the core modifications across webpack config, dependencies, hardware layer, and component updates.
✨ 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/webusb

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

@revan-zhang
Copy link
Contributor

revan-zhang commented Nov 6, 2025

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

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

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

@socket-security
Copy link

socket-security bot commented Nov 6, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​onekeyfe/​hd-shared@​1.1.15 ⏵ 1.1.16831007397 +1100
Added@​onekeyfe/​hd-common-connect-sdk@​1.1.16781008297100
Updated@​onekeyfe/​hd-core@​1.1.15 ⏵ 1.1.168610086 +197 +1100

View full report

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

Caution

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

⚠️ Outside diff range comments (1)
src/views/Dashboard.tsx (1)

74-78: Restore the connect affordance after a failed scan.

When the 30 s timeout fires we flip pageStatus to 'search-timeout' but never call setNeedUserAction(true). After a user authorizes a device but the scan still returns nothing, the connect button stays hidden, so they cannot trigger WebUSB again. Add the reset inside the timeout (and any similar failure paths) so the button comes back.

     setTimeout(() => {
       if (serviceHardware.isSearch) {
         dispatch(setPageStatus('search-timeout'));
+        setNeedUserAction(true);
       }
     }, 30000);
📜 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 7882efd and ce9b686.

⛔ Files ignored due to path filters (3)
  • src/locales/en-US.json is excluded by !src/locales/*.json
  • src/locales/zh-CN.json is excluded by !src/locales/*.json
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • config/webpack.config.js (1 hunks)
  • package.json (2 hunks)
  • src/components/Firmware/Firmware.tsx (7 hunks)
  • src/components/Firmware/V3UploadLocalFirmware.tsx (1 hunks)
  • src/components/SearchDevice/index.tsx (1 hunks)
  • src/hardware/index.ts (4 hunks)
  • src/hardware/instance.ts (2 hunks)
  • src/store/reducers/runtime.ts (4 hunks)
  • src/views/Dashboard.tsx (6 hunks)
🧰 Additional context used
🪛 ESLint
src/components/Firmware/V3UploadLocalFirmware.tsx

[error] 134-135: Delete ······⏎

(prettier/prettier)

src/components/SearchDevice/index.tsx

[error] 30-80: Fragments should contain more than one child - otherwise, there’s no need for a Fragment at all.

(react/jsx-no-useless-fragment)


[error] 31-32: Delete ⏎··········

(prettier/prettier)


[error] 79-80: Delete ··⏎········

(prettier/prettier)


[error] 87-87: Delete ··········

(prettier/prettier)


[error] 93-94: Delete ⏎················

(prettier/prettier)

🔇 Additional comments (3)
config/webpack.config.js (1)

564-569: LGTM! Correct handling of CommonJS modules.

The .cjs extension is now excluded from asset processing, ensuring CommonJS modules are handled by code loaders instead. This aligns with the new hd-common-connect-sdk dependency.

package.json (2)

188-190: LGTM! Formatting fixes applied.

Spacing in resolutions is now consistent.


12-14: All SDK packages verified. No issues found.

✓ Package versions 1.1.16 exist on npm
✓ No security vulnerabilities detected
✓ Old hd-web-sdk completely removed from codebase and dependencies

The migration to the new packages is clean and secure.

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

📜 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 ce9b686 and 94f4898.

📒 Files selected for processing (2)
  • src/components/Firmware/V3UploadLocalFirmware.tsx (0 hunks)
  • src/components/SearchDevice/index.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • src/components/Firmware/V3UploadLocalFirmware.tsx
⏰ 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: test-web
  • GitHub Check: release-web
🔇 Additional comments (1)
src/components/SearchDevice/index.tsx (1)

1-11: Clean refactoring to a prop-driven component.

The interface and imports are well-structured. Moving from internal state and dispatch to props makes this component more reusable and easier to test.

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

♻️ Duplicate comments (3)
src/components/SearchDevice/index.tsx (3)

44-45: Redundant disabled prop.

Past review flagged this: if the Button component auto-disables when loading is true, the explicit disabled={isConnecting} is redundant. Keep it only if the library doesn't guarantee auto-disable behavior.


88-89: Missing space between messages.

Past review flagged this: two messages run together without spacing. They'll render as "Text one.Text two" if the first ends with punctuation.

Add spacing between them:

-          <p className="text-sm font-normal text-gray-500">
-            {intl.formatMessage({ id: 'TR_MAKE_SURE_IT_IS_WELL_CONNECTED' })}
-            {intl.formatMessage({ id: 'TR_SEARCHING_FOR_YOUR_DEVICE' })}
-          </p>
+          <p className="text-sm font-normal text-gray-500">
+            {intl.formatMessage({ id: 'TR_MAKE_SURE_IT_IS_WELL_CONNECTED' })}{' '}
+            {intl.formatMessage({ id: 'TR_SEARCHING_FOR_YOUR_DEVICE' })}
+          </p>

94-122: Prefer logical AND over ternary.

Past review suggested this: condition ? (...) : null works but condition && (...) is more idiomatic for conditional rendering in React.

Replace the ternary:

-          {pageStatus === 'search-timeout' ? (
+          {pageStatus === 'search-timeout' && (
             <>
               <p className="text-sm font-normal text-gray-500">
                 {intl.formatMessage({ id: 'TR_SEARCHING_TAKES_TOO_LONG' })}
               </p>
               {/* ... rest of timeout block ... */}
             </>
-          ) : null}
+          )}
📜 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 94f4898 and 9e745b8.

⛔ Files ignored due to path filters (3)
  • public/static/onekey.png is excluded by !**/*.png
  • src/locales/en-US.json is excluded by !src/locales/*.json
  • src/locales/zh-CN.json is excluded by !src/locales/*.json
📒 Files selected for processing (2)
  • src/components/Firmware/V3UploadLocalFirmware.tsx (1 hunks)
  • src/components/SearchDevice/index.tsx (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: test-web
  • GitHub Check: release-web
🔇 Additional comments (3)
src/components/SearchDevice/index.tsx (3)

1-1: Clean typing and interface.

The FC import and SearchDeviceProps interface are well-defined. Optional props allow flexible usage across different flows.

Also applies to: 8-11


13-21: Simplified component structure.

The component now takes explicit props and limits Redux usage to only pageStatus. Clean and maintainable.


29-43: Strong WebUSB onboarding flow.

The pulsing background, prominent connect button, and clear messaging guide users through WebUSB permission. Great UX improvement.

Also applies to: 46-83

@wabicai wabicai requested a review from originalix November 6, 2025 07:29
@wabicai wabicai merged commit e19cfd4 into main Nov 8, 2025
12 checks passed
@wabicai wabicai deleted the feat/webusb branch November 8, 2025 15:02
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