修复后台用量线程刷新后 UI 未同步更新的问题#186
Open
MDX-Tom wants to merge 4 commits intoqxcnm:mainfrom
Open
Conversation
Owner
|
先不合并。 我本地拉了这个 PR 做关键路径验证,新增的回归用例连续两次失败: 失败点一致:账号页初始能看到旧用量 85%,但 8 秒内没有刷新到新用量 60%: PR 当前虽然是 MERGEABLE/CLEAN,也没有冲突,但没有 CI checks,而且自带的 Playwright 回归没有通过。请先修复自动刷新触发逻辑或测试时序,保证这条用例稳定通过后再合并。 |
Author
|
已更新pr说明,并在本地编译生成.app经人工测试验证能够完成用量UI自动刷新。 |
将刷新策略从前端定时探测调整为事件驱动:用量轮询批次一结束,Service 立即通知 Tauri,Tauri 再通知前端账号页刷新,同时保留用量列表短间隔刷新作为兜底
Author
|
已更新pr说明,并在本地编译生成.app经人工测试验证,提高了用量UI自动刷新的稳定性。 |
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.
变更摘要
改动范围
主要文件
crates/service/src/usage/refresh/mod.rscrates/service/src/usage/refresh/batch.rscrates/service/src/usage/usage_refresh.rsapps/src-tauri/src/lib.rsapps/src/lib/api/usage-refresh-events.tsapps/src/hooks/useAccounts.tsapps/tests/accounts-usage-auto-refresh.spec.ts主要改动
UsageRefreshCompletedEvent与完成回调注册能力,用量轮询批次、批量手动刷新、单账号刷新完成后都会发出刷新完成通知refresh_usage_for_polling_batch返回前触发notify_usage_refresh_completed("polling", processed, total),确保后台轮询一完成就产生前端可消费的信号usage-refresh-completed事件广播给前端窗口listenUsageRefreshCompleted,桌面端监听 Tauri 事件,测试环境支持同名CustomEventrefetch活跃的账号列表与用量列表,并失效用量汇总、今日摘要和启动快照缓存usage-refresh-completed事件,并要求页面在 2 秒内从旧额度更新到新额度,避免再依赖 5 秒兜底轮询实现效果
验证
pnpm -C apps run testpnpm -C apps run buildpnpm -C apps run test:uicargo test --workspace已执行的实际验证:
未执行的验证与原因:
补充说明:
风险与影响面
备注