Skip to content

refactor(llc)!: route getUnreadCount through the generated client - #3049

Draft
VelikovPetar wants to merge 5 commits into
refactor/flu-923_read_receipts_openapi_migrationfrom
refactor/flu-935_unread_counts_openapi_migration
Draft

VelikovPetar wants to merge 5 commits into
refactor/flu-923_read_receipts_openapi_migrationfrom
refactor/flu-935_unread_counts_openapi_migration

Conversation

@VelikovPetar

Copy link
Copy Markdown
Contributor

Submit a pull request

Linear: FLU-935
Github Issue: -

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

Moves StreamChatClient.getUnreadCount onto the OpenAPI-generated client, as new plan group 18 (Unread Counts), split out of group 09 (Users).

  • getUnreadCount returns Result<GetUnreadCountResponse> instead of throwing. On success it still updates the current user's totalUnreadCount, unreadChannels and unreadThreads (via result.onSuccess); a failure leaves them unchanged.
  • GetUnreadCountResponse moves to models/response/ as a freezed class with a non-null duration.
  • UnreadCountsChannel, UnreadCountsThread and UnreadCountsChannelType become freezed plain models, one per file, without fromJson/toJson; they gain value equality and copyWith.
  • New UsersRepository, mirroring UserApi; the mappers go in the existing user_mapper.dart.
  • StreamChatApi.user.getUnreadCount is removed.
Generated Public
DefaultApi.unreadCounts (GET /api/v2/chat/unread) StreamChatClient.getUnreadCount
WrappedUnreadCountsResponse GetUnreadCountResponse (kept)
UnreadCountsChannel / UnreadCountsThread / UnreadCountsChannelType same names (ours, freezed)
— UsersRepository (internal)

Why

The migration moves every endpoint onto the generated client, which returns a Result for every call. This one is the smallest unblocked slice: no parameters, a response that matches ours field for field, and nothing persists it.

Notes for reviewers

  • The v10 names stay. unreadCounts and WrappedUnreadCountsResponse say nothing a caller needs.
  • Same backend handler. /unread and /api/v2/chat/unread both mount v1.UnreadCounts; it's gated by ClassicUnreadCountsEnabled identically on both, so the switch changes nothing about who may call it. Not in beta.
  • v2 sends last_read as epoch nanoseconds rather than RFC 3339; the generated converter handles both.

Testing

  • melos run analyze clean; stream_chat suite green (1,910 tests), flutter_core and persistence green. generate_plan.py --check reports 0 problems.
  • New client_get_unread_count_test.dart: the full envelope against a fully populated generated response, the current-user update, the failure without throwing, and the counts left unchanged on failure.
  • Live v1 vs v2 parity on the demo app for three users (no unread, 541 unread across 42 channels, one unread thread): identical counts, and the real v2 bodies decode through the generated model with the same instants as v1.

Screenshots / Videos

Not applicable: no visible UI change.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VelikovPetar and others added 3 commits October 9, 2026 14:27
…refactor/flu-935_unread_counts_openapi_migration
…refactor/flu-935_unread_counts_openapi_migration
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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