Skip to content

Add automatic settings snapshots with restore#3

Merged
ashinno merged 1 commit into
mainfrom
claude/settings-auto-backup-QdA2b
Jun 6, 2026
Merged

Add automatic settings snapshots with restore#3
ashinno merged 1 commit into
mainfrom
claude/settings-auto-backup-QdA2b

Conversation

@ashinno

@ashinno ashinno commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Adds automatic, rotating settings snapshots so a bad import or accidental change is recoverable — extending the existing SettingsBackup codec rather than reinventing it.

Core (WeChatMultiCore, fully unit-tested)

  • SettingsSnapshots — the snapshot policy engine:
    • SnapshotStore protocol is the filesystem seam (mirrors KeyValueStore), so all logic is tested against an in-memory fake with zero disk access.
    • capture writes a snapshot, dedups when settings are unchanged, throttles via minInterval (periodic path), and prunes to maxSnapshots (default 12).
    • captureIfDue (throttled+deduped, for launch), list (newest-first), restore, and sortable id ⇄ Date helpers.
  • SettingsBackup.sameSettings — content equality ignoring volatile metadata (exportedAt/appVersion/schema), used for dedup.
  • 11 new tests including the headline scenario: snapshot → a bad import wipes settings → restore recovers 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.
  • Preferences → “Restore from Snapshot…” — date picker + restore, alongside the existing Export/Import buttons.

Notes

  • No version bump / changelog change. ChangelogTests pins 2.0.0 as the shipping version, and the repo's convention is to prepend the changelog entry + bump Info.plist at release time — so I left that to the maintainer to keep this PR focused and the suite green.

Verification

  • No Swift toolchain in this Linux container, so I couldn't run swift test locally — 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.
  • The macOS/AppKit bits (the DirectorySnapshotStore I/O, the Preferences NSAlert+NSPopUpButton flow, the launch hook) compile-verify in CI only.

https://claude.ai/code/session_016iLRnVu9GdtixmXEHSVLD8


Generated by Claude Code

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).
@ashinno ashinno marked this pull request as ready for review June 6, 2026 14:07
@ashinno ashinno merged commit 054bb2d into main Jun 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants