You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
Checklist / 检查清单
Description / 描述
Close #1773
两个 commit,建议按顺序看:
c2368572修复手动检查更新无效(issue 本身)。2278761a订阅列表跟随后台更新同步刷新。修复 1 之后,手动检查终于能真正更新订阅了,但列表不会刷新,按钮还会一直显示「存在新版本」,所以一起修掉。背景
手动检查更新无效。 订阅列表点「检查更新」永远显示「已是最新版本」,也不发出任何网络请求。原因是消息两端参数形状不一致:
SubscribeClient.checkUpdate发送的是{ url },而 SW 端requestCheckUpdate(url: string)把整个对象当成 url,拼出的 key 是subscribe[object Object],查不到订阅,直接返回false。这个错位从 MV3 重构(fcb4cc48,v0.17.0)起就存在,v1.4.0、release/v1.4、release/v1.5、main都受影响。定时自动检查传的是字符串,不受影响。列表不同步。 订阅列表只在挂载时拉取一次数据,SW 端也没有供页面订阅的广播。所以静默更新或在安装页确认更新之后,版本号和脚本数都要手动刷新页面才会变。另外 SW 对「已静默更新」和「已打开安装页待确认」都返回
true,UI 统一显示「存在新版本」,静默更新之后这个提示是错的。本次改动
requestCheckUpdate改为解构{ url },与同 group 的install/delete/enable一致。installScript广播 +subscribeMessage模式:upsertScript把订阅的脚本关联写回存储后,发布upsertSubscribe,带上最终的订阅数据;useSubscribeDataManagement订阅这条广播,按 url 就地替换行,新订阅则按创建时间插入。没有复用installSubscribe:它发生在脚本同步之前,脚本数还是旧的,而且它是 SW 触发脚本同步用的内部信号。checkUpdate返回值从true细分为"updated"(已静默更新)和"confirm"(已打开安装页),无更新或检查失败仍返回false。状态格据此处理:updated回到显示更新时间,confirm显示「存在新版本」;updatetime变化后(用户在安装页确认了更新)「存在新版本」也会复位。这个返回值只有 options 页使用,两端随同一个构建发布,不存在新旧版本混用的兼容问题。验证
subscribe.test.ts新增消息边界回归测试(client → MockMessage → service),并覆盖三种返回值和upsertSubscribe广播;新增SubscribeList/hooks.test.ts(行替换、新订阅插入、卸载时取消订阅);components.test.tsx新增状态格的updated/confirm两种情况。这些测试都先确认过在没有实现时失败。CI=true pnpm vitest run --no-coverage --shard=1/2和--shard=2/2:187 files / 2486 tests、187 files / 2413 tests,全部通过。pnpm typecheck、改动文件的 eslint / prettier 均通过。pnpm run build+e2e/session.mjs无头会话,本地http.server托管订阅文件,全程在订阅列表点「检查更新」,页面不刷新):subscribe.ts取自b6e37ccb):显示「已是最新版本」,服务器没收到请求,checktime没变,bug 复现。v0.2.0 · 2 个脚本,时间显示「现在」,没有停在「存在新版本」。@connect:显示「存在新版本」并打开安装页;在安装页点「更新」后,列表就地变为v0.3.0,状态格恢复为更新时间。b6e37ccb基线跑整个ui项目就有约 90 个失败,每次运行的失败集合都不同。原因是ui项目配置了isolate: false,本地又是单 worker(🔧 限制本地测试为单 worker,CI 保留并行分片 #1767),各测试文件的vi.mock通过共享的模块缓存相互串扰。本 PR 的测试在 CI 模式下稳定通过,但单独跑SubscribeList/目录时,components.test.tsx会受index.test.tsx串扰(原有的 favicon 用例同样如此)。这是既有的测试基础设施问题,本 PR 不处理。git diff b6e37ccb...2278761a只涉及订阅 SW 服务、SubscribeClient、订阅列表的 hook / 状态格,以及对应测试,共 7 个文件。