Skip to content

Connection: Transfer ownership without leaving the site - #53359

Merged
fgiannar merged 32 commits into
trunkfrom
add/cnx-ownership-transfer
Oct 13, 2026
Merged

fgiannar merged 32 commits into
trunkfrom
add/cnx-ownership-transfer

Conversation

@fgiannar

@fgiannar fgiannar commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Related to CONNECT-480

Proposed changes

Changing the connection owner currently means leaving the site for Calypso. This adds the in-product transfer flow and points both connection dialogs at it.

  • New endpoint: GET jetpack/v4/connection/owner/candidates lists the connected administrators POST /connection/owner would accept — filtered by the same administrator capability Manager::update_connection_owner() requires, with the current owner left out, so the UI can't offer somebody the change would then refuse. Local user data only; resolving WordPress.com profiles would cost a request per user. Gated on jetpack_disconnect, the same capability as changing the owner.
  • fetchConnectionOwnerCandidates() and setConnectionOwner() in js-packages/api.
  • New <TransferConnectionOwnership> component carrying the whole flow — choose an administrator, confirm what moves with ownership, then a success step the surface dismisses.
  • Manage connection dialog: "Transfer ownership to another admin" swaps the dialog's own content for the flow — one modal with two views, rather than linking out to Calypso or stacking a second modal on top.
  • Owner disconnect dialog: the same card, handing the user to that same view rather than running a second copy of the flow. Its Calypso link and the "View other connected accounts" card are gone.

Three cases it handles rather than failing generically:

  • Each refusal code gets its own message — ownership_locked, new_owner_not_admin, new_owner_not_connected, new_owner_is_existing_owner. The list is built when the dialog opens, so a candidate can stop qualifying while it's on screen.
  • No other connected administrator shows a warning notice explaining what's needed, instead of an empty list under a dead button.
  • A protected owner is told the transfer stops protected-owner features until the new owner confirms, and the action reads "Transfer anyway".

Two smaller behaviour fixes that came out of testing:

  • No page reload. The connection store held the owner and isMaster from page load and had no way to update them — both reducers handled no action at all — so the only way a surface learned about a transfer was reloading. A setConnectionOwner action now records it, patched from the transfer rather than refetched: nothing else in the user connection data turns on ownership, so a request would only confirm what we already know. Surfaces reading connection state update in place.
  • The owner-disconnect warning now says disconnecting "without choosing a new owner" removes everyone, which is the condition that makes it true.

Separation of concerns

TransferConnectionOwnership renders no chrome of its own — no modal, no heading, no way out. It draws only what its steps need: Continue, Back between steps, and the transfer itself. Everything else belongs to the surface hosting it, which is what lets the same component serve the manage dialog now and the Connectors card next.

Owns
TransferConnectionOwnership the steps, the candidate list, the transfer request, and updating the store
ManageConnectionDialog the modal, the heading, which view is showing, and the single exit

The component having no Cancel, Close or Done falls out of that rather than being a separate decision: each is a way of leaving a container the component doesn't own. Its only prop beyond apiRoot/apiNonce is onTransferred, for a host that needs to do something extra once ownership has moved — not to make it work.

Where this departs from the mockups

  • The chooser is a select, not a card per administrator. The radio cards only work while there are three or four; a site can have many more.
  • One heading for the whole flow, "Transfer connection ownership", rather than B2's "Make Kazz the connection owner?" and the success screen's "Ownership transferred". The dialog owns its heading and swaps it per view, not per step.
  • No Done button on the success step. Done is the chrome of whatever contains the flow, not part of it — outside a modal there is nothing for it to dismiss. The dialog's own footer is the exit.
  • Initials badges, and the page fetches no avatars at all. The mockups' badges are initials, and so are these — black for the outgoing owner, --jp-pink for the incoming one. Avatars were tried and dropped: script data carries no avatar for the outgoing owner, so one badge could only ever be initials while the other fetched a Gravatar, which is a guaranteed mismatch. The endpoint no longer returns an avatar URL, so nothing is requested from Gravatar.

Not included, per the issue's scope: the Connectors card itself (blocked on CONNECT-478), gating owner disconnect on transfer (CONNECT-486), and the legacy Connection_Notice form on users.php.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No. No new tracking events. The new endpoint returns local user data (ID, login, display name, email) that an administrator can already read from users.php, and only to a user with jetpack_disconnect. Nothing is fetched from a third party — the badges are initials, not Gravatars.
Screenshot 2026-10-12 at 08 52 29

