Skip to content

Conversation

@gavande1
Copy link
Contributor

@gavande1 gavande1 commented Oct 28, 2025

Related issues

Proposed Changes

  • Add a new mutation endpoint for deleting all preview sites for the user
  • Use the API endpoint to delete preview sites in the preference modal

Testing Instructions

  1. Apply the patch 194679-ghe-Automattic/wpcom on your sandbox.

  2. Run Studio using this branch.

  3. Start the application with:

    npm start
  4. Open Developer Tools and keep the Network tab open.

  5. Navigate to the Preferences tab in Studio and log in (if not already).

  6. Go to the Usage tab and click Delete all preview sites.

  7. Verify that a request to

    /jurassic-ninja/delete/all/delete/all
    

    was sent and returned a successful response

  8. Confirm that the usage numbers are reset.

  9. Close and reopen the Usage tab.

  10. Ensure the updated usage numbers are still reflected.

  11. Open the following file on your system:

    ~/Library/Application Support/Studio/appdata-v1.json
    
  12. Verify that the snapshots array is cleared and shows as [].

Pre-merge Checklist

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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 28, 2025

📊 Performance Test Results

Comparing 040a48c vs trunk

site-editor

Metric trunk 040a48c Diff Change
load 7605.00 ms 9213.00 ms +1608.00 ms 🔴 21.1%

site-startup

Metric trunk 040a48c Diff Change
siteCreation 13030.00 ms 11039.00 ms -1991.00 ms 🟢 -15.3%
siteStartup 3962.00 ms 3947.00 ms -15.00 ms 🟢 -0.4%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

@gavande1 gavande1 force-pushed the update/delete-all-sites-button-behavior branch from 15c97d2 to 02173f7 Compare October 29, 2025 05:46
@gavande1 gavande1 self-assigned this Oct 29, 2025
@gavande1 gavande1 marked this pull request as ready for review October 29, 2025 05:55
@gavande1 gavande1 requested a review from a team October 29, 2025 06:12
@gavande1 gavande1 changed the title Preview Sites: Change the behavior of the “Delete all preview sites” button to delete all existing sites Preview Sites: delete all preview sites using /delete/all API endpoint Oct 29, 2025
@gavande1 gavande1 changed the title Preview Sites: delete all preview sites using /delete/all API endpoint Preview Sites: Delete all preview sites using /delete/all API endpoint Oct 29, 2025
@wojtekn
Copy link
Contributor

wojtekn commented Oct 29, 2025

I was wondering if it will be clear to the user that it removes all preview sites on the account, and not only those created from the given Studio instance, but it seems that the dialog already makes it clear:

All preview sites that exist for your WordPress.com account, along with all posts, pages, comments, and media, will be lost.

};
}

export function withOfflineCheckMutation< TResult, TArg, TBaseQuery extends BaseQueryFn >(
Copy link
Contributor

Choose a reason for hiding this comment

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

We already disable the button to delete preview sites when the user isOffline, so I am wondering if we need this?

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That’s a great point. I agree it’s not needed right now, but I added it just in case we need the offline check elsewhere while using another API. No strong opinion here, though I would slightly prefer keeping it since withOfflineCheckMutation could be useful later.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, we can keep it then 👍 If it is not something that we use often, we can clean this up later.

@gavande1
Copy link
Contributor Author

I was wondering if it will be clear to the user that it removes all preview sites on the account, and not only those created from the given Studio instance, but it seems that the dialog already makes it clear:

This is what I thought as well. That's why I didn't alter the message.

@gavande1 gavande1 force-pushed the update/delete-all-sites-button-behavior branch from 02173f7 to 1c10b07 Compare October 29, 2025 09:34
Copy link
Contributor

@ivan-ottinger ivan-ottinger left a comment

Choose a reason for hiding this comment

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

The changes look good and work correctly. The new endpoint is being used:

Screen Shot on 2025-10-29 at 11:02:48

and the logic clears up the snapshots in the appdata-v1.json as well:
Screen Shot on 2025-10-29 at 11:04:47

One thing I noticed is that the Delete all preview sites button does not get disabled when there are no preview sites left:

Screen Shot on 2025-10-29 at 11:02:01

@gavande1
Copy link
Contributor Author

One thing I noticed is that the Delete all preview sites button does not get disabled when there are no preview sites left:

@ivan-ottinger, Great question. This is the intended behavior for cases where two separate instances of Studio are out of sync. While disabling the button might seem reasonable, there are several scenarios where keeping it enabled is actually helpful.

@ivan-ottinger
Copy link
Contributor

@ivan-ottinger, Great question. This is the intended behavior for cases where two separate instances of Studio are out of sync. While disabling the button might seem reasonable, there are several scenarios where keeping it enabled is actually helpful.

I see. Are you referring to a case where the snapshots are still recorded on some other app instance? Is the intention to clear that leftover snapshosts array with the button?

@wojtekn
Copy link
Contributor

wojtekn commented Oct 29, 2025

I see. Are you referring to a case where the snapshots are still recorded on some other app instance? Is the intention to clear that leftover snapshosts array with the button?

This is the goal, with the new implementation, the button should always be available to let the user clean preview sites from their account.

@ivan-ottinger
Copy link
Contributor

This is the goal, with the new implementation, the button should always be available to let the user clean preview sites from their account.

Makes sense. 👍🏼

@katinthehatsite
Copy link
Contributor

This is the goal, with the new implementation, the button should always be available to let the user clean preview sites from their account.

I am finding this a bit of a strange UI but I guess there are not many ways around it.

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.

👍

@ivan-ottinger
Copy link
Contributor

ivan-ottinger commented Oct 30, 2025

I am finding this a bit of a strange UI but I guess there are not many ways around it.

Yeah. likewise. I thought about it yesterday and maybe I am missing something, but:

Cannot we do the following?

  • disable the Delete all preview sites button when there are no preview site linked to the user's account
  • let the Clear button on the Previews tab remove those already-deleted sites from appdata-v1.json on another Studio instance

The Delete all preview sites button would:

  • trigger the endpoint to clear all preview sites on the server
  • clear preview sites from appdata-v1.json on the local Studio instance

The Clear button on the Previews tab would only clear the leftover preview sites from the appdata-v1.json .

@gavande1
Copy link
Contributor Author

gavande1 commented Oct 30, 2025

Cannot we do the following?

  • disable the Delete all preview sites button when there are no preview site linked to the user's account
  • let the Clear button on the Previews tab remove those already-deleted sites from appdata-v1.json on another Studio instance

Since we are already querying usage on the component. I think it makes sense to do a quick check on the user's account. I will update the code to disable the button when there are no preview sites on the user's account. cc @wojtekn

The remaining suggested behaviours have already been implemented in #1950.

@gavande1
Copy link
Contributor Author

@ivan-ottinger Thanks for the feedback so far. I have addressed your concerns in e45a445. Could you review it again?

@ivan-ottinger
Copy link
Contributor

@ivan-ottinger Thanks for the feedback so far. I have addressed your concerns in e45a445. Could you review it again?

Nice! Thank you for the updates. The changes look good and I can see that if there are no remote preview sites, the button gets disabled:

Screen Shot on 2025-10-30 at 12:55:58

@gavande1 gavande1 merged commit a0e49fc into trunk Oct 30, 2025
12 checks passed
@gavande1 gavande1 deleted the update/delete-all-sites-button-behavior branch October 30, 2025 12:55
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.

5 participants