Skip to content

Jetpack REST connection: connect site and user #22126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 58 commits into from
Aug 18, 2025

Conversation

nbradbury
Copy link
Contributor

@nbradbury nbradbury commented Aug 13, 2025

This PR adds the "connect site" and "connect user" steps to the Jetpack REST connection flow.

To test

  • Make sure the application passwords and Jetpack REST connection experimental features are enabled
  • Switch to a self-hosted site that doesn't have Jetpack installed
  • My Site > Stats
  • Tap "Install Jetpack"
  • Tap Start
  • After the Jetpack plugin installation succeeds, verify that the "Connect site to WordPress.com" and "Connect user to WordPress.com" steps complete

Note: The connection flow will then appear stuck on the "Finalize setup" step. This will be addressed in a separate PR.

Screen_recording_20250813_153323.mp4

nbradbury and others added 30 commits August 12, 2025 08:03
@dangermattic
Copy link
Collaborator

dangermattic commented Aug 13, 2025

5 Warnings
⚠️ strings.xml files should only be updated on release branches, when the translations are downloaded by our automation.
⚠️ Class JetpackConnectionHelper is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class InvalidAuthNotifier is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class JetpackConnector 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
Contributor

wpmobilebot commented Aug 13, 2025

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr22126-6185c2d
Commit6185c2d
Direct Downloadwordpress-prototype-build-pr22126-6185c2d.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Aug 13, 2025

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr22126-6185c2d
Commit6185c2d
Direct Downloadjetpack-prototype-build-pr22126-6185c2d.apk
Note: Google Login is not supported on these builds.

@nbradbury nbradbury requested a review from Copilot August 13, 2025 19:56
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the "connect site" and "connect user" steps in the Jetpack REST connection flow for the WordPress Android app. The changes enable automatic site connection to WordPress.com and user authentication through the Jetpack plugin installation process.

Key changes:

  • Added actual implementation for Jetpack plugin installation and site/user connection steps
  • Created new helper classes (JetpackInstaller, JetpackConnector, JetpackConnectionHelper) to handle the connection logic
  • Updated UI strings and error handling to reflect the new connection flow

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
strings.xml Updated step labels and added new error messages for connection failures
JetpackRestConnectionViewModel.kt Implemented actual connection logic replacing placeholder code, added new dependencies and error types
JetpackRestConnectionScreen.kt Updated UI to reflect renamed connection steps and new error types
JetpackInstaller.kt New class implementing Jetpack plugin installation using wordpress-rs API
JetpackConnector.kt New class handling site and user connection to WordPress.com
JetpackConnectionHelper.kt New helper class for initializing API clients with authentication

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

…-Android into feature/jetpack-connect-site-and-user

Conflicts:
	WordPress/src/main/java/org/wordpress/android/ui/jetpackrestconnection/JetpackInstaller.kt
	WordPress/src/main/java/org/wordpress/android/ui/jetpackrestconnection/JetpackRestConnectionScreen.kt
	WordPress/src/main/java/org/wordpress/android/ui/jetpackrestconnection/JetpackRestConnectionViewModel.kt
	WordPress/src/main/res/values/strings.xml
@nbradbury nbradbury requested a review from adalpari August 14, 2025 11:47
@nbradbury nbradbury marked this pull request as ready for review August 14, 2025 11:47
@nbradbury nbradbury requested a review from Copilot August 14, 2025 11:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Comment on lines +20 to +26
fun initWpApiClient(site: SiteModel): WpApiClient {
requireRestCredentials(site)
return WpApiClient(
wpOrgSiteApiRootUrl = URL(resolveRestApiUrl(site)),
authProvider = createRestAuthProvider(site)
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ I know I have already mentioned this, but what about keeping all the WpApiClient creations inside the WpApiClientProviderso the maintenante is clearer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, this is already a task on the Linear project. I'll DM you the project link.

Copy link
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 and works as expected!
just left a minor comment

@nbradbury nbradbury merged commit 763ed78 into trunk Aug 18, 2025
27 checks passed
@nbradbury nbradbury deleted the feature/jetpack-connect-site-and-user branch August 18, 2025 12:56
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