Skip to content

Agentic UI: Allow cancelling an in-flight push or pull - #4510

Merged
bcotrim merged 7 commits into
trunkfrom
stu-2222-add-sync-cancel
Aug 13, 2026
Merged

Agentic UI: Allow cancelling an in-flight push or pull#4510
bcotrim merged 7 commits into
trunkfrom
stu-2222-add-sync-cancel

Conversation

@bcotrim

@bcotrim bcotrim commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Written with Claude Code, then verified end to end against real pushes and pulls

Proposed Changes

You can now stop an in-flight sync from the site dropdown, with the same boundary Classic uses: a push can be cancelled until the remote import is initiated, a pull until the CLI starts writing your local site. Past that point the button is disabled and the panel says why, because stopping there would leave a half-imported site. Cancelling reports "Push/Pull cancelled" rather than an error, and is logged as such.

Pull Started Pull Cancelled Push Started Push Cancelled
image image image image

Testing Instructions

  1. Connect a site to WordPress.com and start a pull from the site dropdown.
  2. While it reads "Creating remote backup…" or "Downloading backup…", hit the X. The pull stops, you get "Pull cancelled", and Studio Logs shows [Sync] Pull cancelled by user with no error.
  3. Start another pull and wait for "Importing…". The X is now dimmed and the panel explains why; clicking does nothing.
  4. Repeat with a push: cancellable during "Creating backup…"/upload, refused once the remote import starts.
  5. Confirm no studio CLI process survives a cancel (ps aux | grep "main.mjs pull").

Pre-merge Checklist

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

@bcotrim bcotrim changed the title Allow cancelling an in-flight push or pull in the Agentic UI Agentic UI: Allow cancelling an in-flight push or pull Aug 11, 2026
@wpmobilebot

wpmobilebot commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing abdec3a vs trunk

app-size

Metric trunk abdec3a Diff Change
App Size (Mac) 1406.65 MB 1406.67 MB +0.03 MB ⚪ 0.0%

site-editor

Metric trunk abdec3a Diff Change
load 1085 ms 1043 ms 42 ms ⚪ 0.0%

site-startup

Metric trunk abdec3a Diff Change
siteCreation 7530 ms 7524 ms 6 ms ⚪ 0.0%
siteStartup 2877 ms 2873 ms 4 ms ⚪ 0.0%

Results are median values from multiple test runs.

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

Comment thread apps/ui/src/data/sync-activity.ts Outdated
enabled,
label: enabled
? __( 'Cancel pull' )
: __( 'Pull can not be cancelled while importing changes to your local site' ),

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.

I think we can probably tighten the line height here if the sentence splits in two lines:

Image

@katinthehatsite katinthehatsite 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.

Generally, the changes look good to me 👍

I noticed one thing:

  • start and cancel push
  • observe the the header says Push cancelled
  • wait for a couple of minutes
  • observe that the header now says Pushed 2 mins ago even though the push was cancelled

I am wondering if the Pushed 2 mins ago should appear in this case at all, what do you think?

@bcotrim

bcotrim commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

I am wondering if the Pushed 2 mins ago should appear in this case at all, what do you think?

At the moment it is preserving whatever message it was before the push/cancel. Cancel does not update it? Was that the behavior you saw?

I pushed some fixes, can you take another look please?

@katinthehatsite

Copy link
Copy Markdown
Contributor

At the moment it is preserving whatever message it was before the push/cancel. Cancel does not update it? Was that the behavior you saw?

So what seems to happen is that if you push, it shows the pushed x amount of time ago, then you try to push again and cancel, it will show push cancelled followed by pushed x amount of time ago and after a few minutes. So it seems that it would display the message that was indeed there previously as you mentioned. This is a bit confusing but not a big deal as I don't think this would be a common scenario.

*/
const SYNC_ABORT_CONTROLLERS = new Map< string, AbortController >();

// Agentic push/pull resolve with this instead of rejecting when the user cancels.

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.

I think the type below is pretty self-explanatory

remoteSiteId: number;
};

// Stopping is best-effort: the push/pull mutation itself rejects with a

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.

I think this can also be removed as it is already visible from the code

remoteSiteId,
} );
}
// See `pullSiteFromLive` — same registry, so `cancelSyncOperation` covers both UIs.

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.

the template literal on the next line already shows this, I think

Comment thread apps/local/src/index.ts Outdated
{ sitePath: site.path, remoteSiteId, options, signal: release.signal }
);
} catch ( error ) {
// See the pull route — a cancel is reported, not raised as a 500.

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.

The comment restates the code pattern so I would drop it as well

@katinthehatsite katinthehatsite 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.

I think the functionality works as expected 👍 I left some minor suggestions regarding cleaning up the comments.

@bcotrim
bcotrim merged commit 9660a66 into trunk Aug 13, 2026
13 checks passed
@bcotrim
bcotrim deleted the stu-2222-add-sync-cancel branch August 13, 2026 10:35
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