Studio: Use local tree for push - #1940
Conversation
📊 Performance Test ResultsComparing 62442b0 vs trunk site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the file tree handling for push operations to use local file tree data instead of fetching individual wp-content folders. The changes establish a unified approach for both push and pull operations by loading complete file trees upfront, improving consistency and performance.
Key changes:
- Replaced individual wp-content folder fetching with a single local file tree loader
- Introduced new utility functions for sync exclusions and depth limiting
- Updated test infrastructure to work with the new path-based tree structure
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/stores/sync/sync-hooks.ts | Added useLocalFileTree hook for fetching local file tree data |
| src/stores/sync/index.ts | Exported the new useLocalFileTree hook |
| src/preload.ts | Renamed IPC handler from listWpContentFolders to listLocalFileTree |
| src/modules/sync/tests/index.test.tsx | Added mock implementation for listLocalFileTree |
| src/modules/sync/tests/convert-tree-to-options-to-sync.tsx | Refactored tests to use path-based tree structure instead of hook-based approach |
| src/modules/sync/lib/tree-utils.ts | Created utility functions for sync exclusions and depth limiting |
| src/modules/sync/lib/convert-tree-to-sync-options.ts | Added path-based logic for determining sync options and extracting selections |
| src/modules/sync/constants.ts | Expanded folder list and added sync exclusion constants |
| src/modules/sync/components/sync-dialog.tsx | Integrated local file tree loading for push operations |
| src/ipc-handlers.ts | Replaced listWpContentFolders with recursive listLocalFileTree implementation |
| src/hooks/use-content-folders.ts | Removed entire file as functionality replaced by new approach |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Forgot to add to testing instructions that you can also add the |
|
@sejas @fredrikekelund I made some more changes to the exporter 😅 so feel free to give it another test. I will work on fixing tests in the meantime |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (4)
src/modules/sync/tests/convert-tree-to-options-to-sync.tsx:152
- Test expectation uses outdated API. Should be
{ paths: ['plugins/plugin1', 'plugins/plugin3'] }to match the refactored implementation.
specificSelections: {
plugins: [ 'plugin1', 'plugin3' ],
},
src/modules/sync/tests/convert-tree-to-options-to-sync.tsx:185
- Test expectation should be updated to
{ paths: ['themes/theme1', 'themes/theme3'] }to reflect the new path-based API.
specificSelections: {
themes: [ 'theme1', 'theme3' ],
},
src/modules/sync/tests/convert-tree-to-options-to-sync.tsx:218
- Test expectation needs to be updated to use the new format:
{ paths: ['uploads/upload1', 'uploads/upload2'] }.
specificSelections: {
uploads: [ 'upload1', 'upload2' ],
},
src/modules/sync/tests/convert-tree-to-options-to-sync.tsx:261
- Test expectation uses the old multi-category format. Should be consolidated to
{ paths: ['plugins/plugin1', 'themes/theme1', 'themes/theme3'] }per the new implementation.
specificSelections: {
plugins: [ 'plugin1' ],
themes: [ 'theme1', 'theme3' ],
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fredrikekelund
left a comment
There was a problem hiding this comment.
This is shaping up nicely! 👍 I can confirm that root-level files in wp-content are included in the push (still), and the logic is easier to follow now.
I left some comments that would be nice to address before landing, but I think we're on the home stretch now.
sejas
left a comment
There was a problem hiding this comment.
Great work Kat!
I tested many cases and they work pretty well. The only issue I found is that selecting wp-content (or just mu-plugins) also includes the sqlite-database-integration, which should be excluded.
And selecting all (folders and database) it correctly excludes the sqlite-database-integration, however doesn't include the extra folders or files like extra-folder or test-wp-content.php.
We could create a follow-up issue for that, but we should probably fix it before the next release.
| } | ||
| } | ||
| return entry; | ||
| } ); |
There was a problem hiding this comment.
We have the opportunity to unify this if-else logic related to full vs partial export.
For example, currently the push doesn't exclude sqlite-database-integration, and the export site doesn't include other extra folders or files inside the wp-content folder.
We can tackle that as a follow-up.
There was a problem hiding this comment.
For example, currently the push doesn't exclude sqlite-database-integration, and the export site doesn't include other extra folders or files inside the wp-content folder.
Yeah I saw the bit with export, we could unify it. I left it as is for now to preserve the existing functionality.
For the sqlite-database-integration, let's fix it in this PR. It must be something small because this was working before. I will take a look in a bit
There was a problem hiding this comment.
To close the loop: Since we discussed this on Slack, we will solve both issues in #2004 and proceed with merging this one.
There was a problem hiding this comment.
- Follow-up PR: Unify selective push and export logic #2006
Related issues
Fixes STU-756
Proposed Changes
This PR uses local tree of files from Studio sites for push operations instead of using hard-coded folders. For the
pluginsandthemesfolders, the depth is limited to individual plugins and themes and the user can not go further in. For folders likeuploads, the user can go further into separate folders and individual uploads. Some files also remain hidden from the user such as SQLite integration database plugin:Testing Instructions
npm startSynctab and connect a WPCOM sitePushoptionsqlite-integrationplugin)pluginsandthemes, we can only go to the individual plugins and themes and can't get deeperPre-merge Checklist