Skip to content

RS Post List: Bridge posts to FluxC for editor opening#22794

Merged
nbradbury merged 9 commits intotrunkfrom
issue/rspost-list-load-post
Apr 16, 2026
Merged

RS Post List: Bridge posts to FluxC for editor opening#22794
nbradbury merged 9 commits intotrunkfrom
issue/rspost-list-load-post

Conversation

@nbradbury
Copy link
Copy Markdown
Contributor

@nbradbury nbradbury commented Apr 15, 2026

Description

When a user taps a post in the RS post list, the editor loads the post from FluxC's local SQLite database. Since RS posts are fetched via wordpress-rs and never go through FluxC, the editor can't find them. This PR bridges the gap by:

  1. Fast path: Checking if FluxC already has the post (no network call)
  2. Slow path: Fetching the full post via wordpress-rs retrieveWithEditContext, mapping it to a FluxC PostModel, and inserting it into FluxC's DB
  3. Showing a loading indicator during the fetch

Testing instructions

Open post for editing:

  1. Clear storage then login
  2. Enable the the RS post list experimental feature
  3. Open the RS post list
  4. Tap a published post
  • Verify a brief loading indicator appears, then the editor opens with the post content
  1. Go back and tap the same post again
  • Verify the editor opens immediately (fast path, no loading indicator)

Offline:

  1. Turn off network connectivity
  2. Tap a post that hasn't been cached
  • Verify an error snackbar appears

When a user taps a post in the RS post list, the editor needs the post
in FluxC's local database. This adds a bridge that fetches the post via
wordpress-rs, maps it to a PostModel, and inserts it into FluxC's DB
before opening the editor. Includes a fast path that skips the network
call when FluxC already has the post cached.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dangermattic
Copy link
Copy Markdown
Collaborator

dangermattic commented Apr 15, 2026

3 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ Class PostRsToFluxCMapper is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented Apr 15, 2026

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
Versionpr22794-8ab1604
Build Number1488
Application IDorg.wordpress.android.prealpha
Commit8ab1604
Installation URL7n1o0crulrtf0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented Apr 15, 2026

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
Versionpr22794-8ab1604
Build Number1488
Application IDcom.jetpack.android.prealpha
Commit8ab1604
Installation URL76q3fo1s39veg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

- Remove unused PostModel import
- Extract bridgePostOrNull() from moveToDraftAndEdit() to reduce line count
- Suppress CyclomaticComplexMethod on PostRsListScreen composable

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 11.46497% with 139 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.29%. Comparing base (d769205) to head (8ab1604).
⚠️ Report is 2 commits behind head on trunk.

Files with missing lines Patch % Lines
...ordpress/android/ui/postsrs/PostRsToFluxCMapper.kt 0.00% 60 Missing ⚠️
...ordpress/android/ui/postsrs/PostRsListViewModel.kt 30.90% 34 Missing and 4 partials ⚠️
.../wordpress/android/ui/postsrs/PostRsFluxCBridge.kt 3.84% 25 Missing ⚠️
...ess/android/ui/postsrs/screens/PostRsListScreen.kt 0.00% 13 Missing ⚠️
.../wordpress/android/ui/postsrs/PostRsListUiState.kt 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #22794      +/-   ##
==========================================
- Coverage   37.31%   37.29%   -0.03%     
==========================================
  Files        2324     2326       +2     
  Lines      124714   124849     +135     
  Branches    16922    16961      +39     
==========================================
+ Hits        46542    46563      +21     
- Misses      74418    74514      +96     
- Partials     3754     3772      +18     

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

nbradbury and others added 2 commits April 15, 2026 10:04
The custom exception type was never used for branching — all callers
catch generic Exception. Use the standard IllegalStateException instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The class is stateless so the default unscoped binding is fine.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wpmobilebot

This comment was marked as resolved.

Use PostRsRestClient.fetchTermNames() to look up tag names from
tag IDs so posts opened via wordpress-rs show their tags in the
editor. Also replace throw IllegalStateException with error() in
PostRsFluxCBridge to satisfy detekt UseCheckOrError rule.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nbradbury nbradbury marked this pull request as ready for review April 15, 2026 18:53
@nbradbury nbradbury requested review from adalpari and jkmassel April 15, 2026 18:53
@adalpari
Copy link
Copy Markdown
Contributor

I tested the changes, and when loading a post, I can tap on another one, and both are opened. Is that expected?

On the other hand, Claude highlighted this one:

  1. getPostByRemotePostId returns cached stale content. Fast path in PostRsFluxCBridge.kt:38-40 never checks freshness. If the RS list
    has a newer modifiedGmt than the FluxC row, the editor opens stale content. Consider comparing modifiedGmt against the FluxC row's
    remoteLastModified before short-circuiting (you already have modifiedGmt on the list item).

nbradbury and others added 3 commits April 16, 2026 08:15
Add an early return in openPost() when _isOpeningPost is already true,
so a second tap while the first post is still loading is ignored.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Thread lastModified from the RS list UI model through to the bridge so
it can compare against the cached FluxC row's remoteLastModified. When
they differ the fast path is skipped and the post is re-fetched.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The CircularProgressIndicator overlay did not block taps, so users
could interact with the list underneath while a post was loading.
Add a no-op clickable modifier so the overlay consumes all touches.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nbradbury
Copy link
Copy Markdown
Contributor Author

when loading a post, I can tap on another one, and both are opened. Is that expected?

Good catch, fixed in 7a31d50.

getPostByRemotePostId returns cached stale content

Oof, that's one I should've thought about. Resolved in edbef0d.

Copy link
Copy Markdown
Contributor

@adalpari adalpari left a comment

Choose a reason for hiding this comment

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

LGTM! :shipit:

@nbradbury nbradbury merged commit b3c3cbb into trunk Apr 16, 2026
23 of 24 checks passed
@nbradbury nbradbury deleted the issue/rspost-list-load-post branch April 16, 2026 13:27
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