This repository was archived by the owner on Oct 15, 2026. It is now read-only.
Repository navigation
refactor(cloudSync): extract SyncProvider interface - #8
Merged
Merged
Conversation
Introduce a backend-agnostic SyncProvider contract (list, read, write, delete, getManifest/setManifest, getKeyData/setKeyData, clearAll) in providers/types.ts. The Drive client in providers/gdrive.ts is unchanged; a new providers/gdriveProvider.ts adapts it to the interface and is what syncEngine consumes. Pure refactor — no behavior change, no new network surface, encryption layer untouched. Unblocks alt sync backends (WebDAV/iCloud) and encrypted bundle export by giving the engine a single seam to swap. Background's direct gdrive imports (recovery flow) are intentionally left as-is for this PR; they can adopt the interface in a follow-up. https://claude.ai/code/session_01PzcBu8A6n4joSexQRhEWHv
eslint.config.js imports @eslint/js but the package was not declared as a direct devDependency, so it only resolved when pnpm happened to hoist it transitively — pnpm lint failed cleanly on a fresh clone with strict hoisting. Add it explicitly. Pin packageManager to pnpm@10.33.0 (corepack) so contributors no longer silently produce mismatched lockfile versions; the lockfile is regenerated to v9 to match. https://claude.ai/code/session_01PzcBu8A6n4joSexQRhEWHv
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The previous pin (version: 8) conflicts with the packageManager pin in package.json (pnpm@10.33.0) and can't read a v9 lockfile, which broke all four CI jobs at the install step. Dropping the explicit version makes the action read pnpm@10.33.0 directly from package.json, so any future bump only needs a single edit. https://claude.ai/code/session_01PzcBu8A6n4joSexQRhEWHv
Adds unit tests for the SyncProvider adapter built on top of providers/ gdrive.ts. Pins each method's delegation contract (correct gdrive function called with correct args) and the list() translation from DriveFile metadata to SyncObjectInfo (.enc-suffix stripping, size parseInt, modifiedTime → epoch ms, undefined passthrough for missing fields). Establishes the test pattern future SyncProvider implementations (WebDAV, iCloud, encrypted bundle) will follow. https://claude.ai/code/session_01PzcBu8A6n4joSexQRhEWHv
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Phase 1 step 1 of the post-review plan: extract a backend-agnostic
SyncProviderinterface so the sync engine no longer depends on Google Drive directly. Pure refactor — no behavior change.src/shared/cloudSync/providers/types.tsdefinesSyncProvider(getManifest/setManifest,list/read/write/delete,getKeyData/setKeyData,clearAll) plusSyncObjectInfoandProviderKeyData. No Drive-isms in the contract.src/shared/cloudSync/providers/gdriveProvider.tsexposescreateGoogleDriveProvider(accessToken)and adapts the existing Drive client to the interface. Calls dispatch throughimport * as gdrive from './gdrive'so existingvi.mocksetups in the test suite keep intercepting at the gdrive seam.syncEngine.tsnow talks exclusively to aSyncProvidervia agetProvider()helper — everygdrive.*(tokens.accessToken, …)call site is replaced.DriveApiErroris still imported for the auth-errorinstanceofcheck.providers/gdrive.tsis otherwise unchanged; theDriveKeyDatainterface is removed in favor of the sharedProviderKeyDatatype.This unblocks Phase 2 features #2 (alt backends — WebDAV / iCloud / encrypted file export) and #5 (encrypted
.raftbundlesession sharing).Out of scope (intentional)
src/background/index.tsstill imports gdrive directly for theCLOUD_RECOVER_WITH_KEY/ setup / disconnect flows. Migrating those touches setup semantics and broadens this PR — they can adopt the interface alongside the bg modularization step.Env hygiene (separate commit on this branch)
While bringing up the local toolchain I hit two pre-existing issues:
eslint.config.jsimports@eslint/jsbut it was not inpackage.json—pnpm lintfailed on a fresh clone any time pnpm didn't transitively hoist it. Added as an explicit devDependency.pnpm-lock.yamlwas at lockfileVersion 6 (pnpm 8 era), so anyone on current pnpm regenerates it on install. Added"packageManager": "pnpm@10.33.0"to pin via corepack and regenerated the lockfile to v9.The lockfile diff is large (~6.5k lines) because of the v6→v9 format conversion; actual dependency churn is just the new
@eslint/jsentry.Test plan
pnpm typecheck— cleanpnpm lint— clean (now works on a fresh install)pnpm vitest run— 734/734 passing, including alltests/unit/syncEngine.test.tsmocks that exercise the gdrive seamCLOUD_RECOVER_WITH_KEYpath insrc/background/index.ts(uses gdrive directly — left as-is, should be unaffected)https://claude.ai/code/session_01PzcBu8A6n4joSexQRhEWHv
Generated by Claude Code