Skip to content

refactor: move paging code to common [WPB-25633]#4133

Merged
MohamadJaara merged 1 commit into
developfrom
mo/refactor/move-pagging-to-common
May 13, 2026
Merged

refactor: move paging code to common [WPB-25633]#4133
MohamadJaara merged 1 commit into
developfrom
mo/refactor/move-pagging-to-common

Conversation

@MohamadJaara
Copy link
Copy Markdown
Member

@MohamadJaara MohamadJaara commented May 12, 2026

https://wearezeta.atlassian.net/browse/WPB-25633


What's new in this PR?

Issues

  • Kalium's commonMain depended on the app.cash.paging multiplatform shim, which was archived and deprecated by Cash App in September 2025.
  • The paging use cases and MessageScope / ConversationScope extension properties were stuck in androidMain, so iOS consumers of Kalium had no way to call getPaginatedFlowOfMessagesByConversation, getPaginatedFlowOfConversationDetailsWithEventsBySearchQuery, etc.

Causes (Optional)

androidx.paging was Android-only when Kalium adopted paging, so the app.cash.paging shim was the only KMP option. Since paging-common 3.3.0 it ships native KMP targets including iOS, and as of 3.5.0 covers every type Kalium uses. The shim is no longer needed.

Solutions

  • Bumped androidx-paging3 to 3.5.0 in both Kalium and the parent wire-android version catalogs; added a paging-common (androidx.paging:paging-common) alias.
  • Added paging-common to commonMain in :data:persistence, :logic, :domain:cells, :test:benchmarks (exposed as api(...) where the types appear in public signatures).
  • Replaced every app.cash.paging.* import with androidx.paging.*. Cash App's flattened class names were collapsed to AndroidX's nested form:
    • PagingSourceLoadResultPagePagingSource.LoadResult.Page
    • PagingSourceLoadResultErrorPagingSource.LoadResult.Error
    • PagingSourceLoadParamsRefresh / AppendPagingSource.LoadParams.Refresh / Append
  • Dropped the UNCHECKED_CAST helpers in ConversationPagingSourceTest that worked around the shim treating LoadParams.Refresh/Append as unrelated types — AndroidX models them as real subtypes.
  • Moved the paging use cases and scope extensions from logic/src/androidMain to logic/src/commonMain via git mv so history is preserved:
    • feature/message/: GetPaginatedFlowOfMessagesByConversationUseCase, GetPaginatedFlowOfMessagesBySearchQueryAndConversationIdUseCase, FetchOlderNomadMessagesByConversationUseCase, MessageScopeExtensions
    • feature/asset/: GetPaginatedFlowOfAssetMessageByConversationIdUseCase, ObservePaginatedAssetImageMessages
    • feature/conversation/: GetPaginatedFlowOfConversationDetailsWithEventsBySearchQueryUseCase, ConversationScopeExtensions

SQLDelight's androidx-paging3-extensions already returns androidx.paging.PagingSource in 2.2.1, so no QueryPagingSource replacement was needed.

Dependencies (Optional)

Needs releases with:

  • N/A — no companion PRs. The parent wire-android androidx-paging3 / androidx-paging3Compose version-refs were bumped to 3.5.0 in the same change.

Testing

Test Coverage (Optional)

  • Existing paging tests (MessageExtensionsTest, ConversationExtensionsTest, MessageRepositoryExtensionsTest, ConversationRepositoryExtensionsTest, ConversationPagingSourceTest, GetCellConversationsPagedUseCaseTest, GetPaginatedFlowOfConversationDetailsWithEventsBySearchQueryUseCaseTest) were updated to the AndroidX API and continue to assert the same behaviour. No new tests were added because no new behaviour was introduced.

How to Test

Build verification (run from kalium/):

./gradlew :data:persistence:compileKotlinMetadata :logic:compileKotlinMetadata \
          :domain:cells:compileKotlinMetadata :test:benchmarks:compileKotlinMetadata
./gradlew :data:persistence:compileKotlinIosSimulatorArm64 \
          :logic:compileKotlinIosSimulatorArm64 \
          :domain:cells:compileKotlinIosSimulatorArm64 \
          -PUSE_UNIFIED_CORE_CRYPTO=true
./gradlew :logic:compileAndroidHostTest
./gradlew detekt
./gradlew :data:persistence:jvmTest :logic:jvmTest :domain:cells:jvmTest \
          -Djava.library.path=./native/libs

Manual smoke (parent wire-android staging-debug):

  1. Install apk.
  2. Open a conversation with several hundred messages — scroll up; verify older messages page in without duplication or jank.
  3. From the conversation list, type a search query — verify search results paginate as you scroll.
  4. Open the Files / Cells tab and scroll a folder with > 30 items — verify subsequent pages load.

@MohamadJaara MohamadJaara requested a review from a team as a code owner May 12, 2026 16:21
@MohamadJaara MohamadJaara requested review from Garzas, alexandreferris, sbakhtiarov, typfel and yamilmedina and removed request for a team May 12, 2026 16:21
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

Test Results

0 tests   - 4 890   0 ✅  - 4 775   0s ⏱️ - 2m 44s
0 suites  -   803   0 💤  -   115 
0 files    -   803   0 ❌ ±    0 

Results for commit 7e83f7e. ± Comparison against base commit de33718.

♻️ This comment has been updated with latest results.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.54%. Comparing base (de33718) to head (7e83f7e).

Files with missing lines Patch % Lines
...ire/kalium/cells/domain/paging/FilePagingSource.kt 0.00% 3 Missing ⚠️
...um/benchmarks/persistence/BenchmarkPagingAccess.kt 0.00% 2 Missing ⚠️
...benchmarks/persistence/MessageReadBenchmarkData.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #4133      +/-   ##
=============================================
- Coverage      61.60%   61.54%   -0.06%     
  Complexity      4023     4023              
=============================================
  Files           2057     2065       +8     
  Lines          67321    67384      +63     
  Branches        6635     6636       +1     
=============================================
- Hits           41475    41474       -1     
- Misses         23202    23267      +65     
+ Partials        2644     2643       -1     
Files with missing lines Coverage Δ
...istence/dao/conversation/ConversationExtensions.kt 89.09% <ø> (ø)
...wire/kalium/persistence/dao/message/KaliumPager.kt 100.00% <ø> (ø)
...alium/persistence/dao/message/MessageExtensions.kt 46.15% <ø> (ø)
...um/cells/domain/paging/ConversationPagingSource.kt 100.00% <100.00%> (ø)
...domain/usecase/GetCellConversationsPagedUseCase.kt 85.71% <ø> (ø)
...m/cells/domain/usecase/GetCellFilesPagedUseCase.kt 0.00% <ø> (ø)
...a/conversation/ConversationRepositoryExtensions.kt 90.90% <ø> (ø)
.../logic/data/message/MessageRepositoryExtensions.kt 39.53% <ø> (ø)
...inatedFlowOfAssetMessageByConversationIdUseCase.kt 0.00% <ø> (ø)
...eature/asset/ObservePaginatedAssetImageMessages.kt 0.00% <ø> (ø)
... and 10 more

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de33718...7e83f7e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchmo/refactor/move-pagging-to-common
Testbedubuntu-latest

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymicroseconds (µs)
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInFiles📈 view plot
⚠️ NO THRESHOLD
929.85 µs
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInMemory📈 view plot
⚠️ NO THRESHOLD
590,622.22 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.inboxPagingDeepPageBenchmark📈 view plot
⚠️ NO THRESHOLD
131,140.86 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.inboxPagingFirstPageBenchmark📈 view plot
⚠️ NO THRESHOLD
127,122.48 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.localMarkAsReadBenchmark📈 view plot
⚠️ NO THRESHOLD
3,410.85 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.messagePagingDeepPageBenchmark📈 view plot
⚠️ NO THRESHOLD
26,527.24 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.messagePagingFirstPageBenchmark📈 view plot
⚠️ NO THRESHOLD
11,373.53 µs
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.messageInsertionBenchmark📈 view plot
⚠️ NO THRESHOLD
1,356,288.39 µs
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.queryMessagesBenchmark📈 view plot
⚠️ NO THRESHOLD
21,713.24 µs
🐰 View full continuous benchmarking report in Bencher

@MohamadJaara MohamadJaara changed the title refactor: move paging code to common refactor: move paging code to common [WPB-25633] May 13, 2026
@MohamadJaara MohamadJaara enabled auto-merge May 13, 2026 08:43
@MohamadJaara MohamadJaara added this pull request to the merge queue May 13, 2026
Merged via the queue into develop with commit f320484 May 13, 2026
29 of 30 checks passed
@MohamadJaara MohamadJaara deleted the mo/refactor/move-pagging-to-common branch May 13, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants