Skip to content

Conversation

@erskingardner
Copy link
Member

@erskingardner erskingardner commented Oct 2, 2025

Summary by CodeRabbit

  • New Features

    • Added the ability to upload a group image, including selecting the image type and target server.
    • Provides confirmation details after a successful upload for better feedback.
  • Chores

    • Updated underlying dependencies to improve stability and compatibility.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 2, 2025

Walkthrough

Adds a new cross-language API to upload a group image, including Dart and Rust endpoints, result types, and (de)serialization for a new fixed-size byte array (12 bytes). Updates FFI dispatch IDs, codegen metadata, and Rust dependencies. Introduces UploadGroupImageResult and U8Array12 types across layers.

Changes

Cohort / File(s) Summary of edits
Dart public API
lib/src/rust/api/groups.dart
Added uploadGroupImage(...) delegating to Rust; introduced UploadGroupImageResult with fields encryptedHash (U8Array32), imageKey (U8Array32), imageNonce (U8Array12); minor comment tweak.
Dart FRB generated wiring
lib/src/rust/frb_generated.dart
Added crateApiGroupsUploadGroupImage(...) API, implementation, and const meta; wired funcId 59; added SSE/DCO (de)serializers for UploadGroupImageResult and U8Array12; updated content hash and related IDs.
Dart FRB platform (IO) serialization
lib/src/rust/frb_generated.io.dart
Added DCO/SSE encode/decode methods for U8Array12 and UploadGroupImageResult.
Dart core types
lib/src/rust/lib.dart
Added U8Array12 fixed-size list wrapper with constructors and internal accessor.
Rust API (groups)
rust/src/api/groups.rs
Added UploadGroupImageResult struct and upload_group_image(...) async function using whitenoise::ImageType; maps inputs and returns result fields.
Rust FRB generated wiring
rust/src/frb_generated.rs
Added wire function for upload; mapped dispatch funcId 59; implemented IntoDart and SSE encode/decode for UploadGroupImageResult; added SSE encode/decode for [u8; 12].
Rust dependencies
rust/Cargo.toml
Bumped mdk-core to 0.5.1 (new rev) and updated whitenoise rev.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as Dart App
  participant API as Dart API (groups.dart)
  participant FRB as Dart FRB (frb_generated.dart)
  participant Wire as FRB Wire (rust frb_generated.rs)
  participant Svc as Rust API (groups.rs)
  participant WN as Whitenoise
  participant Srv as Server

  App->>API: uploadGroupImage(accountPubkey, groupId, filePath, imageType, serverUrl)
  API->>FRB: crateApiGroupsUploadGroupImage(...)
  FRB->>Wire: SSE call (funcId 59, args)
  Wire->>Svc: upload_group_image(...)
  Svc->>WN: upload_group_image(account, group, file, type, url)
  WN->>Srv: Upload image bytes
  Srv-->>WN: Encrypted hash/key/nonce
  WN-->>Svc: Result {encrypted_hash, image_key, image_nonce}
  Svc-->>Wire: UploadGroupImageResult
  Wire-->>FRB: SSE encode result
  FRB-->>API: UploadGroupImageResult
  API-->>App: UploadGroupImageResult (U8Array32, U8Array32, U8Array12)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • Quwaysim
  • josefinalliende
  • codeswot

Poem

I nibbled bytes and chewed through wire,
Packed keys and nonce the servers require—
A hop, a hash, an image sent,
Across the fields of rusted vent.
With twelve little carrots in a row,
Our groups now gleam—upload and go! 🥕📷

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% 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 clearly and concisely describes the main change, which is adding a bridge method for uploading group images, and directly reflects the core functionality introduced in the PR without extra detail.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-group-image-upload

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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

🧹 Nitpick comments (3)
rust/Cargo.toml (1)

19-19: Git deps pinned; consider removing redundant version with git+rev.

Cargo ignores version when git is specified. Dropping version avoids confusion and lockfile churn.

Also applies to: 32-32

lib/src/rust/api/groups.dart (1)

85-98: Wrapper method wiring is correct. Consider typing imageType.

Arg order matches Rust; call path is correct. Recommend replacing the String imageType with a typed enum to avoid magic strings and runtime parse errors.

As per coding guidelines

rust/src/api/groups.rs (1)

