Skip to content

Conversation

@jgmontoya
Copy link
Contributor

@jgmontoya jgmontoya commented Jan 22, 2026

Description

Adds the pin_order attribute to chat summary and accounts_groups as well as adds the set_chat_pin_order method so the app can set this value as needed

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore
  • 🧪 Tests

Checklist

  • Run just precommit to ensure that formatting and linting are correct
  • Updated the CHANGELOG.md file with your changes (if they affect the user experience)

Summary by CodeRabbit

  • New Features

    • Chat pinning: pin/unpin conversations and set a custom pin order.
    • New API to update a chat's pin order so ordering changes take effect immediately.
  • Behavior Changes

    • Chat list ordering: pinned chats first (by pin order), then recent unpinned chats, then groups with no messages (by creation date).
  • Data Model

    • Account and chat summaries now surface pin order for pinned state.
  • Documentation

    • Sorting semantics documented for clarity.

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

Walkthrough

Adds chat pinning support: introduces pinOrder/pin_order fields to AccountGroup and ChatSummary across Dart and Rust, adds a new RPC/method to set a chat's pin order (Dart FFI -> Rust -> whitenoise), and updates generated encoders/decoders and dispatcher funcIds.

Changes

Cohort / File(s) Summary
Dart API Models & FFI
lib/src/rust/api/account_groups.dart, lib/src/rust/api/chat_list.dart, lib/src/rust/frb_generated.dart
Added pinOrder to AccountGroup and ChatSummary; updated constructors, hashCode, and operator==; added setChatPinOrder(...) API and corresponding FFI/task meta; adjusted generated encode/decode usage and funcId wiring.
Rust API Types & Logic
rust/src/api/account_groups.rs, rust/src/api/chat_list.rs
Added pin_order: Option<i64> to AccountGroup and ChatSummary; propagate from whitenoise conversions; added pub async fn set_chat_pin_order(...) endpoint and updated chat-list sorting documentation.
Generated Rust Bridge
rust/src/frb_generated.rs, rust/src/frb_generated.rs (wire impl)
Added wire handler for set_chat_pin_order; updated SseEncode/SseDecode and IntoDart flows to include pin_order; shifted dispatcher funcIds and updated codegen content hash.
Misc Rust Changes
rust/src/api/groups.rs, rust/Cargo.toml
Added PartialEq, Eq derives to GroupType; bumped whitenoise git rev in Cargo.toml.

Sequence Diagram

sequenceDiagram
    actor Client as Dart Client
    participant FFI as FFI Bridge
    participant RustAPI as Rust API
    participant WN as Whitenoise

    Client->>FFI: setChatPinOrder(accountPubkey, mlsGroupId, pinOrder)
    FFI->>FFI: Marshal args (funcId 57)
    FFI->>RustAPI: Invoke set_chat_pin_order(account_pubkey, mls_group_id, pin_order)
    RustAPI->>RustAPI: Validate inputs & await
    RustAPI->>WN: whitenoise.set_chat_pin_order(account_pubkey, mls_group_id, pin_order)
    WN-->>RustAPI: Result/OK
    RustAPI-->>FFI: Return void
    FFI-->>Client: Complete Future<void>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • untreu2
  • josefinalliende
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding pin_order attribute to account_groups and chat_list, plus introducing set_chat_pin_order method.
Docstring Coverage ✅ Passed Docstring coverage is 93.75% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@github-actions
Copy link

➡️ Coverage: 99.58% → 99.58% (0.00%)

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

Caution

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

⚠️ Outside diff range comments (1)
rust/src/api/account_groups.rs (1)

18-33: Use #[frb(non_opaque)] for AccountGroup (required for Flutter compatibility).

This struct is part of the Rust API surface and should follow the project guideline for non-opaque FRB structs.

♻️ Proposed fix
-#[frb]
+#[frb(non_opaque)]
 #[derive(Debug, Clone)]
 pub struct AccountGroup {

As per coding guidelines, apply #[frb(non_opaque)] on structs in rust/src/api/**/*.rs.

🤖 Fix all issues with AI agents
In `@rust/src/api/chat_list.rs`:
- Around line 122-153: Reorder input parsing in set_chat_pin_order so all inputs
are parsed before performing lookups: call Whitenoise::get_instance() first,
then parse account_pubkey with PublicKey::parse and decode mls_group_id with
hex::decode / GroupId::from_slice, and only after those parses call
whitenoise.find_account_by_pubkey(&pubkey).await and then
whitenoise.set_chat_pin_order(&account, &group_id, pin_order).await; keep
existing error handling and return types intact.

@jgmontoya jgmontoya force-pushed the feat/add-pin-order-to-rust branch from 80a8fa8 to 8f3bbc6 Compare January 22, 2026 16:40
@github-actions
Copy link

➡️ Coverage: 99.58% → 99.58% (0.00%)

Copy link
Collaborator

@josefinalliende josefinalliende left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not related to this PR but it is a blocker for merge: Since this commit cc99f378bb80707005fc81191697f423910d28c0 in the rust crate, the signup turns to be extremely slow... from 2s to above 20s....

marmot-protocol/whitenoise-rs@cc99f37

@jgmontoya jgmontoya force-pushed the feat/add-pin-order-to-rust branch from 8f3bbc6 to 16fc844 Compare January 23, 2026 15:08
@github-actions
Copy link

➡️ Coverage: 99.6% → 99.6% (0.00%)

@jgmontoya jgmontoya merged commit b9da1ec into master Jan 23, 2026
4 checks passed
@jgmontoya jgmontoya deleted the feat/add-pin-order-to-rust branch January 23, 2026 16:31
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