Skip to content

feat(ui): redesign image CDN handling and thumbnail resizing#2531

Open
xsahil03x wants to merge 4 commits intofeat/design-refreshfrom
fix/image-cache
Open

feat(ui): redesign image CDN handling and thumbnail resizing#2531
xsahil03x wants to merge 4 commits intofeat/design-refreshfrom
fix/image-cache

Conversation

@xsahil03x
Copy link
Member

@xsahil03x xsahil03x commented Mar 6, 2026

Description of the pull request

  • Introduce StreamImageCDN for centralized URL resolution and stable cache key generation
  • Replace raw string-based thumbnail parameters (thumbnailSize, thumbnailResizeType, thumbnailCropType) with a structured ImageResize object across ImageAttachment, MediaAttachmentThumbnail, and ImageAttachmentThumbnail
  • Add imageCDN to StreamChatConfigurationData to allow custom CDN implementations
  • Remove getResizedImageUrl extension on String in favor of StreamImageCDN.resolveUrl
  • Improve image caching by using StreamImageCDN.cacheKey to strip volatile query parameters (e.g., signed tokens) from CachedNetworkImage
  • Add comprehensive migration guide for the redesign and breaking changes

Summary by CodeRabbit

  • New Features

    • Introduced redesigned image CDN system with configurable resize and crop modes
    • Added support for custom CDN implementations via configuration
  • Documentation

    • Added comprehensive migration guide for image CDN updates
  • Refactor

    • Simplified image attachment configuration parameters

* Introduce `StreamImageCDN` for centralized URL resolution and stable cache key generation
* Replace raw string-based thumbnail parameters (`thumbnailSize`, `thumbnailResizeType`, `thumbnailCropType`) with a structured `ImageResize` object across `ImageAttachment`, `MediaAttachmentThumbnail`, and `ImageAttachmentThumbnail`
* Add `imageCDN` to `StreamChatConfigurationData` to allow custom CDN implementations
* Remove `getResizedImageUrl` extension on `String` in favor of `StreamImageCDN.resolveUrl`
* Improve image caching by using `StreamImageCDN.cacheKey` to strip volatile query parameters (e.g., signed tokens) from `CachedNetworkImage`
* Add comprehensive migration guide for the redesign and breaking changes
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 593c59f3-0b6d-4815-b952-09af647a47af

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/image-cache

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.

@xsahil03x
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

1 similar comment
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🧹 Nitpick comments (1)
packages/stream_chat_flutter/lib/src/utils/stream_image_cdn.dart (1)

142-149: Consider documenting the ro parameter.

The 'ro': '0' parameter is added without explanation. If this is for rotation (defaulting to no rotation), consider adding a brief comment for clarity, or expose it through the ImageResize configuration if rotation should be configurable.

💡 Suggested documentation
     final queryParameters = {
       ...uri.queryParameters,
       'w': resize.width == 0 ? '*' : resize.width.floor().toString(),
       'h': resize.height == 0 ? '*' : resize.height.floor().toString(),
       'resize': resize.mode.value,
+      // Disable rotation by default
       'ro': '0',
       if (resize.mode == ResizeMode.crop) 'crop': resize.crop.value,
     };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/stream_chat_flutter/lib/src/utils/stream_image_cdn.dart` around
lines 142 - 149, The queryParameters map currently sets 'ro': '0' with no
explanation; update the code around queryParameters (the variable building the
CDN params) to either add a concise inline comment explaining that 'ro' denotes
rotation and '0' means no rotation, or modify the ImageResize model (and places
that construct resize) to expose rotation as a configurable field and use
resize.rotation (or similar) instead of the hardcoded '0'; ensure references
include ResizeMode.crop and the queryParameters construction so reviewers can
find the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@migrations/redesign/image_cdn.md`:
- Line 22: Remove the incorrect reference to a `stableCacheKey` String extension
in the quick reference line and leave only the `getResizedImageUrl` removal;
update the entry that currently reads "[StreamImageCDN] New class replacing
`getResizedImageUrl` and `stableCacheKey` String extensions" to mention only
`getResizedImageUrl`, and optionally add a parenthetical note that
`StreamImageCDN.cacheKey()` now provides stable cache keys (referencing
StreamImageCDN and its cacheKey() method) so readers aren’t misled about a
non-existent `stableCacheKey` String extension.

---

Nitpick comments:
In `@packages/stream_chat_flutter/lib/src/utils/stream_image_cdn.dart`:
- Around line 142-149: The queryParameters map currently sets 'ro': '0' with no
explanation; update the code around queryParameters (the variable building the
CDN params) to either add a concise inline comment explaining that 'ro' denotes
rotation and '0' means no rotation, or modify the ImageResize model (and places
that construct resize) to expose rotation as a configurable field and use
resize.rotation (or similar) instead of the hardcoded '0'; ensure references
include ResizeMode.crop and the queryParameters construction so reviewers can
find the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 483094b8-07d9-47d1-b0ec-dd1da44c02ab

📥 Commits

Reviewing files that changed from the base of the PR and between 6b4e3b7 and f7d8905.

📒 Files selected for processing (9)
  • migrations/redesign/README.md
  • migrations/redesign/image_cdn.md
  • packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart
  • packages/stream_chat_flutter/lib/src/attachment/thumbnail/image_attachment_thumbnail.dart
  • packages/stream_chat_flutter/lib/src/attachment/thumbnail/media_attachment_thumbnail.dart
  • packages/stream_chat_flutter/lib/src/stream_chat_configuration.dart
  • packages/stream_chat_flutter/lib/src/utils/extensions.dart
  • packages/stream_chat_flutter/lib/src/utils/stream_image_cdn.dart
  • packages/stream_chat_flutter/lib/stream_chat_flutter.dart
💤 Files with no reviewable changes (1)
  • packages/stream_chat_flutter/lib/src/utils/extensions.dart

@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.65%. Comparing base (6b4e3b7) to head (659bc78).

Files with missing lines Patch % Lines
...m_chat_flutter/lib/src/utils/stream_image_cdn.dart 35.00% 13 Missing ⚠️
...tachment/thumbnail/image_attachment_thumbnail.dart 66.66% 3 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                   @@
##           feat/design-refresh    #2531      +/-   ##
=======================================================
+ Coverage                64.61%   64.65%   +0.03%     
=======================================================
  Files                      434      435       +1     
  Lines                    26359    26358       -1     
=======================================================
+ Hits                     17032    17041       +9     
+ Misses                    9327     9317      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI commented Mar 6, 2026

@xsahil03x I've opened a new pull request, #2532, to work on those changes. Once the pull request is ready, I'll request review from you.

…age CDN migration guide (#2532)

Co-authored-by: xsahil03x <25670178+xsahil03x@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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.

2 participants