Repository navigation
feat: 客户端同步市场已安装插件清单并在换机后静默补装 - #718
Open
ArthurYang999 wants to merge 1 commit into
Open
ArthurYang999 wants to merge 1 commit into
ArthurYang999 wants to merge 1 commit into
Conversation
通过账号侧 synced-market-plugins 文档复用现有同步链路,本机插件注册表仍保持设备本地,无需改 Sync 服务。 Co-authored-by: Cursor <cursoragent@cursor.com>
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.
背景 / 问题
账号云同步开启后,插件数据(
PLUGIN/)和部分用户设置会同步,但已安装插件列表不会同步。换机登录同一账号后,需要重新从市场安装插件,体验不完整。原因分析
ZTOOLS/plugins,在storageRouting中被明确标为 device 数据(含本地path,且切账号仍保留),因此不进账号 changelog;ACCOUNT_SYNC_PREFIXES原先只有user-settings/ai-models/web-search-engines/avatar/PLUGIN/,没有「市场已装清单」;applyRemoteChange不触发本地change事件,即使有清单文档,也需要在pull/live后主动对账补装。修改内容
数据与路由
src/shared/storageKeys.ts:新增syncedMarketPlugins(synced-market-plugins);src/main/core/storage/storageRouting.ts:将ZTOOLS/synced-market-plugins加入ACCOUNT_EXACT_KEYS与ACCOUNT_SYNC_PREFIXES,走现有文档同步链路,不改 Sync 服务;ZTOOLS/plugins仍保持设备本地注册表,不同步。清单维护(
src/main/core/sync/syncedMarketPlugins.ts,新增){ plugins: Array<{ name, version? }> }(按 name 去重;内容未变则跳过 put);installedFrom: 'market'并 upsert 清单;installedFrom: 'local',不进清单;npm 已有installedFrom: 'npm',不进清单;对账补装
src/main/api/renderer/sync.ts:注入市场安装回调;在 SyncClientpull与进入live时防抖调度对账;installPluginFromMarket;本机已有同名 → 跳过(不强制升/降级);清单缺、本机有 → 保留本机(只增不减);文档与测试
docs/sync-implementation.md:白名单与市场插件对账说明;tests/main/syncedMarketPlugins.test.ts(新增):候选判定、upsert/remove、播种、对账只增不减;tests/main/storage3.test.ts:断言该文档进 account DB / changelog,且ZTOOLS/plugins仍在 device。行为对照
ZTOOLS/plugins测试与验证
pnpm exec vitest run tests/main/syncedMarketPlugins.test.ts tests/main/storage3.test.ts通过;pluginInstaller/pluginRemovalCleanup相关回归通过;