Skip to content

Conversation

@rf2tsl
Copy link
Contributor

@rf2tsl rf2tsl commented Jan 19, 2026

Acceptance Criteria
it seems weird to have MembersListFragment, ProfileSummaryFragment and RoomTitleFragment, they all have essentially the same fields, I think we should fully remove ProfileSummaryFragment from the code base, and also look into removing RoomTitleFragment, we should move this logic to the backend and treat group and 1-1 room's name and avatar the same way on the frontend

Sidebar with AP for better understanding.

Approvd
https://app.approvd.io/silverlogic/BA/stories/44506

Summary by CodeRabbit

  • New Features

    • Show the other participant in direct (1‑on‑1) chats for clearer identification.
    • Indicate if you’re the sole administrator in a group chat to clarify admin responsibilities.
    • Use the other participant’s profile name and image for direct-message chat titles and avatars.
  • Tests

    • Added GraphQL tests covering title, image, other-participant, sole-admin resolution, permissions, and edge cases.

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 19, 2026

Walkthrough

Added two public GraphQL fields to BaseChatRoomObjectType: other_participant (returns the non-group chat partner or null) and is_sole_admin (boolean indicating if the requester is the only admin in a group). Resolvers updated to derive title/image from the other participant for non-group rooms and to evaluate sole-admin status for groups.

Changes

Cohort / File(s) Summary
Chat room GraphQL type: fields & resolvers
baseapp_chats/graphql/object_types.py
Added other_participant (type: ChatRoomParticipant), is_sole_admin (bool) fields; implemented get_other_participant(room, info) static helper; added resolve_other_participant, resolve_is_sole_admin; updated resolve_title and resolve_image to prefer the other participant for non-group rooms; added fields to Meta.fields.
Tests: GraphQL queries & scenarios
baseapp_chats/tests/test_graphql_queries.py
Added GraphQL query constants (ROOM_TITLE_GRAPHQL, ROOM_TITLE_AND_IMAGE_GRAPHQL, ROOM_OTHER_PARTICIPANT_GRAPHQL, ROOM_IS_SOLE_ADMIN_GRAPHQL) and extensive tests covering title/image resolution for 1‑on‑1 vs group rooms, missing profiles/images, otherParticipant resolution, permission checks, and multiple isSoleAdmin scenarios (admin changes, non-admin, non-participant).

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant GraphQL as GraphQL Resolver
  participant Room as ChatRoom
  participant Participants as Participants/Profiles

  Client->>GraphQL: query chatRoom { id, otherParticipant, isSoleAdmin, title, image }
  GraphQL->>Room: load room by id
  GraphQL->>Participants: fetch participants & profiles, determine current profile/participant
  alt room.isGroup == false
    GraphQL->>Participants: get_other_participant(excluding current profile)
    Participants-->>GraphQL: other participant profile or null
    GraphQL-->>Client: otherParticipant, title (other profile name or fallback), image (other profile image or fallback), isSoleAdmin = false
  else room.isGroup == true
    GraphQL->>Participants: fetch participant roles/admin flags
    Participants-->>GraphQL: current participant info, admins list
    GraphQL-->>Client: otherParticipant = null, title = room.title, image = room.image, isSoleAdmin = (current_is_admin AND admins_count == 1)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through fields and code tonight,
Found the friend who sits just out of sight,
I checked the crowns in the group’s bright den,
Counted one, then two — then one again,
Chats glow clearer in the rabbit’s light.

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title references a feature branch name and issue tracker ID (BA-2965) but does not describe the actual changes. The changes add new GraphQL fields (other_participant, is_sole_admin) and resolver logic, whereas the title suggests fragment refactoring and profile deduplication. Rename the title to clearly describe the main changes, such as 'Add other_participant and is_sole_admin fields to ChatRoom GraphQL type' or 'Implement chat room title and image resolution in backend'.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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.

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

🤖 Fix all issues with AI agents
In `@baseapp_chats/graphql/object_types.py`:
- Around line 240-255: In resolve_other_participant, ensure current_profile is
actually a member before returning other_participant: first check membership
(e.g., participants.filter(profile_id=current_profile.pk).exists() or similar)
and return None if the current_profile is not in self.participants; only then
compute and return other_participant
(self.participants.exclude(profile_id=current_profile.pk).first()). Keep the
existing group check and current_profile None handling.

Copy link
Member

@nossila nossila left a comment

Choose a reason for hiding this comment

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

@rf2tsl can you add tests cases to cover the behavior on those 2 new generated fields?

@rf2tsl rf2tsl merged commit 4fd67ae into master Jan 29, 2026
10 checks passed
@rf2tsl rf2tsl deleted the feature/BA-2965-duplicated-profile-fragments-refactor branch January 29, 2026 22:52
rf2tsl added a commit to silverlogic/baseapp-frontend that referenced this pull request Jan 29, 2026
Note* This only focuses on the web app, in order to totally remove the
duplicate fragments we need to make some changes for the native app as
well. This will need another story

REQUIRES BE: silverlogic/baseapp-backend#375

Acceptance Criteria 
it seems weird to have MembersListFragment, ProfileSummaryFragment and
RoomTitleFragment, they all have essentially the same fields, I think we
should fully remove ProfileSummaryFragment from the code base, and also
look into removing RoomTitleFragment, we should move this logic to the
backend and treat group and 1-1 room's name and avatar the same way on
the frontend

Sidebar with AP for better understanding. 

Approvd 
https://app.approvd.io/silverlogic/BA/stories/44506 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Chat rooms now expose an explicit admin flag and a primary participant
field for richer profile details.

* **Refactor**
* Unified title/image hooks across web and native for consistent avatar
and title behavior.
* Profile summary now loads from a chat-focused query, simplifying data
flow without changing UI.
* Reduced coupling to old fragment shapes, improving reliability of chat
header and profile displays.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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