Skip to content

Conversation

ByteZhang1024
Copy link
Contributor

@ByteZhang1024 ByteZhang1024 commented Aug 26, 2025

Summary by CodeRabbit

  • New Features

    • Added support for uploading blur data alongside the main file and thumbnail.
    • Enhanced, unified progress tracking across all upload parts (total and per-file progress).
    • Completion behavior updated to keep the window open after uploads finish.
  • Chores

    • Updated firmware dependency to a newer revision.

Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Walkthrough

Adds support for a third upload stream (blur) alongside data and thumbnail. Updates message schema, types, and device upload flow to include BlurRequest and blur_data_length. Implements chunk selection per request type, unified progress tracking, and removes a UI close message. Updates firmware submodule reference.

Changes

Cohort / File(s) Summary
Device upload flow
packages/core/src/api/device/DeviceUploadResource.ts
Extends upload to handle blur data stream; adds blurDataHex handling and length; updates processResourceRequest to support BlurRequest; introduces shared chunking helper and progress tracking; removes UI close postMessage.
Core API types
packages/core/src/types/api/deviceUploadResource.ts
Adds required blurDataHex: string to DeviceUploadResourceParams.
Message schema
packages/core/src/data/messages/messages.json
Adds blur_data_length to ResourceUpload; introduces BlurRequest message; adds MessageType_BlurRequest enum mapping.
Transport types
packages/hd-transport/src/types/messages.ts
Exports new BlurRequest type; augments ResourceUpload with optional blur_data_length; updates MessageType mapping to include BlurRequest.
Firmware submodule
submodules/firmware
Updates submodule commit reference to fcb847d….

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as Host App
  participant Core as DeviceUploadResource
  participant Dev as Device (Firmware)

  App->>Core: start ResourceUpload(data, thumbnail, blur, meta)
  Core->>Dev: ResourceUpload{... lengths incl. blur_data_length}
  Dev-->>Core: ResourceAck | Error

  alt Ack
    loop Until Success
      Dev-->>Core: ResourceRequest | ZoomRequest | BlurRequest
      alt ResourceRequest (main)
        Core->>Dev: Chunk(main, offset, len)
      else ZoomRequest (thumbnail)
        Core->>Dev: Chunk(thumbnail, offset, len)
      else BlurRequest (blur)
        Core->>Dev: Chunk(blur, offset, len)
      end
      Note over Core: Update uploadProgress<br/>total/uploaded/currentFile
    end
    Dev-->>Core: Success
    Core-->>App: Completed
  else Error
    Core-->>App: Failed
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/homescreen

🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@revan-zhang
Copy link
Contributor

revan-zhang commented Aug 26, 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)

@ByteZhang1024 ByteZhang1024 marked this pull request as ready for review September 1, 2025 11:53
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: 9

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/DeviceUploadResource.ts (2)

57-65: Validate all payload hex fields as hex; make blur optional for back-compat

dataHex and thumbnailDataHex are validated as string, blurDataHex as hexString and required. Align all to hexString. If some firmware doesn’t support blur, make blurDataHex optional and default to empty bytes.

Apply:

-      { name: 'dataHex', type: 'string', required: true },
-      { name: 'thumbnailDataHex', type: 'string', required: true },
-      { name: 'blurDataHex', type: 'hexString', required: true },
+      { name: 'dataHex', type: 'hexString', required: true },
+      { name: 'thumbnailDataHex', type: 'hexString', required: true },
+      { name: 'blurDataHex', type: 'hexString' },
@@
-    this.paramsData = {
-      data: new Uint8Array(hexToBytes(dataHex)),
-      thumbnailData: new Uint8Array(hexToBytes(thumbnailDataHex)),
-      blurData: new Uint8Array(hexToBytes(blurDataHex)),
-    };
+    this.paramsData = {
+      data: new Uint8Array(hexToBytes(dataHex)),
+      thumbnailData: new Uint8Array(hexToBytes(thumbnailDataHex)),
+      blurData: blurDataHex ? new Uint8Array(hexToBytes(blurDataHex)) : new Uint8Array(),
+    };

Also applies to: 67-75


83-86: Bug: hashing the wrong data type (string vs bytes)

blake2s expects bytes. Passing a hex string hashes its UTF-8, not the binary. Use the parsed bytes.

-    const fileHash = bytesToHex(blake2s(this.payload.dataHex)).slice(0, 8);
+    const fileHash = bytesToHex(blake2s(this.paramsData.data)).slice(0, 8);
📜 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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear 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 cf49b26 and 468c935.

📒 Files selected for processing (5)
  • packages/core/src/api/device/DeviceUploadResource.ts (4 hunks)
  • packages/core/src/data/messages/messages.json (3 hunks)
  • packages/core/src/types/api/deviceUploadResource.ts (1 hunks)
  • packages/hd-transport/src/types/messages.ts (3 hunks)
  • submodules/firmware (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). (3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: build (22)
  • GitHub Check: lint (22)
🔇 Additional comments (7)
packages/core/src/data/messages/messages.json (2)

7562-7574: BlurRequest mirrors ZoomRequest — good symmetry

Field names and IDs match the ZoomRequest shape. Looks consistent.

Verify host handling is updated to respond to BlurRequest with ResourceAck chunks.


12386-12386: Transport and switch mappings for BlurRequest added — Verified hd-transport/src/types/messages.ts includes BlurRequest in the enum→type mapping and DeviceUploadResource.ts handles BlurRequest in its switch/case logic.

packages/hd-transport/src/types/messages.ts (3)

2763-2764: Blur length optionality: confirm protocol contract

zoom_data_length is required (number), but blur_data_length is optional. If blur is now a required third stream (core code requires blurDataHex), make this non-optional to match the contract; otherwise, keep it optional and make host-side blur optional too. Please align both sides.


2772-2776: New BlurRequest type: looks correct

Shape matches ResourceRequest/ZoomRequest (offset, data_length). No issues.


4644-4645: MessageType mapping updated: good

BlurRequest is properly added to MessageType.

packages/core/src/api/device/DeviceUploadResource.ts (2)

88-97: blur_data_length populated: OK, but sync with transport type

You always send blur_data_length. If transport keeps it optional, that’s fine; if blur is mandatory, make the transport field required too. Keep them consistent.


169-175: TypedCall response union updated: looks good

Allows BlurRequest in both ResourceAck and initial ResourceUpload. Flow matches the new three-stream protocol.

Also applies to: 182-189

@ByteZhang1024 ByteZhang1024 enabled auto-merge (squash) September 2, 2025 01:28
@wabicai wabicai self-requested a review September 2, 2025 02:24
@ByteZhang1024 ByteZhang1024 merged commit 3c9d959 into onekey Sep 2, 2025
10 checks passed
@ByteZhang1024 ByteZhang1024 deleted the feat/homescreen branch September 2, 2025 02:31
ByteZhang1024 added a commit that referenced this pull request Sep 2, 2025
ByteZhang1024 added a commit that referenced this pull request Sep 2, 2025
* feat: support blur resource (#550)

* fix: example

* feat: add btc params

* chore: update blur screent example

* chore: fix lint

* chore: release 1.1.11-alpha.2
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