Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to speed up sites on Windows programmatically #211

Merged
merged 15 commits into from
Jun 12, 2024

Conversation

fluiddot
Copy link
Contributor

@fluiddot fluiddot commented Jun 5, 2024

Note

This PR is a proposal to solve 7013-gh-Automattic/dotcom-forge. I'd appreciate any feedback on the proposal and the messaging. Thanks 🙇 !

Proposed Changes

  • Add sudo-prompt package to prompt the user for admin permission actions.
  • Add a Windows-only helper function to prompt the user to speed up sites. We'll provide three options:
    • Update Windows Defender configuration automatically. This will require admin permissions.
    • Open the Developer documentation that explains how to do it manually.
    • Skip the step.
  • Update onboarding logic to prompt the user to speed up sites when creating the first site.
  • Add a menu option under the Help section to allow users to trigger again the prompt to speed up sites.

Screenshot 2024-06-11 145127

Testing Instructions

Windows

No Optimizations

  1. Remove app data by deleting the folder located at %appdata%\Studio.
  2. Remove all created sites.
  3. Open the app.
  4. Observe that the onboarding screen is shown.
  5. Click on the Add Site button.
  6. Observe a dialog is displayed with two options.
  7. Click on the second option to skip it.
  8. Observe the site takes a significant time to be created.

Speed Up Sites Optimization

  1. Remove app data by deleting the folder located at %appdata%\Studio.
  2. Remove all created sites.
  3. Open the app.
  4. Observe that the onboarding screen is shown.
  5. Click on the Add Site button.
  6. Observe a dialog is displayed with two options.
  7. Click on the first option to automatically speed up sites.
  8. Observe the OS prompts for admin permission.
  9. Observe the site creation is faster than the previous test case.

Manual Optimization

  1. Remove app data by deleting the folder located at %appdata%\Studio.
  2. Remove all created sites.
  3. Open the app.
  4. Observe that the onboarding screen is shown.
  5. Click on the Add Site button.
  6. Observe a dialog is displayed with three options.
  7. Click on the second option to display documentation.
  8. Observe the browser is opened and show documentation about how to speed up sites on Windows.
  9. Observe the site is created in the meantime.

Prompt Only Displayed First Time

  1. Remove app data by deleting the folder located at %appdata%\Studio.
  2. Remove all created sites.
  3. Open the app.
  4. Observe that the onboarding screen is shown.
  5. Click on the Add Site button.
  6. Observe a dialog is displayed with two options.
  7. Click on the second option to skip it
  8. Observe the site is created.
  9. Delete the site created.
  10. Observe the onboarding screen is displayed again.
  11. Click on the Add Site button.
  12. Observe the prompt to speed up sites is not displayed.

Help Section

  1. Open the app.
  2. Open the application menu (located in the top bar).
  3. Click on Help button.
  4. Observe the item "How can I make Studio faster?" is displayed.
  5. Click on it.
  6. Observe a dialog is displayed with two options.

macOS

No Dialog Displayed

  1. Remove app data by deleting the folder located at $HOME/Library/Application Support/Studio.
  2. Remove all created sites.
  3. Open the app.
  4. Observe that the onboarding screen is shown.
  5. Click on the Add Site button.
  6. Observe no dialog is displayed and that the site is created

No New Help Option

  1. Open the app.
  2. Click on the Help button in the application menu.
  3. Observe the there's no item related to how to make Studio app faster.

Pre-merge Checklist

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

@fluiddot fluiddot self-assigned this Jun 5, 2024
@fluiddot fluiddot force-pushed the add/exclude-app-in-windows-defender branch from 13fd65c to d0ed46c Compare June 6, 2024 11:33
@fluiddot fluiddot force-pushed the add/exclude-app-in-windows-defender branch from d0ed46c to 2306c3f Compare June 6, 2024 12:44
@fluiddot fluiddot marked this pull request as ready for review June 6, 2024 12:53
@fluiddot fluiddot requested review from a team and matt-west June 6, 2024 12:53
@@ -11,6 +11,7 @@ export interface UserData {
[ stat: string ]: number;
};
};
promptWindowsSpeedUpResult?: PromptWindowsSpeedUpResult;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The result is persisted to show only once the prompt in the onboarding.

const exeDir = path.dirname( app.getPath( 'exe' ) );
exePath = path.join( exeDir, '..', 'app-*', exeFilename );
}
const command = `PowerShell -NoProfile -ExecutionPolicy Bypass -Command "Add-MpPreference -ExclusionProcess ${ exePath }"`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

let exePath = app.getPath( 'exe' );
// When the app is packaged, the exe path points to "%appdata%\Local\studio\app-{app-version}\Studio.exe".
// To avoid updating this configuration on each update, we use a wilcard in the path to include all versions.
if ( app.isPackaged ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The app is not packaged when it's executed from the Electron shell located in node_modules. This value is also used to distinguish development and production environments.

buttons,
title: __( 'Want to speed up sites?' ),
message: __(
"If the Real-Time Protection Service of Windows Defender is enabled on your machine, it may slow down the process of creating and starting a site.\n\nTo enhance site speed, it's recommended adjusting the configuration accordingly.\n\nThe app can do this automatically for you, or alternatively, you can follow the documentation."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd appreciate any feedback on the messaging. The content is mostly based on the Documentation.

Copy link

Choose a reason for hiding this comment

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

Could we maybe add the Needs Copy Review label or ping @\Automattic/editorial to get some extra help from the Publications team? I don't feel overly confident in my copy abilities, but feel the adjusting the configuration accordingly line is perhaps a bit too vague in this context.

Maybe it could be updated to something like the following?

For optimal performance, we recommend disabling this service for the Studio app.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we maybe add the Needs Copy Review label or ping @\Automattic/editorial to get some extra help from the Publications team? I don't feel overly confident in my copy abilities, but feel the adjusting the configuration accordingly line is perhaps a bit too vague in this context.

Good idea, I've just added the label.

Maybe it could be updated to something like the following?

For optimal performance, we recommend disabling this service for the Studio app.

The idea is to exclude the app from this service, not disabling as Windows Defender is meant to protect user's machine from security threats.

Copy link

Choose a reason for hiding this comment

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

Oh, that's what I was trying to convey with the for the Studio app part of the suggestion, but see it wasn't clear. 😅 How about something like the following?

For optimal performance, we recommend excluding the Studio app from this service.

I'm sure the Publications team will have some better suggestions than myself, though!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, that's what I was trying to convey with the for the Studio app part of the suggestion, but see it wasn't clear. 😅

Ah, true. I've just re-read it and I found it clearer now 😅 .

[...] How about something like the following?
For optimal performance, we recommend excluding the Studio app from this service.

Sounds good, I'll update the message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I applied this suggestion in df02d63.

Copy link

@SiobhyB SiobhyB left a comment

Choose a reason for hiding this comment

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

Thank you for working on this @fluiddot! The happy path works well for me. Before allowing the change via the dialog, it took around 23 seconds to create a new site:

slow.mov

After, it took about 12 seconds:

quicker.mov

I also confirmed that the prompt was only displayed the first time and displays in the Help section. 🙌 I'll add some more thoughts on the copy separately.

const MANUAL_UPDATE = __( "I'll do it my own by following the documentation." );
const AUTOMATIC_UPDATE = __( 'Sounds good, do it for me.' );

const buttons = [ NOT_INTERESTED, MANUAL_UPDATE, AUTOMATIC_UPDATE ];
Copy link

Choose a reason for hiding this comment

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

When looking at the dialog, I think it would feel more intuitive for me to see the Sounds good, do it for me option at the top of the list, not the bottom.

I also wondered if it'd make sense for the I'm not interested option to follow the same Don't ask again pattern we use for the demo update and arm64 optimisation dialogs:

Screenshot 2024-06-10 at 12 38 42 Screenshot 2024-06-10 at 11 41 12

Wdyt?

Copy link

Choose a reason for hiding this comment

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

@matt-west, I'd be interested to hear your perspective on this, too. The three options feel a little cluttered to me:

Screenshot 2024-06-10 at 12 46 40

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When looking at the dialog, I think it would feel more intuitive for me to see the Sounds good, do it for me option at the top of the list, not the bottom.

I originally put the buttons in that order but changed them at the last moment because the default response when canceling the dialog is associated with the first element. I thought this order might be following design guidelines, but I've just checked the documentation and it's recommended to have the "Yes" action in the first position:

The "do it" action button(s) should appear as the leftmost buttons. The safe, nondestructive action should appear as the rightmost button.

I'll apply this change.

I also wondered if it'd make sense for the I'm not interested option to follow the same Don't ask again pattern we use for the demo update and arm64 optimisation dialogs:

This dialog is only prompted automatically once, so I think we wouldn't need to provide a turn-off option. WDYT?

Copy link

Choose a reason for hiding this comment

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

This dialog is only prompted automatically once, so I think we wouldn't need to provide a turn-off option. WDYT?

Good point, the main motivation behind the suggestion was making I'm not interested less prominent, which I think moving to the last position in the button list would accomplish. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reordered the buttons in fe04881 and 2bf5df4.

Copy link
Contributor Author

@fluiddot fluiddot Jun 11, 2024

Choose a reason for hiding this comment

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

Do we need to include the option for manually applying the change? I think we could simplify this dialog by removing that option.

My rationale behind adding the option was to provide a middle solution where the user could check the documentation. However, if we foresee that the option won't be helpful to the user and reduces the clarity of the dialog, I'll be happy to remove it. WDYT @matt-west ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. Let's be opinionated here and remove that option. Well need to adjust the body copy to reflect this change too.

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 need to adjust the body copy to reflect this change too.

Originally, I thought of adding a link to the documentation in the body but the native dialog just renders plain text 😞. Do you think we should reference the documentation or simply offering the option to run the action automatically?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to reference the docs here. If we find that users are confused about what Windows Defender is and how it works, we can add some additional copy to the dialog.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I applied this suggestion in f260f97.

src/menu.ts Show resolved Hide resolved
@fluiddot fluiddot added the [Status] Needs Copy Review Add this when you'd like to get a review / feedback from the Editorial team on your PR label Jun 10, 2024
message: __(
'If the Real-Time Protection Service of Windows Defender is enabled on your machine, it may slow down the process of creating and starting a site.\n\nFor optimal performance, we recommend excluding the Studio app from this service.\n\nThe app can do this automatically for you, or alternatively, you can follow the documentation.'
),
cancelId: buttons.indexOf( NOT_INTERESTED ),
Copy link
Contributor Author

@fluiddot fluiddot Jun 10, 2024

Choose a reason for hiding this comment

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

When closing the dialog, it returns by default the ID 0, we have to set the specific button associated with canceling the process.

@fluiddot fluiddot requested a review from SiobhyB June 10, 2024 17:12
@kristastevens
Copy link

Hi @fluiddot, I read through the PR and I have a few questions about the modal.

Here's the text on the modal:

Want to speed up sites?

If the Real-Time Protection Service of Windows Defender is enabled on your machine, it may slow down the process of creating and starting a site.

To enhance site speed, it's recommended adjusting the configuration accordingly.

The app can do this automatically for you, or alternatively, you can follow the documentation.

  • Sounds good, do it for me.
  • I'll do it my own by following the documentation.
  • I'm not interested.

Questions:

  1. Does turning off Real-time protection speed up just the site creation process?
  2. Does this refer to the Real-time protection feature of Microsoft Defender (vs. Windows Defender)?
  3. Are we saying here that we can turn Real-time protection off automatically, if they click "Sounds good, do it for me."?

Your answers will help me to come up with an alternative wording. Thanks in advance!

@fluiddot
Copy link
Contributor Author

fluiddot commented Jun 11, 2024

Thank you @kristastevens for helping us with the wording 🙇 !

Questions:

  1. Does turning off Real-time protection speed up just the site creation process?

Real-time protection slows down the execution of PHP files for sites served locally. This applies to all sites created on the Studio app as they are local. So excluding the app in this service speeds up sites in general. However, the most notorious items are creating and starting a site.

  1. Does this refer to the Real-time protection feature of Microsoft Defender (vs. Windows Defender)?

I checked different documentation and found references to multiple names: Windows Security, Microsoft Defender, and Windows Defender. On Windows 11, if I navigate to the screen to add exclusions the description says:

Add or remove items that you want to exclude from Microsoft Defender Antivirus scans.

I understand that the service is Microsoft Defender and that's part of the OS feature Windows Security. Hence, we could use Microsoft Defender.

  1. Are we saying here that we can turn Real-time protection off automatically, if they click "Sounds good, do it for me."

Yes, the app will automatically add an exclusion to the Real-time protection to disable this service only for the Studio app. I think it's important to convey that we only disable it for the app, so Microsoft Defender will keep protecting the user's machine.

UPDATE: After f3a441a, the message has been changed to:

If the Real-Time Protection Service of Microsoft Defender is enabled on your machine, it may slow down the process of creating and starting a site.

For optimal performance, we recommend excluding the Studio app from this service. The app can do this automatically for you.

Copy link

@SiobhyB SiobhyB left a comment

Choose a reason for hiding this comment

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

Going ahead to approve, pending any copy or UI suggestions from Krista or Matt, so as not to block this PR with upcoming AFK. The main flows, including automatically speeding up the site and dismissing the dialog, work great for me. Thanks @fluiddot! 🙌

@kristastevens
Copy link

Hi @fluiddot, thanks so much for the clarification. Here's an alternative wording:

Want to speed up site creation?

Microsoft Defender's Real-time protection may slow site creation.

To create sites quickly, we recommend disabling Real-time protection for the WordPress app.

Sounds good, do it for me.
I'll do it my own by following the documentation.
I'm not interested.

@fluiddot
Copy link
Contributor Author

Hi @fluiddot, thanks so much for the clarification. Here's an alternative wording:
[...]

Great, thanks @kristastevens for your help on the wording. I applied this in af63a6e.

[...]
To create sites quickly, we recommend disabling Real-time protection for the WordPress app.
[...]

I'd like to note that this PR is related to the Studio app, not WordPress.

@fluiddot fluiddot merged commit 9da80ea into trunk Jun 12, 2024
10 checks passed
@fluiddot fluiddot deleted the add/exclude-app-in-windows-defender branch June 12, 2024 10:56
@github-actions github-actions bot removed [Status] Needs Copy Review Add this when you'd like to get a review / feedback from the Editorial team on your PR [Status] Editorial Input Requested labels Jun 12, 2024
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.

None yet

5 participants