Skip to content

Conversation

andremion
Copy link
Contributor

@andremion andremion commented Jun 17, 2025

🎯 Goal

Introduce the ability to cancel link previews in the message composer.

🛠 Implementation details

  • Added a cancelLinkPreview method to MessageComposerController and MessageComposerViewModel.
  • Updated ComposerLinkPreview to accept an onCancel callback.
  • When sending a message, if linkPreviews is empty, skipEnrichUrl will be set to true.
  • Connected the cancel action in the UI to the new methods.
  • 🚨 Breaking change: Updated ChatComponentFactory and MessageComposer to pass the new onCancelLinkPreviewClick callback.

🎨 UI Changes

Before After
Screen_recording_20250617_140641.webm
Screen_recording_20250617_140525.webm

🧪 Testing

  • Type a link in the message composer
  • When the link preview appears, click on the close icon to cancel the link preview
  • Send the message

🎉 GIF

Please provide a suitable gif that describes your work on this pull request

@andremion andremion added the compose Jetpack Compose label Jun 17, 2025
Copy link
Contributor

github-actions bot commented Jun 17, 2025

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 3.23 MB 3.23 MB 0.00 MB 🟢
stream-chat-android-offline 3.46 MB 3.46 MB 0.00 MB 🟢
stream-chat-android-ui-components 10.55 MB 10.55 MB 0.00 MB 🟢
stream-chat-android-compose 12.76 MB 12.77 MB 0.00 MB 🟢

@andremion andremion requested a review from Copilot June 17, 2025 13:50
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds the ability for users to cancel link previews in the message composer and ensures no URL enrichment occurs after cancellation.

  • Introduces cancelLinkPreview in the controller and view model
  • Updates UI components and factory interface to accept and invoke an onCancelLinkPreviewClick callback
  • Adjusts message-sending logic to skip URL enrichment when the preview list is empty

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
stream-chat-android-ui-common/src/.../MessageComposerController.kt Adds skipEnrichUrl flag in sendMessage and a cancelLinkPreview method
stream-chat-android-compose/src/.../MessageComposerViewModel.kt Exposes cancelLinkPreview() on the view model
stream-chat-android-compose/src/.../ChatComponentFactory.kt Adds onCancelLinkPreviewClick callback to the factory interface
stream-chat-android-compose/src/.../MessageComposer.kt Propagates the new cancel callback through all MessageComposer overloads
stream-chat-android-compose/src/.../ComposerLinkPreview.kt Calls onCancel() before hiding the preview
stream-chat-android-compose-sample/src/.../HyperLinksTests.kt Removes ignored tests and updates assertions for no-preview cases
Comments suppressed due to low confidence (3)

stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/MessageComposerController.kt:1095

  • Provide a meaningful KDoc for cancelLinkPreview() or remove the empty doc comment to avoid an empty documentation stub.
    /**

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/ChatComponentFactory.kt:1328

  • Add KDoc to describe the onCancelLinkPreviewClick callback, explaining when it is invoked and how consumers should use it.
        onCancelLinkPreviewClick: () -> Unit,

stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/HyperLinksTests.kt:57

  • Consider adding an E2E test that verifies tapping the cancel icon on a link preview actually removes the preview and causes skipEnrichUrl to be applied when sending the message.
    @Test

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
13.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Contributor

github-actions bot commented Oct 6, 2025

This pull request has been automatically marked as stale because it has been inactive for 14 days. It will be closed in 7 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Oct 6, 2025
andremion and others added 5 commits October 7, 2025 20:00
This commit introduces the ability to cancel link previews in the message composer.

Key changes:
- Added a `cancelLinkPreview` method to `MessageComposerController` and `MessageComposerViewModel`.
- Updated `ComposerLinkPreview` to accept an `onCancel` callback.
- When sending a message, if `linkPreviews` is empty, `skipEnrichUrl` will be set to `true`.
- Connected the cancel action in the UI to the new methods.
- Updated `ChatComponentFactory` and `MessageComposer` to pass the new `onCancelLinkPreviewClick` callback.
@andremion andremion force-pushed the AND-309-do-not-show-link-preview-when-it-is-dismissed branch from e318ea6 to 8f42c13 Compare October 7, 2025 19:01
Copy link

sonarqubecloud bot commented Oct 7, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
51.4% Coverage on New Code (required ≥ 80%)
4.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@github-actions github-actions bot removed the Stale label Oct 13, 2025
@andremion
Copy link
Contributor Author

To be done when we can do breaking changes

@andremion andremion closed this Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚨 breaking-changes Pull request containing breaking changes compose Jetpack Compose

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants