Skip to content

CMM-2390 Fetch all terms in post editor picker - #23292

Open
nbradbury wants to merge 4 commits into
trunkfrom
term-picker-100-cap
Open

CMM-2390 Fetch all terms in post editor picker#23292
nbradbury wants to merge 4 commits into
trunkfrom
term-picker-100-cap

Conversation

@nbradbury

@nbradbury nbradbury commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Fixes CMM-2390

The Problem

The new wordpress-rs Compose term picker loads terms 100 at a time and only advances when the user taps a "Load more" row. On a site with more than 100 categories or tags, the picker shows exactly 100 and looks truncated.

The Solution

  • Fetches all category/tag pages before displaying terms.
  • Preserves successfully fetched pages if a later request fails.
  • Shows an error only when the first page fails.
  • Removes manual “Load more” UI and state.
  • Injects the I/O dispatcher for testability.
  • Adds focused tests covering full pagination and failure handling.

Testing

  • Login to the Jurassic Ninja site I DM'd you
  • Open the RS post list
  • Tap the overflow menu on a post
  • Select "Post settings"
  • Tap "Categories"

Verify:

  • More than 100 categories are present immediately.
  • There is no Load more row.
  • Scrolling reaches the complete category list.
  • Existing category selections remain checked.
  • Selecting or clearing categories and saving works normally.

@dangermattic

dangermattic commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@wpmobilebot

wpmobilebot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr23292-914e542
Build Number1498
Application IDcom.jetpack.android.prealpha
Commit914e542
Installation URL5und96ogg2vqg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr23292-914e542
Build Number1498
Application IDorg.wordpress.android.prealpha
Commit914e542
Installation URL1p9j8qjf4j2t0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

This comment was marked as resolved.

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 38.03%. Comparing base (b8157ff) to head (914e542).

Files with missing lines Patch % Lines
...android/ui/postsrs/terms/TermSelectionViewModel.kt 97.22% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #23292      +/-   ##
==========================================
+ Coverage   37.93%   38.03%   +0.10%     
==========================================
  Files        2352     2352              
  Lines      128925   128873      -52     
  Branches    17940    17934       -6     
==========================================
+ Hits        48907    49021     +114     
+ Misses      76012    75830     -182     
- Partials     4006     4022      +16     

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nbradbury
nbradbury marked this pull request as ready for review September 3, 2026 19:04
@nbradbury
nbradbury requested a lite review from Copilot September 3, 2026 19:04

This comment was marked as resolved.

@nbradbury
nbradbury marked this pull request as draft September 3, 2026 19:12
loadFirstPage() launched a fresh coroutine on every call — init, retry,
after creating a term, and after a debounced search — without cancelling
the previous one. Now that a load walks every page, two loads can easily
overlap: the newer one clears loadedTerms while the older one is still
suspended mid-fetch, and the older one then appends its remaining pages
into the list, mixing unfiltered terms into search results.

Track the load as a Job and cancel it at the top of loadFirstPage().
fetchAllPages only touches loadedTerms after resuming from withContext,
which throws CancellationException once the job is cancelled, so the
abandoned load can no longer publish. No onCleared() override is needed
— viewModelScope already cancels its children.
@nbradbury
nbradbury marked this pull request as ready for review September 3, 2026 21:38
@nbradbury
nbradbury requested a review from adalpari September 3, 2026 21:38
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.

5 participants