Implement selective file push for GitHub multi-file sync to reduce unnecessary writes
Problem
Currently, when syncing to GitHub in multi-file mode, all JSON files (token sets, themes, metadata) are pushed regardless of whether they've actually changed. This results in:
- Unnecessary writes and longer sync times
- Bloated commit histories with unchanged files
- Increased risk of merge conflicts
- Harder change reviews
Solution
This PR implements selective file pushing that only syncs files that have actually changed, leveraging the existing change detection from @ChangedStateList.tsx.
Key Changes
🚀 New Feature Flag
- Added
selectiveSyncfeature flag to control the new behavior - Maintains backward compatibility when flag is disabled
🔧 Core Implementation
-
GitTokenStorage: Added optional
changedFilesparameter to filter files during push -
GitHub Provider: Integrated
useChangedStatehook to detect changes and pass selective file information -
Remote Tokens: Enhanced
pushTokensto support feature flags
🛠️ Utility Functions
-
getChangedFiles(): Determines which files have changes based on state comparison -
filterChangedFiles(): Filters file arrays to only include changed items
How It Works
// When both selectiveSync and multiFileSync flags are enabled:
const changedFiles = getChangedFiles(changedPushState);
// Only files in changedFiles Set are included in the GitHub push
// Example: If only 'global' token set changed:
changedFiles = new Set(['global']) // Only global.json is pushed
Behavior
| Feature Flags | Behavior |
|---|---|
selectiveSync: false or missing |
Push all files (existing behavior) |
selectiveSync: true + multiFileSync: true |
Push only changed files |
selectiveSync: true + multiFileSync: false |
Push all files (single file mode) |
Testing
- ✅ Comprehensive unit tests for utility functions
- ✅ GitTokenStorage tests covering selective and full sync scenarios
- ✅ Integration tests ensuring backward compatibility
- ✅ Mock updates to support new hook dependencies
Benefits
- Faster syncs: Only changed files are processed
- Cleaner history: Commits only include actual changes
- Better reviews: Easier to see what actually changed
- Reduced conflicts: Less chance of merge conflicts on unchanged files
This change is fully backward compatible and only activates when both feature flags are enabled.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
http://168.63.129.16:80/machine/
- Triggering command:
/usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs(http block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
⚠️ No Changeset found
Latest commit: f07d9e6d301bd46419d8ca8263117fae01a74c40
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR