Skip to content

Do not keep active live locations in the channel cache - #6769

Merged
gpunto merged 2 commits into
v6from
fix/v6-live-locations-cache
Oct 2, 2026
Merged

gpunto merged 2 commits into
v6from
fix/v6-live-locations-cache

Conversation

@gpunto

@gpunto gpunto commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Goal

The in-memory channel cache kept a channel's active live locations. Loading a channel again in the same session reads the cache first, so after the sharer stopped, the stopped location came back and stayed until its original end time. #6750 already stopped restoring them from the database; this covers the cache.

Part of AND-1576

Implementation

  • Drop active live locations when a channel is cached. They come from the server response and events only.
  • Ignore live locations when deciding whether a cached channel changed, so channels with an active location are not written again on every insert.

Active live locations are still exposed as before: ChannelState, the channel list and GlobalState read them from the in-memory global state, which the server responses and events keep up to date. Only the local copy goes away.

Testing

  • DatabaseChannelRepositoryCacheTest checks cached channels come back without live locations and that an unchanged channel with live locations is not written again.
  • On a device, another member shared a live location, the current user loaded the channel, the sharer stopped, then the current user queried the channel again. Before the change the stopped location was back in the global state. With it, it stays gone.

🤖 Generated with Claude Code

@gpunto gpunto added the pr:bug Bug fix label Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled (or ignored for dependabot PRs).

🎉 Great job! This PR is ready for review.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.26 MB 5.32 MB 0.06 MB 🟢
stream-chat-android-offline 5.49 MB 5.54 MB 0.05 MB 🟢
stream-chat-android-ui-components 10.64 MB 10.76 MB 0.12 MB 🟢
stream-chat-android-compose 12.87 MB 13.15 MB 0.29 MB 🟡

@gpunto
gpunto marked this pull request as ready for review October 1, 2026 14:21
@gpunto
gpunto requested a review from a team as a code owner October 1, 2026 14:21
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a31978db-77cb-4283-99e6-20d1fb554ded

📥 Commits

Reviewing files that changed from the base of the PR and between 974497d and d95d9b8.

📒 Files selected for processing (2)
  • stream-chat-android-offline/src/main/java/io/getstream/chat/android/offline/repository/domain/channel/internal/DatabaseChannelRepository.kt
  • stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/domain/channel/internal/DatabaseChannelRepositoryCacheTest.kt

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

Channel caching now clears activeLiveLocations on channel copies before caching them. Robolectric tests cover selecting one channel and selecting multiple channels.

Changes

Channel cache live-location handling

Layer / File(s) Summary
Clear live locations when caching channels
stream-chat-android-offline/src/main/java/io/getstream/chat/android/offline/repository/domain/channel/internal/DatabaseChannelRepository.kt, stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/domain/channel/internal/DatabaseChannelRepositoryCacheTest.kt
The collection overload clears activeLiveLocations on channel copies before caching them. The vararg overload delegates to the collection overload. Robolectric tests check selection of one or multiple channels.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to d95d9

Cached channels omit active live locations, and the tests cover the cache-backed selection paths. No actionable merge-blocking risk remains.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to d95d9

The change removes a source of stale live-location state without changing sharing permissions or mutating the original channel data. The inspected update paths preserve live locations separately from the cache. No introduced or worsened security issue was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed behavior affects location payloads for channels passing through the local repository cache. The operation removes a field from a derived copy; it introduces no destination for coordinates and does not grant additional sharing authority.

Trust Boundaries and Controls

  • observed — The cache is a derived representation, not the live-location state owner. Global updates replace matching message identities, retain other current locations, and exclude expired locations; channel views then filter by channel identity. An empty cache-derived list therefore does not clear valid live locations already held in global state.

Resilience and Maintainability Implications

  • inferred — Repeated cache writes apply the same sanitization while preserving channel identity and caller-owned data. Cache insertion precedes the asynchronous database write, but its sanitized location payload does not depend on that write succeeding. Database-restored channels also omit locations, so both inspected recovery paths maintain the non-restoration invariant.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description explains the goal, implementation, and testing. It omits the UI Changes, contributor checklist, reviewer checklist, and GIF sections, but these sections are not critical for this non-U…
Title check ✅ Passed The title clearly and concisely describes the main change: active live locations are removed from the channel cache.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

A rabbit checks the channel cache,
Live locations leave each copy.
One channel, then a list,
The tests confirm the empty fields.
I hop along, content with the result.

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

@andremion andremion left a comment

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.

Looks good, thanks.

@gpunto
gpunto merged commit 0e00f4a into v6 Oct 2, 2026
19 of 20 checks passed
@gpunto
gpunto deleted the fix/v6-live-locations-cache branch October 2, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants