Skip to content

Conversation

wabicai
Copy link
Contributor

@wabicai wabicai commented Sep 28, 2025

Summary by CodeRabbit

  • New Features

    • Bootloader update can auto-download the latest binary when none is provided.
  • Improvements

    • Expo Playground preserves the original URL during redirects and restores it reliably on reload.
    • File picker UI simplified to a clearer vertical layout with optional descriptions.
    • WebUSB authorization copy and translations refined; added a common “Select” label.
    • Firmware reboot handling is more resilient to device reconnection issues.
  • Chores

    • Bumped packages and examples to 1.1.15-alpha.0.
    • Minor redirects cleanup.

Copy link
Contributor

coderabbitai bot commented Sep 28, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Removes the emmcFileWrite API and its types, refactors DeviceUpdateBootloader to use FirmwareUpdateBaseMethod with an EMMC update path, relaxes reboot error handling, updates SPA redirect restoration and 404 target, tweaks UI/i18n and firmware presets, changes default connect src, and bumps many package versions.

Changes

Cohort / File(s) Summary
Routing & SPA redirects
.github/templates/404.html, packages/connect-examples/expo-playground/app/entry.client.tsx, packages/connect-examples/expo-playground/public/_redirects
404 redirect target updated to /expo-playground/index.html. SPA restoration simplified to read spa_redirect_url, compare with current URL and call history.replaceState when differing; sessionStorage key cleared. Trailing whitespace trimmed in _redirects.
UI layout & i18n
packages/connect-examples/expo-playground/app/components/common/ParameterInput.tsx, packages/connect-examples/expo-playground/app/components/global/WebUsbAuthorizeDialog.tsx, packages/connect-examples/expo-playground/app/i18n/locales/en.ts
File picker layout moved to vertical with added description block. WebUSB dialog translation keys renamed under firmware.webusb.*. Added translation.common.select and new firmware webusb i18n entries.
Expo firmware presets/config
packages/connect-examples/expo-playground/app/data/methods/firmware.ts
Removed emmcFileWrite method config. Added deviceUpdateBootloader preset with optional .bin binary parameter and guidance.
Core API: emmcFileWrite removal
packages/core/src/api/EmmcFileWrite.ts, packages/core/src/api/index.ts, packages/core/src/inject.ts, packages/core/src/types/api/emmcFileWrite.ts, packages/core/src/types/api/export.ts, packages/core/src/types/api/index.ts
Deleted EmmcFileWrite implementation and removed all related exports, types, and CoreApi mapping entries.
Bootloader update & firmware base changes
packages/core/src/api/device/DeviceUpdateBootloader.ts, packages/core/src/api/firmware/FirmwareUpdateBaseMethod.ts
DeviceUpdateBootloader now extends FirmwareUpdateBaseMethod<any>. Adds updateBootloaderWithEmmcFileWrite path for bootloader-mode devices, consolidates binary fetch/validation, replaces legacy UI messages with FirmwareUpdateTipMessage, and wraps reboot to tolerate disconnect-related errors.
Shared constants
packages/connect-examples/shared-constants/constants.js
Default connect source URL updated to https://jssdk.onekey.so/1.1.15-alpha.0/ (still overridable via CONNECT_SRC).
Package version bumps
packages/*/package.json, packages/*/*/package.json (e.g., packages/core/package.json, packages/hd-*/*.package.json, packages/connect-examples/*/package.json, ...)
Bumped package versions from 1.1.141.1.15-alpha.0 across core, transports, SDKs, examples and updated internal dependency pins accordingly.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App
  participant DeviceUpdate as DeviceUpdateBootloader
  participant Base as FirmwareUpdateBaseMethod
  participant Device

  App->>DeviceUpdate: deviceUpdateBootloader({ binary? })
  DeviceUpdate->>DeviceUpdate: if no binary -> fetch resource
  DeviceUpdate->>Device: get features
  alt features.bootloader_mode == true
    DeviceUpdate->>App: Tip(StartTransferData)
    DeviceUpdate->>Device: emmcCommonUpdateProcess(binary)
    DeviceUpdate->>App: Tip(ConfirmOnDevice)
    DeviceUpdate->>Base: reboot(normal)
    Note right of Base: reboot errors from disconnect may be caught and treated as success
    DeviceUpdate-->>App: UpdateBootloaderSuccess
  else
    DeviceUpdate->>Device: updateBootloader(binary) (non-emmc path)
    DeviceUpdate->>Base: reboot(normal)
    DeviceUpdate-->>App: UpdateBootloaderSuccess
  end
