Skip to content

Refactor deep link connection handling and connectSite mutation#2665

Open
epeicher wants to merge 3 commits intotrunkfrom
stu-1086-refactor-connectsite-mutation-and
Open

Refactor deep link connection handling and connectSite mutation#2665
epeicher wants to merge 3 commits intotrunkfrom
stu-1086-refactor-connectsite-mutation-and

Conversation

@epeicher
Copy link
Contributor

@epeicher epeicher commented Feb 25, 2026

Related issues

Proposed Changes

  • Simplified the useListenDeepLinkConnection hook by removing unnecessary queries and directly using the connectSite function with updated parameters.
  • Updated the handleConnect function in ContentTabSync to accept remoteSiteId instead of a full site object, streamlining the connection process.
  • Enhanced the connectSite mutation in the Redux slice to handle remote site connections more effectively, including error handling for site not found scenarios.

Testing Instructions

Connect a site via the Sync tab

  • Select a local site, go to the Sync tab, connect a WordPress.com site, and verify it connects successfully.

Deep link connection

  • Trigger a deep link connection (e.g., via WordPress.com "Connect to Studio" flow). Verify the correct local site is selected, the Sync tab opens, and the site connects. One example could be: wp-studio://sync-connect-site?studioSiteId=<local_studio_id>&remoteSiteId=<remote_blog_id>

Deep link with auto-open push

  • Create a Studio site or open one that is not connected to WP.com, select Publish site, and follow the process to create the site
  • Click on Open in Studio
  • Verify that the Sync modal open as expected.

Add a new connected site

  • Click Add Site
  • Choose Connect to a WordPress.com site and select a remote site
  • Fill in the site name and create the site
  • Verify the new local site is created and it starts pulling from the remote site (you should see the Sync tab activate with a pull in progress)

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

- Simplified the `useListenDeepLinkConnection` hook by removing unnecessary queries and directly using the `connectSite` function with updated parameters.
- Updated the `handleConnect` function in `ContentTabSync` to accept `remoteSiteId` instead of a full site object, streamlining the connection process.
- Enhanced the `connectSite` mutation in the Redux slice to handle remote site connections more effectively, including error handling for site not found scenarios.
@epeicher epeicher self-assigned this Feb 25, 2026
@epeicher epeicher requested a review from a team February 25, 2026 17:37
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Feb 25, 2026

📊 Performance Test Results

Comparing df3ea3a vs trunk

site-editor

Metric trunk df3ea3a Diff Change
load 1486.00 ms 1479.00 ms -7.00 ms ⚪ 0.0%

site-startup

Metric trunk df3ea3a Diff Change
siteCreation 7092.00 ms 7085.00 ms -7.00 ms ⚪ 0.0%
siteStartup 4948.00 ms 4909.00 ms -39.00 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@katinthehatsite
Copy link
Contributor

One this is that we might want to double-check this with https://github.com/Automattic/studio/pull/2375/commits as they are likely going to overlap 😅

@katinthehatsite
Copy link
Contributor

Also, perhaps this PR already solves the issue from the other PR - I will give it a test now 👀

Copy link
Contributor

@katinthehatsite katinthehatsite left a comment

Choose a reason for hiding this comment

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

I did not finish testing everything yet but I noticed that there is a small delay for me when I click on Connect site or Connect another site:

Screen.Recording.2026-02-26.at.11.18.18.AM.mov

Initially, I thought that it was not connecting so I clicked multiple times before seeing it connect. In the second try, I click and waited and then it connected. I think if we have the small delay, we should probably set the Connect button to loading state to indicate to the user that the connection is happening.

setSelectedRemoteSite( selectedSiteFromList );
} else {
await handleConnect( selectedSiteFromList );
await handleConnect( siteId );
Copy link
Contributor

Choose a reason for hiding this comment

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

There are two more calls for handleConnect in this file in onPull and onPush - do we also need to adjust passing an id there now that it expects a number?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well spotted! That code might be called when using deeplinks and it needed to be updated accordingly! Done as part of f78b4fd

…bject

The onPush and onPull callbacks were passing the full SyncSite object
to handleConnect, which expects a number (remoteSiteId). This caused
the connectSite mutation to silently fail when matching by ID.
@epeicher
Copy link
Contributor Author

One this is that we might want to double-check this with https://github.com/Automattic/studio/pull/2375/commits as they are likely going to overlap 😅

Ok, this can wait for that PR to be merged, this PR is not urgent as it is a refactor

@epeicher
Copy link
Contributor Author

I think if we have the small delay, we should probably set the Connect button to loading state to indicate to the user that the connection is happening.

Absolutely, that will improve the UX. I will compare also with trunk and check if there are differences, but anyway, adding a loading state will prevent confusion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants