Skip to content

RS Post Settings: Performance improvements#22685

Open
nbradbury wants to merge 17 commits intotrunkfrom
feature/rsposts-settings-performance
Open

RS Post Settings: Performance improvements#22685
nbradbury wants to merge 17 commits intotrunkfrom
feature/rsposts-settings-performance

Conversation

@nbradbury
Copy link
Contributor

@nbradbury nbradbury commented Mar 12, 2026

Description

On self-hosted sites, a new WpApiClient was created for every API call — 5 client instantiations just to open the settings screen (1 post fetch + 4 async field resolutions). Now WpApiClientProvider caches self-hosted clients the same way it already caches WP.com clients, and the ViewModel reuses a single lazy client. This reduces self-hosted load time from 5 client creations to 1.

This PR also adds a shimmer effect when loading post settings, improving upon the simple progress spinner we used previously.

Testing instructions

  1. Run trunk with a content-heavy self-hosted site (provided via DM)
  • Verify RS post settings load slowly
  1. Run this branch with the same site
  • Verify RS post settings load noticeably faster than before
  • Verify a shimmer effect appears while loading
content-heavy.mp4

nbradbury and others added 12 commits March 12, 2026 06:58
Replace Toast with Compose Snackbar for inline error messages with retry
actions, add pull-to-refresh support, show "Saving..." label alongside
the spinner, display "Not Set" placeholder for empty status, and improve
accessibility with content descriptions for password toggle and featured
image placeholder. Extract shared error utilities from PostRsListViewModel
into PostRsErrorUtils for reuse across both list and settings screens.
Add unit tests for PostRsSettingsViewModel.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Preserve unsaved edits when refreshing post from server
- Remove unreachable snackbar when site is null (activity finishes immediately)
- Fix PullToRefreshBox content indentation
- Remove redundant offline mocks in refresh tests
- Rename misleading test name for status selection
- Add test for save-online sets isSaving

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract preserveEdits() helper to shorten refreshPost() below the
60-line detekt limit, and remove empty line after opening brace in
test class.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add navigationBarsPadding to SnackbarHost so snackbars aren't
obscured by the system navigation bar. Wrap ErrorContent in a
centered Box so the error message displays in the center of the
screen instead of at the top.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add fillMaxWidth and TextAlign.Center to the ErrorContent on the
term selection screen so the network error message is properly
centered horizontally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The network error snackbar shown when saving in airplane mode was
missing an actionLabel and onAction callback, so no Retry button
appeared. Add both so the user can retry saving after reconnecting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Set the snackbar action color to MaterialTheme.colorScheme.primary
so the Retry text on snackbars matches the primary color used by
the Retry button on the error empty state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…race condition

When disabling airplane mode and immediately tapping Retry, Android may not
have re-established connectivity yet, causing a spurious network error. Now
the save always proceeds to the API call, which handles network errors
naturally via its catch block using PostRsErrorUtils.friendlyErrorMessage().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use BackHandler(onBack=) instead of wrapping lambda
- Use ?.let { } ?: Modifier for conditional click modifiers
- Replace PostApiException with RuntimeException
- Inline isAuthError wrapper in PostRsListViewModel
- Remove status bar hiding to fix PTR triggering on system bar pull

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace RuntimeException with PostApiRequestException to fix
TooGenericExceptionThrown detekt violations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On self-hosted sites, a new WpApiClient was created for every API call
(5 instantiations just to open post settings). Cache self-hosted clients
in WpApiClientProvider (mirroring the existing WP.com pattern), add a
per-site client cache in PostRsRestClient, and use a lazy property in
PostRsSettingsViewModel to reuse the same client across fetch and save.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Now that WpApiClientProvider caches self-hosted clients, the per-site
client cache in PostRsRestClient is redundant — remove it. Also remove
the now-unused site parameters from fetchPost() and savePost() in the
ViewModel, and replace shadowed locals with simple null guards.

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

dangermattic commented Mar 12, 2026

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@nbradbury nbradbury changed the base branch from trunk to feature/rsposts-settings-polish March 12, 2026 17:48
@nbradbury nbradbury changed the title RS Post Settings: Performance and polish improvements RS Post Settings: Performance improvements Mar 12, 2026
nbradbury and others added 2 commits March 12, 2026 13:59
…eption, remove unused methods

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

wpmobilebot commented Mar 12, 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
Versionpr22685-78ec06d
Build Number1487
Application IDcom.jetpack.android.prealpha
Commit78ec06d
Installation URL3hdh4iulvjtjo
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 12, 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
Versionpr22685-78ec06d
Build Number1487
Application IDorg.wordpress.android.prealpha
Commit78ec06d
Installation URL7s5t749d0rul8
Note: Google Login is not supported on these builds.

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 2.24719% with 87 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.61%. Comparing base (6ad0a42) to head (78ec06d).

Files with missing lines Patch % Lines
...android/ui/postsrs/screens/PostRsSettingsScreen.kt 0.00% 60 Missing ⚠️
...fluxc/network/rest/wpapi/rs/WpApiClientProvider.kt 0.00% 18 Missing ⚠️
...ress/android/ui/postsrs/PostRsSettingsViewModel.kt 18.18% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #22685      +/-   ##
==========================================
- Coverage   37.63%   37.61%   -0.02%     
==========================================
  Files        2272     2272              
  Lines      118333   118381      +48     
  Branches    16363    16367       +4     
==========================================
+ Hits        44530    44531       +1     
- Misses      70150    70200      +50     
+ Partials     3653     3650       -3     

☔ 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 nbradbury requested review from adalpari and removed request for adalpari March 12, 2026 21:08
Base automatically changed from feature/rsposts-settings-polish to trunk March 13, 2026 11:14
nbradbury and others added 3 commits March 13, 2026 07:28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Show hero image shimmer and placeholder rows while loading instead
of a titled app bar with a centered spinner.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract shared HeroOverlay composable to deduplicate gradient
  and back button between loading skeleton and hero layout
- Inline statusResId variable
- Remove unreachable site null guards in ViewModel
- Remove extra blank line in WpApiClientProvider

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

@nbradbury nbradbury marked this pull request as ready for review March 13, 2026 13:06
@nbradbury nbradbury requested a review from adalpari March 13, 2026 13:06
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.

3 participants