Loading
sequenceDiagram
  autonumber
  participant Browser
  participant Entry as entry.client.tsx

  Browser->>Entry: page load
  Entry->>Entry: read sessionStorage.spa_redirect_url
  alt redirectUrl exists and != current location
    Entry->>Browser: history.replaceState(..., redirectUrl)
    Entry->>Entry: remove spa_redirect_url
  else
    Entry-->>Browser: no redirect
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title has a typo in “suppoort” and uses awkward phrasing that obscures the main change of enabling deviceUpdateBootloader to use emmcFileWrite, so it does not clearly summarize the primary fix. Correct the spelling and reword for clarity, for example: “fix: enable deviceUpdateBootloader to use emmcFileWrite.”
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 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 dcf55c0 and f8343da.

📒 Files selected for processing (1)
  • packages/connect-examples/shared-constants/constants.js (1 hunks)

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

@revan-zhang
Copy link
Contributor

revan-zhang commented Sep 28, 2025

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

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@wabicai wabicai requested review from originalix and ByteZhang1024 and removed request for originalix September 28, 2025 07:49
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: 5

Caution

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

⚠️ Outside diff range comments (2)
packages/core/src/api/device/DeviceUpdateBootloader.ts (2)

64-79: Make routing robust when bootloader_mode is undefined

If features.bootloader_mode is undefined, the function falls through without returning. Default to the normal path.

Apply:

