Skip to content

Studio: Add UI for when local tree for push has errors - #2271

Merged
katinthehatsite merged 3 commits into
trunkfrom
fix/add-error-node-for-fetching-local-tree
Dec 22, 2025
Merged

Studio: Add UI for when local tree for push has errors#2271
katinthehatsite merged 3 commits into
trunkfrom
fix/add-error-node-for-fetching-local-tree

Conversation

@katinthehatsite

Copy link
Copy Markdown
Contributor

Related issues

Fixes STU-966

Proposed Changes

This PR adds a node to handle errors when there is an issue retrieving nodes from the local tree:

Screenshot 2025-12-17 at 10 25 18 AM

Testing Instructions

  • Pull the changes from this branch
  • Apply the following diff:
index 31db0fc9..b538c66b 100644
--- a/src/stores/sync/sync-hooks.ts
+++ b/src/stores/sync/sync-hooks.ts
@@ -83,6 +83,9 @@ export function useLocalFileTree() {
                        setIsLoading( true );
                        setError( null );
                        try {
+                               // TEMPORARY: Simulate error for testing
+                               throw new Error( 'Simulated error for testing error handling' );
+                               
                                const rawNodes = await getIpcApi().listLocalFileTree( siteId, path, 3 );
                                return convertRawToTreeNodes( rawNodes );
                        } catch ( err ) {
  • Start Studio with npm start
  • Ensure that you have at least one WP.com site connected to Studio
  • Navigate to the Sync tab
  • Click on Push
  • Select Specific files and folders option
  • Confirm that when you open wp-content, you see the error shown on the screenshot above

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@katinthehatsite katinthehatsite self-assigned this Dec 17, 2025
@katinthehatsite katinthehatsite changed the title Add error node Dec 17, 2025
@katinthehatsite
katinthehatsite requested a review from a team December 17, 2025 09:36
<Icon icon={ cautionFilled } size={ 20 } className="fill-red-600" />
{ __(
'Error retrieving files and directories. Please close and reopen this dialog to try again.'
) }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did not add an explicit retry because this seems to be rather an edge case but we can add it if we consider it necessary

@github-actions

github-actions Bot commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

📊 Performance Test Results

Comparing e2f610e vs trunk

site-editor

Metric trunk e2f610e Diff Change
load 18926.00 ms 13447.00 ms -5479.00 ms 🟢 -28.9%

site-startup

Metric trunk e2f610e Diff Change
siteCreation 28988.00 ms 27630.00 ms -1358.00 ms 🟢 -4.7%
siteStartup 11132.00 ms 11058.00 ms -74.00 ms 🟢 -0.7%

Results are median values from multiple test runs.

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

@gavande1 gavande1 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 have tested this and works great. LGTM 👍

Image
@katinthehatsite

Copy link
Copy Markdown
Contributor Author

Update: I updated the style to look like this based on the comment from Linear

Screenshot 2025-12-17 at 2 28 51 PM

@gcsecsey gcsecsey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding the error message and for iterating on the styling @katinthehatsite!

Changes LGTM and work well:

Image
@katinthehatsite
katinthehatsite merged commit d8bf6dc into trunk Dec 22, 2025
10 checks passed
@katinthehatsite
katinthehatsite deleted the fix/add-error-node-for-fetching-local-tree branch December 22, 2025 19:08

@sejas sejas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding the error case. Great work.
I left a couple of suggestions to consider. We could refactor renderEmptyContent and the useEffect.

if ( type === 'push' && localFileTreeError ) {
setTreeState( ( treeState ) => updateNodeById( treeState, 'wp-content', { children: [] } ) );
}
}, [ type, localFileTreeError, setTreeState ] );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure if this useEffect is necessary or it could be just an if when rendering the node.children.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Adjusted in #2352

Comment on lines 169 to +175
{ node.children.length === 0 ? (
<div className="text-gray-500 italic" aria-label={ __( 'Empty folder' ) }>
{ __( 'Empty' ) }
</div>
renderEmptyContent && renderEmptyContent( node.id ) ? (
renderEmptyContent( node.id )
) : (
<div className="text-gray-500 italic" aria-label={ __( 'Empty folder' ) }>
{ __( 'Empty' ) }
</div>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would suggest renaming renderEmptyContent to renderErrorContent. Or in case we want to keep it tied to empty children, then I think we should move the Empty logic into that function too. The condition renderEmptyContent && renderEmptyContent( node.id ) ? seems a bit tricky.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made adjustments in #2352 for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants