Skip to content

Conversation

@mahmoud-elmorabea
Copy link
Contributor

@mahmoud-elmorabea mahmoud-elmorabea commented Jan 6, 2026

The issue

This PR fixes an issue for in-app Android. Sometimes when there are multiple messages the GistModalActivity animation takes longer than the processor to update the state. In which case, the activity dismisses the wrong message.

  • Activity showing message 1
  • Message 1 is dismissed by the controller
  • Message 2 is queued up and shown in a new instance of the activity
  • onDestroy of old activity runs and grabs the current message -> which is now message 2
    Dismisses it as per this

This is not really related to SSE but it's more apparent because SSE shows subsequent messages faster.

The fix

  • When the GistModalActivity is created, it holds on to the message it was created to show
  • When onDestroy runs, we make sure not to call dismiss unless our message is being shown

Note

Addresses a race condition where GistModalActivity could dismiss the wrong modal during transitions.

  • Stores activityMessage and in onDestroy only dismisses if it matches the currently displayed message (by queueId); refactors isPersistentMessage(Message?)
  • Middleware change: use store.state.shouldUseSse (instead of sseEnabled) to trigger ProcessMessageQueue after dismissing a message

Written by Cursor Bugbot for commit 1a8bb41. This will update automatically on new commits. Configure here.

@mahmoud-elmorabea mahmoud-elmorabea self-assigned this Jan 6, 2026
@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Sample app builds 📱

Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.


@mahmoud-elmorabea mahmoud-elmorabea changed the title chore: Sse wrap up chore: SSE bug fixes Jan 6, 2026
@github-actions
Copy link

github-actions bot commented Jan 6, 2026

  • java_layout: Build failed. See CI job logs to determine the issue and try re-building.

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

  • kotlin_compose: Build failed. See CI job logs to determine the issue and try re-building.

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.18%. Comparing base (126b67c) to head (1a8bb41).

Files with missing lines Patch % Lines
...saginginapp/gist/presentation/GistModalActivity.kt 37.50% 2 Missing and 3 partials ⚠️
.../messaginginapp/state/InAppMessagingMiddlewares.kt 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##             feature/in-app-sse     #639      +/-   ##
========================================================
+ Coverage                 67.85%   68.18%   +0.32%     
- Complexity                  748      752       +4     
========================================================
  Files                       142      142              
  Lines                      4303     4303              
  Branches                    580      580              
========================================================
+ Hits                       2920     2934      +14     
+ Misses                     1165     1147      -18     
- Partials                    218      222       +4     

☔ 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.

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

  • java_layout: sse-wrap-up (1767713150)

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

  • kotlin_compose: sse-wrap-up (1767713151)

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Build available to test
Version: sse-wrap-up-SNAPSHOT
Repository: https://s01.oss.sonatype.org/content/repositories/snapshots/

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

📏 SDK Binary Size Comparison Report

Module Last Recorded Size Current Size Change in Size
core 29.85 KB 29.85 KB ✅ No Change
datapipelines 38.89 KB 38.89 KB ✅ No Change
messagingpush 30.25 KB 30.25 KB ✅ No Change
messaginginapp 106.50 KB 106.61 KB ⬆️ +0.11KB
tracking-migration 22.89 KB 22.89 KB ✅ No Change

@mahmoud-elmorabea mahmoud-elmorabea marked this pull request as ready for review January 6, 2026 15:52
@mahmoud-elmorabea mahmoud-elmorabea requested a review from a team as a code owner January 6, 2026 15:52
if (!isPersistentMessage()) {
inAppManager.dispatch(InAppMessagingAction.DismissMessage(message = state.message))

if (ourMessage != null && inAppManager != null && ourMessage.queueId == displayedMessage?.queueId) {
Copy link

Choose a reason for hiding this comment

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

Null queueId comparison incorrectly matches non-displayed state

The condition ourMessage.queueId == displayedMessage?.queueId can incorrectly evaluate to true when displayedMessage is null (no message currently displayed) and ourMessage.queueId is also null, since null == null is true in Kotlin. This defeats the race condition fix because a message with a null queueId would trigger a dismiss dispatch even when no message is currently in the Displayed state. The check needs to ensure displayedMessage is non-null before comparing queueId values.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Gist activity is always started with a message

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

  • java_layout: sse-wrap-up (1767773205)

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

  • kotlin_compose: sse-wrap-up (1767773209)

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