9-11: New API and result struct are coherent and safe-by-default. Consider enum for image type.

  • Flow: get_instance → parse inputs → call whitenoise → return tuple → struct — good.
  • Suggest accepting a typed image enum instead of String and converting to whitenoise::ImageType. Avoids stringly-typed interface and centralizes validation.

Example (outside the shown range):

#[frb]
#[derive(Debug, Clone)]
pub enum FlutterImageType { Png, Jpeg }

impl From<FlutterImageType> for ImageType {
    fn from(x: FlutterImageType) -> Self {
        match x { FlutterImageType::Png => ImageType::Png, FlutterImageType::Jpeg => ImageType::Jpeg }
    }
}

Then adjust signature within this range:

-    image_type: String,
+    image_type: FlutterImageType,

and convert with let image_type: ImageType = image_type.into();.

As per coding guidelines

Also applies to: 343-376

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 812eabb and 2ec0834.

⛔ Files ignored due to path filters (1)
  • rust/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • lib/src/rust/api/groups.dart (3 hunks)
  • lib/src/rust/frb_generated.dart (12 hunks)
  • lib/src/rust/frb_generated.io.dart (3 hunks)
  • lib/src/rust/lib.dart (1 hunks)
  • rust/Cargo.toml (2 hunks)
  • rust/src/api/groups.rs (2 hunks)
  • rust/src/frb_generated.rs (8 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.dart

📄 CodeRabbit inference engine (.cursor/rules/flutter.mdc)

**/*.dart: Always declare the type of each variable and function (parameters and return value). Avoid using 'any'. Create necessary types.
Don't leave blank lines within a function.
One export per file.
Use PascalCase for classes.
Use camelCase for variables, functions, and methods.
Use underscores_case for file and directory names.
Use UPPERCASE for environment variables. Avoid magic numbers and define constants.
Start each function with a verb.
Use verbs for boolean variables. Example: isLoading, hasError, canDelete, etc.
Use complete words instead of abbreviations and correct spelling, except for standard and well-known abbreviations (API, URL, i, j, err, ctx, req, res, next).
Write short functions with a single purpose. Less than 20 instructions.
Name functions with a verb and something else. If it returns a boolean, use isX or hasX, canX, etc. If it doesn't return anything, use executeX or saveX, etc.
Avoid nesting blocks by early checks and returns, or extraction to utility functions.
Use higher-order functions (map, filter, reduce, etc.) to avoid function nesting. Use arrow functions for simple functions (less than 3 instructions). Use named functions for non-simple functions.
Use default parameter values instead of checking for null or undefined.
Reduce function parameters using RO-RO: use an object to pass multiple parameters and to return results. Declare necessary types for input arguments and output.
Use a single level of abstraction in functions.
Don't abuse primitive types and encapsulate data in composite types.
Avoid data validations in functions and use classes with internal validation.
Prefer immutability for data. Use readonly for data that doesn't change. Use 'as const' for literals that don't change.
Declare interfaces to define contracts.
Write small classes with a single purpose. Less than 200 instructions, less than 10 public methods, less than 10 properties.
Use exceptions to handle errors you don't expect. If you catch an exception, it sh...

Files:

  • lib/src/rust/api/groups.dart
  • lib/src/rust/lib.dart
  • lib/src/rust/frb_generated.io.dart
  • lib/src/rust/frb_generated.dart
🧬 Code graph analysis (2)
rust/src/frb_generated.rs (1)
rust/src/api/groups.rs (1)
  • upload_group_image (353-376)
rust/src/api/groups.rs (1)
rust/src/api/utils.rs (1)
  • group_id_from_string (56-59)
⏰ 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). (1)
  • GitHub Check: Flutter CI
🔇 Additional comments (3)
lib/src/rust/lib.dart (1)

11-21: U8Array12 addition mirrors U8Array32 — looks good.

Assertions and constructors align with existing pattern.

lib/src/rust/api/groups.dart (1)

233-255: UploadGroupImageResult shape matches Rust — LGTM.

Fields/types align with bridge types.

lib/src/rust/frb_generated.dart (1)

80-80: Verified Bridge wiring and codecs for U8Array12/UploadGroupImageResult: Rust fn, result struct, Dart API stub, and DCO/SSE codecs are all present and funcIds 58–62 are sequential.

@erskingardner erskingardner merged commit 29561c6 into master Oct 2, 2025
2 checks passed
@erskingardner erskingardner deleted the add-group-image-upload branch October 2, 2025 12:46
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