Skip to content

feat(group_chat): combined chats list with unread badges and live-update recovery - #726

Open
harshal-2304 wants to merge 3 commits into
developfrom
chatlist
Open

feat(group_chat): combined chats list with unread badges and live-update recovery#726
harshal-2304 wants to merge 3 commits into
developfrom
chatlist

Conversation

@harshal-2304

Copy link
Copy Markdown
Member
  • Chats list — chat icon with green unread dot on the Connect app bar, plus a /chats screen: avatar, name, day label, Sender: message preview, unread badge. Group rooms only, sorted by recency.
  • Live-update recovery — a foreground chat push for the open thread triggers a refetch, and replaces the socket if it turns up a message the socket never delivered. Fixes messages only appearing after leaving and re-entering the room.
  • Mark read on send — sending moves last_read_at, so you no longer see your own message badged as unread after exiting.

@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a group-chat inbox with unread indicators and foreground-push recovery for open threads, plus marks sent messages as read.

  • Adds the /chats route, localized empty states, room tiles, sorting, previews, unread badges, and Connect app-bar entry.
  • Adds paginated room-list state refreshed by lifecycle and foreground push events.
  • Adds foreground-push thread refetching and socket replacement when the refreshed thread appears to contain missed activity.
  • Updates the send path to advance room read state.

Confidence Score: 0/5

The PR is not safe to merge because group chats can remain unreachable, concurrent refreshes can corrupt pagination, and foreground-push recovery can make incorrect socket replacement decisions.

The previously reported pagination defects remain in the current implementation: filtered empty or short pages have no automatic continuation path, refresh can merge stale load-more data against reset offsets, and superseded requests can strand loading state. The socket recovery path also still infers delivery from a generic newest-message change, allowing healthy connections to be replaced and degraded connections to be retained.

Files Needing Attention: lib/features/group_chat/presentation/providers/chat_rooms_providers.dart, lib/features/group_chat/presentation/screens/chats_screen.dart, lib/features/group_chat/presentation/screens/group_chat_screen.dart

Important Files Changed

Filename Overview
lib/features/group_chat/presentation/providers/chat_rooms_providers.dart Adds shared paginated group-room state, but the previously reported filtered-page reachability and refresh/load-more race defects remain outstanding.
lib/features/group_chat/presentation/screens/group_chat_screen.dart Adds push-backed thread recovery and mark-read-on-send, but the previously reported socket-health classification defects remain outstanding.
lib/features/group_chat/presentation/screens/chats_screen.dart Adds the chats list and refresh UI, while its scroll-only pagination trigger contributes to the outstanding inability to reach group rooms behind filtered pages.
lib/features/group_chat/presentation/utils/chat_rooms_list.dart Adds group filtering, ordering, unread, push-targeting, and preview helpers; its message-identity-free push targeting feeds the outstanding recovery ambiguity.
lib/features/connect/presentation/screens/connect_screen.dart Adds the chats action and unread dot backed by the shared room provider.
lib/core/config/router/app_router.dart Registers the new top-level chats screen route.
lib/core/config/router/app_routes.dart Defines the /chats route constant.
lib/features/group_chat/presentation/widgets/chat_room_tile.dart Renders group identity, date, message preview, avatar, and unread count for each chat row.
test/features/group_chat/presentation/utils/chat_rooms_list_test.dart Covers the room-list utility behavior added by the PR.

Sequence Diagram

sequenceDiagram
  participant User
  participant Connect
  participant Rooms as Chat rooms provider
  participant API
  participant Thread as Group chat screen
  participant Push
  participant Socket
  User->>Connect: Open community hub
  Connect->>Rooms: Watch rooms and unread state
  Rooms->>API: List chat rooms
  API-->>Rooms: Mixed paginated rooms
  Rooms-->>Connect: Group rooms and unread dot
  User->>Thread: Open group chat
  Socket-->>Thread: Live chat events
  Push-->>Thread: Foreground chat push
  Thread->>API: Refresh current thread
  Thread->>Socket: Replace connection when recovery check indicates missed activity
Loading

Reviews (4): Last reviewed commit: "fix(group_chat): mark room as read immed..." | Re-trigger Greptile

Comment thread lib/features/group_chat/presentation/screens/group_chat_screen.dart
Comment on lines +89 to +90
/// How many extra pages a single load will walk looking for group rooms.
static const int _emptyPageBudget = 5;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Filtered pagination stops early

If the server places the first group room after more than five consecutive direct-message-only pages, _pagePastDirectRooms exhausts this fixed budget while hasMore remains true. The empty screen has no scroll-driven loadMore path, so existing group chats and their unread indicator remain hidden.

Knowledge Base Used: Community connection and AI assistance

Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/features/group_chat/presentation/providers/chat_rooms_providers.dart
Line: 89-90

Comment:
**Filtered pagination stops early**

If the server places the first group room after more than five consecutive direct-message-only pages, `_pagePastDirectRooms` exhausts this fixed budget while `hasMore` remains true. The empty screen has no scroll-driven `loadMore` path, so existing group chats and their unread indicator remain hidden.

**Knowledge Base Used:** [Community connection and AI assistance](https://app.greptile.com/webuddhist/-/custom-context/knowledge-base/openpecha/webuddhist-app/-/docs/community-connect-and-ai.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +227 to +232
void retry() {
if (state.rooms.isEmpty) {
loadInitial();
} else {
loadMore();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Retry strands pagination state

If the user retries while the automatic direct-room walk has a loadMore request in flight, loadInitial advances the generation without resetting isLoadingMore. The superseded request then returns without clearing that flag, permanently blocking later pagination and leaving deeper group rooms unreachable.

Knowledge Base Used: Community connection and AI assistance

Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/features/group_chat/presentation/providers/chat_rooms_providers.dart
Line: 227-232

Comment:
**Retry strands pagination state**

If the user retries while the automatic direct-room walk has a `loadMore` request in flight, `loadInitial` advances the generation without resetting `isLoadingMore`. The superseded request then returns without clearing that flag, permanently blocking later pagination and leaving deeper group rooms unreachable.

**Knowledge Base Used:** [Community connection and AI assistance](https://app.greptile.com/webuddhist/-/custom-context/knowledge-base/openpecha/webuddhist-app/-/docs/community-connect-and-ai.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment thread lib/features/group_chat/presentation/screens/group_chat_screen.dart Outdated
@harshal-2304 harshal-2304 self-assigned this Sep 4, 2026
Base automatically changed from feat/group-chat-delete-message to develop September 5, 2026 15:16
- Implemented group chat feature including chat rooms and messaging.
- Added localization strings for multiple languages (Nepali, Chinese, Hindi, Mongolian, English).
- Created new screens for displaying chat rooms and individual chat threads.
- Introduced state management for chat rooms using Riverpod.
- Added utility functions for managing chat room data and unread message indicators.
- Developed UI components for chat room tiles and empty chat states.
- Included tests for chat room functionalities and utilities.
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.

1 participant