Skip to content

Replace site-settings snackbar with My Site connectivity banner#22834

Open
jkmassel wants to merge 1 commit into
trunkfrom
jkmassel/site-offline-banner
Open

Replace site-settings snackbar with My Site connectivity banner#22834
jkmassel wants to merge 1 commit into
trunkfrom
jkmassel/site-offline-banner

Conversation

@jkmassel
Copy link
Copy Markdown
Contributor

@jkmassel jkmassel commented May 4, 2026

Description

Follow-up to #22785 (review feedback from @nbradbury). The snackbar from a failed editor capabilities fetch is non-actionable and disappears, leaving the user with no way to recover. On a cold launch with flaky network, it pops up before the user has done anything.

This PR moves the fetch into a new SiteConnectivityBannerViewModelSlice that posts a persistent SingleActionCard banner into the My Site header (last position, below the reauth banner) when the fetch fails AND there's no cache. Tapping the banner retries the fetch (bypassing the per-session dedup). Successful fetch — or a cached value — clears the banner.

The banner copy is generic — "Unable to connect to your site. Some functionality might be limited." — because the apiRoot fetch failure signals broader site reachability problems, not just editor issues.

Why a slice?

MySiteViewModel already carries LargeClass/LongMethod/LongParameterList suppressions. The fetch is logically self-contained (takes a SiteModel, posts a card or null), so it makes sense to extract. The slice owns the per-site session dedup that #22833 introduced inline — same behavior, dedicated home, dedicated tests.

Testing instructions

Covered by 9 new unit tests in SiteConnectivityBannerViewModelSliceTest:

  • Fetch succeeds → banner null
  • Fetch fails with no cache → banner shown
  • Fetch fails with cached value → banner null (silent)
  • Background dedup after success
  • Background retry after failure (no dedup until success)
  • User-initiated bypasses dedup
  • Banner retry tap bypasses dedup and clears banner on success
  • clearBanner() clears
  • Two different sites → both fetch (no cross-site dedup)

Manual:

  1. Put the device in airplane mode and cold-launch the app (without any saved data – you'll probably have to delete and re-install it), then go to My Site.
  • Verify the connectivity banner appears at the top of My Site (below the site header, below the reauth banner if present).
  • Verify there is no snackbar.
  1. Re-enable connectivity and tap the banner.
  • Verify the fetch runs and the banner disappears on success.
  1. Background the app and reopen with a working network.
  • Verify the banner does not appear.
  1. With a site that has cached capabilities, simulate a network failure on the next fetch.
  • Verify the banner does NOT appear (silent failure when we have data).

Related

@dangermattic
Copy link
Copy Markdown
Collaborator

dangermattic commented May 4, 2026

1 Warning
⚠️ This PR is assigned to the milestone 26.8. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented May 4, 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
Versionpr22834-ac1833c
Build Number1488
Application IDcom.jetpack.android.prealpha
Commitac1833c
Installation URL5k5ibp6iugcb8
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 May 4, 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
Versionpr22834-ac1833c
Build Number1488
Application IDorg.wordpress.android.prealpha
Commitac1833c
Installation URL0gfphu7e70vqg
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

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

@jkmassel jkmassel force-pushed the jkmassel/pr-22785-followups branch from 17973a8 to 5d99212 Compare May 4, 2026 19:54
@jkmassel jkmassel force-pushed the jkmassel/pr-22785-followups branch from 5d99212 to 873cc18 Compare May 13, 2026 18:37
Base automatically changed from jkmassel/pr-22785-followups to trunk May 13, 2026 18:53
@jkmassel jkmassel force-pushed the jkmassel/site-offline-banner branch from 84c2e15 to 10236eb Compare May 20, 2026 19:31
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.32%. Comparing base (0a2a007) to head (ac1833c).

Files with missing lines Patch % Lines
...nnectivity/SiteConnectivityBannerViewModelSlice.kt 89.28% 0 Missing and 3 partials ⚠️
...org/wordpress/android/ui/mysite/MySiteViewModel.kt 91.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #22834   +/-   ##
=======================================
  Coverage   37.31%   37.32%           
=======================================
  Files        2319     2320    +1     
  Lines      124558   124571   +13     
  Branches    16920    16924    +4     
=======================================
+ Hits        46484    46496   +12     
+ Misses      74319    74315    -4     
- Partials     3755     3760    +5     

☔ 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.

@jkmassel jkmassel force-pushed the jkmassel/site-offline-banner branch 2 times, most recently from 30db3cf to 185341e Compare May 20, 2026 22:19
@jkmassel jkmassel marked this pull request as ready for review May 21, 2026 00:39
@jkmassel jkmassel requested a review from nbradbury May 21, 2026 00:39
@jkmassel jkmassel self-assigned this May 21, 2026
@jkmassel jkmassel force-pushed the jkmassel/site-offline-banner branch from 185341e to 2d6b663 Compare May 21, 2026 00:39
@jkmassel jkmassel added this to the 26.8 milestone May 21, 2026
Follow-up to #22785. The snackbar from a failed editor capabilities fetch
is non-actionable and disappears, leaving the user with no way to recover.
On a cold launch with flaky network, it pops up before the user has done
anything.

Move the fetch into a new SiteConnectivityBannerViewModelSlice that posts
a persistent SingleActionCard banner into the My Site header (last
position, below the reauth banner) when the fetch fails AND there's no
cache. Tapping the banner retries the fetch (bypassing the per-session
dedup). Successful fetch — or a cached value — clears the banner.

The slice cancels the in-flight fetch on site switch and on each new
fetchCapabilities call, and discards results whose site no longer matches
the active selection — postValue isn't a suspension point, so cancellation
alone won't catch a fetch that has already returned but not yet posted.

Banner taps are no-ops while a retry is in flight, so rapid tapping
doesn't queue concurrent network calls.
@nbradbury
Copy link
Copy Markdown
Contributor

nbradbury commented May 21, 2026

@jkmassel This is an improvement, but if I enable airplane mode immediately after logging in, I see three separate warnings about connectivity.

Is there any way we can reduce the number of warnings? Perhaps skip showing the slice when the problem is lack of connectivity, since we know the "No connection" banner will appear.

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