-    // Check if device is in bootloader mode
-    if (features && features.bootloader_mode) {
+    // Route by mode (default to normal path)
+    if (features?.bootloader_mode) {
       // Use emmcFileWrite + reboot logic for bootloader mode
       this.postTipMessage(FirmwareUpdateTipMessage.UpdateBootloader);
-      return this.updateBootloaderWithEmmcFileWrite(device, binary);
+      return this.updateBootloaderWithEmmcFileWrite(binary);
     }
 
-    if (features && !features.bootloader_mode) {
+    {
       // Use original updateBootloader logic for normal mode
       await updateBootloader(
         this.device.getCommands().typedCall.bind(this.device.getCommands()),
         this.postMessage,
         device,
         binary
       );
-      return Promise.resolve(true);
+      return true;
     }

78-79: Nit: avoid Promise.resolve for static values

Return the boolean directly. It’s clearer.

Apply:

-      return Promise.resolve(true);
+      return true;
📜 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 ea0fc2d and dcf55c0.

📒 Files selected for processing (31)
  • .github/templates/404.html (1 hunks)
  • packages/connect-examples/electron-example/package.json (2 hunks)
  • packages/connect-examples/expo-example/package.json (2 hunks)
  • packages/connect-examples/expo-playground/app/components/common/ParameterInput.tsx (1 hunks)
  • packages/connect-examples/expo-playground/app/components/global/WebUsbAuthorizeDialog.tsx (4 hunks)
  • packages/connect-examples/expo-playground/app/data/methods/firmware.ts (1 hunks)
  • packages/connect-examples/expo-playground/app/entry.client.tsx (1 hunks)
  • packages/connect-examples/expo-playground/app/i18n/locales/en.ts (2 hunks)
  • packages/connect-examples/expo-playground/package.json (2 hunks)
  • packages/connect-examples/expo-playground/public/_redirects (1 hunks)
  • packages/connect-examples/shared-constants/constants.js (1 hunks)
  • packages/core/package.json (2 hunks)
  • packages/core/src/api/EmmcFileWrite.ts (0 hunks)
  • packages/core/src/api/device/DeviceUpdateBootloader.ts (1 hunks)
  • packages/core/src/api/firmware/FirmwareUpdateBaseMethod.ts (1 hunks)
  • packages/core/src/api/index.ts (0 hunks)
  • packages/core/src/inject.ts (0 hunks)
  • packages/core/src/types/api/emmcFileWrite.ts (0 hunks)
  • packages/core/src/types/api/export.ts (0 hunks)
  • packages/core/src/types/api/index.ts (0 hunks)
  • packages/hd-ble-sdk/package.json (2 hunks)
  • packages/hd-common-connect-sdk/package.json (2 hunks)
  • packages/hd-transport-electron/package.json (2 hunks)
  • packages/hd-transport-emulator/package.json (2 hunks)
  • packages/hd-transport-http/package.json (2 hunks)
  • packages/hd-transport-lowlevel/package.json (2 hunks)
  • packages/hd-transport-react-native/package.json (2 hunks)
  • packages/hd-transport-web-device/package.json (2 hunks)
  • packages/hd-transport/package.json (1 hunks)
  • packages/hd-web-sdk/package.json (2 hunks)
  • packages/shared/package.json (1 hunks)
💤 Files with no reviewable changes (6)
  • packages/core/src/api/index.ts
  • packages/core/src/types/api/export.ts
  • packages/core/src/types/api/index.ts
  • packages/core/src/inject.ts
  • packages/core/src/types/api/emmcFileWrite.ts
  • packages/core/src/api/EmmcFileWrite.ts
⏰ 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: Socket Security: Pull Request Alerts
  • GitHub Check: lint (22)
  • GitHub Check: build (22)
🔇 Additional comments (9)
packages/connect-examples/electron-example/package.json (1)

5-26: Version alignment looks good.

The example app version and the electron transport dependency stay in lockstep with the alpha release train. Ship it.

packages/hd-transport-http/package.json (1)

3-28: HTTP transport bump synced correctly.

The package version and its shared/transport deps all point to 1.1.15-alpha.0, so consumers won’t hit mixed builds.

packages/connect-examples/expo-playground/app/i18n/locales/en.ts (2)

69-69: New common copy is fine.

Adding common.select matches existing phrasing and keeps the namespace consistent.


599-612: WebUSB authorize strings read clean.

The new firmware namespace mirrors the dialog content and keeps the guidance crisp.

packages/hd-transport-react-native/package.json (1)

3-24: React Native transport stays in sync.

Version and internal deps now target 1.1.15-alpha.0, so the BLE stack pulls the right bits.

packages/hd-transport/package.json (1)

3-3: Core transport version bump looks solid.

No other manifest shifts, just the alpha tag—exactly what we need for the prerelease.

packages/connect-examples/expo-playground/app/entry.client.tsx (1)

42-56: Nice SPA restore flow.

Replacing the history entry before we mount keeps the router in sync with the intended deep link. Clean and effective.

packages/core/src/api/device/DeviceUpdateBootloader.ts (1)

16-16: Good move: unify on FirmwareUpdateBaseMethod

Extending FirmwareUpdateBaseMethod centralizes EMMC write, progress, and reboot handling. Cleaner surface.

packages/core/src/api/firmware/FirmwareUpdateBaseMethod.ts (1)

412-430: Safe to broaden reboot disconnect handling. Search shows only one call in DeviceUpdateBootloader.ts, and it ignores reboot’s return value—merging the proposed diff won’t break existing usage.

@wabicai wabicai requested a review from originalix September 28, 2025 07:56
@wabicai wabicai merged commit 245ea17 into onekey Sep 28, 2025
8 of 9 checks passed
@wabicai wabicai deleted the fix/bootloader-update branch September 28, 2025 08: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.

3 participants