Testing instructions

Needs a site with at least two administrators who have both connected their WordPress.com accounts, logged in as the connection owner.

The transfer itself

  • Go to My Jetpack → Connection → Manage connection.
Screenshot 2026-10-12 at 08 52 29
  • Click Transfer ownership to another admin. It should open a step inside the dialog rather than navigating to WordPress.com.
Screenshot 2026-10-12 at 10 08 25
  • Pick an administrator from the select, click Continue. Check the confirm step names the right person and lists what changes.
Screenshot 2026-10-12 at 08 52 56
  • Click Back — you should return to the chooser with nothing transferred.
  • Continue → Transfer ownership. You should get the success step, then Close closes the dialog while the card correctly reflects the ownership update.
Screenshot 2026-10-12 at 08 53 09
  • Confirm the new owner on users.php (the Connected to WordPress.com column) and that the manage dialog no longer offers you owner-only actions.

One dialog, one exit, and no reload

  • While the step is open, check there is no second modal behind it — the heading changes and the action list is replaced, in the dialog that was already open.
  • The footer keeps Need help? throughout, and its button is the dialog's only exit: Cancel while choosing or confirming, Close once ownership has moved. Escape, clicking outside and a ✕ all do nothing — the manage dialog disables them by design. Update: Escape and click-outside now work once ownership has moved
  • On the confirm step, Back appears once, in the step, and moves back to the chooser. The footer never says Back: it leaves the dialog rather than the step.
  • The page must not reload at any point. After pressing Close, the dialog shuts and the page stays as it was.
  • Reopen Manage connection: it should show the action list — not the step you were last on — and Transfer ownership to another admin should be gone, because you are no longer the owner. That is the store update rather than a refresh.

From the owner disconnect warning

Screenshot 2026-10-08 at 15 05 24
  • As the owner, open Manage connection → Disconnect my user account.
  • The warning should offer Transfer ownership to another admin as a card. Clicking it closes the warning and returns you to the manage dialog showing the transfer step.
  • Check the copy reads "Disconnecting the owner account without choosing a new owner will remove the Jetpack connection for all users on this site."

No other connected administrators

Screenshot 2026-10-08 at 15 06 44
  • On a site where you're the only connected admin, open the transfer step.
  • You should get a warning notice — "No other connected administrators" — the only control there is the footer's Cancel, which closes the dialog.

Refusal messages

  • With the confirm step open, make the chosen candidate stop qualifying in another tab (demote them to Editor, or disconnect their WordPress.com account), then click Transfer ownership.
  • You should get a specific message — "That user is no longer an administrator…" or "That user is no longer connected to WordPress.com…" — not a generic failure.

Protected owner,

  • Set up the protected owner via: wp eval 'var_export( Automattic\Jetpack\Connection\Protected_Owner::set( WPCOM_ID, LOCAL_ID ) );'
  • On a site where you're the protected owner, the confirm step should carry a warning that protected-owner features stop until the new owner confirms, an extra bullet saying they need to confirm, and a Transfer anyway button.
Screenshot 2026-10-12 at 10 11 12

Non-owner admin

  • Logged in as an administrator who isn't the connection owner, the manage dialog should not offer the transfer card at all.

Error states

Screenshot 2026-10-12 at 10 08 51

Both need a snippet in a mu-plugin (wp-content/mu-plugins/), removed afterwards.

  • Ownership locked. add_filter( 'jetpack_connection_ownership_transferable', '__return_false' );
    Transfer from the confirm step: you should get "Ownership of this connection is locked and cannot be transferred."
    -- Note the filter is currently being deprecated, however you can still test with it atm.

  • WordPress.com refuses the change. Make the outbound call fail:

add_filter( 'pre_http_request', function ( $pre, $args, $url ) {
	return false !== strpos( $url, 'wordpress.com' )
		? new WP_Error( 'http_request_failed', 'Simulated failure' )
		: $pre;
}, 10, 3 );

