Add automatic settings snapshots with restore#3
Merged
Conversation
Core (WeChatMultiCore, fully unit-tested): - SettingsSnapshots: rotating, deduped, throttled snapshots layered on the existing SettingsBackup codec. SnapshotStore protocol is the filesystem seam (mirrors KeyValueStore) so the policy is tested against an in-memory fake — capture/skip/throttle/prune/list/restore, plus id<->date parsing. - SettingsBackup.sameSettings: content equality ignoring volatile metadata, used to avoid writing duplicate snapshots. - 11 new tests covering the engine, including the headline restore-recovers -a-bad-import scenario. App (thin shell): - DirectorySnapshotStore writes JSON snapshots under ~/Library/Application Support/WeChat Multi/Snapshots/. - WeChatLauncher takes a throttled snapshot on launch and a forced one before every import; exposes list + restore. - Preferences gains 'Restore from Snapshot…' (date picker + restore). Docs: README feature bullet. No version bump (left for release time).
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.
Adds automatic, rotating settings snapshots so a bad import or accidental change is recoverable — extending the existing
SettingsBackupcodec rather than reinventing it.Core (
WeChatMultiCore, fully unit-tested)SettingsSnapshots— the snapshot policy engine:SnapshotStoreprotocol is the filesystem seam (mirrorsKeyValueStore), so all logic is tested against an in-memory fake with zero disk access.capturewrites a snapshot, dedups when settings are unchanged, throttles viaminInterval(periodic path), and prunes tomaxSnapshots(default 12).captureIfDue(throttled+deduped, for launch),list(newest-first),restore, and sortableid ⇄ Datehelpers.SettingsBackup.sameSettings— content equality ignoring volatile metadata (exportedAt/appVersion/schema), used for dedup.restorerecovers the prior state.App (thin shell)
DirectorySnapshotStore— JSON snapshots under~/Library/Application Support/WeChat Multi/Snapshots/(survives clone resets, which only touch~/Applications/...+ containers).WeChatLauncher— throttled snapshot ~3s after launch (off the main thread), a forced snapshot before every import, plus list/restore methods. Snapshot failures are swallowed so they can never block launch or import.Notes
ChangelogTestspins2.0.0as the shipping version, and the repo's convention is to prepend the changelog entry + bumpInfo.plistat release time — so I left that to the maintainer to keep this PR focused and the suite green.Verification
swift testlocally — CI (build.yml) runs the full Core suite on this PR and is the gate. I reviewed symbol/signature consistency across the Core API and both call sites by hand.DirectorySnapshotStoreI/O, the PreferencesNSAlert+NSPopUpButtonflow, the launch hook) compile-verify in CI only.https://claude.ai/code/session_016iLRnVu9GdtixmXEHSVLD8
Generated by Claude Code