feat(helix-cli): make sync ID-first and reconcile local/cloud change safely#869
Merged
feat(helix-cli): make sync ID-first and reconcile local/cloud change safely#869
Conversation
… safely Use project.id as canonical identity, add create-or-choose project resolution, and implement hash/timestamp reconcile with clear push/pull action plans. Also validate local .hx queries before push, improve sync prompts/output, and harden SSE handling to avoid non-fatal parse noise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use project.id as canonical identity, add create-or-choose project resolution, and implement hash/timestamp reconcile with clear push/pull action plans.
Also validate local .hx queries before push, improve sync prompts/output, and harden SSE handling to avoid non-fatal parse noise.
Greptile Summary
This PR significantly enhances the sync command with ID-first project resolution, hash/timestamp-based conflict detection, and safe bidirectional synchronization. The implementation adds SHA256 hashing for content comparison, timestamp-based divergence detection with clock skew tolerance (5s window), and pre-push validation of local
.hxqueries.Key improvements:
project.idadded to config as canonical identity, with fallback to name-based matching for backward compatibilityArchitecture changes:
The implementation is thorough with proper error handling, user confirmations, and detailed sync action plans showing which files will be created/changed/deleted.
Important Files Changed
project.idfield to ProjectConfig with backward compatibilityMissingProjectChoiceenum andselect_missing_project_choicefor create-or-choose project flowFlowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD Start[helix sync command] --> Auth[Authenticate user] Auth --> ResolveProject[Resolve project by ID or name] ResolveProject --> FetchRemote[Fetch remote snapshot from cloud] FetchRemote --> BuildManifests[Build local & remote manifests<br/>with SHA256 + timestamps] BuildManifests --> Compare{Compare<br/>manifests} Compare -->|Both empty| InSync[Already in sync] Compare -->|Identical hashes| InSync Compare -->|Local only| ValidateLocal[Validate local .hx queries] ValidateLocal -->|Valid| PromptPush{Prompt: Push<br/>to cloud?} ValidateLocal -->|Invalid| ErrorValidation[Error: Fix validation issues] PromptPush -->|Yes| PushToCloud[Push local snapshot to cloud] PromptPush -->|No| NoChange[No changes applied] Compare -->|Remote only| PromptPull{Prompt: Pull<br/>from cloud?} PromptPull -->|Yes| PullFromCloud[Pull remote snapshot to local] PromptPull -->|No| NoChange Compare -->|Diverged| CheckTimestamps{Check file<br/>timestamps} CheckTimestamps -->|Local newer| LocalNewerFlow[Local newer flow] CheckTimestamps -->|Remote newer| RemoteNewerFlow[Remote newer flow] CheckTimestamps -->|Tie/Unknown| TieFlow[Tie resolution flow] LocalNewerFlow --> ValidateLocal2[Validate local queries] ValidateLocal2 -->|Valid| PromptPush2{Prompt: Push?} ValidateLocal2 -->|Invalid| OfferPull{Offer pull instead?} PromptPush2 -->|Yes| PushToCloud PromptPush2 -->|No| OfferPull OfferPull -->|Yes| PullFromCloud OfferPull -->|No| NoChange RemoteNewerFlow --> PromptPull2{Prompt: Pull?} PromptPull2 -->|Yes| PullFromCloud PromptPull2 -->|No| NoChange TieFlow --> ValidateTie[Validate local queries] ValidateTie --> PromptTieAction{Prompt: Choose<br/>action} PromptTieAction -->|Push| PushToCloud PromptTieAction -->|Pull| PullFromCloud PromptTieAction -->|No-op| NoChange PushToCloud --> Success[Sync complete] PullFromCloud --> Success InSync --> Success NoChange --> SuccessLast reviewed commit: 75e0037