Transfer from the confirm step: you should get "Could not confirm new owner." and stay on the confirm step so you can retry. Then check users.php — the owner must be unchanged. update_connection_owner() notifies WordPress.com first and only writes master_user on success, so a partial failure has to leave the old owner in place.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the add/cnx-ownership-transfer branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/cnx-ownership-transfer
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/cnx-ownership-transfer

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [JS Package] API [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Stats Data [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Tests] Includes Tests RNA labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Backup plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Boost plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Search plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Social plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Protect plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Videopress plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Stats Data plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control

jp-launch-control Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 6 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/js-packages/api/index.jsx 25/144 (17.36%) -0.24% 2 ❤️‍🩹
projects/js-packages/connection/components/manage-connection-dialog/index.tsx 64/67 (95.52%) -2.26% 2 ❤️‍🩹
projects/packages/connection/src/class-rest-connector.php 688/734 (93.73%) 0.14% 1 ❤️‍🩹
projects/js-packages/connection/components/owner-disconnect-dialog/index.tsx 23/23 (100.00%) 0.00% 0 💚
projects/js-packages/connection/state/actions.jsx 53/66 (80.30%) 0.94% 0 💚

7 files are newly checked for coverage. Only the first 5 are listed here.

File Coverage
projects/js-packages/connection/components/transfer-connection-ownership/use-ownership-transfer.ts 55/59 (93.22%) 💚
projects/js-packages/connection/components/transfer-connection-ownership/candidate-identity.tsx 6/6 (100.00%) 💚
projects/js-packages/connection/components/transfer-connection-ownership/candidate-list.tsx 14/14 (100.00%) 💚
projects/js-packages/connection/components/transfer-connection-ownership/confirm-step.tsx 3/3 (100.00%) 💚
projects/js-packages/connection/components/transfer-connection-ownership/done-step.tsx 2/2 (100.00%) 💚

Full summary · PHP report · JS report

@fgiannar fgiannar changed the title Add/cnx ownership transfer Connection: Transfer ownership without leaving the site Oct 9, 2026
@fgiannar fgiannar added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Oct 9, 2026
@fgiannar
fgiannar requested a balanced review from Copilot October 9, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Optional-action handling, error accessibility, and documented navigation behavior remain inconsistent.

5 open findings
What changed in this PR

Adds an in-product connection ownership transfer flow, replacing redirects to WordPress.com.

Changes:

  • Adds the candidate REST endpoint and JavaScript API methods.
  • Adds and integrates the transfer workflow into connection dialogs.
  • Adds tests, styling, and user-facing changelogs.
File Description
projects/​plugins/​videopress/​changelog/​add-cnx-ownership-transfer Adds VideoPress release note.
projects/​plugins/​stats/​changelog/​add-cnx-ownership-transfer Adds Stats release note.
projects/​plugins/​social/​changelog/​add-cnx-ownership-transfer Adds Social release note.
projects/​plugins/​search/​changelog/​add-cnx-ownership-transfer Adds Search release note.
projects/​plugins/​protect/​changelog/​add-cnx-ownership-transfer Adds Protect release note.
projects/​plugins/​jetpack/​changelog/​add-cnx-ownership-transfer Adds Jetpack release note.
projects/​plugins/​boost/​changelog/​add-cnx-ownership-transfer Adds Boost release note.
projects/​plugins/​backup/​changelog/​add-cnx-ownership-transfer Adds Backup release note.
projects/​packages/​connection/​tests/​php/​REST_Endpoints_Test.php Tests candidate filtering and authorization.
projects/​packages/​connection/​src/​class-rest-connector.php Implements the candidate endpoint.
projects/​packages/​connection/​changelog/​add-cnx-ownership-transfer Documents the endpoint.
projects/​js-packages/​connection/​index.jsx Exports the transfer component and type.
projects/​js-packages/​connection/​components/​transfer-connection-ownership/​use-ownership-transfer.ts Manages transfer state and requests.
projects/​js-packages/​connection/​components/​transfer-connection-ownership/​types.ts Defines candidate data.
projects/​js-packages/​connection/​components/​transfer-connection-ownership/​test/​component.tsx Tests transfer behavior and errors.
projects/​js-packages/​connection/​components/​transfer-connection-ownership/​style.scss Styles the transfer workflow.
projects/​js-packages/​connection/​components/​transfer-connection-ownership/​index.tsx Composes transfer steps and actions.
projects/​js-packages/​connection/​components/​transfer-connection-ownership/​done-step.tsx Renders transfer confirmation.
projects/​js-packages/​connection/​components/​transfer-connection-ownership/​confirm-step.tsx Renders transfer review and warnings.
projects/​js-packages/​connection/​components/​transfer-connection-ownership/​candidate-list.tsx Renders candidate selection and empty states.
projects/​js-packages/​connection/​components/​transfer-connection-ownership/​candidate-identity.tsx Renders candidate identity badges.
projects/​js-packages/​connection/​components/​owner-disconnect-dialog/​test/​component.tsx Tests handoff to the transfer flow.
projects/​js-packages/​connection/​components/​owner-disconnect-dialog/​index.tsx Replaces external transfer navigation.
projects/​js-packages/​connection/​components/​manage-connection-dialog/​test/​component.tsx Tests integrated transfer navigation.
projects/​js-packages/​connection/​components/​manage-connection-dialog/​style.scss Sizes the embedded workflow.
projects/​js-packages/​connection/​components/​manage-connection-dialog/​index.tsx Embeds and coordinates ownership transfer.
projects/​js-packages/​connection/​changelog/​add-cnx-ownership-transfer Documents the new UI flow.
projects/​js-packages/​api/​index.jsx Adds candidate-fetch and owner-update methods.
projects/​js-packages/​api/​changelog/​add-cnx-ownership-transfer Documents the API methods.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@fgiannar
fgiannar requested a review from coder-karen October 9, 2026 12:01
@fgiannar
fgiannar force-pushed the add/cnx-ownership-transfer branch from ad5b9ab to e5a0222 Compare October 9, 2026 12:32

@coder-karen coder-karen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @fgiannar, this tests well!

I've got a couple of questions / suggestions after reviewing code:

If ownership is locked, shouldn't we prevent offering the option to transfer at all? Before getting to the stage where we click 'transfer ownership', that is.

On the done step, Done is the only exit, and with onOwnershipTransferred set, leaveTransfer calls it and returns without leaving the step or resetting isTransferOpen / newOwnerId. So the component passing the callback has to close the dialog itself, otherwise it looks like the user is stuck. Even then, the stale state sends the next open straight back to the chooser, where Back fires the callback again, so there is a 'done loop' that can't end.
Could the callback branch reset both before returning?
And the docblock could say what's expected of the consumer, e.g. that it should close the dialog or refresh its own state.
Not an issue right now as noone uses the component, but probably makes sense to clarify now before it gets used.

  1. Component usage:
    You can use Stack instead of hand-written flex CSS. Five classes in style.scss just recreate it: -form, __transfer-ownership, __identity, __handover, __who (style.scss#L3-L15, L46-L50, L62-L78). For example:
    <Stack direction="column" gap="lg" className="jp-connection__transfer-ownership-form">
    <Stack direction="row" align="center" gap="md">

@github-actions github-actions Bot added the Docs label Oct 12, 2026
fgiannar and others added 16 commits October 13, 2026 08:02
`checkStatus` rejects with an Error whose message is "<server text> (Status
400)" and hangs the REST body off `response`. The catch read `err.code`,
which is never set on that Error, so every refusal fell through to the
default branch and printed the raw server string — all four mapped messages
were unreachable.

The tests missed it because they rejected with the body alone, the shape the
component assumed rather than the one it receives. They now reject the way
`checkStatus` does, and cover each code.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
`align-self: stretch` beside `margin-inline: auto` does nothing: an auto
cross-axis margin absorbs the free space first, so the step shrink-wrapped
and the centred column was whatever its content happened to need. The done
step made it obvious, being the shortest, but every view was sized by
accident. Set the width explicitly instead.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
All three pointed at the top of the same page, leaving the reader to find
the part that answers them. The two "how does someone connect" links now
open the connection section, and the ownership link the one describing the
connection owner.

The anchor is an argument rather than a fragment in the slug: getRedirectUrl
discards anything after a `#`.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
@wordpress/ui's scale starts at 13px and body-sm is 12px, so the step had
been rendering as fine print inside a dialog whose own copy is 16px. Take the
base from Jetpack's `--font-body` and keep the secondary pieces relative to
it, rather than inheriting a scale built for denser surfaces.

`--font-label` would have made this worse: base-styles jumps 12px to 16px
with nothing in between, which is why three other projects each declare their
own 14px token.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
… gaps

The step reloaded the page itself, where every other post-action in this
package — disconnect, unlink, protected-owner confirm and release — is handed
to the consumer. Add `onOwnershipTransferred` for the same reason, keeping
the reload as its default: the transfer changes what the current user may do,
so a consumer that does nothing must not be left showing owner-only actions.

Tests for what was untested: that leaving a completed transfer reports the
new owner, that the owner-disconnect warning hands over to this dialog rather
than opening a second flow, the candidates fetch failure, and the logged-out
and not-the-owner cases on the endpoint.

Leftovers: a `.check-users` rule with no renderer, an `isLoading` the hook
returned and nobody read, and `ConnectionOwnerCandidate`, which the Connectors
card will need and could not import.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
The confirm step spliced the display name into the string handed to
createInterpolateElement, so a name containing a `<` would have been parsed
as markup rather than shown. Pass it as the element's child instead.

The other four names in this step go straight into JSX, where React escapes
them, so they stay as they are.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
…to do

Both error messages arrived after an async failure as plain styled text, with
focus still on the button that triggered them, so a screen reader user got no
sign the transfer had been refused. Render them as error Notices, which
announce themselves and match the warning, info and success notices the flow
already uses.

The success step also rendered Done unconditionally while the chooser hides
its dismiss without a callback, so a consumer handling completion itself got
a button that did nothing. Guard it the same way.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
Three places where the component built by hand what @wordpress/ui provides,
and the hand-built version was missing the accessible half each time:

* The confirm button swapped its label to "Transferring…" and set `disabled`.
  `Button` has `loading` and `loadingAnnouncement`, and derives `disabled`
  from `loading`, so the state is announced rather than only shown.
* `CandidateIdentity` reached for `<strong>` and `<span>` where every sibling
  step uses `Text`. Dropping `Text`'s variants over their type scale never
  required dropping `Text`.
* Five class rules re-declared what `Stack` does. Its `lg` and `md` gaps are
  the 16px and 12px those rules hardcoded, so the layout is unchanged; the
  classes stay for what is genuinely ours, like the load-bearing
  `flex-shrink: 0`.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
The dialog tracked "which view" and "did it complete" separately, so the two
could disagree. After a consumer callback neither was cleared: the user was
left on a dead Done button, and the next open came back to the chooser still
believing a transfer had happened, where Back re-fired the callback.

Collapse them into one value, with the new owner living inside the state that
means completed. Closing is a single write, so the pair cannot drift, and an
id only exists where there is one to read.

This is the two-sources-of-truth problem an earlier review judged unreachable.
It was, until `onOwnershipTransferred` added a path where the page does not
reload — which I added without rechecking that.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
The owner and `isMaster` were seeded into the connection store once at page
load and never written again — both reducers handled no action at all — so
the only way a surface learned about a transfer was a full reload. That reload
was the reason for a Done button, a consumer callback, a hidden navigation
inside a shared component, and the stale-state problem behind all of them.

Add `setConnectionOwner`, patched from the transfer rather than refetched:
nothing else in the user connection data turns on ownership — the permissions
it reports are plain capability checks — so a request would only confirm what
the caller already knows.

With the store current, the component sheds the chrome that existed to work
around it. It now renders only what its steps need — Continue, Back, Transfer
— and leaving is the surrounding surface's business: in the dialog, the
footer returns to the actions, which already reflect the new owner.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
"Back" on the success step promised a step to return to that no longer
exists, and on the confirm step it collided with the step's own Back — two
controls, same word, different destinations.

The footer is now purely the dialog's exit: Cancel, or Close once ownership
has moved. Step navigation belongs to the step, which has the only Back.

Closing also forgets the view, so reopening starts on the actions rather than
on whatever was last on screen — the staleness that was previously masked by
the footer never closing from inside the flow.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
The README documents each exported component, and this one is exported for
the Connectors card to reuse — so say what it renders, what it deliberately
does not, and that it updates the store rather than expecting a reload.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
The confirm step claimed the new owner's account would power site-level
features. Those come from the site connection; the owner's account is about
whose WordPress.com data this site's data is. Per jetpack.com/support/primary-user,
the owner owns the data WordPress.com stores for the site and is the point of
contact for support about it — so say that instead.

The notice link now goes to that page, via the `jetpack-support-primary-user`
slug the legacy owner notice already uses, rather than to an anchor in the
general connection doc.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
* The transfer view no longer carries an owner id nothing reads, and the
  dialog can be dismissed with Escape or a click outside once ownership has
  moved, where there is nothing left to lose.
* `useOwnershipTransfer` stops touching an unmounted step: closing mid-request
  could otherwise land a completed transfer after the view had been reset, so
  the next open started on the step. The store still learns the new owner.
* The protected-owner flag comes from the store's selector rather than from
  script data, and the select compares candidates by value rather than against
  the string "null".
* The candidates response is typed as `unknown` and narrowed, rather than
  annotated with a shape the API client never checks.
* The README no longer claims every surface updates: a host passing its own
  copy down as props only reflects the change if that copy comes from the store.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
The flag was seeded at page load and never written again, so after ownership
moves it describes a site state that may no longer hold: the server may have
released the anchor, or ownership may have moved to the anchored user. Only
the server knows which, and the store already uses null for "cannot say".

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
When a site has exactly one connected administrator there is nothing to
choose between, so choose it: the select opens on them and Continue is
available straight away.

The manage dialog's content padding was a flat 80px with no breakpoint, which
on a phone left a couple of hundred pixels of content — enough to truncate the
select's placeholder and wrap the heading a word at a time. Start at 2rem/1rem
and keep the 80px from 600px up, matching the disconnect dialog.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
@fgiannar
fgiannar force-pushed the add/cnx-ownership-transfer branch from f7cdb59 to 516f2f0 Compare October 13, 2026 05:03
fgiannar and others added 5 commits October 13, 2026 09:00
Cancel stayed live during the request, and leaving did not cancel anything:
the transfer still landed and still reached the store, so ownership moved
with nobody told, and a refusal was never shown at all.

The component knows it is busy and the dialog owns the exit, so the one
reports and the other acts on it.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
The notice spliced the display name into the string handed to
createInterpolateElement, so a name containing a `<` would be parsed as
markup. Pass it as the element's child, as the line above it already does.

`<name />` was never extracted: the type drops any tag containing a space, so
where it was the only tag the conversion map widened to `{}` and checked
nothing. Both are `<name/>` now, and the map is enforced.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
WordPress ships @wordpress/components to the page as `wp.components`, so it
costs nothing to use. @wordpress/ui is not provided that way and is bundled
into ours, and its select brings Base UI and the whole Floating UI
positioning stack with it.

Swapping the one control takes the shared jetpack-connection.js from 462KB to
251KB, and 104KB to 51KB gzipped — every page that loads the script was
paying that, not just this step. The trade is a native `<select>`, which
looks less like the @wordpress/ui controls around it and behaves better on
mobile and with assistive tech.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
`onTransferred` was created in the test but never passed to the dialog, which
has no such prop since the consumer callback was removed — so asserting it
was never called proved nothing.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
Swapping to the transfer step unmounts the link that was clicked, so focus
fell to the document body — a keyboard or screen reader user was left outside
the dialog they were still in, with no announcement that the view had changed.

Focus the heading instead, which is what the dialog is labelled by, so the
new view announces itself.

CONNECT-480

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYDknke15qyKNtrT2KMcyo
@fgiannar

Copy link
Copy Markdown
Contributor Author

Many thanks for reviewing @LiamSarsfield !

The footer Cancel stays enabled while the transfer request is in flight (manage-connection-dialog/index.tsx:197), so it closes the dialog without cancelling anything. A success still moves ownership, and a refusal is never shown. Could it be disabled while transferring?

Done via 3d51d08

+1 to @coder-karen's point about surfacing the lock before the last click. The description says a protected owner no longer triggers the lock. The anchored owner can transfer, but on an anchored site whose current owner isn't the anchored user, that owner gets the card and chooser and then ownership_locked (class-manager.php:1332).

This would be an edge case that can be handled in a follow-up PR, when we migrate the component in the Connectors screen.

The Back and Escape notes in the description doesn't appear to match the code yet.

Leftover from previous versions, I have updated the PR description now.

Smaller things:

  • Focus drops to the page body when the dialog swaps views.

Fixed via 3d2ccbb

  • confirm-step.tsx:107 still passes the display name through createInterpolateElement.

Fixed via 5182d44

  • The onTransferred assertion in the dialog test can't fail.

Fixed via 577fe61

  • With "View other connected accounts" gone, is there still a path from here to connected non-admin users?

Yes, pls note that the existing link would redirect to the core users page without any filtering for connected users. We've added the corresponding link in the Connectors card ( via #53150) instead (central hub for managing Jetpack Connection) with actual filtering for connected users.

@fgiannar

fgiannar commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Many thanks @coder-karen ! Great findings on the build sizes and I've made a note of this so going forward @wordpress/components is preferred over @wordpress/ui

Replaced via 0a1dd20

@coder-karen coder-karen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This tests well for me, thanks!

@fgiannar
fgiannar merged commit 5905bde into trunk Oct 13, 2026
175 of 176 checks passed
@fgiannar
fgiannar deleted the add/cnx-ownership-transfer branch October 13, 2026 10:58
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. labels Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs [JS Package] API [JS Package] Connection [Package] Connection [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Stats Data [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. RNA [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants