Skip to content

Conversation

@epeicher
Copy link
Contributor

@epeicher epeicher commented Apr 25, 2025

Related issues

Resolves STU-167

Proposed Changes

  • Use the percentage field from the backup status endpoint
  • Increase the progress of the backup status proportionally to the percentage returned in previous step.
  • Use the importState messages when available to provide greater detail of the Importing Backup step

Testing Instructions

  • Apply this changes and run npm start
  • Go to the Sync tab and connect with a non-trivial site, for example a WooCommerce site with multiple products. You can find an example of a non-trivial site here 37a5a-pb that you can Import if required
  • Additionally, you can apply the following patch for testing to see the numeric progress of the Download step
diff --git i/src/components/sync-connected-sites.tsx w/src/components/sync-connected-sites.tsx
index c4bb29b1..a94b7c0c 100644
--- i/src/components/sync-connected-sites.tsx
+++ w/src/components/sync-connected-sites.tsx
@@ -248,6 +248,7 @@ const SyncConnectedSitesList = ( { selectedSite }: SyncConnectedSitesListProps )
 											sitePullState.status.message }
 									</div>
 									<ProgressBar value={ sitePullState.status.progress } maxValue={ 100 } />
+									<p>{ sitePullState.status.progress }</p>
 								</div>
 							) }
 							{ isPullError && (
  • Run a Pull and check the progress

Pre-merge Checklist

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

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 proposed changes look good to me and work correctly in my tests. The progress is smoother and displays relevant status messages. Great work, Roberto!

I have left a couple smaller comments below.

It took me a bit longer to review this one as I haven't touched this part of the codebase before. Because of that, I think it makes sense if more eyes take a look at the proposed changes in case I missed something. 🙂

Comment on lines +46 to +51
type SyncBackupResponse = {
status: 'in-progress' | 'finished' | 'failed';
download_url: string;
percent: number;
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for extracting out this type. It is more readable to me now.

if ( response.status === 'in-progress' ) {
newProgressInfo = pullStatesProgressInfo[ frontendStatus ];
newProgressInfo.progress =
IN_PROGRESS_INITIAL_VALUE + IN_PROGRESS_TO_DOWNLOADING_STEP * ( response.percent / 100 );
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this spread of the percentage / progress. Nice!

Comment on lines 247 to 248
{ importState[ connectedSite.localSiteId ]?.statusMessage ||
sitePullState.status.message }
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a bit subjective, but maybe we could consider extracting out this logic for better readability (e.g. into a separate const statusMessage).

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 makes total sense to me, updated as part of 6afe9c9

@epeicher epeicher marked this pull request as ready for review April 29, 2025 13:37
@epeicher epeicher requested review from a team and sejas April 29, 2025 13:37
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.

Nice!, Great idea using the import states to give more information to the user.
In the future we could even improve when importing certain tables in both features, pull and import.

One thing I would like to improve is displaying "Import completed" for a few seconds before showing "Pull complete." Can we omit or replace that message? Perhaps something like: "Applying final details…", "Finishing the import…" or "Starting the site…" could work.

Screenshot 2025-04-29 at 20 00 49

We should also test it in other languages, such as Ukrainian, because the change in the length of the new strings affects the size of the progress bar.

Video BEFORE

before-pressable-pull.mp4

Video AFTER

after-pressable-pull.mp4

@epeicher
Copy link
Contributor Author

Thanks @sejas, for the review and the suggestions. I have created a PoC of the Import step that updates the bar progress based on the Import inner steps. Also, I have replaced the Importing completed step by Applying final details as ChatGPT liked that the most 😛 , but happy to use another wording.

I have used an external function for that, but I would like to get some feedback. Other options that I would like to try are:

  • Move that function to a external utils file or similar
  • Use a custom hook where I can use the useI18n
  • Do not overcomplicate the progress with another formula, so discard the progress refinement

Commit here e1c64bc

Please let me know your view on this.

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.

Great work! It runs super smoothly.
Let's add ellipsis to the Applying final details …

pull-with-import-states.mp4

}
if ( importState ) {
if ( importState.progress === 100 ) {
return { message: __( 'Applying final details' ), progress: 99 };
Copy link
Member

Choose a reason for hiding this comment

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

Let's also add ellipsis to this sentence:

Suggested change
return { message: __( 'Applying final details' ), progress: 99 };
return { message: __( 'Applying final details' ), progress: 99 };

@sejas sejas enabled auto-merge (squash) May 2, 2025 17:28
@sejas sejas merged commit 21c8034 into trunk May 2, 2025
4 of 8 checks passed
@sejas sejas deleted the stu-167-studio-sync-add-percentage-based-or-more-states-into-account branch May 2, 2025 17:30
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