Skip to content

Remove updateSingleConnectedWpcomSite IPC handler#2823

Merged
epeicher merged 5 commits intotrunkfrom
stu-173-consider-removing-updatesingleconnectedwpcomsite-ipc-handler
Mar 17, 2026
Merged

Remove updateSingleConnectedWpcomSite IPC handler#2823
epeicher merged 5 commits intotrunkfrom
stu-173-consider-removing-updatesingleconnectedwpcomsite-ipc-handler

Conversation

@epeicher
Copy link
Contributor

@epeicher epeicher commented Mar 17, 2026

Related issues

How AI was used in this PR

AI was used to implement and verify the refactor. All changes were reviewed for correctness.

Proposed Changes

  • Remove the updateSingleConnectedWpcomSite IPC handler, which duplicated logic already present in updateConnectedWpcomSites
  • Update call sites in connected-sites.ts and use-listen-deep-link-connection.ts to use the bulk handler with the single site wrapped in an array
  • Remove the handler from IPC registration (ipc-handlers.ts), preload bridge (preload.ts), and test mocks
  • Restore lastPullTimestamp/lastPushTimestamp updates on push/pull success — these were accidentally dropped in Move pull and push states from SyncSitesProvider to a new Redux slice #2037 when push/pull states moved from SyncSitesProvider to a Redux slice. The useUpdateSiteTimestampMutation was left as dead code, never called from the new thunks.

Testing Instructions

  • Connect a local site to a WordPress.com site via the deep link flow and verify the connection persists after restart
  • Trigger a sync (pull/push) on an already-connected site and verify site details update correctly
  • After a successful push or pull, hover over the Push/Pull buttons and verify the tooltip shows the correct "last synced" timestamp (instead of "You have not pulled/pushed this site yet")
  • Open ~/Library/Application Support/Studio/appdata-v1.json and confirm lastPullTimestamp/lastPushTimestamp are set after sync
  • Disconnect and reconnect a site to exercise the full lifecycle
  • Check DevTools console for any IPC-related errors

Pre-merge Checklist

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

Replace all usages with the existing updateConnectedWpcomSites handler
by wrapping the single site in an array. This eliminates a redundant
IPC handler that duplicated logic already present in the bulk variant.
@epeicher epeicher self-assigned this Mar 17, 2026
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Mar 17, 2026

📊 Performance Test Results

Comparing e176572 vs trunk

app-size

Metric trunk e176572 Diff Change
App Size (Mac) 1236.36 MB 1236.40 MB +0.05 MB ⚪ 0.0%

site-editor

Metric trunk e176572 Diff Change
load 1897 ms 1898 ms +1 ms ⚪ 0.0%

site-startup

Metric trunk e176572 Diff Change
siteCreation 7157 ms 7141 ms 16 ms ⚪ 0.0%
siteStartup 3939 ms 3945 ms +6 ms ⚪ 0.0%

Results are median values from multiple test runs.

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

The updateSiteTimestamp calls were dropped in #2037 when push/pull
states moved from SyncSitesProvider to a Redux slice. Wire them back
up by dispatching the RTK Query mutation from the thunks.
@epeicher epeicher requested a review from a team March 17, 2026 10:07
…oving-updatesingleconnectedwpcomsite-ipc-handler
…oving-updatesingleconnectedwpcomsite-ipc-handler
Comment on lines +614 to +620
void dispatch(
connectedSitesApi.endpoints.updateSiteTimestamp.initiate( {
siteId: remoteSiteId,
localSiteId: selectedSiteId,
type: 'push',
} )
);
Copy link
Contributor

Choose a reason for hiding this comment

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

useUpdateSiteTimestampMutation doesn't appear to be used anywhere. I think it'd be better to call getIpcApi().updateConnectedWpcomSites directly here and remove the updateSiteTimestamp mutation altogether.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Removed the updateSiteTimestamp RTK Query mutation entirely and replaced it with a direct getIpcApi().updateConnectedWpcomSites() call from the thunks. Done as part of e176572.

Replace the RTK Query mutation with a plain async function that calls
getIpcApi().updateConnectedWpcomSites() directly from the thunks.
Await the timestamp write before invalidating the cache to avoid a
race where the re-fetch reads stale data.
Copy link
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

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

I tested the the deep link and also puling a new site. I confirm both worked and I saw the tooltip with latest pull timestamp.

@epeicher epeicher merged commit 3bc1aa9 into trunk Mar 17, 2026
11 checks passed
@epeicher epeicher deleted the stu-173-consider-removing-updatesingleconnectedwpcomsite-ipc-handler branch March 17, 2026 17:06
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.

4 participants